diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-11 19:54:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-11 19:54:20 +0200 |
commit | 88a04ac016f57c2d78e714682445dff2e7db4ade (patch) | |
tree | a48ca81ee3b29953121308168db22532d5b57fe2 /Source/JavaScriptCore/bytecompiler | |
parent | 284837daa07b29d6a63a748544a90b1f5842ac5c (diff) | |
download | qtwebkit-88a04ac016f57c2d78e714682445dff2e7db4ade.tar.gz |
Imported WebKit commit 42d95198c30c2d1a94a5081181aad0b2be7c316c (http://svn.webkit.org/repository/webkit/trunk@128206)
This includes the rewrite of the configure part of the build system which should fix the QtQuick2 detection
and allow for further simplifications in the future
Diffstat (limited to 'Source/JavaScriptCore/bytecompiler')
-rw-r--r-- | Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp | 32 | ||||
-rw-r--r-- | Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h | 2 |
2 files changed, 27 insertions, 7 deletions
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp index 52b576da2..82f9d6f60 100644 --- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp +++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp @@ -272,6 +272,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, JSScope* scope, S , m_scopeNode(programNode) , m_codeBlock(codeBlock) , m_thisRegister(CallFrame::thisArgumentOffset()) + , m_emptyValueRegister(0) , m_finallyDepth(0) , m_dynamicScopeDepth(0) , m_baseScopeDepth(0) @@ -353,6 +354,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* sc , m_scopeNode(functionBody) , m_codeBlock(codeBlock) , m_activationRegister(0) + , m_emptyValueRegister(0) , m_finallyDepth(0) , m_dynamicScopeDepth(0) , m_baseScopeDepth(0) @@ -386,8 +388,6 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* sc m_codeBlock->setActivationRegister(m_activationRegister->index()); } - // Both op_tear_off_activation and op_tear_off_arguments tear off the 'arguments' - // object, if created. if (m_codeBlock->needsFullScopeChain() || functionBody->usesArguments()) { RegisterID* unmodifiedArgumentsRegister = addVar(); // Anonymous, so it can't be modified by user code. RegisterID* argumentsRegister = addVar(propertyNames().arguments, false); // Can be changed by assigning to 'arguments'. @@ -526,6 +526,7 @@ BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, JSScope* scope, SymbolT , m_scopeNode(evalNode) , m_codeBlock(codeBlock) , m_thisRegister(CallFrame::thisArgumentOffset()) + , m_emptyValueRegister(0) , m_finallyDepth(0) , m_dynamicScopeDepth(0) , m_baseScopeDepth(codeBlock->baseScopeDepth()) @@ -1111,18 +1112,33 @@ unsigned BytecodeGenerator::addConstant(const Identifier& ident) return result.iterator->second; } +// We can't hash JSValue(), so we use a dedicated data member to cache it. +RegisterID* BytecodeGenerator::addConstantEmptyValue() +{ + if (!m_emptyValueRegister) { + int index = m_nextConstantOffset; + m_constantPoolRegisters.append(FirstConstantRegisterIndex + m_nextConstantOffset); + ++m_nextConstantOffset; + m_codeBlock->addConstant(JSValue()); + m_emptyValueRegister = &m_constantPoolRegisters[index]; + } + + return m_emptyValueRegister; +} + RegisterID* BytecodeGenerator::addConstantValue(JSValue v) { - int index = m_nextConstantOffset; + if (!v) + return addConstantEmptyValue(); + int index = m_nextConstantOffset; JSValueMap::AddResult result = m_jsValueMap.add(JSValue::encode(v), m_nextConstantOffset); if (result.isNewEntry) { m_constantPoolRegisters.append(FirstConstantRegisterIndex + m_nextConstantOffset); ++m_nextConstantOffset; - m_codeBlock->addConstant(JSValue(v)); + m_codeBlock->addConstant(v); } else index = result.iterator->second; - return &m_constantPoolRegisters[index]; } @@ -2046,10 +2062,12 @@ RegisterID* BytecodeGenerator::emitReturn(RegisterID* src) if (m_codeBlock->needsFullScopeChain()) { emitOpcode(op_tear_off_activation); instructions().append(m_activationRegister->index()); - instructions().append(m_codeBlock->argumentsRegister()); - } else if (m_codeBlock->usesArguments() && m_codeBlock->numParameters() != 1 && !m_codeBlock->isStrictMode()) { + } + + if (m_codeBlock->usesArguments() && m_codeBlock->numParameters() != 1 && !m_codeBlock->isStrictMode()) { emitOpcode(op_tear_off_arguments); instructions().append(m_codeBlock->argumentsRegister()); + instructions().append(m_activationRegister ? m_activationRegister->index() : emitLoad(0, JSValue())->index()); } // Constructors use op_ret_object_or_this to check the result is an diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h index 037a2ce25..28a806eb3 100644 --- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h +++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h @@ -637,6 +637,7 @@ namespace JSC { unsigned addConstant(const Identifier&); RegisterID* addConstantValue(JSValue); + RegisterID* addConstantEmptyValue(); unsigned addRegExp(RegExp*); unsigned addConstantBuffer(unsigned length); @@ -713,6 +714,7 @@ namespace JSC { RegisterID m_thisRegister; RegisterID m_calleeRegister; RegisterID* m_activationRegister; + RegisterID* m_emptyValueRegister; SegmentedVector<RegisterID, 32> m_constantPoolRegisters; SegmentedVector<RegisterID, 32> m_calleeRegisters; SegmentedVector<RegisterID, 32> m_parameters; |