diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-16 12:36:13 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2013-08-16 16:51:10 +0200 |
commit | 85e6b8e9e7e158b5cb4238c2dd5e28406bc913e2 (patch) | |
tree | 60607ebe1834a8378375421e946d62fe0e90c1ea /src/qml/compiler/qv4compiler.cpp | |
parent | d017fe9b38c74d2cc2fa754af3bf9e32357f149c (diff) |
Cleanup: Store lookup tables inside the CompilationUnit
The size of each lookup is fixed, so it's easier to include in the unit itself.
Change-Id: I66135efe4056eb0b4d7ff312eaa347fe98d8887f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4compiler.cpp')
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 7f2f611898..385f668b42 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -127,7 +127,7 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit() registerString(*f->locals.at(i)); } - int unitSize = QV4::CompiledData::Unit::calculateSize(strings.size(), irModule->functions.size(), regexps.size()); + int unitSize = QV4::CompiledData::Unit::calculateSize(strings.size(), irModule->functions.size(), regexps.size(), lookups.size()); uint functionDataSize = 0; for (int i = 0; i < irModule->functions.size(); ++i) { @@ -142,9 +142,7 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit() functionDataSize += QV4::CompiledData::Function::calculateSize(f->formals.size(), f->locals.size(), f->nestedFunctions.size(), lineNumberMappingCount); } - const uint lookupDataSize = CompiledData::Lookup::calculateSize() * lookups.count(); - - char *data = (char *)malloc(unitSize + functionDataSize + stringDataSize + lookupDataSize); + char *data = (char *)malloc(unitSize + functionDataSize + stringDataSize); QV4::CompiledData::Unit *unit = (QV4::CompiledData::Unit*)data; memcpy(unit->magic, QV4::CompiledData::magic_str, sizeof(unit->magic)); @@ -156,9 +154,9 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit() unit->functionTableSize = irModule->functions.size(); unit->offsetToFunctionTable = unit->offsetToStringTable + unit->stringTableSize * sizeof(uint); unit->lookupTableSize = lookups.count(); + unit->offsetToLookupTable = unit->offsetToFunctionTable + unit->functionTableSize * sizeof(uint); unit->regexpTableSize = regexps.size(); - unit->offsetToRegexpTable = unit->offsetToFunctionTable + unit->functionTableSize * sizeof(uint); - unit->offsetToLookupTable = unitSize + stringDataSize + functionDataSize; + unit->offsetToRegexpTable = unit->offsetToLookupTable + unit->lookupTableSize * CompiledData::Lookup::calculateSize(); unit->sourceFileIndex = getStringId(irModule->fileName); // write strings and string table |