Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (175425 => 175426)
--- trunk/Source/_javascript_Core/ChangeLog 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-10-31 21:27:10 UTC (rev 175426)
@@ -1,3 +1,51 @@
+2014-10-31 Michael Saboff <msab...@apple.com>
+
+ Add scope operand to op_push_with_scope, op_push_name_scope and op_pop_scope
+ https://bugs.webkit.org/show_bug.cgi?id=138252
+
+ Reviewed by Geoffrey Garen.
+
+ Added scope operand to op_push_with_scope, op_push_name_scope and op_pop_scope.
+ Although the scope register is filled in with the ScopeChain register for all
+ three bytecodes, this operand is not used in the processing of the bytecodes.
+ That will be addressed in a future patch.
+
+ * bytecode/BytecodeList.json: Lengthened the three bytecodes.
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dumpBytecode): Added code to dump the scope operand.
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::BytecodeGenerator):
+ (JSC::BytecodeGenerator::emitPushWithScope):
+ (JSC::BytecodeGenerator::emitPopScope):
+ (JSC::BytecodeGenerator::emitComplexPopScopes):
+ (JSC::BytecodeGenerator::emitPopScopes):
+ (JSC::BytecodeGenerator::emitPushFunctionNameScope):
+ (JSC::BytecodeGenerator::emitPushCatchScope):
+ * bytecompiler/BytecodeGenerator.h:
+ (JSC::BytecodeGenerator::scopeRegister):
+ Added scope register to these emit functions and the bytecodes they emit.
+ New m_scopeRegister and accessor.
+
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC::ContinueNode::emitBytecode):
+ (JSC::BreakNode::emitBytecode):
+ (JSC::ReturnNode::emitBytecode):
+ (JSC::WithNode::emitBytecode):
+ (JSC::TryNode::emitBytecode):
+ Created a RegisterID for the ScopeChain register and used it to emit the updated
+ bytecodes.
+
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_push_with_scope):
+ (JSC::JIT::emit_op_push_name_scope):
+ * jit/JITOpcodes32_64.cpp:
+ (JSC::JIT::emit_op_push_with_scope):
+ (JSC::JIT::emit_op_push_name_scope):
+ * llint/LLIntSlowPaths.cpp:
+ (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+ * llint/LowLevelInterpreter.asm:
+ Updated the operand indecies for the processing of the updated bytecodes.
+
2014-10-31 Andreas Kling <akl...@apple.com>
Make writes to RegExpObject.lastIndex cacheable.
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeList.json (175425 => 175426)
--- trunk/Source/_javascript_Core/bytecode/BytecodeList.json 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeList.json 2014-10-31 21:27:10 UTC (rev 175426)
@@ -107,9 +107,9 @@
{ "name" : "op_resolve_scope", "length" : 6 },
{ "name" : "op_get_from_scope", "length" : 8 },
{ "name" : "op_put_to_scope", "length" : 7 },
- { "name" : "op_push_with_scope", "length" : 2 },
- { "name" : "op_pop_scope", "length" : 1 },
- { "name" : "op_push_name_scope", "length" : 5 },
+ { "name" : "op_push_with_scope", "length" : 3 },
+ { "name" : "op_pop_scope", "length" : 2 },
+ { "name" : "op_push_name_scope", "length" : 6 },
{ "name" : "op_catch", "length" : 2 },
{ "name" : "op_throw", "length" : 2 },
{ "name" : "op_throw_static_error", "length" : 3 },
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (175425 => 175426)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2014-10-31 21:27:10 UTC (rev 175426)
@@ -1425,21 +1425,25 @@
break;
}
case op_push_with_scope: {
- int r0 = (++it)->u.operand;
- printLocationOpAndRegisterOperand(out, exec, location, it, "push_with_scope", r0);
+ int dst = (++it)->u.operand;
+ int newScope = (++it)->u.operand;
+ printLocationAndOp(out, exec, location, it, "push_with_scope");
+ out.printf("%s, %s", registerName(dst).data(), registerName(newScope).data());
break;
}
case op_pop_scope: {
- printLocationAndOp(out, exec, location, it, "pop_scope");
+ int r0 = (++it)->u.operand;
+ printLocationOpAndRegisterOperand(out, exec, location, it, "pop_scope", r0);
break;
}
case op_push_name_scope: {
+ int dst = (++it)->u.operand;
int id0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
unsigned attributes = (++it)->u.operand;
JSNameScope::Type scopeType = (JSNameScope::Type)(++it)->u.operand;
printLocationAndOp(out, exec, location, it, "push_name_scope");
- out.printf("%s, %s, %u %s", idName(id0, identifier(id0)).data(), registerName(r1).data(), attributes, (scopeType == JSNameScope::FunctionNameScope) ? "functionScope" : ((scopeType == JSNameScope::CatchScope) ? "catchScope" : "unknownScopeType"));
+ out.printf("%s, %s, %s, %u %s", registerName(dst).data(), idName(id0, identifier(id0)).data(), registerName(r1).data(), attributes, (scopeType == JSNameScope::FunctionNameScope) ? "functionScope" : ((scopeType == JSNameScope::CatchScope) ? "catchScope" : "unknownScopeType"));
break;
}
case op_catch: {
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (175425 => 175426)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2014-10-31 21:27:10 UTC (rev 175426)
@@ -164,6 +164,7 @@
, m_scopeNode(programNode)
, m_codeBlock(vm, codeBlock)
, m_thisRegister(CallFrame::thisArgumentOffset())
+ , m_scopeRegister(JSStack::ScopeChain)
, m_lexicalEnvironmentRegister(0)
, m_emptyValueRegister(0)
, m_globalObjectRegister(0)
@@ -209,6 +210,7 @@
, m_symbolTable(codeBlock->symbolTable())
, m_scopeNode(functionBody)
, m_codeBlock(vm, codeBlock)
+ , m_scopeRegister(JSStack::ScopeChain)
, m_lexicalEnvironmentRegister(0)
, m_emptyValueRegister(0)
, m_globalObjectRegister(0)
@@ -444,6 +446,7 @@
, m_scopeNode(evalNode)
, m_codeBlock(vm, codeBlock)
, m_thisRegister(CallFrame::thisArgumentOffset())
+ , m_scopeRegister(JSStack::ScopeChain)
, m_lexicalEnvironmentRegister(0)
, m_emptyValueRegister(0)
, m_globalObjectRegister(0)
@@ -2049,22 +2052,23 @@
instructions().append(src->index());
}
-RegisterID* BytecodeGenerator::emitPushWithScope(RegisterID* scope)
+RegisterID* BytecodeGenerator::emitPushWithScope(RegisterID* dst, RegisterID* scope)
{
ControlFlowContext context;
context.isFinallyBlock = false;
m_scopeContextStack.append(context);
m_localScopeDepth++;
- return emitUnaryNoDstOp(op_push_with_scope, scope);
+ return emitUnaryOp(op_push_with_scope, dst, scope);
}
-void BytecodeGenerator::emitPopScope()
+void BytecodeGenerator::emitPopScope(RegisterID* srcDst)
{
ASSERT(m_scopeContextStack.size());
ASSERT(!m_scopeContextStack.last().isFinallyBlock);
emitOpcode(op_pop_scope);
+ instructions().append(srcDst->index());
m_scopeContextStack.removeLast();
m_localScopeDepth--;
@@ -2195,7 +2199,7 @@
return LabelScopePtr::null();
}
-void BytecodeGenerator::emitComplexPopScopes(ControlFlowContext* topScope, ControlFlowContext* bottomScope)
+void BytecodeGenerator::emitComplexPopScopes(RegisterID* scope, ControlFlowContext* topScope, ControlFlowContext* bottomScope)
{
while (topScope > bottomScope) {
// First we count the number of dynamic scopes we need to remove to get
@@ -2211,8 +2215,10 @@
if (nNormalScopes) {
// We need to remove a number of dynamic scopes to get to the next
// finally block
- while (nNormalScopes--)
+ while (nNormalScopes--) {
emitOpcode(op_pop_scope);
+ instructions().append(scope->index());
+ }
// If topScope == bottomScope then there isn't a finally block left to emit.
if (topScope == bottomScope)
@@ -2308,7 +2314,7 @@
}
}
-void BytecodeGenerator::emitPopScopes(int targetScopeDepth)
+void BytecodeGenerator::emitPopScopes(RegisterID* scope, int targetScopeDepth)
{
ASSERT(scopeDepth() - targetScopeDepth >= 0);
@@ -2318,12 +2324,14 @@
return;
if (!m_finallyDepth) {
- while (scopeDelta--)
+ while (scopeDelta--) {
emitOpcode(op_pop_scope);
+ instructions().append(scope->index());
+ }
return;
}
- emitComplexPopScopes(&m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta);
+ emitComplexPopScopes(scope, &m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta);
}
TryData* BytecodeGenerator::pushTry(Label* start)
@@ -2371,16 +2379,17 @@
instructions().append(true);
}
-void BytecodeGenerator::emitPushFunctionNameScope(const Identifier& property, RegisterID* value, unsigned attributes)
+void BytecodeGenerator::emitPushFunctionNameScope(RegisterID* dst, const Identifier& property, RegisterID* value, unsigned attributes)
{
emitOpcode(op_push_name_scope);
+ instructions().append(dst->index());
instructions().append(addConstant(property));
instructions().append(value->index());
instructions().append(attributes);
instructions().append(JSNameScope::FunctionNameScope);
}
-void BytecodeGenerator::emitPushCatchScope(const Identifier& property, RegisterID* value, unsigned attributes)
+void BytecodeGenerator::emitPushCatchScope(RegisterID* dst, const Identifier& property, RegisterID* value, unsigned attributes)
{
ControlFlowContext context;
context.isFinallyBlock = false;
@@ -2388,6 +2397,7 @@
m_localScopeDepth++;
emitOpcode(op_push_name_scope);
+ instructions().append(dst->index());
instructions().append(addConstant(property));
instructions().append(value->index());
instructions().append(attributes);
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (175425 => 175426)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2014-10-31 21:27:10 UTC (rev 175426)
@@ -289,6 +289,8 @@
// Returns the register storing "this"
RegisterID* thisRegister() { return &m_thisRegister; }
+
+ RegisterID* scopeRegister() { return &m_scopeRegister; }
// Returns the next available temporary register. Registers returned by
// newTemporary require a modified form of reference counting: any
@@ -510,7 +512,7 @@
PassRefPtr<Label> emitJumpIfFalse(RegisterID* cond, Label* target);
PassRefPtr<Label> emitJumpIfNotFunctionCall(RegisterID* cond, Label* target);
PassRefPtr<Label> emitJumpIfNotFunctionApply(RegisterID* cond, Label* target);
- void emitPopScopes(int targetScopeDepth);
+ void emitPopScopes(RegisterID* srcDst, int targetScopeDepth);
RegisterID* emitHasIndexedProperty(RegisterID* dst, RegisterID* base, RegisterID* propertyName);
RegisterID* emitHasStructureProperty(RegisterID* dst, RegisterID* base, RegisterID* propertyName, RegisterID* enumerator);
@@ -536,11 +538,11 @@
void emitThrowReferenceError(const String& message);
- void emitPushFunctionNameScope(const Identifier& property, RegisterID* value, unsigned attributes);
- void emitPushCatchScope(const Identifier& property, RegisterID* value, unsigned attributes);
+ void emitPushFunctionNameScope(RegisterID* dst, const Identifier& property, RegisterID* value, unsigned attributes);
+ void emitPushCatchScope(RegisterID* dst, const Identifier& property, RegisterID* value, unsigned attributes);
- RegisterID* emitPushWithScope(RegisterID* scope);
- void emitPopScope();
+ RegisterID* emitPushWithScope(RegisterID* dst, RegisterID* scope);
+ void emitPopScope(RegisterID* srcDst);
void emitDebugHook(DebugHookID, unsigned line, unsigned charOffset, unsigned lineStart);
@@ -591,7 +593,7 @@
ALWAYS_INLINE void rewindBinaryOp();
ALWAYS_INLINE void rewindUnaryOp();
- void emitComplexPopScopes(ControlFlowContext* topScope, ControlFlowContext* bottomScope);
+ void emitComplexPopScopes(RegisterID*, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
typedef HashMap<double, JSValue> NumberMap;
typedef HashMap<StringImpl*, JSString*, IdentifierRepHash> IdentifierStringMap;
@@ -751,6 +753,7 @@
RegisterID m_ignoredResultRegister;
RegisterID m_thisRegister;
RegisterID m_calleeRegister;
+ RegisterID m_scopeRegister;
RegisterID* m_lexicalEnvironmentRegister;
RegisterID* m_emptyValueRegister;
RegisterID* m_globalObjectRegister;
Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (175425 => 175426)
--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2014-10-31 21:27:10 UTC (rev 175426)
@@ -2250,7 +2250,7 @@
LabelScopePtr scope = generator.continueTarget(m_ident);
ASSERT(scope);
- generator.emitPopScopes(scope->scopeDepth());
+ generator.emitPopScopes(generator.scopeRegister(), scope->scopeDepth());
generator.emitJump(scope->continueTarget());
}
@@ -2277,7 +2277,7 @@
LabelScopePtr scope = generator.breakTarget(m_ident);
ASSERT(scope);
- generator.emitPopScopes(scope->scopeDepth());
+ generator.emitPopScopes(generator.scopeRegister(), scope->scopeDepth());
generator.emitJump(scope->breakTarget());
}
@@ -2298,7 +2298,7 @@
}
if (generator.scopeDepth()) {
returnRegister = generator.emitMove(generator.newTemporary(), returnRegister.get());
- generator.emitPopScopes(0);
+ generator.emitPopScopes(generator.scopeRegister(), 0);
}
generator.emitDebugHook(WillLeaveCallFrame, lastLine(), startOffset(), lineStartOffset());
@@ -2313,9 +2313,9 @@
RefPtr<RegisterID> scope = generator.emitNode(m_expr);
generator.emitExpressionInfo(m_divot, m_divot - m_expressionLength, m_divot);
- generator.emitPushWithScope(scope.get());
+ generator.emitPushWithScope(generator.scopeRegister(), scope.get());
generator.emitNode(dst, m_statement);
- generator.emitPopScope();
+ generator.emitPopScope(generator.scopeRegister());
}
// ------------------------------ CaseClauseNode --------------------------------
@@ -2555,10 +2555,10 @@
// block should "catch" that exception.
tryData = generator.pushTry(here.get());
}
-
- generator.emitPushCatchScope(m_exceptionIdent, exceptionRegister.get(), DontDelete);
+
+ generator.emitPushCatchScope(generator.scopeRegister(), m_exceptionIdent, exceptionRegister.get(), DontDelete);
generator.emitNode(dst, m_catchBlock);
- generator.emitPopScope();
+ generator.emitPopScope(generator.scopeRegister());
generator.emitLabel(catchEndLabel.get());
}
Modified: trunk/Source/_javascript_Core/jit/JITOpcodes.cpp (175425 => 175426)
--- trunk/Source/_javascript_Core/jit/JITOpcodes.cpp 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes.cpp 2014-10-31 21:27:10 UTC (rev 175426)
@@ -444,7 +444,7 @@
void JIT::emit_op_push_with_scope(Instruction* currentInstruction)
{
- emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
+ emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
callOperation(operationPushWithScope, regT0);
}
@@ -506,8 +506,8 @@
void JIT::emit_op_push_name_scope(Instruction* currentInstruction)
{
- emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
- callOperation(operationPushNameScope, &m_codeBlock->identifier(currentInstruction[1].u.operand), regT0, currentInstruction[3].u.operand, currentInstruction[4].u.operand);
+ emitGetVirtualRegister(currentInstruction[3].u.operand, regT0);
+ callOperation(operationPushNameScope, &m_codeBlock->identifier(currentInstruction[2].u.operand), regT0, currentInstruction[4].u.operand, currentInstruction[5].u.operand);
}
void JIT::emit_op_catch(Instruction* currentInstruction)
Modified: trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp (175425 => 175426)
--- trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp 2014-10-31 21:27:10 UTC (rev 175426)
@@ -752,7 +752,7 @@
void JIT::emit_op_push_with_scope(Instruction* currentInstruction)
{
- emitLoad(currentInstruction[1].u.operand, regT1, regT0);
+ emitLoad(currentInstruction[2].u.operand, regT1, regT0);
callOperation(operationPushWithScope, regT1, regT0);
}
@@ -786,8 +786,8 @@
void JIT::emit_op_push_name_scope(Instruction* currentInstruction)
{
- emitLoad(currentInstruction[2].u.operand, regT1, regT0);
- callOperation(operationPushNameScope, &m_codeBlock->identifier(currentInstruction[1].u.operand), regT1, regT0, currentInstruction[3].u.operand, currentInstruction[4].u.operand);
+ emitLoad(currentInstruction[3].u.operand, regT1, regT0);
+ callOperation(operationPushNameScope, &m_codeBlock->identifier(currentInstruction[2].u.operand), regT1, regT0, currentInstruction[4].u.operand, currentInstruction[5].u.operand);
}
void JIT::emit_op_catch(Instruction* currentInstruction)
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (175425 => 175426)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2014-10-31 21:27:10 UTC (rev 175426)
@@ -1269,10 +1269,10 @@
LLINT_SLOW_PATH_DECL(slow_path_push_with_scope)
{
LLINT_BEGIN();
- JSValue v = LLINT_OP_C(1).jsValue();
+ JSValue v = LLINT_OP_C(2).jsValue();
JSObject* o = v.toObject(exec);
LLINT_CHECK_EXCEPTION();
-
+
exec->setScope(JSWithScope::create(exec, o));
LLINT_END();
@@ -1289,8 +1289,8 @@
{
LLINT_BEGIN();
CodeBlock* codeBlock = exec->codeBlock();
- JSNameScope::Type type = static_cast<JSNameScope::Type>(pc[4].u.operand);
- JSNameScope* scope = JSNameScope::create(exec, codeBlock->identifier(pc[1].u.operand), LLINT_OP(2).jsValue(), pc[3].u.operand, type);
+ JSNameScope::Type type = static_cast<JSNameScope::Type>(pc[5].u.operand);
+ JSNameScope* scope = JSNameScope::create(exec, codeBlock->identifier(pc[2].u.operand), LLINT_OP(3).jsValue(), pc[4].u.operand, type);
exec->setScope(scope);
LLINT_END();
}
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (175425 => 175426)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2014-10-31 21:25:42 UTC (rev 175425)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2014-10-31 21:27:10 UTC (rev 175426)
@@ -1235,19 +1235,19 @@
_llint_op_push_with_scope:
traceExecution()
callSlowPath(_llint_slow_path_push_with_scope)
- dispatch(2)
+ dispatch(3)
_llint_op_pop_scope:
traceExecution()
callSlowPath(_llint_slow_path_pop_scope)
- dispatch(1)
+ dispatch(2)
_llint_op_push_name_scope:
traceExecution()
callSlowPath(_llint_slow_path_push_name_scope)
- dispatch(5)
+ dispatch(6)
_llint_op_throw: