From 88a04ac016f57c2d78e714682445dff2e7db4ade Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 11 Sep 2012 19:54:20 +0200 Subject: 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 --- .../bytecompiler/BytecodeGenerator.cpp | 32 +++++++++++++++++----- .../bytecompiler/BytecodeGenerator.h | 2 ++ 2 files changed, 27 insertions(+), 7 deletions(-) (limited to 'Source/JavaScriptCore/bytecompiler') 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 m_constantPoolRegisters; SegmentedVector m_calleeRegisters; SegmentedVector m_parameters; -- cgit v1.2.1