Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (147183 => 147184)
--- trunk/Source/_javascript_Core/ChangeLog 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-03-29 00:09:56 UTC (rev 147184)
@@ -1,3 +1,41 @@
+2013-03-28 Geoffrey Garen <gga...@apple.com>
+
+ Simplified the bytecode by removing op_jmp_scopes
+ https://bugs.webkit.org/show_bug.cgi?id=113545
+
+ Reviewed by Filip Pizlo.
+
+ We already have op_pop_scope and op_jmp, so we don't need op_jmp_scopes.
+ Using op_jmp_scopes was also adding a "jump to self" to codegen for
+ return statements, which was pretty silly.
+
+ * _javascript_Core.order:
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dumpBytecode):
+ * bytecode/Opcode.h:
+ (JSC::padOpcodeName):
+ * bytecode/PreciseJumpTargets.cpp:
+ (JSC::computePreciseJumpTargets):
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::emitComplexPopScopes):
+ (JSC::BytecodeGenerator::emitPopScopes):
+ * bytecompiler/BytecodeGenerator.h:
+ (BytecodeGenerator):
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC::ContinueNode::emitBytecode):
+ (JSC::BreakNode::emitBytecode):
+ (JSC::ReturnNode::emitBytecode):
+ * jit/JIT.cpp:
+ (JSC::JIT::privateCompileMainPass):
+ * jit/JIT.h:
+ * jit/JITOpcodes.cpp:
+ * jit/JITOpcodes32_64.cpp:
+ * jit/JITStubs.cpp:
+ * jit/JITStubs.h:
+ * llint/LLIntSlowPaths.cpp:
+ * llint/LLIntSlowPaths.h:
+ * llint/LowLevelInterpreter.asm:
+
2013-03-28 Mark Hahnenberg <mhahnenb...@apple.com>
Safari hangs during test262 run in CodeCache::pruneSlowCase
Modified: trunk/Source/_javascript_Core/_javascript_Core.order (147183 => 147184)
--- trunk/Source/_javascript_Core/_javascript_Core.order 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/_javascript_Core.order 2013-03-29 00:09:56 UTC (rev 147184)
@@ -1270,7 +1270,6 @@
__ZN3JSC3JIT21emitSlow_op_nstricteqEPNS_11InstructionERPNS_13SlowCaseEntryE
_cti_op_nstricteq
__ZN3JSC14LogicalNotNode30emitBytecodeInConditionContextERNS_17BytecodeGeneratorEPNS_5LabelES4_b
-__ZN3JSC3JIT18emit_op_jmp_scopesEPNS_11InstructionE
_cti_op_negate
__ZN3JSCL16mathProtoFuncMaxEPNS_9ExecStateE
__ZN3WTF15ThreadConditionD1Ev
@@ -1471,7 +1470,6 @@
__ZNK3WTF6String5upperEv
__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE
__ZN3JSC23createNotAFunctionErrorEPNS_9ExecStateENS_7JSValueE
-_cti_op_jmp_scopes
__ZNK3WTF6String6latin1Ev
__ZN3JSC3JIT30privateCompileGetByIdProtoListEPNS_17StructureStubInfoEPNS_30PolymorphicAccessStructureListEiPNS_9StructureES6_RKNS_10IdentifierERKNS_12PropertySlotEmPNS_9ExecStateE
__ZN3JSC3JIT15emit_op_eq_nullEPNS_11InstructionE
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -1447,12 +1447,6 @@
out.printf("[%4d] push_name_scope \t%s, %s, %u", location, idName(id0, m_identifiers[id0]).data(), registerName(exec, r1).data(), attributes);
break;
}
- case op_jmp_scopes: {
- int scopeDelta = (++it)->u.operand;
- int offset = (++it)->u.operand;
- out.printf("[%4d] jmp_scopes\t^%d, %d(->%d)", location, scopeDelta, offset, location + offset);
- break;
- }
case op_catch: {
int r0 = (++it)->u.operand;
out.printf("[%4d] catch\t\t %s", location, registerName(exec, r0).data());
Modified: trunk/Source/_javascript_Core/bytecode/Opcode.h (147183 => 147184)
--- trunk/Source/_javascript_Core/bytecode/Opcode.h 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/bytecode/Opcode.h 2013-03-29 00:09:56 UTC (rev 147184)
@@ -172,7 +172,6 @@
macro(op_jnlesseq, 4) \
macro(op_jngreater, 4) \
macro(op_jngreatereq, 4) \
- macro(op_jmp_scopes, 3) \
macro(op_loop, 2) \
macro(op_loop_if_true, 3) \
macro(op_loop_if_false, 3) \
Modified: trunk/Source/_javascript_Core/bytecode/PreciseJumpTargets.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/bytecode/PreciseJumpTargets.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/bytecode/PreciseJumpTargets.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -61,7 +61,6 @@
case op_jfalse:
case op_jeq_null:
case op_jneq_null:
- case op_jmp_scopes:
case op_loop_if_true:
case op_loop_if_false:
out.append(bytecodeOffset + current[2].u.operand);
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -2242,7 +2242,7 @@
return 0;
}
-PassRefPtr<Label> BytecodeGenerator::emitComplexJumpScopes(Label* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope)
+void BytecodeGenerator::emitComplexPopScopes(ControlFlowContext* topScope, ControlFlowContext* bottomScope)
{
while (topScope > bottomScope) {
// First we count the number of dynamic scopes we need to remove to get
@@ -2256,25 +2256,14 @@
}
if (nNormalScopes) {
- size_t begin = instructions().size();
-
// We need to remove a number of dynamic scopes to get to the next
// finally block
- emitOpcode(op_jmp_scopes);
- instructions().append(nNormalScopes);
+ while (nNormalScopes--)
+ emitOpcode(op_pop_scope);
- // If topScope == bottomScope then there isn't actually a finally block
- // left to emit, so make the jmp_scopes jump directly to the target label
- if (topScope == bottomScope) {
- instructions().append(target->bind(begin, instructions().size()));
- return target;
- }
-
- // Otherwise we just use jmp_scopes to pop a group of scopes and go
- // to the next instruction
- RefPtr<Label> nextInsn = newLabel();
- instructions().append(nextInsn->bind(begin, instructions().size()));
- emitLabel(nextInsn.get());
+ // If topScope == bottomScope then there isn't a finally block left to emit.
+ if (topScope == bottomScope)
+ return;
}
Vector<ControlFlowContext> savedScopeContextStack;
@@ -2364,28 +2353,24 @@
--topScope;
}
}
- return emitJump(target);
}
-PassRefPtr<Label> BytecodeGenerator::emitJumpScopes(Label* target, int targetScopeDepth)
+void BytecodeGenerator::emitPopScopes(int targetScopeDepth)
{
ASSERT(scopeDepth() - targetScopeDepth >= 0);
- ASSERT(target->isForward());
size_t scopeDelta = scopeDepth() - targetScopeDepth;
ASSERT(scopeDelta <= m_scopeContextStack.size());
if (!scopeDelta)
- return emitJump(target);
+ return;
- if (m_finallyDepth)
- return emitComplexJumpScopes(target, &m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta);
+ if (!m_finallyDepth) {
+ while (scopeDelta--)
+ emitOpcode(op_pop_scope);
+ return;
+ }
- size_t begin = instructions().size();
-
- emitOpcode(op_jmp_scopes);
- instructions().append(scopeDelta);
- instructions().append(target->bind(begin, instructions().size()));
- return target;
+ emitComplexPopScopes(&m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta);
}
RegisterID* BytecodeGenerator::emitGetPropertyNames(RegisterID* dst, RegisterID* base, RegisterID* i, RegisterID* size, Label* breakTarget)
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (147183 => 147184)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2013-03-29 00:09:56 UTC (rev 147184)
@@ -486,7 +486,7 @@
PassRefPtr<Label> emitJumpIfFalse(RegisterID* cond, Label* target);
PassRefPtr<Label> emitJumpIfNotFunctionCall(RegisterID* cond, Label* target);
PassRefPtr<Label> emitJumpIfNotFunctionApply(RegisterID* cond, Label* target);
- PassRefPtr<Label> emitJumpScopes(Label* target, int targetScopeDepth);
+ void emitPopScopes(int targetScopeDepth);
RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base, RegisterID* i, RegisterID* size, Label* breakTarget);
RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* base, RegisterID* i, RegisterID* size, RegisterID* iter, Label* target);
@@ -562,7 +562,7 @@
ALWAYS_INLINE void rewindBinaryOp();
ALWAYS_INLINE void rewindUnaryOp();
- PassRefPtr<Label> emitComplexJumpScopes(Label* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
+ void emitComplexPopScopes(ControlFlowContext* topScope, ControlFlowContext* bottomScope);
typedef HashMap<double, JSValue> NumberMap;
typedef HashMap<StringImpl*, JSString*, IdentifierRepHash> IdentifierStringMap;
Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -1785,7 +1785,8 @@
LabelScope* scope = generator.continueTarget(m_ident);
ASSERT(scope);
- generator.emitJumpScopes(scope->continueTarget(), scope->scopeDepth());
+ generator.emitPopScopes(scope->scopeDepth());
+ generator.emitJump(scope->continueTarget());
return dst;
}
@@ -1799,7 +1800,8 @@
LabelScope* scope = generator.breakTarget(m_ident);
ASSERT(scope);
- generator.emitJumpScopes(scope->breakTarget(), scope->scopeDepth());
+ generator.emitPopScopes(scope->scopeDepth());
+ generator.emitJump(scope->breakTarget());
return dst;
}
@@ -1812,19 +1814,15 @@
if (dst == generator.ignoredResult())
dst = 0;
- RegisterID* r0 = m_value ? generator.emitNode(dst, m_value) : generator.emitLoad(dst, jsUndefined());
- RefPtr<RegisterID> returnRegister;
+
+ RefPtr<RegisterID> returnRegister = m_value ? generator.emitNode(dst, m_value) : generator.emitLoad(dst, jsUndefined());
if (generator.scopeDepth()) {
- RefPtr<Label> l0 = generator.newLabel();
- if (generator.hasFinaliser()) {
- returnRegister = generator.emitMove(generator.newTemporary(), r0);
- r0 = returnRegister.get();
- }
- generator.emitJumpScopes(l0.get(), 0);
- generator.emitLabel(l0.get());
+ returnRegister = generator.emitMove(generator.newTemporary(), returnRegister.get());
+ generator.emitPopScopes(0);
}
+
generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine(), charPosition());
- return generator.emitReturn(r0);
+ return generator.emitReturn(returnRegister.get());
}
// ------------------------------ WithNode -------------------------------------
Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/jit/JIT.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -293,7 +293,6 @@
DEFINE_OP(op_jeq_null)
DEFINE_OP(op_jfalse)
DEFINE_OP(op_jmp)
- DEFINE_OP(op_jmp_scopes)
DEFINE_OP(op_jneq_null)
DEFINE_OP(op_jneq_ptr)
DEFINE_OP(op_jless)
Modified: trunk/Source/_javascript_Core/jit/JIT.h (147183 => 147184)
--- trunk/Source/_javascript_Core/jit/JIT.h 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/jit/JIT.h 2013-03-29 00:09:56 UTC (rev 147184)
@@ -678,7 +678,6 @@
void emit_op_jeq_null(Instruction*);
void emit_op_jfalse(Instruction*);
void emit_op_jmp(Instruction*);
- void emit_op_jmp_scopes(Instruction*);
void emit_op_jneq_null(Instruction*);
void emit_op_jneq_ptr(Instruction*);
void emit_op_jless(Instruction*);
Modified: trunk/Source/_javascript_Core/jit/JITOpcodes.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/jit/JITOpcodes.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -719,14 +719,6 @@
emitPutVirtualRegister(currentInstruction[1].u.operand);
}
-void JIT::emit_op_jmp_scopes(Instruction* currentInstruction)
-{
- JITStubCall stubCall(this, cti_op_jmp_scopes);
- stubCall.addArgument(TrustedImm32(currentInstruction[1].u.operand));
- stubCall.call();
- addJump(jump(), currentInstruction[2].u.operand);
-}
-
void JIT::emit_op_switch_imm(Instruction* currentInstruction)
{
unsigned tableIndex = currentInstruction[1].u.operand;
Modified: trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -1032,14 +1032,6 @@
map(m_bytecodeOffset + OPCODE_LENGTH(op_catch), exception, regT1, regT0);
}
-void JIT::emit_op_jmp_scopes(Instruction* currentInstruction)
-{
- JITStubCall stubCall(this, cti_op_jmp_scopes);
- stubCall.addArgument(TrustedImm32(currentInstruction[1].u.operand));
- stubCall.call();
- addJump(jump(), currentInstruction[2].u.operand);
-}
-
void JIT::emit_op_switch_imm(Instruction* currentInstruction)
{
unsigned tableIndex = currentInstruction[1].u.operand;
Modified: trunk/Source/_javascript_Core/jit/JITStubs.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/jit/JITStubs.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/jit/JITStubs.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -3306,19 +3306,6 @@
callFrame->setScope(scope);
}
-DEFINE_STUB_FUNCTION(void, op_jmp_scopes)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- unsigned count = stackFrame.args[0].int32();
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSScope* tmp = callFrame->scope();
- while (count--)
- tmp = tmp->next();
- callFrame->setScope(tmp);
-}
-
DEFINE_STUB_FUNCTION(void, op_put_by_index)
{
STUB_INIT_STACK_FRAME(stackFrame);
Modified: trunk/Source/_javascript_Core/jit/JITStubs.h (147183 => 147184)
--- trunk/Source/_javascript_Core/jit/JITStubs.h 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/jit/JITStubs.h 2013-03-29 00:09:56 UTC (rev 147184)
@@ -410,7 +410,6 @@
int JIT_STUB cti_has_property(STUB_ARGS_DECLARATION) WTF_INTERNAL;
void JIT_STUB cti_op_debug(STUB_ARGS_DECLARATION) WTF_INTERNAL;
void JIT_STUB cti_op_end(STUB_ARGS_DECLARATION) WTF_INTERNAL;
-void JIT_STUB cti_op_jmp_scopes(STUB_ARGS_DECLARATION) WTF_INTERNAL;
void JIT_STUB cti_op_pop_scope(STUB_ARGS_DECLARATION) WTF_INTERNAL;
void JIT_STUB cti_op_profile_did_call(STUB_ARGS_DECLARATION) WTF_INTERNAL;
void JIT_STUB cti_op_profile_will_call(STUB_ARGS_DECLARATION) WTF_INTERNAL;
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (147183 => 147184)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2013-03-29 00:09:56 UTC (rev 147184)
@@ -1204,18 +1204,6 @@
LLINT_END();
}
-LLINT_SLOW_PATH_DECL(slow_path_jmp_scopes)
-{
- LLINT_BEGIN();
- unsigned count = pc[1].u.operand;
- JSScope* tmp = exec->scope();
- while (count--)
- tmp = tmp->next();
- exec->setScope(tmp);
- pc += pc[2].u.operand;
- LLINT_END();
-}
-
LLINT_SLOW_PATH_DECL(slow_path_jtrue)
{
LLINT_BEGIN();
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h (147183 => 147184)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h 2013-03-29 00:09:56 UTC (rev 147184)
@@ -174,7 +174,6 @@
LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_del_by_val);
LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_by_index);
LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_getter_setter);
-LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jmp_scopes);
LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jtrue);
LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jfalse);
LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jless);
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (147183 => 147184)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2013-03-28 23:46:09 UTC (rev 147183)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2013-03-29 00:09:56 UTC (rev 147184)
@@ -973,12 +973,6 @@
dispatch(5)
-_llint_op_jmp_scopes:
- traceExecution()
- callSlowPath(_llint_slow_path_jmp_scopes)
- dispatch(0)
-
-
_llint_op_loop_if_true:
traceExecution()
jumpTrueOrFalse(