diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-14 16:29:47 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-14 16:29:47 +0200 |
commit | d0424a769059c84ae20beb3c217812792ea6726b (patch) | |
tree | 6f94a5c3db8c52c6694ee56498542a6c35417350 /Source/JavaScriptCore/bytecompiler | |
parent | 88a04ac016f57c2d78e714682445dff2e7db4ade (diff) | |
download | qtwebkit-d0424a769059c84ae20beb3c217812792ea6726b.tar.gz |
Imported WebKit commit 37c5e5041d39a14ea0d429a77ebd352e4bd26516 (http://svn.webkit.org/repository/webkit/trunk@128608)
New snapshot that enables WebKit2 build on Windows (still some bugs) and allows for WebKit to be built with qmake && make
Diffstat (limited to 'Source/JavaScriptCore/bytecompiler')
-rw-r--r-- | Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp | 78 | ||||
-rw-r--r-- | Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h | 11 | ||||
-rw-r--r-- | Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp | 6 |
3 files changed, 76 insertions, 19 deletions
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp index 82f9d6f60..055f605d2 100644 --- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp +++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp @@ -260,7 +260,7 @@ void BytecodeGenerator::preserveLastVar() m_lastVar = &m_calleeRegisters.last(); } -BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, JSScope* scope, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock, CompilationKind compilationKind) +BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, JSScope* scope, SharedSymbolTable* symbolTable, ProgramCodeBlock* codeBlock, CompilationKind compilationKind) : m_shouldEmitDebugHooks(scope->globalObject()->debugger()) , m_shouldEmitProfileHooks(scope->globalObject()->globalObjectMethodTable()->supportsProfiling(scope->globalObject())) , m_shouldEmitRichSourceInfo(scope->globalObject()->globalObjectMethodTable()->supportsRichSourceInfo(scope->globalObject())) @@ -295,13 +295,15 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, JSScope* scope, S if (m_shouldEmitDebugHooks) m_codeBlock->setNeedsFullScopeChain(true); + codeBlock->setGlobalData(m_globalData); + symbolTable->setUsesNonStrictEval(codeBlock->usesEval() && !codeBlock->isStrictMode()); + m_codeBlock->setNumParameters(1); // Allocate space for "this" + prependComment("entering Program block"); emitOpcode(op_enter); - codeBlock->setGlobalData(m_globalData); // FIXME: Move code that modifies the global object to Interpreter::execute. - m_codeBlock->setNumParameters(1); // Allocate space for "this" codeBlock->m_numCapturedVars = codeBlock->m_numVars; if (compilationKind == OptimizingCompilation) @@ -342,7 +344,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, JSScope* scope, S } } -BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* scope, SymbolTable* symbolTable, CodeBlock* codeBlock, CompilationKind) +BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* scope, SharedSymbolTable* symbolTable, CodeBlock* codeBlock, CompilationKind) : m_shouldEmitDebugHooks(scope->globalObject()->debugger()) , m_shouldEmitProfileHooks(scope->globalObject()->globalObjectMethodTable()->supportsProfiling(scope->globalObject())) , m_shouldEmitRichSourceInfo(scope->globalObject()->globalObjectMethodTable()->supportsRichSourceInfo(scope->globalObject())) @@ -378,7 +380,9 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* sc m_codeBlock->setNeedsFullScopeChain(true); codeBlock->setGlobalData(m_globalData); - + symbolTable->setUsesNonStrictEval(codeBlock->usesEval() && !codeBlock->isStrictMode()); + symbolTable->setParameterCountIncludingThis(functionBody->parameters()->size() + 1); + prependComment("entering Function block"); emitOpcode(op_enter); if (m_codeBlock->needsFullScopeChain()) { @@ -388,7 +392,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* sc m_codeBlock->setActivationRegister(m_activationRegister->index()); } - if (m_codeBlock->needsFullScopeChain() || functionBody->usesArguments()) { + if (functionBody->usesArguments() || codeBlock->usesEval() || m_shouldEmitDebugHooks) { // May reify arguments object. 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'. @@ -419,6 +423,25 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* sc } } + bool capturesAnyArgument = codeBlock->usesArguments() || codeBlock->usesEval() || m_shouldEmitDebugHooks; // May reify arguments object. + if (!capturesAnyArgument && functionBody->hasCapturedVariables()) { + FunctionParameters& parameters = *functionBody->parameters(); + for (size_t i = 0; i < parameters.size(); ++i) { + if (!functionBody->captures(parameters[i])) + continue; + capturesAnyArgument = true; + break; + } + } + + if (capturesAnyArgument) { + symbolTable->setCaptureMode(SharedSymbolTable::AllOfTheThings); + symbolTable->setCaptureStart(-CallFrame::offsetFor(symbolTable->parameterCountIncludingThis())); + } else { + symbolTable->setCaptureMode(SharedSymbolTable::SomeOfTheThings); + symbolTable->setCaptureStart(m_codeBlock->m_numVars); + } + RegisterID* calleeRegister = resolveCallee(functionBody); // May push to the scope chain and/or add a captured var. const DeclarationStacks::FunctionStack& functionStack = functionBody->functionStack(); @@ -484,9 +507,11 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* sc addVar(ident, varStack[i].second & DeclarationStacks::IsConstant); } - if (m_shouldEmitDebugHooks) + if (m_shouldEmitDebugHooks || codeBlock->usesEval()) codeBlock->m_numCapturedVars = codeBlock->m_numVars; + symbolTable->setCaptureEnd(codeBlock->m_numCapturedVars); + FunctionParameters& parameters = *functionBody->parameters(); m_parameters.grow(parameters.size() + 1); // reserve space for "this" @@ -514,7 +539,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* sc } } -BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, JSScope* scope, SymbolTable* symbolTable, EvalCodeBlock* codeBlock, CompilationKind) +BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, JSScope* scope, SharedSymbolTable* symbolTable, EvalCodeBlock* codeBlock, CompilationKind) : m_shouldEmitDebugHooks(scope->globalObject()->debugger()) , m_shouldEmitProfileHooks(scope->globalObject()->globalObjectMethodTable()->supportsProfiling(scope->globalObject())) , m_shouldEmitRichSourceInfo(scope->globalObject()->globalObjectMethodTable()->supportsRichSourceInfo(scope->globalObject())) @@ -549,11 +574,13 @@ BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, JSScope* scope, SymbolT if (m_shouldEmitDebugHooks || m_baseScopeDepth) m_codeBlock->setNeedsFullScopeChain(true); - prependComment("entering Eval block"); - emitOpcode(op_enter); codeBlock->setGlobalData(m_globalData); + symbolTable->setUsesNonStrictEval(codeBlock->usesEval() && !codeBlock->isStrictMode()); m_codeBlock->setNumParameters(1); + prependComment("entering Eval block"); + emitOpcode(op_enter); + const DeclarationStacks::FunctionStack& functionStack = evalNode->functionStack(); for (size_t i = 0; i < functionStack.size(); ++i) m_codeBlock->addFunctionDecl(FunctionExecutable::create(*m_globalData, functionStack[i])); @@ -1355,7 +1382,7 @@ ResolveResult BytecodeGenerator::resolve(const Identifier& property) } #if !ASSERT_DISABLED if (JSActivation* activation = jsDynamicCast<JSActivation*>(currentVariableObject)) - ASSERT(activation->isValidScopedLookup(entry.getIndex())); + ASSERT(activation->isValid(entry)); #endif return ResolveResult::lexicalResolve(entry.getIndex(), depth, flags); } @@ -1636,6 +1663,31 @@ RegisterID* BytecodeGenerator::emitGetStaticVar(RegisterID* dst, const ResolveRe } } +RegisterID* BytecodeGenerator::emitInitGlobalConst(const ResolveResult& resolveResult, const Identifier& identifier, RegisterID* value) +{ + ASSERT(m_codeType == GlobalCode); + switch (resolveResult.type()) { + case ResolveResult::IndexedGlobal: + case ResolveResult::ReadOnlyIndexedGlobal: + emitOpcode(op_init_global_const); + instructions().append(resolveResult.registerPointer()); + instructions().append(value->index()); + return value; + + case ResolveResult::WatchedIndexedGlobal: + emitOpcode(op_init_global_const_check); + instructions().append(resolveResult.registerPointer()); + instructions().append(value->index()); + instructions().append(jsCast<JSGlobalObject*>(resolveResult.globalObject())->symbolTable()->get(identifier.impl()).addressOfIsWatched()); + instructions().append(addConstant(identifier)); + return value; + + default: + ASSERT_NOT_REACHED(); + return 0; + } +} + RegisterID* BytecodeGenerator::emitPutStaticVar(const ResolveResult& resolveResult, const Identifier& identifier, RegisterID* value) { switch (resolveResult.type()) { @@ -1731,7 +1783,9 @@ RegisterID* BytecodeGenerator::emitDirectPutById(RegisterID* base, const Identif instructions().append(0); instructions().append(0); instructions().append(0); - instructions().append(property != m_globalData->propertyNames->underscoreProto); + instructions().append( + property != m_globalData->propertyNames->underscoreProto + && PropertyName(property).asIndex() == PropertyName::NotAnIndex); return value; } diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h index 28a806eb3..398719749 100644 --- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h +++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h @@ -261,9 +261,9 @@ namespace JSC { JS_EXPORT_PRIVATE static void setDumpsGeneratedCode(bool dumpsGeneratedCode); static bool dumpsGeneratedCode(); - BytecodeGenerator(ProgramNode*, JSScope*, SymbolTable*, ProgramCodeBlock*, CompilationKind); - BytecodeGenerator(FunctionBodyNode*, JSScope*, SymbolTable*, CodeBlock*, CompilationKind); - BytecodeGenerator(EvalNode*, JSScope*, SymbolTable*, EvalCodeBlock*, CompilationKind); + BytecodeGenerator(ProgramNode*, JSScope*, SharedSymbolTable*, ProgramCodeBlock*, CompilationKind); + BytecodeGenerator(FunctionBodyNode*, JSScope*, SharedSymbolTable*, CodeBlock*, CompilationKind); + BytecodeGenerator(EvalNode*, JSScope*, SharedSymbolTable*, EvalCodeBlock*, CompilationKind); ~BytecodeGenerator(); @@ -462,6 +462,7 @@ namespace JSC { RegisterID* emitGetStaticVar(RegisterID* dst, const ResolveResult&, const Identifier&); RegisterID* emitPutStaticVar(const ResolveResult&, const Identifier&, RegisterID* value); + RegisterID* emitInitGlobalConst(const ResolveResult&, const Identifier&, RegisterID* value); RegisterID* emitResolve(RegisterID* dst, const ResolveResult&, const Identifier& property); RegisterID* emitResolveBase(RegisterID* dst, const ResolveResult&, const Identifier& property); @@ -654,7 +655,7 @@ namespace JSC { public: Vector<Instruction>& instructions() { return m_instructions; } - SymbolTable& symbolTable() { return *m_symbolTable; } + SharedSymbolTable& symbolTable() { return *m_symbolTable; } #if ENABLE(BYTECODE_COMMENTS) Vector<Comment>& comments() { return m_comments; } #endif @@ -697,7 +698,7 @@ namespace JSC { bool m_shouldEmitRichSourceInfo; Strong<JSScope> m_scope; - SymbolTable* m_symbolTable; + SharedSymbolTable* m_symbolTable; #if ENABLE(BYTECODE_COMMENTS) Vector<Comment> m_comments; diff --git a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp b/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp index 63f4657c9..e4d35471f 100644 --- a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp +++ b/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp @@ -1387,9 +1387,11 @@ RegisterID* ConstDeclNode::emitCodeSingle(BytecodeGenerator& generator) RefPtr<RegisterID> value = m_init ? generator.emitNode(m_init) : generator.emitLoad(0, jsUndefined()); - if (resolveResult.isStatic()) + if (resolveResult.isStatic()) { + if (generator.codeType() == GlobalCode) + return generator.emitInitGlobalConst(resolveResult, m_ident, value.get()); return generator.emitPutStaticVar(resolveResult, m_ident, value.get()); - + } if (generator.codeType() != EvalCode) return value.get(); |