Title: [159652] trunk/Source/_javascript_Core
Revision
159652
Author
[email protected]
Date
2013-11-21 15:55:58 -0800 (Thu, 21 Nov 2013)

Log Message

BytecodeGenerator should align the stack according to native conventions
https://bugs.webkit.org/show_bug.cgi?id=124735

Reviewed by Mark Lam.

* bytecompiler/BytecodeGenerator.h:
(JSC::CallArguments::registerOffset):
(JSC::CallArguments::argumentCountIncludingThis):
* bytecompiler/NodesCodegen.cpp:
(JSC::CallArguments::CallArguments):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (159651 => 159652)


--- trunk/Source/_javascript_Core/ChangeLog	2013-11-21 23:24:39 UTC (rev 159651)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-11-21 23:55:58 UTC (rev 159652)
@@ -1,5 +1,18 @@
 2013-11-21  Filip Pizlo  <[email protected]>
 
+        BytecodeGenerator should align the stack according to native conventions
+        https://bugs.webkit.org/show_bug.cgi?id=124735
+
+        Reviewed by Mark Lam.
+
+        * bytecompiler/BytecodeGenerator.h:
+        (JSC::CallArguments::registerOffset):
+        (JSC::CallArguments::argumentCountIncludingThis):
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::CallArguments::CallArguments):
+
+2013-11-21  Filip Pizlo  <[email protected]>
+
         Unreviewed, preemptive build fix.
 
         * runtime/StackAlignment.h:

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (159651 => 159652)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2013-11-21 23:24:39 UTC (rev 159651)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2013-11-21 23:55:58 UTC (rev 159652)
@@ -1736,10 +1736,10 @@
     UnlinkedValueProfile profile = ""
     ASSERT(dst);
     ASSERT(dst != ignoredResult());
-    instructions().append(dst->index()); // result
-    instructions().append(func->index()); // func
-    instructions().append(callArguments.argumentCountIncludingThis()); // argCount
-    instructions().append(callArguments.registerOffset()); // registerOffset
+    instructions().append(dst->index());
+    instructions().append(func->index());
+    instructions().append(callArguments.argumentCountIncludingThis());
+    instructions().append(callArguments.stackOffset());
 #if ENABLE(LLINT)
     instructions().append(m_codeBlock->addLLIntCallLinkInfo());
 #else
@@ -1850,9 +1850,9 @@
     UnlinkedValueProfile profile = ""
     ASSERT(dst != ignoredResult());
     instructions().append(dst->index());
-    instructions().append(func->index()); // func
-    instructions().append(callArguments.argumentCountIncludingThis()); // argCount
-    instructions().append(callArguments.registerOffset()); // registerOffset
+    instructions().append(func->index());
+    instructions().append(callArguments.argumentCountIncludingThis());
+    instructions().append(callArguments.stackOffset());
 #if ENABLE(LLINT)
     instructions().append(m_codeBlock->addLLIntCallLinkInfo());
 #else

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (159651 => 159652)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2013-11-21 23:24:39 UTC (rev 159651)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2013-11-21 23:55:58 UTC (rev 159652)
@@ -69,17 +69,16 @@
 
         RegisterID* thisRegister() { return m_argv[0].get(); }
         RegisterID* argumentRegister(unsigned i) { return m_argv[i + 1].get(); }
-        unsigned registerOffset() { return -m_argv.last()->index() + CallFrame::offsetFor(argumentCountIncludingThis()); }
-        unsigned argumentCountIncludingThis() { return m_argv.size(); }
+        unsigned stackOffset() { return -m_argv[0]->index() + JSStack::CallFrameHeaderSize; }
+        unsigned argumentCountIncludingThis() { return m_argv.size() - m_padding; }
         RegisterID* profileHookRegister() { return m_profileHookRegister.get(); }
         ArgumentsNode* argumentsNode() { return m_argumentsNode; }
 
     private:
-        void newArgument(BytecodeGenerator&);
-
         RefPtr<RegisterID> m_profileHookRegister;
         ArgumentsNode* m_argumentsNode;
         Vector<RefPtr<RegisterID>, 8, UnsafeVectorOverflow> m_argv;
+        unsigned m_padding;
     };
 
     struct FinallyContext {

Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (159651 => 159652)


--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2013-11-21 23:24:39 UTC (rev 159651)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2013-11-21 23:55:58 UTC (rev 159652)
@@ -44,6 +44,7 @@
 #include "RegExpCache.h"
 #include "RegExpObject.h"
 #include "SamplingTool.h"
+#include "StackAlignment.h"
 #include <wtf/Assertions.h>
 #include <wtf/RefCountedLeakCounter.h>
 #include <wtf/Threading.h>
@@ -420,6 +421,7 @@
 
 CallArguments::CallArguments(BytecodeGenerator& generator, ArgumentsNode* argumentsNode, unsigned additionalArguments)
     : m_argumentsNode(argumentsNode)
+    , m_padding(0)
 {
     if (generator.shouldEmitProfileHooks())
         m_profileHookRegister = generator.newTemporary();
@@ -435,15 +437,13 @@
         m_argv[i] = generator.newTemporary();
         ASSERT(static_cast<size_t>(i) == m_argv.size() - 1 || m_argv[i]->index() == m_argv[i + 1]->index() - 1);
     }
+    
+    while (stackOffset() % stackAlignmentRegisters()) {
+        m_argv.insert(0, generator.newTemporary());
+        m_padding++;
+    }
 }
 
-inline void CallArguments::newArgument(BytecodeGenerator& generator)
-{
-    RefPtr<RegisterID> tmp = generator.newTemporary();
-    ASSERT(m_argv.isEmpty() || tmp->index() == m_argv.last()->index() + 1); // Calling convention assumes that all arguments are contiguous.
-    m_argv.append(tmp.release());
-}
-
 // ------------------------------ EvalFunctionCallNode ----------------------------------
 
 RegisterID* EvalFunctionCallNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to