Title: [134361] trunk/Source/_javascript_Core
Revision
134361
Author
[email protected]
Date
2012-11-12 22:04:51 -0800 (Mon, 12 Nov 2012)

Log Message

The act of getting the callee during 'this' construction should be explicit in bytecode
https://bugs.webkit.org/show_bug.cgi?id=102016

Reviewed by Michael Saboff.

This is mostly a rollout of http://trac.webkit.org/changeset/116673, but also includes
changes to have create_this use the result of get_callee.
        
No performance or behavioral impact. This is just meant to allow us to profile
get_callee in the future.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dump):
* bytecode/Opcode.h:
(JSC):
(JSC::padOpcodeName):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGCapabilities.h:
(JSC::DFG::canCompileOpcode):
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
* jit/JIT.h:
(JIT):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_get_callee):
(JSC):
(JSC::JIT::emit_op_create_this):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_get_callee):
(JSC):
(JSC::JIT::emit_op_create_this):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (134360 => 134361)


--- trunk/Source/_javascript_Core/ChangeLog	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-11-13 06:04:51 UTC (rev 134361)
@@ -1,5 +1,46 @@
 2012-11-12  Filip Pizlo  <[email protected]>
 
+        The act of getting the callee during 'this' construction should be explicit in bytecode
+        https://bugs.webkit.org/show_bug.cgi?id=102016
+
+        Reviewed by Michael Saboff.
+
+        This is mostly a rollout of http://trac.webkit.org/changeset/116673, but also includes
+        changes to have create_this use the result of get_callee.
+        
+        No performance or behavioral impact. This is just meant to allow us to profile
+        get_callee in the future.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::dump):
+        * bytecode/Opcode.h:
+        (JSC):
+        (JSC::padOpcodeName):
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::BytecodeGenerator):
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::parseBlock):
+        * dfg/DFGCapabilities.h:
+        (JSC::DFG::canCompileOpcode):
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompileMainPass):
+        * jit/JIT.h:
+        (JIT):
+        * jit/JITOpcodes.cpp:
+        (JSC::JIT::emit_op_get_callee):
+        (JSC):
+        (JSC::JIT::emit_op_create_this):
+        * jit/JITOpcodes32_64.cpp:
+        (JSC::JIT::emit_op_get_callee):
+        (JSC):
+        (JSC::JIT::emit_op_create_this):
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+        * llint/LowLevelInterpreter32_64.asm:
+        * llint/LowLevelInterpreter64.asm:
+
+2012-11-12  Filip Pizlo  <[email protected]>
+
         Unreviewed, fix ARMv7 build.
 
         * assembler/MacroAssemblerARMv7.h:

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (134360 => 134361)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2012-11-13 06:04:51 UTC (rev 134361)
@@ -629,6 +629,11 @@
             dumpBytecodeCommentAndNewLine(location);
             break;
         }
+        case op_get_callee: {
+            int r0 = (++it)->u.operand;
+            dataLog("[%4d] op_get_callee %s\n", location, registerName(exec, r0).data());
+            break;
+        }
         case op_create_this: {
             int r0 = (++it)->u.operand;
             dataLog("[%4d] create_this %s", location, registerName(exec, r0).data());

Modified: trunk/Source/_javascript_Core/bytecode/Opcode.h (134360 => 134361)


--- trunk/Source/_javascript_Core/bytecode/Opcode.h	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/bytecode/Opcode.h	2012-11-13 06:04:51 UTC (rev 134361)
@@ -44,7 +44,8 @@
         macro(op_create_activation, 2) \
         macro(op_init_lazy_reg, 2) \
         macro(op_create_arguments, 2) \
-        macro(op_create_this, 2) \
+        macro(op_create_this, 3) \
+        macro(op_get_callee, 2) \
         macro(op_convert_this, 3) \
         \
         macro(op_new_object, 2) \

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (134360 => 134361)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2012-11-13 06:04:51 UTC (rev 134361)
@@ -457,8 +457,15 @@
 
     if (isConstructor()) {
         prependComment("'this' because we are a Constructor function");
-        emitOpcode(op_create_this);
-        instructions().append(m_thisRegister.index());
+
+        RefPtr<RegisterID> func = newTemporary(); 
+
+        emitOpcode(op_get_callee); 
+        instructions().append(func->index());
+
+        emitOpcode(op_create_this); 
+        instructions().append(m_thisRegister.index()); 
+        instructions().append(func->index()); 
     } else if (!codeBlock->isStrictMode() && (functionBody->usesThis() || codeBlock->usesEval() || m_shouldEmitDebugHooks)) {
         UnlinkedValueProfile profile = ""
         instructions().append(m_thisRegister.index());

Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (134360 => 134361)


--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2012-11-13 06:04:51 UTC (rev 134361)
@@ -218,7 +218,7 @@
 
         if (operand == JSStack::Callee)
             return getCallee();
-
+        
         // Is this an argument?
         if (operandIsArgument(operand))
             return getArgument(operand);
@@ -2124,7 +2124,8 @@
         }
 
         case op_create_this: {
-            set(currentInstruction[1].u.operand, addToGraph(CreateThis, get(JSStack::Callee)));
+            int calleeOperand = currentInstruction[2].u.operand;
+            set(currentInstruction[1].u.operand, addToGraph(CreateThis, get(calleeOperand)));
             NEXT_OPCODE(op_create_this);
         }
             
@@ -2177,6 +2178,11 @@
             NEXT_OPCODE(op_new_regexp);
         }
             
+        case op_get_callee: {
+            set(currentInstruction[1].u.operand, get(JSStack::Callee));
+            NEXT_OPCODE(op_get_callee);
+        }
+
         // === Bitwise operations ===
 
         case op_bitand: {

Modified: trunk/Source/_javascript_Core/dfg/DFGCapabilities.h (134360 => 134361)


--- trunk/Source/_javascript_Core/dfg/DFGCapabilities.h	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/dfg/DFGCapabilities.h	2012-11-13 06:04:51 UTC (rev 134361)
@@ -116,6 +116,7 @@
     case op_enter:
     case op_convert_this:
     case op_create_this:
+    case op_get_callee:
     case op_bitand:
     case op_bitor:
     case op_bitxor:

Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (134360 => 134361)


--- trunk/Source/_javascript_Core/jit/JIT.cpp	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp	2012-11-13 06:04:51 UTC (rev 134361)
@@ -251,6 +251,7 @@
         DEFINE_OP(op_call_varargs)
         DEFINE_OP(op_catch)
         DEFINE_OP(op_construct)
+        DEFINE_OP(op_get_callee)
         DEFINE_OP(op_create_this)
         DEFINE_OP(op_convert_this)
         DEFINE_OP(op_init_lazy_reg)

Modified: trunk/Source/_javascript_Core/jit/JIT.h (134360 => 134361)


--- trunk/Source/_javascript_Core/jit/JIT.h	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/jit/JIT.h	2012-11-13 06:04:51 UTC (rev 134361)
@@ -647,6 +647,7 @@
         void emit_op_call_put_result(Instruction*);
         void emit_op_catch(Instruction*);
         void emit_op_construct(Instruction*);
+        void emit_op_get_callee(Instruction*);
         void emit_op_create_this(Instruction*);
         void emit_op_convert_this(Instruction*);
         void emit_op_create_arguments(Instruction*);

Modified: trunk/Source/_javascript_Core/jit/JITOpcodes.cpp (134360 => 134361)


--- trunk/Source/_javascript_Core/jit/JITOpcodes.cpp	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes.cpp	2012-11-13 06:04:51 UTC (rev 134361)
@@ -1210,9 +1210,17 @@
     addSlowCase(branchPtr(Equal, Address(regT1, JSCell::structureOffset()), TrustedImmPtr(m_globalData->stringStructure.get())));
 }
 
+void JIT::emit_op_get_callee(Instruction* currentInstruction)
+{
+    unsigned result = currentInstruction[1].u.operand;
+    emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
+    emitPutVirtualRegister(result);
+}
+
 void JIT::emit_op_create_this(Instruction* currentInstruction)
 {
-    emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
+    int callee = currentInstruction[2].u.operand;
+    emitGetVirtualRegister(callee, regT0);
     loadPtr(Address(regT0, JSFunction::offsetOfCachedInheritorID()), regT2);
     addSlowCase(branchTestPtr(Zero, regT2));
     

Modified: trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp (134360 => 134361)


--- trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp	2012-11-13 06:04:51 UTC (rev 134361)
@@ -1467,9 +1467,17 @@
     emitStore(dst, JSValue());
 }
 
+void JIT::emit_op_get_callee(Instruction* currentInstruction)
+{
+    int dst = currentInstruction[1].u.operand;
+    emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
+    emitStoreCell(dst, regT0);
+}
+
 void JIT::emit_op_create_this(Instruction* currentInstruction)
 {
-    emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
+    int callee = currentInstruction[2].u.operand;
+    emitLoadPayload(callee, regT0);
     loadPtr(Address(regT0, JSFunction::offsetOfCachedInheritorID()), regT2);
     addSlowCase(branchTestPtr(Zero, regT2));
     

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (134360 => 134361)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2012-11-13 06:04:51 UTC (rev 134361)
@@ -478,7 +478,7 @@
 LLINT_SLOW_PATH_DECL(slow_path_create_this)
 {
     LLINT_BEGIN();
-    JSFunction* constructor = jsCast<JSFunction*>(exec->callee());
+    JSFunction* constructor = jsCast<JSFunction*>(LLINT_OP(2).jsValue().asCell());
     
 #if !ASSERT_DISABLED
     ConstructData constructData;

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm (134360 => 134361)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm	2012-11-13 06:04:51 UTC (rev 134361)
@@ -349,17 +349,27 @@
 
 _llint_op_create_this:
     traceExecution()
-    loadp Callee[cfr], t0
+    loadi 8[PC], t0
+    loadp PayloadOffset[cfr, t0, 8], t0
     loadp JSFunction::m_cachedInheritorID[t0], t2
     btpz t2, .opCreateThisSlow
     allocateBasicJSObject(JSFinalObjectSizeClassIndex, t2, t0, t1, t3, .opCreateThisSlow)
     loadi 4[PC], t1
     storei CellTag, TagOffset[cfr, t1, 8]
     storei t0, PayloadOffset[cfr, t1, 8]
-    dispatch(2)
+    dispatch(3)
 
 .opCreateThisSlow:
     callSlowPath(_llint_slow_path_create_this)
+    dispatch(3)
+
+
+_llint_op_get_callee:
+    traceExecution()
+    loadi 4[PC], t0
+    loadp PayloadOffset + Callee[cfr], t1
+    storei CellTag, TagOffset[cfr, t0, 8]
+    storei t1, PayloadOffset[cfr, t0, 8]
     dispatch(2)
 
 

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm (134360 => 134361)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm	2012-11-13 06:04:36 UTC (rev 134360)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm	2012-11-13 06:04:51 UTC (rev 134361)
@@ -241,16 +241,25 @@
 
 _llint_op_create_this:
     traceExecution()
-    loadp Callee[cfr], t0
+    loadisFromInstruction(2, t0)
+    loadp [cfr, t0, 8], t0
     loadp JSFunction::m_cachedInheritorID[t0], t2
     btpz t2, .opCreateThisSlow
     allocateBasicJSObject(JSFinalObjectSizeClassIndex, t2, t0, t1, t3, .opCreateThisSlow)
     loadisFromInstruction(1, t1)
     storeq t0, [cfr, t1, 8]
-    dispatch(2)
+    dispatch(3)
 
 .opCreateThisSlow:
     callSlowPath(_llint_slow_path_create_this)
+    dispatch(3)
+
+
+_llint_op_get_callee:
+    traceExecution()
+    loadis 8[PB, PC, 8], t0
+    loadp Callee[cfr], t1
+    storep t1, [cfr, t0, 8]
     dispatch(2)
 
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to