aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4function.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-08-16 08:57:58 +0200
committerLars Knoll <lars.knoll@digia.com>2013-08-16 10:14:22 +0200
commitd017fe9b38c74d2cc2fa754af3bf9e32357f149c (patch)
treed56a6421c026d4ec03165722b66540c7752a9d1e /src/qml/jsruntime/qv4function.cpp
parentb88626a3a59f7dcd01be6fe2a8236b14ca1176f5 (diff)
Store line number mappings in the compiled function
Change-Id: I4e37aac3618b20ccd52ce4833098781374a3daf6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4function.cpp')
-rw-r--r--src/qml/jsruntime/qv4function.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 24ea1fbb32..b814637e12 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -99,20 +99,42 @@ void Function::mark()
}
namespace QV4 {
-bool operator<(const LineNumberMapping &mapping, qptrdiff pc)
+struct LineNumberMappingHelper
{
- return mapping.codeOffset < pc;
-}
+ const quint32 *table;
+ int lowerBound(int begin, int end, qptrdiff offset) {
+ int middle;
+ int n = int(end - begin);
+ int half;
+
+ while (n > 0) {
+ half = n >> 1;
+ middle = begin + half;
+ if (table[middle * 2] < offset) {
+ begin = middle + 1;
+ n -= half + 1;
+ } else {
+ n = half;
+ }
+ }
+ return begin;
+ }
+};
+
}
int Function::lineNumberForProgramCounter(qptrdiff offset) const
{
- QVector<LineNumberMapping>::ConstIterator it = qLowerBound(lineNumberMappings.begin(), lineNumberMappings.end(), offset);
- if (it != lineNumberMappings.constBegin() && lineNumberMappings.count() > 0)
- --it;
- if (it == lineNumberMappings.constEnd())
+ LineNumberMappingHelper helper;
+ helper.table = compiledFunction->lineNumberMapping();
+ const uint count = compiledFunction->nLineNumberMappingEntries;
+
+ int pos = helper.lowerBound(0, count, offset);
+ if (pos != 0 && count > 0)
+ --pos;
+ if (pos == count)
return -1;
- return it->lineNumber;
+ return helper.table[pos * 2 + 1];
}
QT_END_NAMESPACE