diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-14 10:17:37 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-15 09:08:39 +0200 |
commit | 5f3ef18bf8c3e0e3ba1c80bcdeaece46cbb45c06 (patch) | |
tree | 645b8834e773e408bdb07b33dc8e7733335bf1e3 /src/qml/compiler/qv4compileddata_p.h | |
parent | 131964a3b5ac0cb6de5f1d306035003751da907a (diff) |
Begin using the compiled data structures for runtime strings
Change-Id: Idbf278a96624bf101df35de40577b38e593f22be
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4compileddata_p.h')
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 47e4e48957..67ddfb3bb4 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -56,10 +56,13 @@ struct Function; namespace QV4 { +struct Function; struct ExecutionContext; namespace CompiledData { +struct String; + static const char magic_str[] = "qv4cdata"; struct Unit @@ -77,6 +80,13 @@ struct Unit uint offsetToStringTable; uint functionTableSize; uint offsetToFunctionTable; + uint indexOfRootFunction; + + const String *stringAt(int idx) const { + const uint *offsetTable = reinterpret_cast<const uint*>((reinterpret_cast<const char *>(this)) + offsetToStringTable); + const uint offset = offsetTable[idx]; + return reinterpret_cast<const String*>(reinterpret_cast<const char *>(this) + offset); + } static int calculateSize(uint nStrings, uint nFunctions) { return (sizeof(Unit) + (nStrings + nFunctions) * sizeof(uint) + 7) & ~7; } }; @@ -110,6 +120,11 @@ struct String QArrayData str; // uint16 strdata[] + QString qString() const { + QStringDataPtr holder { const_cast<QStringData *>(static_cast<const QStringData*>(&str)) }; + return QString(holder); + } + static int calculateSize(const QString &str) { return (sizeof(String) + (str.length() + 1) * sizeof(quint16) + 7) & ~0x7; } @@ -201,11 +216,29 @@ struct QmlUnit struct CompilationUnit { + CompilationUnit() + : refCount(0) + , data(0) + , runtimeIdentifiers(0) + {} virtual ~CompilationUnit(); + + void ref() { ++refCount; } + void deref() { if (!--refCount) delete this; } + + int refCount; Unit *data; + QV4::String **runtimeIdentifiers; // Array + + QV4::Function *linkToEngine(QV4::ExecutionEngine *engine); + + // ### runtime data // pointer to qml data for QML unit + +protected: + virtual QV4::Function *linkBackendToEngine(QV4::ExecutionEngine *engine) = 0; }; struct MasmCompilationUnit : public CompilationUnit @@ -214,8 +247,12 @@ struct MasmCompilationUnit : public CompilationUnit // free all jitted code } + virtual QV4::Function *linkBackendToEngine(QV4::ExecutionEngine *engine); + // Coderef + execution engine + // ### remove + QV4::Function *rootFunction; }; struct MothCompilationUnit : public CompilationUnit |