Add scope operand to op_new_func* byte codes
https://bugs.webkit.org/show_bug.cgi?id=138707
Reviewed by Mark Lam.
Added scope operand to op_new_func and op_new_func_expr to replace the implicit use
of exec->scope().
* bytecode/BytecodeList.json: Increased size of op_new_func & op_new_func_expr bytecodes.
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpBytecode): Added scope operand to dump output.
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitNewFunctionInternal):
(JSC::BytecodeGenerator::emitNewFunctionExpression):
Emit scope operand.
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
Added new scope source nodes to NewFunction, NewFunctionExpression & NewFunctionNoCheck.
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileNewFunctionNoCheck):
(JSC::DFG::SpeculativeJIT::compileNewFunctionExpression):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
Use scope children when making new function JIT_Operation calls. Use JSScope* value instead of
exec->scope().
* dfg/DFGOperations.h:
* dfg/DFGOperations.cpp:
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::callOperation):
* jit/JIT.h:
* jit/JITInlines.h:
(JSC::JIT::callOperation):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_new_func):
(JSC::JIT::emit_op_new_func_exp):
* jit/JITOperations.cpp:
* jit/JITOperations.h:
Added new Jsc JIT_Operation parameter type for JSScope* values. Created declarations and
definitions for new JIT_Operations with Jsc parameters. Use the JSScope* parameters in lieu
of exec->scope() in operationNewFunction().
Removed comment for unused Jsa (JSLexicalEnvironment*) JIT_Operation parameter type.
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
Use the scope operand instead of exec->scope().
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
Changed the operand indecies for added scope operand.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index cb41782..c619422 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,65 @@
+2014-11-13 Michael Saboff <msaboff@apple.com>
+
+ Add scope operand to op_new_func* byte codes
+ https://bugs.webkit.org/show_bug.cgi?id=138707
+
+ Reviewed by Mark Lam.
+
+ Added scope operand to op_new_func and op_new_func_expr to replace the implicit use
+ of exec->scope().
+
+ * bytecode/BytecodeList.json: Increased size of op_new_func & op_new_func_expr bytecodes.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dumpBytecode): Added scope operand to dump output.
+
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::emitNewFunctionInternal):
+ (JSC::BytecodeGenerator::emitNewFunctionExpression):
+ Emit scope operand.
+
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::parseBlock):
+ * dfg/DFGFixupPhase.cpp:
+ (JSC::DFG::FixupPhase::fixupNode):
+ Added new scope source nodes to NewFunction, NewFunctionExpression & NewFunctionNoCheck.
+
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileNewFunctionNoCheck):
+ (JSC::DFG::SpeculativeJIT::compileNewFunctionExpression):
+ * dfg/DFGSpeculativeJIT32_64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ * dfg/DFGSpeculativeJIT64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ Use scope children when making new function JIT_Operation calls. Use JSScope* value instead of
+ exec->scope().
+
+ * dfg/DFGOperations.h:
+ * dfg/DFGOperations.cpp:
+ * dfg/DFGSpeculativeJIT.h:
+ (JSC::DFG::SpeculativeJIT::callOperation):
+ * jit/JIT.h:
+ * jit/JITInlines.h:
+ (JSC::JIT::callOperation):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_new_func):
+ (JSC::JIT::emit_op_new_func_exp):
+ * jit/JITOperations.cpp:
+ * jit/JITOperations.h:
+ Added new Jsc JIT_Operation parameter type for JSScope* values. Created declarations and
+ definitions for new JIT_Operations with Jsc parameters. Use the JSScope* parameters in lieu
+ of exec->scope() in operationNewFunction().
+ Removed comment for unused Jsa (JSLexicalEnvironment*) JIT_Operation parameter type.
+
+ * llint/LLIntSlowPaths.cpp:
+ (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+ Use the scope operand instead of exec->scope().
+
+ * llint/LowLevelInterpreter.asm:
+ * llint/LowLevelInterpreter32_64.asm:
+ * llint/LowLevelInterpreter64.asm:
+ Changed the operand indecies for added scope operand.
+
2014-11-13 Mark Lam <mark.lam@apple.com>
Change X86/64 JIT probes to save/restore xmm regs as double instead of __m128. [Follow up]
diff --git a/Source/JavaScriptCore/bytecode/BytecodeList.json b/Source/JavaScriptCore/bytecode/BytecodeList.json
index f0cab0e..e694218 100644
--- a/Source/JavaScriptCore/bytecode/BytecodeList.json
+++ b/Source/JavaScriptCore/bytecode/BytecodeList.json
@@ -93,8 +93,8 @@
{ "name" : "op_switch_imm", "length" : 4 },
{ "name" : "op_switch_char", "length" : 4 },
{ "name" : "op_switch_string", "length" : 4 },
- { "name" : "op_new_func", "length" : 4 },
- { "name" : "op_new_func_exp", "length" : 3 },
+ { "name" : "op_new_func", "length" : 5 },
+ { "name" : "op_new_func_exp", "length" : 4 },
{ "name" : "op_call", "length" : 9 },
{ "name" : "op_call_eval", "length" : 9 },
{ "name" : "op_call_varargs", "length" : 9 },
diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
index 29bb9b7..275ff4a 100644
--- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -1271,17 +1271,19 @@
}
case op_new_func: {
int r0 = (++it)->u.operand;
+ int r1 = (++it)->u.operand;
int f0 = (++it)->u.operand;
int shouldCheck = (++it)->u.operand;
printLocationAndOp(out, exec, location, it, "new_func");
- out.printf("%s, f%d, %s", registerName(r0).data(), f0, shouldCheck ? "<Checked>" : "<Unchecked>");
+ out.printf("%s, %s, f%d, %s", registerName(r0).data(), registerName(r1).data(), f0, shouldCheck ? "<Checked>" : "<Unchecked>");
break;
}
case op_new_func_exp: {
int r0 = (++it)->u.operand;
+ int r1 = (++it)->u.operand;
int f0 = (++it)->u.operand;
printLocationAndOp(out, exec, location, it, "new_func_exp");
- out.printf("%s, f%d", registerName(r0).data(), f0);
+ out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0);
break;
}
case op_call: {
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
index 4b9bf7f..b2134ef 100644
--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
@@ -1715,6 +1715,7 @@
{
emitOpcode(op_new_func);
instructions().append(dst->index());
+ instructions().append(scopeRegister()->index());
instructions().append(index);
instructions().append(doNullCheck);
return dst;
@@ -1735,6 +1736,7 @@
emitOpcode(op_new_func_exp);
instructions().append(r0->index());
+ instructions().append(scopeRegister()->index());
instructions().append(index);
return r0;
}
diff --git a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
index 22ee4b3..d3d83d0 100644
--- a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
+++ b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
@@ -3433,22 +3433,22 @@
}
case op_new_func: {
- if (!currentInstruction[3].u.operand) {
+ if (!currentInstruction[4].u.operand) {
set(VirtualRegister(currentInstruction[1].u.operand),
- addToGraph(NewFunctionNoCheck, OpInfo(currentInstruction[2].u.operand)));
+ addToGraph(NewFunctionNoCheck, OpInfo(currentInstruction[3].u.operand), get(VirtualRegister(currentInstruction[2].u.operand))));
} else {
set(VirtualRegister(currentInstruction[1].u.operand),
addToGraph(
NewFunction,
- OpInfo(currentInstruction[2].u.operand),
- get(VirtualRegister(currentInstruction[1].u.operand))));
+ OpInfo(currentInstruction[3].u.operand),
+ get(VirtualRegister(currentInstruction[1].u.operand)), get(VirtualRegister(currentInstruction[2].u.operand))));
}
NEXT_OPCODE(op_new_func);
}
case op_new_func_exp: {
set(VirtualRegister(currentInstruction[1].u.operand),
- addToGraph(NewFunctionExpression, OpInfo(currentInstruction[2].u.operand)));
+ addToGraph(NewFunctionExpression, OpInfo(currentInstruction[3].u.operand), get(VirtualRegister(currentInstruction[2].u.operand))));
NEXT_OPCODE(op_new_func_exp);
}
diff --git a/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp b/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
index 79bf908..d4039dd 100644
--- a/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
+++ b/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
@@ -1172,6 +1172,16 @@
break;
}
+ case NewFunction: {
+ fixEdge<CellUse>(node->child2());
+ break;
+ }
+
+ case NewFunctionNoCheck:
+ case NewFunctionExpression: {
+ fixEdge<CellUse>(node->child1());
+ break;
+ }
#if !ASSERT_DISABLED
// Have these no-op cases here to ensure that nobody forgets to add handlers for new opcodes.
@@ -1213,9 +1223,6 @@
case GetMyArgumentsLength:
case GetMyArgumentsLengthSafe:
case CheckArgumentsNotCreated:
- case NewFunction:
- case NewFunctionNoCheck:
- case NewFunctionExpression:
case Jump:
case Return:
case Throw:
diff --git a/Source/JavaScriptCore/dfg/DFGOperations.cpp b/Source/JavaScriptCore/dfg/DFGOperations.cpp
index b7ac22d..9dca32a 100644
--- a/Source/JavaScriptCore/dfg/DFGOperations.cpp
+++ b/Source/JavaScriptCore/dfg/DFGOperations.cpp
@@ -820,12 +820,12 @@
return JSValue::encode(argumentsValue.get(exec, index));
}
-JSCell* JIT_OPERATION operationNewFunctionNoCheck(ExecState* exec, JSCell* functionExecutable)
+JSCell* JIT_OPERATION operationNewFunctionNoCheck(ExecState* exec, JSScope* scope, JSCell* functionExecutable)
{
ASSERT(functionExecutable->inherits(FunctionExecutable::info()));
VM& vm = exec->vm();
NativeCallFrameTracer tracer(&vm, exec);
- return JSFunction::create(vm, static_cast<FunctionExecutable*>(functionExecutable), exec->scope());
+ return JSFunction::create(vm, static_cast<FunctionExecutable*>(functionExecutable), scope);
}
size_t JIT_OPERATION operationIsObject(ExecState* exec, EncodedJSValue value)
diff --git a/Source/JavaScriptCore/dfg/DFGOperations.h b/Source/JavaScriptCore/dfg/DFGOperations.h
index cc45167..448ebe6 100644
--- a/Source/JavaScriptCore/dfg/DFGOperations.h
+++ b/Source/JavaScriptCore/dfg/DFGOperations.h
@@ -101,7 +101,7 @@
void JIT_OPERATION operationTearOffInlinedArguments(ExecState*, JSCell*, JSCell*, InlineCallFrame*) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationGetInlinedArgumentByVal(ExecState*, int32_t, InlineCallFrame*, int32_t) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationGetArgumentByVal(ExecState*, int32_t, int32_t) WTF_INTERNAL;
-JSCell* JIT_OPERATION operationNewFunctionNoCheck(ExecState*, JSCell*) WTF_INTERNAL;
+JSCell* JIT_OPERATION operationNewFunctionNoCheck(ExecState*, JSScope*, JSCell*) WTF_INTERNAL;
double JIT_OPERATION operationFModOnInts(int32_t, int32_t) WTF_INTERNAL;
size_t JIT_OPERATION operationIsObject(ExecState*, EncodedJSValue) WTF_INTERNAL;
size_t JIT_OPERATION operationIsFunction(EncodedJSValue) WTF_INTERNAL;
diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
index 0799886..f0724df 100644
--- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
+++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
@@ -4159,9 +4159,11 @@
{
GPRFlushedCallResult result(this);
GPRReg resultGPR = result.gpr();
+ SpeculateCellOperand scope(this, node->child1());
+ GPRReg scopeGPR = scope.gpr();
flushRegisters();
callOperation(
- operationNewFunctionNoCheck, resultGPR, m_jit.codeBlock()->functionDecl(node->functionDeclIndex()));
+ operationNewFunctionNoCheck, resultGPR, scopeGPR, m_jit.codeBlock()->functionDecl(node->functionDeclIndex()));
cellResult(resultGPR, node);
}
@@ -4169,10 +4171,12 @@
{
GPRFlushedCallResult result(this);
GPRReg resultGPR = result.gpr();
+ SpeculateCellOperand scope(this, node->child1());
+ GPRReg scopeGPR = scope.gpr();
flushRegisters();
callOperation(
operationNewFunctionNoCheck,
- resultGPR,
+ resultGPR, scopeGPR,
m_jit.codeBlock()->functionExpr(node->functionExprIndex()));
cellResult(resultGPR, node);
}
diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
index a1caa4e..e8969f1 100644
--- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
+++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
@@ -1049,7 +1049,7 @@
m_jit.setupArgumentsWithExecState(arg1, arg2, arg3);
return appendCallWithExceptionCheckSetResult(operation, result);
}
- JITCompiler::Call callOperation(C_JITOperation_ECC operation, GPRReg result, GPRReg arg1, JSCell* cell)
+ JITCompiler::Call callOperation(C_JITOperation_EJscC operation, GPRReg result, GPRReg arg1, JSCell* cell)
{
m_jit.setupArgumentsWithExecState(arg1, TrustedImmPtr(cell));
return appendCallWithExceptionCheckSetResult(operation, result);
@@ -1288,6 +1288,11 @@
m_jit.setupArgumentsWithExecState(arg1, arg2);
return appendCallWithExceptionCheckSetResult(operation, result);
}
+ JITCompiler::Call callOperation(J_JITOperation_EJscC operation, GPRReg result, GPRReg arg1, JSCell* cell)
+ {
+ m_jit.setupArgumentsWithExecState(arg1, TrustedImmPtr(cell));
+ return appendCallWithExceptionCheckSetResult(operation, result);
+ }
JITCompiler::Call callOperation(J_JITOperation_ESsiCI operation, GPRReg result, StructureStubInfo* stubInfo, GPRReg arg1, const StringImpl* uid)
{
m_jit.setupArgumentsWithExecState(TrustedImmPtr(stubInfo), arg1, TrustedImmPtr(uid));
@@ -1595,6 +1600,11 @@
m_jit.setupArgumentsWithExecState(arg1, arg2);
return appendCallWithExceptionCheckSetResult(operation, resultPayload, resultTag);
}
+ JITCompiler::Call callOperation(J_JITOperation_EJscC operation, GPRReg resultTag, GPRReg resultPayload, GPRReg arg1, JSCell* cell)
+ {
+ m_jit.setupArgumentsWithExecState(arg1, TrustedImmPtr(cell));
+ return appendCallWithExceptionCheckSetResult(operation, resultPayload, resultTag);
+ }
JITCompiler::Call callOperation(J_JITOperation_ESsiCI operation, GPRReg resultTag, GPRReg resultPayload, StructureStubInfo* stubInfo, GPRReg arg1, const StringImpl* uid)
{
m_jit.setupArgumentsWithExecState(TrustedImmPtr(stubInfo), arg1, TrustedImmPtr(uid));
diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
index 1818389..9193b4a 100644
--- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
+++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
@@ -4516,7 +4516,9 @@
GPRReg valuePayloadGPR = value.payloadGPR();
GPRReg resultTagGPR = resultTag.gpr();
GPRReg resultPayloadGPR = resultPayload.gpr();
-
+ SpeculateCellOperand scope(this, node->child2());
+ GPRReg scopeGPR = scope.gpr();
+
m_jit.move(valuePayloadGPR, resultPayloadGPR);
m_jit.move(valueTagGPR, resultTagGPR);
@@ -4524,7 +4526,7 @@
addSlowPathGenerator(
slowPathCall(
- notCreated, this, operationNewFunction, JSValueRegs(resultTagGPR, resultPayloadGPR),
+ notCreated, this, operationNewFunction, JSValueRegs(resultTagGPR, resultPayloadGPR), scopeGPR,
m_jit.codeBlock()->functionDecl(node->functionDeclIndex())));
jsValueResult(resultTagGPR, resultPayloadGPR, node);
diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
index ba176db..fd755ab 100644
--- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
+++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
@@ -4546,6 +4546,8 @@
case NewFunction: {
JSValueOperand value(this, node->child1());
GPRTemporary result(this, Reuse, value);
+ SpeculateCellOperand scope(this, node->child2());
+ GPRReg scopeGPR = scope.gpr();
GPRReg valueGPR = value.gpr();
GPRReg resultGPR = result.gpr();
@@ -4557,7 +4559,7 @@
addSlowPathGenerator(
slowPathCall(
notCreated, this, operationNewFunction,
- resultGPR, m_jit.codeBlock()->functionDecl(node->functionDeclIndex())));
+ resultGPR, scopeGPR, m_jit.codeBlock()->functionDecl(node->functionDeclIndex())));
jsValueResult(resultGPR, node);
break;
diff --git a/Source/JavaScriptCore/jit/JIT.h b/Source/JavaScriptCore/jit/JIT.h
index ddf2994..2872de0 100644
--- a/Source/JavaScriptCore/jit/JIT.h
+++ b/Source/JavaScriptCore/jit/JIT.h
@@ -697,6 +697,7 @@
#endif
MacroAssembler::Call callOperation(J_JITOperation_EJIdc, int, GPRReg, const Identifier*);
MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg);
+ MacroAssembler::Call callOperation(J_JITOperation_EJscC, int, GPRReg, JSCell*);
#if USE(JSVALUE64)
MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EJJ, int, GPRReg, GPRReg);
#else
diff --git a/Source/JavaScriptCore/jit/JITInlines.h b/Source/JavaScriptCore/jit/JITInlines.h
index 7843d2f..2e4744d 100644
--- a/Source/JavaScriptCore/jit/JITInlines.h
+++ b/Source/JavaScriptCore/jit/JITInlines.h
@@ -258,6 +258,12 @@
return appendCallWithExceptionCheck(operation);
}
+ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJscC operation, int dst, GPRReg arg1, JSCell* cell)
+{
+ setupArgumentsWithExecState(arg1, TrustedImmPtr(cell));
+ return appendCallWithExceptionCheckSetJSValueResult(operation, dst);
+}
+
ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EP operation, int dst, void* pointer)
{
setupArgumentsWithExecState(TrustedImmPtr(pointer));
diff --git a/Source/JavaScriptCore/jit/JITOpcodes.cpp b/Source/JavaScriptCore/jit/JITOpcodes.cpp
index 957c0a3..9d791c7 100644
--- a/Source/JavaScriptCore/jit/JITOpcodes.cpp
+++ b/Source/JavaScriptCore/jit/JITOpcodes.cpp
@@ -1034,7 +1034,7 @@
{
Jump lazyJump;
int dst = currentInstruction[1].u.operand;
- if (currentInstruction[3].u.operand) {
+ if (currentInstruction[4].u.operand) {
#if USE(JSVALUE32_64)
lazyJump = branch32(NotEqual, tagFor(dst), TrustedImm32(JSValue::EmptyValueTag));
#else
@@ -1042,18 +1042,28 @@
#endif
}
- FunctionExecutable* funcExec = m_codeBlock->functionDecl(currentInstruction[2].u.operand);
- callOperation(operationNewFunction, dst, funcExec);
+#if USE(JSVALUE64)
+ emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
+#else
+ emitLoadPayload(currentInstruction[2].u.operand, regT0);
+#endif
+ FunctionExecutable* funcExec = m_codeBlock->functionDecl(currentInstruction[3].u.operand);
+ callOperation(operationNewFunction, dst, regT0, funcExec);
- if (currentInstruction[3].u.operand)
+ if (currentInstruction[4].u.operand)
lazyJump.link(this);
}
void JIT::emit_op_new_func_exp(Instruction* currentInstruction)
{
int dst = currentInstruction[1].u.operand;
- FunctionExecutable* funcExpr = m_codeBlock->functionExpr(currentInstruction[2].u.operand);
- callOperation(operationNewFunction, dst, funcExpr);
+#if USE(JSVALUE64)
+ emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
+#else
+ emitLoadPayload(currentInstruction[2].u.operand, regT0);
+#endif
+ FunctionExecutable* funcExpr = m_codeBlock->functionExpr(currentInstruction[3].u.operand);
+ callOperation(operationNewFunction, dst, regT0, funcExpr);
}
void JIT::emit_op_new_array(Instruction* currentInstruction)
diff --git a/Source/JavaScriptCore/jit/JITOperations.cpp b/Source/JavaScriptCore/jit/JITOperations.cpp
index 8e24166..6c92a44 100644
--- a/Source/JavaScriptCore/jit/JITOperations.cpp
+++ b/Source/JavaScriptCore/jit/JITOperations.cpp
@@ -947,12 +947,12 @@
return JSValue::encode(constructArrayWithSizeQuirk(exec, profile, exec->lexicalGlobalObject(), sizeValue));
}
-EncodedJSValue JIT_OPERATION operationNewFunction(ExecState* exec, JSCell* functionExecutable)
+EncodedJSValue JIT_OPERATION operationNewFunction(ExecState* exec, JSScope* scope, JSCell* functionExecutable)
{
ASSERT(functionExecutable->inherits(FunctionExecutable::info()));
VM& vm = exec->vm();
NativeCallFrameTracer tracer(&vm, exec);
- return JSValue::encode(JSFunction::create(vm, static_cast<FunctionExecutable*>(functionExecutable), exec->scope()));
+ return JSValue::encode(JSFunction::create(vm, static_cast<FunctionExecutable*>(functionExecutable), scope));
}
JSCell* JIT_OPERATION operationNewObject(ExecState* exec, Structure* structure)
diff --git a/Source/JavaScriptCore/jit/JITOperations.h b/Source/JavaScriptCore/jit/JITOperations.h
index 6039d62..ffbc846 100644
--- a/Source/JavaScriptCore/jit/JITOperations.h
+++ b/Source/JavaScriptCore/jit/JITOperations.h
@@ -69,7 +69,7 @@
Idc: const Identifier*
J: EncodedJSValue
Jcp: const JSValue*
- Jsa: JSLexicalEnvironment*
+ Jsc: JSScope*
Jss: JSString*
O: JSObject*
P: pointer (char*)
@@ -113,6 +113,7 @@
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EPP)(ExecState*, void*, void*);
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EPS)(ExecState*, void*, size_t);
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EPc)(ExecState*, Instruction*);
+typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJscC)(ExecState*, JSScope*, JSCell*);
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_ESS)(ExecState*, size_t, size_t);
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_ESsiCI)(ExecState*, StructureStubInfo*, JSCell*, StringImpl*);
typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_ESsiJI)(ExecState*, StructureStubInfo*, EncodedJSValue, StringImpl*);
@@ -127,6 +128,7 @@
typedef JSCell* JIT_OPERATION (*C_JITOperation_ECC)(ExecState*, JSCell*, JSCell*);
typedef JSCell* JIT_OPERATION (*C_JITOperation_EIcf)(ExecState*, InlineCallFrame*);
typedef JSCell* JIT_OPERATION (*C_JITOperation_EJ)(ExecState*, EncodedJSValue);
+typedef JSCell* JIT_OPERATION (*C_JITOperation_EJscC)(ExecState*, JSScope*, JSCell*);
typedef JSCell* JIT_OPERATION (*C_JITOperation_EJZ)(ExecState*, EncodedJSValue, int32_t);
typedef JSCell* JIT_OPERATION (*C_JITOperation_EJZC)(ExecState*, EncodedJSValue, int32_t, JSCell*);
typedef JSCell* JIT_OPERATION (*C_JITOperation_EJJC)(ExecState*, EncodedJSValue, EncodedJSValue, JSCell*);
@@ -266,7 +268,7 @@
EncodedJSValue JIT_OPERATION operationNewArrayWithProfile(ExecState*, ArrayAllocationProfile*, const JSValue* values, int32_t size) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationNewArrayBufferWithProfile(ExecState*, ArrayAllocationProfile*, const JSValue* values, int32_t size) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationNewArrayWithSizeAndProfile(ExecState*, ArrayAllocationProfile*, EncodedJSValue size) WTF_INTERNAL;
-EncodedJSValue JIT_OPERATION operationNewFunction(ExecState*, JSCell*) WTF_INTERNAL;
+EncodedJSValue JIT_OPERATION operationNewFunction(ExecState*, JSScope*, JSCell*) WTF_INTERNAL;
JSCell* JIT_OPERATION operationNewObject(ExecState*, Structure*) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationNewRegexp(ExecState*, void*) WTF_INTERNAL;
void JIT_OPERATION operationHandleWatchdogTimer(ExecState*) WTF_INTERNAL;
diff --git a/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp b/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
index 0d7f44b..66942e2 100644
--- a/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
+++ b/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
@@ -1001,18 +1001,20 @@
LLINT_BEGIN();
CodeBlock* codeBlock = exec->codeBlock();
ASSERT(codeBlock->codeType() != FunctionCode || !codeBlock->needsActivation() || exec->hasActivation());
+ JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
#if LLINT_SLOW_PATH_TRACING
dataLogF("Creating function!\n");
#endif
- LLINT_RETURN(JSFunction::create(vm, codeBlock->functionDecl(pc[2].u.operand), exec->scope()));
+ LLINT_RETURN(JSFunction::create(vm, codeBlock->functionDecl(pc[3].u.operand), scope));
}
LLINT_SLOW_PATH_DECL(slow_path_new_func_exp)
{
LLINT_BEGIN();
CodeBlock* codeBlock = exec->codeBlock();
- FunctionExecutable* function = codeBlock->functionExpr(pc[2].u.operand);
- JSFunction* func = JSFunction::create(vm, function, exec->scope());
+ JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
+ FunctionExecutable* function = codeBlock->functionExpr(pc[3].u.operand);
+ JSFunction* func = JSFunction::create(vm, function, scope);
LLINT_RETURN(func);
}
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
index 29ac65a..8b8fb0f 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
@@ -1132,7 +1132,7 @@
_llint_op_new_func_exp:
traceExecution()
callSlowPath(_llint_slow_path_new_func_exp)
- dispatch(3)
+ dispatch(4)
_llint_op_call:
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
index 72f379b..f5a84e4 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
@@ -1911,13 +1911,13 @@
_llint_op_new_func:
traceExecution()
- btiz 12[PC], .opNewFuncUnchecked
+ btiz 16[PC], .opNewFuncUnchecked
loadi 4[PC], t1
bineq TagOffset[cfr, t1, 8], EmptyValueTag, .opNewFuncDone
.opNewFuncUnchecked:
callSlowPath(_llint_slow_path_new_func)
.opNewFuncDone:
- dispatch(4)
+ dispatch(5)
macro arrayProfileForCall()
loadi 16[PC], t3
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
index f8faa6f..c4f294d 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
@@ -1769,14 +1769,14 @@
_llint_op_new_func:
traceExecution()
- loadisFromInstruction(3, t2)
+ loadisFromInstruction(4, t2)
btiz t2, .opNewFuncUnchecked
loadisFromInstruction(1, t1)
btqnz [cfr, t1, 8], .opNewFuncDone
.opNewFuncUnchecked:
callSlowPath(_llint_slow_path_new_func)
.opNewFuncDone:
- dispatch(4)
+ dispatch(5)
macro arrayProfileForCall()
loadisFromInstruction(4, t3)