Fix 32-bit getter call alignment.
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 23:28:48 +0000 (23:28 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 23:28:48 +0000 (23:28 +0000)
Reviewed by Mark Hahnenberg.

* jit/Repatch.cpp:
(JSC::generateGetByIdStub):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166266 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jit/Repatch.cpp

index 1979178..48a3b4e 100644 (file)
@@ -1,5 +1,14 @@
 2014-03-25  Filip Pizlo  <fpizlo@apple.com>
 
+        Fix 32-bit getter call alignment.
+
+        Reviewed by Mark Hahnenberg.
+
+        * jit/Repatch.cpp:
+        (JSC::generateGetByIdStub):
+
+2014-03-25  Filip Pizlo  <fpizlo@apple.com>
+
         Repatch should plant calls to getters directly rather than through a C helper
         https://bugs.webkit.org/show_bug.cgi?id=129589
 
index c7ae166..0605e12 100644 (file)
@@ -340,8 +340,8 @@ static void generateGetByIdStub(
             // - Any byte between FP (exclusive) and SP (inclusive) could be live in the calling
             //   code.
             //
-            // Therefore, we temporary grow the stack for the purpose of the call and then
-            // degrow it after.
+            // Therefore, we temporarily grow the stack for the purpose of the call and then
+            // shrink it after.
             
             callLinkInfo = std::make_unique<CallLinkInfo>();
             callLinkInfo->callType = CallLinkInfo::Call;
@@ -363,15 +363,14 @@ static void generateGetByIdStub(
             unsigned numberOfRegsForCall =
                 JSStack::CallFrameHeaderSize + numberOfParameters;
             
-            unsigned alignedNumberOfNeededRegs =
-                WTF::roundUpToMultipleOf(stackAlignmentRegisters(), numberOfRegsForCall);
+            unsigned numberOfBytesForCall =
+                numberOfRegsForCall * sizeof(Register) - sizeof(CallerFrameAndPC);
             
-            unsigned alignedNumberOfNeededBytes =
-                alignedNumberOfNeededRegs * sizeof(Register);
+            unsigned alignedNumberOfBytesForCall =
+                WTF::roundUpToMultipleOf(stackAlignmentBytes(), numberOfBytesForCall);
             
             stubJit.subPtr(
-                MacroAssembler::TrustedImm32(
-                    alignedNumberOfNeededBytes - sizeof(CallerFrameAndPC)),
+                MacroAssembler::TrustedImm32(alignedNumberOfBytesForCall),
                 MacroAssembler::stackPointerRegister);
             
             MacroAssembler::Address calleeFrame = MacroAssembler::Address(
@@ -404,8 +403,7 @@ static void generateGetByIdStub(
             fastPathCall = stubJit.nearCall();
             
             stubJit.addPtr(
-                MacroAssembler::TrustedImm32(
-                    alignedNumberOfNeededBytes - sizeof(CallerFrameAndPC)),
+                MacroAssembler::TrustedImm32(alignedNumberOfBytesForCall),
                 MacroAssembler::stackPointerRegister);
             
             done.append(stubJit.jump());
@@ -419,8 +417,7 @@ static void generateGetByIdStub(
             slowPathCall = stubJit.nearCall();
             
             stubJit.addPtr(
-                MacroAssembler::TrustedImm32(
-                    alignedNumberOfNeededBytes - sizeof(CallerFrameAndPC)),
+                MacroAssembler::TrustedImm32(alignedNumberOfBytesForCall),
                 MacroAssembler::stackPointerRegister);
             
             done.append(stubJit.jump());