summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/bytecompiler/BytecodeGenerator.cpp')
-rw-r--r--JavaScriptCore/bytecompiler/BytecodeGenerator.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
index a4fd0d3..59537b6 100644
--- a/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
+++ b/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
@@ -256,9 +256,9 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const Debugger* d
m_nextGlobalIndex -= symbolTable->size();
for (size_t i = 0; i < functionStack.size(); ++i) {
- FunctionBodyNode* function = functionStack[i];
- globalObject->removeDirect(function->ident()); // Make sure our new function is not shadowed by an old property.
- emitNewFunction(addGlobalVar(function->ident(), false), function);
+ FuncDeclNode* funcDecl = functionStack[i];
+ globalObject->removeDirect(funcDecl->m_ident); // Make sure our new function is not shadowed by an old property.
+ emitNewFunction(addGlobalVar(funcDecl->m_ident, false), funcDecl);
}
Vector<RegisterID*, 32> newVars;
@@ -272,8 +272,8 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const Debugger* d
emitLoad(newVars[i], jsUndefined());
} else {
for (size_t i = 0; i < functionStack.size(); ++i) {
- FunctionBodyNode* function = functionStack[i];
- globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, adoptRef(new FunctionExecutable(function->ident(), function)), scopeChain.node()), DontDelete);
+ FuncDeclNode* funcDecl = functionStack[i];
+ globalObject->putWithAttributes(exec, funcDecl->m_ident, funcDecl->makeFunction(exec, scopeChain.node()), DontDelete);
}
for (size_t i = 0; i < varStack.size(); ++i) {
if (globalObject->hasProperty(exec, varStack[i].first))
@@ -339,10 +339,10 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Debug
const DeclarationStacks::FunctionStack& functionStack = functionBody->functionStack();
for (size_t i = 0; i < functionStack.size(); ++i) {
- FunctionBodyNode* function = functionStack[i];
- const Identifier& ident = function->ident();
+ FuncDeclNode* funcDecl = functionStack[i];
+ const Identifier& ident = funcDecl->m_ident;
m_functions.add(ident.ustring().rep());
- emitNewFunction(addVar(ident, false), function);
+ emitNewFunction(addVar(ident, false), funcDecl);
}
const DeclarationStacks::VarStack& varStack = functionBody->varStack();
@@ -397,12 +397,6 @@ BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const Debugger* debugge
codeBlock->setGlobalData(m_globalData);
m_codeBlock->m_numParameters = 1; // Allocate space for "this"
- const DeclarationStacks::FunctionStack& functionStack = evalNode->functionStack();
- for (size_t i = 0; i < functionStack.size(); ++i) {
- FunctionBodyNode* function = functionStack[i];
- m_codeBlock->addFunctionDecl(adoptRef(new FunctionExecutable(function->ident(), function)));
- }
-
preserveLastVar();
}
@@ -476,8 +470,7 @@ RegisterID* BytecodeGenerator::constRegisterFor(const Identifier& ident)
return 0;
SymbolTableEntry entry = symbolTable().get(ident.ustring().rep());
- if (entry.isNull())
- return 0;
+ ASSERT(!entry.isNull());
return &registerFor(entry.getIndex());
}
@@ -772,6 +765,18 @@ PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionApply(RegisterID* cond
return target;
}
+unsigned BytecodeGenerator::addConstant(FuncDeclNode* n)
+{
+ // No need to explicitly unique function body nodes -- they're unique already.
+ return m_codeBlock->addFunction(n);
+}
+
+unsigned BytecodeGenerator::addConstant(FuncExprNode* n)
+{
+ // No need to explicitly unique function expression nodes -- they're unique already.
+ return m_codeBlock->addFunctionExpression(n);
+}
+
unsigned BytecodeGenerator::addConstant(const Identifier& ident)
{
UString::Rep* rep = ident.ustring().rep();
@@ -1308,13 +1313,11 @@ RegisterID* BytecodeGenerator::emitNewArray(RegisterID* dst, ElementNode* elemen
return dst;
}
-RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* function)
+RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FuncDeclNode* n)
{
- unsigned index = m_codeBlock->addFunctionDecl(adoptRef(new FunctionExecutable(function->ident(), function)));
-
emitOpcode(op_new_func);
instructions().append(dst->index());
- instructions().append(index);
+ instructions().append(addConstant(n));
return dst;
}
@@ -1329,12 +1332,9 @@ RegisterID* BytecodeGenerator::emitNewRegExp(RegisterID* dst, RegExp* regExp)
RegisterID* BytecodeGenerator::emitNewFunctionExpression(RegisterID* r0, FuncExprNode* n)
{
- FunctionBodyNode* function = n->body();
- unsigned index = m_codeBlock->addFunctionExpr(adoptRef(new FunctionExecutable(function->ident(), function)));
-
emitOpcode(op_new_func_exp);
instructions().append(r0->index());
- instructions().append(index);
+ instructions().append(addConstant(n));
return r0;
}
@@ -1805,7 +1805,7 @@ void BytecodeGenerator::emitSubroutineReturn(RegisterID* retAddrSrc)
instructions().append(retAddrSrc->index());
}
-void BytecodeGenerator::emitPushNewScope(RegisterID* dst, const Identifier& property, RegisterID* value)
+void BytecodeGenerator::emitPushNewScope(RegisterID* dst, Identifier& property, RegisterID* value)
{
ControlFlowContext context;
context.isFinallyBlock = false;