diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-11-12 16:07:56 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-11-21 13:08:28 +0100 |
commit | f58b5229a31e9fec49b4eb055c56f9a78e423866 (patch) | |
tree | 6214fb89929fd9482c2154b0fe17c7cba0f509cb /src/qml/compiler | |
parent | e6db292366fa6ad25536fee08b2a972ea617d968 (diff) |
Fix run-time string handling with regards to the new heap
Changed runtimeStrings to be an array of Heap::String pointers instead of
indirect String pointers. Later that member along with other GC related members
will go into a managed subclass. Meanwhile the generated code no more loads
String pointers directly but just passes the index into the run-time strings to
the run-time functions, which in turn will load the heap string into a scoped
string.
Also replaced the template<T> Value::operator=(T *m) with a non-template
overload that takes a Managed *, in order to help the compiler choose the
non-template operator=(Heap::Base *) overload. This allows removing a bunch
of Value::fromHeapObject calls.
Change-Id: I20415c0549d33cca6813441a2495976b66d4c00e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 23 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 2 |
2 files changed, 10 insertions, 15 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 34b270632d..f327f9b70e 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -65,13 +65,11 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) Q_ASSERT(!runtimeStrings); Q_ASSERT(data); - runtimeStrings = (QV4::String **)malloc(data->stringTableSize * sizeof(QV4::String*)); + runtimeStrings = (QV4::Heap::String **)malloc(data->stringTableSize * sizeof(QV4::Heap::String*)); // memset the strings to 0 in case a GC run happens while we're within the loop below - memset(runtimeStrings, 0, data->stringTableSize * sizeof(QV4::String*)); - for (uint i = 0; i < data->stringTableSize; ++i) { - // #### GC - runtimeStrings[i] = reinterpret_cast<QV4::String*>(engine->newIdentifier(data->stringAt(i))); - } + memset(runtimeStrings, 0, data->stringTableSize * sizeof(QV4::Heap::String*)); + for (uint i = 0; i < data->stringTableSize; ++i) + runtimeStrings[i] = engine->newIdentifier(data->stringAt(i)); runtimeRegularExpressions = new QV4::Value[data->regexpTableSize]; // memset the regexps to 0 in case a GC run happens while we're within the loop below @@ -85,7 +83,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) flags |= IR::RegExp::RegExp_IgnoreCase; if (re->flags & CompiledData::RegExp::RegExp_Multiline) flags |= IR::RegExp::RegExp_Multiline; - runtimeRegularExpressions[i] = QV4::Value::fromHeapObject(engine->newRegExpObject(data->stringAt(re->stringIndex), flags)); + runtimeRegularExpressions[i] = engine->newRegExpObject(data->stringAt(re->stringIndex), flags); } if (data->lookupTableSize) { @@ -111,7 +109,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) l->classList[j] = 0; l->level = -1; l->index = UINT_MAX; - l->name = runtimeStrings[compiledLookups[i].nameIndex]; + l->nameIndex = compiledLookups[i].nameIndex; if (type == CompiledData::Lookup::Type_IndexedGetter || type == CompiledData::Lookup::Type_IndexedSetter) l->engine = engine; } @@ -119,13 +117,15 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) if (data->jsClassTableSize) { runtimeClasses = (QV4::InternalClass**)malloc(data->jsClassTableSize * sizeof(QV4::InternalClass*)); + Scope scope(engine); + ScopedString memberName(scope); for (uint i = 0; i < data->jsClassTableSize; ++i) { int memberCount = 0; const CompiledData::JSClassMember *member = data->jsClassAt(i, &memberCount); QV4::InternalClass *klass = engine->objectClass; for (int j = 0; j < memberCount; ++j, ++member) - klass = klass->addMember(runtimeStrings[member->nameOffset], member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data); + klass = klass->addMember((memberName = runtimeStrings[member->nameOffset]), member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data); runtimeClasses[i] = klass; } @@ -174,11 +174,6 @@ void CompilationUnit::markObjects(QV4::ExecutionEngine *e) for (uint i = 0; i < data->regexpTableSize; ++i) runtimeRegularExpressions[i].mark(e); } - if (runtimeLookups) { - for (uint i = 0; i < data->lookupTableSize; ++i) - if (runtimeLookups[i].name) - runtimeLookups[i].name->mark(e); - } } #endif // V4_BOOTSTRAP diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 2e8e43dda7..2f335958e6 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -587,7 +587,7 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount ExecutionEngine *engine; QString fileName() const { return data->stringAt(data->sourceFileIndex); } - QV4::String **runtimeStrings; // Array + QV4::Heap::String **runtimeStrings; // Array QV4::Lookup *runtimeLookups; QV4::Value *runtimeRegularExpressions; QV4::InternalClass **runtimeClasses; |