diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-07-18 15:48:21 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-08-02 13:56:35 +0000 |
commit | 3181e3dae0f01077ff209c4e8d9c83e901f20b0e (patch) | |
tree | 500b027e8f636916cbdad275dddf4f59eb290a9e /src/qml/compiler/qqmlirbuilder.cpp | |
parent | 49946ef87478fb34dc017a0ff7592ef9a0336d31 (diff) |
Introduce an accumulator in the interpreter, and change instructions
This reduces the number of stores to the stack (for which we need a
write-barrier in the future) by keeping the last calculated value in the
accumulator register (which is a local variable).
In the future we might want to collapse certain common instruction
patterns into a super-sized instruction.
Change-Id: I02ebed2db957765e994c8f939bf7585894881deb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qqmlirbuilder.cpp')
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index cd85482cb3..27e9d3f417 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -2053,7 +2053,7 @@ void JSCodeGen::beginFunctionBodyHook() #ifndef V4_BOOTSTRAP Instruction::LoadQmlContext load; - load.result = Reference::fromTemp(this, _qmlContextTemp).asLValue(); + load.result = Reference::fromTemp(this, _qmlContextTemp).temp(); bytecodeGenerator->addInstruction(load); #if 0 @@ -2065,7 +2065,7 @@ void JSCodeGen::beginFunctionBodyHook() #endif Instruction::LoadQmlImportedScripts loadScripts; - loadScripts.result = Reference::fromTemp(this, _importedScriptsTemp).asLValue(); + loadScripts.result = Reference::fromTemp(this, _importedScriptsTemp).temp(); bytecodeGenerator->addInstruction(loadScripts); #endif } @@ -2093,11 +2093,11 @@ QV4::Compiler::Codegen::Reference JSCodeGen::fallbackNameLookup(const QString &n if (_context->compilationMode == QV4::Compiler::QmlBinding) _context->idObjectDependencies.insert(mapping.idIndex); - Reference result = Reference::fromTemp(this); Instruction::LoadIdObject load; - load.base = Reference::fromTemp(this, _qmlContextTemp).asRValue(); + load.base = Reference::fromTemp(this, _qmlContextTemp).temp(); load.index = mapping.idIndex; - load.result = result.asLValue(); + + Reference result = Reference::fromAccumulator(this); bytecodeGenerator->addInstruction(load); result.isReadonly = true; return result; @@ -2112,12 +2112,10 @@ QV4::Compiler::Codegen::Reference JSCodeGen::fallbackNameLookup(const QString &n return Reference::fromSubscript(imports, Reference::fromConst(this, QV4::Encode(r.scriptIndex))); } else if (r.type) { if (r.type->isCompositeSingleton()) { - Reference result = Reference::fromTemp(this); Instruction::LoadQmlSingleton load; - load.result = result.asRValue(); load.name = registerString(name); bytecodeGenerator->addInstruction(load); - return result; + return Reference::fromAccumulator(this); } return Reference::fromName(this, name); } else { |