diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-03-03 14:41:31 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-07 16:55:12 +0100 |
commit | 245f5ce7bb194438fc643e5c928382f47556e2f2 (patch) | |
tree | 73d82c57dddf8e8e0c206cd50fe8af4542d3f299 /src/qml/jsruntime/qv4function.cpp | |
parent | 4c4bddb0254acbc53b80e804bbbc26cfdd4e87a1 (diff) |
Add a Line instruction to the interpreter
This unifies the way we handle line numbers in the
JIT and Interpreter.
Remove the now unused lineNumberMapping code and data.
Change-Id: I1d60b1fbb77e70b531fa73d93410683e84dd1e3c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4function.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index e01febcfa3..6fdf61f2c3 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -86,80 +86,4 @@ Function::~Function() { } - -namespace QV4 { -template <int field, typename SearchType> -struct LineNumberMappingHelper -{ - const quint32 *table; - int lowerBound(int begin, int end, SearchType value) { - int middle; - int n = int(end - begin); - int half; - - while (n > 0) { - half = n >> 1; - middle = begin + half; - if (table[middle * 2 + field] < static_cast<quint32>(value)) { - begin = middle + 1; - n -= half + 1; - } else { - n = half; - } - } - return begin; - } - int upperBound(int begin, int end, SearchType value) { - int middle; - int n = int(end - begin); - int half; - - while (n > 0) { - half = n >> 1; - middle = begin + half; - if (value < table[middle * 2 + field]) { - n = half; - } else { - begin = middle + 1; - n -= half + 1; - } - } - return begin; - } -}; -} - -int Function::lineNumberForProgramCounter(qptrdiff offset) const -{ - // Access the first field, the program counter - LineNumberMappingHelper<0, qptrdiff> helper; - helper.table = compiledFunction->lineNumberMapping(); - const uint count = compiledFunction->nLineNumberMappingEntries; - - int pos = helper.lowerBound(0, count, offset); - if (pos != 0 && count > 0) - --pos; - if (static_cast<uint>(pos) == count) - return -1; - return helper.table[pos * 2 + 1]; -} - -QList<qptrdiff> Function::programCountersForAllLines() const -{ - // Only store 1 breakpoint per line... - QHash<quint32, qptrdiff> offsetsPerLine; - const quint32 *mapping = compiledFunction->lineNumberMapping(); - - // ... and make it the first instruction by walking backwards over the line mapping table - // and inserting all entries keyed on line. - for (quint32 i = compiledFunction->nLineNumberMappingEntries; i > 0; ) { - --i; // the loop is written this way, because starting at endIndex-1 and checking for i>=0 will never end: i>=0 is always true for unsigned. - quint32 offset = mapping[i * 2]; - quint32 line = mapping[i * 2 + 1]; - offsetsPerLine.insert(line, offset); - } - - return offsetsPerLine.values(); -} - QT_END_NAMESPACE |