Title: [288268] trunk/Source/_javascript_Core
Revision
288268
Author
[email protected]
Date
2022-01-19 20:03:12 -0800 (Wed, 19 Jan 2022)

Log Message

[JSC] Fix non-JIT Windows LLInt
https://bugs.webkit.org/show_bug.cgi?id=235388

Reviewed by Mark Lam.

We should implement cCall3 which calls llint_link_call etc. from LLInt code.
This implementation needs to work on Windows too, so it requires stack modification.
While we do not have a problem on JIT Windows build, it is required for non JIT Windows
build. (If JIT is enabled, LLInt is fine. But if JIT is entirely disabled, this change
is required.)

* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::llint_link_call):
(JSC::LLInt::llint_virtual_call):
* llint/LLIntSlowPaths.h:
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
* offlineasm/cloop.rb:
* offlineasm/instructions.rb:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (288267 => 288268)


--- trunk/Source/_javascript_Core/ChangeLog	2022-01-20 03:53:27 UTC (rev 288267)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-01-20 04:03:12 UTC (rev 288268)
@@ -1,3 +1,26 @@
+2022-01-19  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Fix non-JIT Windows LLInt
+        https://bugs.webkit.org/show_bug.cgi?id=235388
+
+        Reviewed by Mark Lam.
+
+        We should implement cCall3 which calls llint_link_call etc. from LLInt code.
+        This implementation needs to work on Windows too, so it requires stack modification.
+        While we do not have a problem on JIT Windows build, it is required for non JIT Windows
+        build. (If JIT is enabled, LLInt is fine. But if JIT is entirely disabled, this change
+        is required.)
+
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::llint_link_call):
+        (JSC::LLInt::llint_virtual_call):
+        * llint/LLIntSlowPaths.h:
+        * llint/LowLevelInterpreter.asm:
+        * llint/LowLevelInterpreter32_64.asm:
+        * llint/LowLevelInterpreter64.asm:
+        * offlineasm/cloop.rb:
+        * offlineasm/instructions.rb:
+
 2022-01-19  Saam Barati  <[email protected]>
 
         Update ARM64EHash

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (288267 => 288268)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2022-01-20 03:53:27 UTC (rev 288267)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2022-01-20 04:03:12 UTC (rev 288268)
@@ -581,12 +581,12 @@
     LLINT_RETURN_TWO(pc, callFrame);
 }
 
-extern "C" SlowPathReturnType llint_link_call(CallFrame* calleeFrame, JSCell* globalObject, CallLinkInfo* callLinkInfo, JSCell*)
+extern "C" SlowPathReturnType llint_link_call(CallFrame* calleeFrame, JSCell* globalObject, CallLinkInfo* callLinkInfo)
 {
     return linkFor(calleeFrame, jsCast<JSGlobalObject*>(globalObject), callLinkInfo);
 }
 
-extern "C" SlowPathReturnType llint_virtual_call(CallFrame* calleeFrame, JSCell* globalObject, CallLinkInfo* callLinkInfo, JSCell*)
+extern "C" SlowPathReturnType llint_virtual_call(CallFrame* calleeFrame, JSCell* globalObject, CallLinkInfo* callLinkInfo)
 {
     JSCell* calleeAsFunctionCellIgnored;
     return virtualForWithFunction(jsCast<JSGlobalObject*>(globalObject), calleeFrame, callLinkInfo, calleeAsFunctionCellIgnored);

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h (288267 => 288268)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h	2022-01-20 03:53:27 UTC (rev 288267)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h	2022-01-20 04:03:12 UTC (rev 288268)
@@ -38,8 +38,8 @@
 
 extern "C" SlowPathReturnType llint_trace_operand(CallFrame*, const Instruction*, int fromWhere, int operand) REFERENCED_FROM_ASM;
 extern "C" SlowPathReturnType llint_trace_value(CallFrame*, const Instruction*, int fromWhere, VirtualRegister operand) REFERENCED_FROM_ASM;
-extern "C" SlowPathReturnType llint_link_call(CallFrame*, JSCell*, CallLinkInfo*, JSCell*) REFERENCED_FROM_ASM;
-extern "C" SlowPathReturnType llint_virtual_call(CallFrame*, JSCell*, CallLinkInfo*, JSCell*) REFERENCED_FROM_ASM;
+extern "C" SlowPathReturnType llint_link_call(CallFrame*, JSCell*, CallLinkInfo*) REFERENCED_FROM_ASM;
+extern "C" SlowPathReturnType llint_virtual_call(CallFrame*, JSCell*, CallLinkInfo*) REFERENCED_FROM_ASM;
 extern "C" void llint_write_barrier_slow(CallFrame*, JSCell*) REFERENCED_FROM_ASM WTF_INTERNAL;
 
 #define LLINT_SLOW_PATH_DECL(name) \

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (288267 => 288268)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2022-01-20 03:53:27 UTC (rev 288267)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2022-01-20 04:03:12 UTC (rev 288268)
@@ -2533,7 +2533,7 @@
     move t2, a2
     move t3, a1
     move cfr, a0
-    cCall4(function)
+    cCall3(function)
     functionEpilogue()
     untagReturnAddress sp
     btpz r1, .doNotTrash

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm (288267 => 288268)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm	2022-01-20 03:53:27 UTC (rev 288267)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm	2022-01-20 04:03:12 UTC (rev 288268)
@@ -94,7 +94,9 @@
 end
 
 macro cCall2(function)
-    if ARMv7 or MIPS
+    if C_LOOP or C_LOOP_WIN
+        cloopCallSlowPath function, a0, a1
+    elsif ARMv7 or MIPS
         call function
     elsif X86 or X86_WIN
         subp 8, sp
@@ -102,8 +104,6 @@
         push a0
         call function
         addp 16, sp
-    elsif C_LOOP or C_LOOP_WIN
-        cloopCallSlowPath function, a0, a1
     else
         error
     end
@@ -117,6 +117,23 @@
     end
 end
 
+macro cCall3(function)
+    if C_LOOP or C_LOOP_WIN
+        cloopCallSlowPath3 function, a0, a1, a2
+    elsif ARMv7 or MIPS
+        call function
+    elsif X86 or X86_WIN
+        subp 4, sp
+        push a2
+        push a1
+        push a0
+        call function
+        addp 16, sp
+    else
+        error
+    end
+end
+
 macro cCall4(function)
     if C_LOOP or C_LOOP_WIN
         cloopCallSlowPath4 function, a0, a1, a2, a3

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm (288267 => 288268)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm	2022-01-20 03:53:27 UTC (rev 288267)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm	2022-01-20 04:03:12 UTC (rev 288268)
@@ -96,7 +96,9 @@
 
 macro cCall2(function)
     checkStackPointerAlignment(t4, 0xbad0c002)
-    if X86_64 or ARM64 or ARM64E or RISCV64
+    if C_LOOP or C_LOOP_WIN
+        cloopCallSlowPath function, a0, a1
+    elsif X86_64 or ARM64 or ARM64E or RISCV64
         call function
     elsif X86_64_WIN
         # Note: this implementation is only correct if the return type size is > 8 bytes.
@@ -113,11 +115,9 @@
         move sp, a0
         addp 32, a0
         call function
-        addp 48, sp
         move 8[r0], r1
         move [r0], r0
-    elsif C_LOOP or C_LOOP_WIN
-        cloopCallSlowPath function, a0, a1
+        addp 48, sp
     else
         error
     end
@@ -140,6 +140,36 @@
     end
 end
 
+macro cCall3(function)
+    checkStackPointerAlignment(t4, 0xbad0c004)
+    if C_LOOP or C_LOOP_WIN
+        cloopCallSlowPath3 function, a0, a1, a2
+    elsif X86_64 or ARM64 or ARM64E or RISCV64
+        call function
+    elsif X86_64_WIN
+        # Note: this implementation is only correct if the return type size is > 8 bytes.
+        # See macro cCall2Void for an implementation when the return type <= 8 bytes.
+        # On Win64, when the return type is larger than 8 bytes, we need to allocate space on the stack for the return value.
+        # On entry rcx (a0), should contain a pointer to this stack space. The other parameters are shifted to the right,
+        # rdx (a1) should contain the first argument, r8 (a2) should contain the second argument, and r9 (a3) should contain the third argument.
+        # On return, rax contains a pointer to this stack value, and we then need to copy the 16 byte return value into rax (r0) and rdx (r1)
+        # since the return value is expected to be split between the two.
+        # See http://msdn.microsoft.com/en-us/library/7572ztz4.aspx
+        move a2, a3
+        move a1, a2
+        move a0, a1
+        subp 64, sp
+        move sp, a0
+        addp 32, a0
+        call function
+        move 8[r0], r1
+        move [r0], r0
+        addp 64, sp
+    else
+        error
+    end
+end
+
 # This barely works. arg3 and arg4 should probably be immediates.
 macro cCall4(function)
     checkStackPointerAlignment(t4, 0xbad0c004)

Modified: trunk/Source/_javascript_Core/offlineasm/cloop.rb (288267 => 288268)


--- trunk/Source/_javascript_Core/offlineasm/cloop.rb	2022-01-20 03:53:27 UTC (rev 288267)
+++ trunk/Source/_javascript_Core/offlineasm/cloop.rb	2022-01-20 04:03:12 UTC (rev 288268)
@@ -572,6 +572,14 @@
     $asm.putc "#{operands[0].cLabel}(#{operands[1].clDump}, #{operands[2].clDump});"
 end
 
+def cloopEmitCallSlowPath3(operands)
+    $asm.putc "{"
+    $asm.putc "    cloopStack.setCurrentStackPointer(sp.vp());"
+    $asm.putc "    SlowPathReturnType result = #{operands[0].cLabel}(#{operands[1].clDump}, #{operands[2].clDump}, #{operands[3].clDump});"
+    $asm.putc "    decodeResult(result, t0, t1);"
+    $asm.putc "}"
+end
+
 def cloopEmitCallSlowPath4(operands)
     $asm.putc "{"
     $asm.putc "    cloopStack.setCurrentStackPointer(sp.vp());"
@@ -1183,6 +1191,9 @@
         when "cloopCallSlowPathVoid"
             cloopEmitCallSlowPathVoid(operands)
 
+        when "cloopCallSlowPath3"
+            cloopEmitCallSlowPath3(operands)
+
         when "cloopCallSlowPath4"
             cloopEmitCallSlowPath4(operands)
 

Modified: trunk/Source/_javascript_Core/offlineasm/instructions.rb (288267 => 288268)


--- trunk/Source/_javascript_Core/offlineasm/instructions.rb	2022-01-20 03:53:27 UTC (rev 288267)
+++ trunk/Source/_javascript_Core/offlineasm/instructions.rb	2022-01-20 04:03:12 UTC (rev 288268)
@@ -463,6 +463,7 @@
      "cloopCallNative",         # operands: callee
      "cloopCallSlowPath",       # operands: callTarget, currentFrame, currentPC
      "cloopCallSlowPathVoid",   # operands: callTarget, currentFrame, currentPC
+     "cloopCallSlowPath3",      # operands: callTarget, a0, a1, a2
      "cloopCallSlowPath4",      # operands: callTarget, a0, a1, a2, a3
 
      # For debugging only:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to