Title: [138641] trunk/Source/_javascript_Core
Revision
138641
Author
fpi...@apple.com
Date
2013-01-02 13:28:28 -0800 (Wed, 02 Jan 2013)

Log Message

DFG inliner should not use the callee's bytecode variable for resolving references to the callee in inlined code
https://bugs.webkit.org/show_bug.cgi?id=105938

Reviewed by Mark Hahnenberg.
        
This simplifies a bunch of code for referring to the callee. It also ought to simplify how we do
closure call inlining: for inlined closure call frames we will simply require that the callee is
already stashed on the stack in the Callee slot in the inline call frame header.

* dfg/DFGByteCodeParser.cpp:
(ByteCodeParser):
(JSC::DFG::ByteCodeParser::getDirect):
(JSC::DFG::ByteCodeParser::get):
(InlineStackEntry):
(JSC::DFG::ByteCodeParser::InlineStackEntry::remapOperand):
(JSC::DFG::ByteCodeParser::handleCall):
(JSC::DFG::ByteCodeParser::handleInlining):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
(JSC::DFG::ByteCodeParser::parse):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (138640 => 138641)


--- trunk/Source/_javascript_Core/ChangeLog	2013-01-02 21:19:57 UTC (rev 138640)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-01-02 21:28:28 UTC (rev 138641)
@@ -1,3 +1,25 @@
+2013-01-02  Filip Pizlo  <fpi...@apple.com>
+
+        DFG inliner should not use the callee's bytecode variable for resolving references to the callee in inlined code
+        https://bugs.webkit.org/show_bug.cgi?id=105938
+
+        Reviewed by Mark Hahnenberg.
+        
+        This simplifies a bunch of code for referring to the callee. It also ought to simplify how we do
+        closure call inlining: for inlined closure call frames we will simply require that the callee is
+        already stashed on the stack in the Callee slot in the inline call frame header.
+
+        * dfg/DFGByteCodeParser.cpp:
+        (ByteCodeParser):
+        (JSC::DFG::ByteCodeParser::getDirect):
+        (JSC::DFG::ByteCodeParser::get):
+        (InlineStackEntry):
+        (JSC::DFG::ByteCodeParser::InlineStackEntry::remapOperand):
+        (JSC::DFG::ByteCodeParser::handleCall):
+        (JSC::DFG::ByteCodeParser::handleInlining):
+        (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
+        (JSC::DFG::ByteCodeParser::parse):
+
 2013-01-02  Ryosuke Niwa  <rn...@webkit.org>
 
         Another Windows port build fix attempt. Try not exporting this symbol from JSC

Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (138640 => 138641)


--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2013-01-02 21:19:57 UTC (rev 138640)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2013-01-02 21:28:28 UTC (rev 138641)
@@ -162,7 +162,7 @@
     void handleCall(Interpreter*, Instruction* currentInstruction, NodeType op, CodeSpecializationKind);
     void emitFunctionCheck(JSFunction* expectedFunction, NodeIndex callTarget, int registerOffset, CodeSpecializationKind);
     // Handle inlining. Return true if it succeeded, false if we need to plant a call.
-    bool handleInlining(bool usesResult, int callTarget, NodeIndex callTargetNodeIndex, int resultOperand, bool certainAboutExpectedFunction, JSFunction*, int registerOffset, int argumentCountIncludingThis, unsigned nextOffset, CodeSpecializationKind);
+    bool handleInlining(bool usesResult, NodeIndex callTargetNodeIndex, int resultOperand, bool certainAboutExpectedFunction, JSFunction*, int registerOffset, int argumentCountIncludingThis, unsigned nextOffset, CodeSpecializationKind);
     // Handle setting the result of an intrinsic.
     void setIntrinsicResult(bool usesResult, int resultOperand, NodeIndex);
     // Handle intrinsic functions. Return true if it succeeded, false if we need to plant a call.
@@ -218,8 +218,7 @@
             return getJSConstant(constant);
         }
 
-        if (operand == JSStack::Callee)
-            return getCallee();
+        ASSERT(operand != JSStack::Callee);
         
         // Is this an argument?
         if (operandIsArgument(operand))
@@ -230,6 +229,13 @@
     }
     NodeIndex get(int operand)
     {
+        if (operand == JSStack::Callee) {
+            if (m_inlineStackTop->m_inlineCallFrame)
+                return cellConstant(m_inlineStackTop->m_inlineCallFrame->callee.get());
+            
+            return getCallee();
+        }
+        
         return getDirect(m_inlineStackTop->remapOperand(operand));
     }
     enum SetMode { NormalSet, SetOnEntry };
@@ -1153,7 +1159,6 @@
         CodeBlock* m_codeBlock;
         CodeBlock* m_profiledBlock;
         InlineCallFrame* m_inlineCallFrame;
-        VirtualRegister m_calleeVR; // absolute virtual register, not relative to call frame
         
         ScriptExecutable* executable() { return m_codeBlock->ownerExecutable(); }
         
@@ -1217,7 +1222,6 @@
             CodeBlock*,
             CodeBlock* profiledBlock,
             BlockIndex callsiteBlockHead,
-            VirtualRegister calleeVR,
             JSFunction* callee,
             VirtualRegister returnValueVR,
             VirtualRegister inlineCallFrameStart,
@@ -1240,8 +1244,7 @@
                 return result;
             }
 
-            if (operand == JSStack::Callee)
-                return m_calleeVR;
+            ASSERT(operand != JSStack::Callee);
 
             return operand + m_inlineCallFrame->stackOffset;
         }
@@ -1386,7 +1389,7 @@
                 
                 return;
             }
-        } else if (handleInlining(usesResult, currentInstruction[1].u.operand, callTarget, resultOperand, certainAboutExpectedFunction, expectedFunction, registerOffset, argumentCountIncludingThis, nextOffset, kind))
+        } else if (handleInlining(usesResult, callTarget, resultOperand, certainAboutExpectedFunction, expectedFunction, registerOffset, argumentCountIncludingThis, nextOffset, kind))
             return;
     }
     
@@ -1403,7 +1406,7 @@
     addToGraph(CheckFunction, OpInfo(expectedFunction), callTarget, thisArgument);
 }
 
-bool ByteCodeParser::handleInlining(bool usesResult, int callTarget, NodeIndex callTargetNodeIndex, int resultOperand, bool certainAboutExpectedFunction, JSFunction* expectedFunction, int registerOffset, int argumentCountIncludingThis, unsigned nextOffset, CodeSpecializationKind kind)
+bool ByteCodeParser::handleInlining(bool usesResult, NodeIndex callTargetNodeIndex, int resultOperand, bool certainAboutExpectedFunction, JSFunction* expectedFunction, int registerOffset, int argumentCountIncludingThis, unsigned nextOffset, CodeSpecializationKind kind)
 {
     // First, the really simple checks: do we have an actual JS function?
     if (!expectedFunction)
@@ -1481,8 +1484,7 @@
 
     InlineStackEntry inlineStackEntry(
         this, codeBlock, profiledBlock, m_graph.m_blocks.size() - 1,
-        (VirtualRegister)m_inlineStackTop->remapOperand(callTarget), expectedFunction,
-        (VirtualRegister)m_inlineStackTop->remapOperand(
+        expectedFunction, (VirtualRegister)m_inlineStackTop->remapOperand(
             usesResult ? resultOperand : InvalidVirtualRegister),
         (VirtualRegister)inlineCallFrameStart, argumentCountIncludingThis, kind);
     
@@ -3495,7 +3497,6 @@
     CodeBlock* codeBlock,
     CodeBlock* profiledBlock,
     BlockIndex callsiteBlockHead,
-    VirtualRegister calleeVR,
     JSFunction* callee,
     VirtualRegister returnValueVR,
     VirtualRegister inlineCallFrameStart,
@@ -3504,7 +3505,6 @@
     : m_byteCodeParser(byteCodeParser)
     , m_codeBlock(codeBlock)
     , m_profiledBlock(profiledBlock)
-    , m_calleeVR(calleeVR)
     , m_exitProfile(profiledBlock->exitProfile())
     , m_callsiteBlockHead(callsiteBlockHead)
     , m_returnValue(returnValueVR)
@@ -3530,7 +3530,6 @@
         // Inline case.
         ASSERT(codeBlock != byteCodeParser->m_codeBlock);
         ASSERT(callee);
-        ASSERT(calleeVR != InvalidVirtualRegister);
         ASSERT(inlineCallFrameStart != InvalidVirtualRegister);
         ASSERT(callsiteBlockHead != NoBlock);
         
@@ -3632,7 +3631,6 @@
         // Machine code block case.
         ASSERT(codeBlock == byteCodeParser->m_codeBlock);
         ASSERT(!callee);
-        ASSERT(calleeVR == InvalidVirtualRegister);
         ASSERT(returnValueVR == InvalidVirtualRegister);
         ASSERT(inlineCallFrameStart == InvalidVirtualRegister);
         ASSERT(callsiteBlockHead == NoBlock);
@@ -3773,9 +3771,8 @@
 #endif
     
     InlineStackEntry inlineStackEntry(
-        this, m_codeBlock, m_profiledBlock, NoBlock, InvalidVirtualRegister, 0,
-        InvalidVirtualRegister, InvalidVirtualRegister, m_codeBlock->numParameters(),
-        CodeForCall);
+        this, m_codeBlock, m_profiledBlock, NoBlock, 0, InvalidVirtualRegister, InvalidVirtualRegister,
+        m_codeBlock->numParameters(), CodeForCall);
     
     parseCodeBlock();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to