Title: [270981] trunk/Source/_javascript_Core
Revision
270981
Author
[email protected]
Date
2020-12-18 11:25:34 -0800 (Fri, 18 Dec 2020)

Log Message

Add tagging to JIT probe's return address.
https://bugs.webkit.org/show_bug.cgi?id=220008
rdar://71279530

Reviewed by Keith Miller and Robin Morisset.

* assembler/MacroAssemblerARM64.cpp:
* assembler/testmasm.cpp:
(JSC::testProbeModifiesProgramCounter):
* runtime/JSCPtrTag.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (270980 => 270981)


--- trunk/Source/_javascript_Core/ChangeLog	2020-12-18 19:16:16 UTC (rev 270980)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-12-18 19:25:34 UTC (rev 270981)
@@ -1,3 +1,16 @@
+2020-12-17  Mark Lam  <[email protected]>
+
+        Add tagging to JIT probe's return address.
+        https://bugs.webkit.org/show_bug.cgi?id=220008
+        rdar://71279530
+
+        Reviewed by Keith Miller and Robin Morisset.
+
+        * assembler/MacroAssemblerARM64.cpp:
+        * assembler/testmasm.cpp:
+        (JSC::testProbeModifiesProgramCounter):
+        * runtime/JSCPtrTag.h:
+
 2020-12-18  Yusuke Suzuki  <[email protected]>
 
         [CSSJIT] Do not use trampoline if JITCage is disabled

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp (270980 => 270981)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp	2020-12-18 19:16:16 UTC (rev 270980)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp	2020-12-18 19:25:34 UTC (rev 270981)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -300,8 +300,10 @@
 static_assert(!(sizeof(LRRestorationRecord) & 0xf), "LRRestorationRecord must be 16-byte aligned");
 
 #if CPU(ARM64E)
+#define JIT_PROBE_PC_PTR_TAG 0xeeac
 #define JIT_PROBE_EXECUTOR_PTR_TAG 0x28de
 #define JIT_PROBE_STACK_INITIALIZATION_FUNCTION_PTR_TAG 0x315c
+static_assert(JIT_PROBE_PC_PTR_TAG == JITProbePCPtrTag);
 static_assert(JIT_PROBE_EXECUTOR_PTR_TAG == JITProbeExecutorPtrTag);
 static_assert(JIT_PROBE_STACK_INITIALIZATION_FUNCTION_PTR_TAG == JITProbeStackInitializationFunctionPtrTag);
 #endif
@@ -360,9 +362,12 @@
     "stp       x6, x29, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_X28_OFFSET) "]" "\n"
     "stp       x7, x26, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_LR_OFFSET) "]" "\n" // Save values lr and sp (original sp value computed into x26 above).
 
+    "add       x30, x30, #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n" // The PC after the probe is at 2 instructions past the return point.
+#if CPU(ARM64E)
+    "movz      x27, #" STRINGIZE_VALUE_OF(JIT_PROBE_PC_PTR_TAG) "\n"
+    "pacib     x30, x27" "\n"
+#endif
     "str       x30, [sp, #" STRINGIZE_VALUE_OF(SAVED_PROBE_RETURN_PC_OFFSET) "]" "\n" // Save a duplicate copy of return pc (in lr).
-
-    "add       x30, x30, #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n" // The PC after the probe is at 2 instructions past the return point.
     "str       x30, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_PC_OFFSET) "]" "\n"
 
     "stp       x0, x1, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_NZCV_OFFSET) "]" "\n" // Store nzcv and fpsr (preloaded into x0 and x1 above).
@@ -496,7 +501,6 @@
     "ldr       x30, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_SP_OFFSET) "]" "\n" // preload the target sp.
     "ldr       x27, [sp, #" STRINGIZE_VALUE_OF(SAVED_PROBE_RETURN_PC_OFFSET) "]" "\n"
     "ldr       x28, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_PC_OFFSET) "]" "\n"
-    "add       x27, x27, #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n"
     "cmp       x27, x28" "\n"
     "bne     " LOCAL_LABEL_STRING(ctiMasmProbeTrampolineEnd) "\n"
 
@@ -509,6 +513,19 @@
     "str       x27, [x30, #" STRINGIZE_VALUE_OF(LR_RESTORATION_LR_OFFSET) "]" "\n"
      // 3. Force the return ramp to return to the probe return site.
     "ldr       x27, [sp, #" STRINGIZE_VALUE_OF(SAVED_PROBE_RETURN_PC_OFFSET) "]" "\n"
+#if CPU(ARM64E)
+    "movz      x28, #" STRINGIZE_VALUE_OF(JIT_PROBE_PC_PTR_TAG) "\n"
+    "autib     x27, x28" "\n"
+    "lsr       x28, x27, #8" "\n"
+    "and       x28, x28, #0xff000000000000" "\n"
+    "orr       x28, x28, x27" "\n"
+    "ldrb      w28, [x28]" "\n"
+#endif
+    "sub       x27, x27, #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n" // The return point PC is at 2 instructions before the end of the probe.
+#if CPU(ARM64E)
+    "movz      x28, #" STRINGIZE_VALUE_OF(JIT_PROBE_PC_PTR_TAG) "\n"
+    "pacib     x27, x28" "\n"
+#endif
     "str       x27, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_PC_OFFSET) "]" "\n"
 
     LOCAL_LABEL_STRING(ctiMasmProbeTrampolineEnd) ":" "\n"
@@ -520,8 +537,18 @@
     "stp       x27, x28, [x30, #" STRINGIZE_VALUE_OF(OUT_NZCV_OFFSET) "]" "\n"
     "ldp       x27, x28, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_X27_OFFSET) "]" "\n"
     "stp       x27, x28, [x30, #" STRINGIZE_VALUE_OF(OUT_X27_OFFSET) "]" "\n"
+    "ldr       x28, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_PC_OFFSET) "]" "\n" // Set up the outgoing record so that we'll jump to the new PC.
+#if CPU(ARM64E)
+    "movz      x27, #" STRINGIZE_VALUE_OF(JIT_PROBE_PC_PTR_TAG) "\n"
+    "autib     x28, x27" "\n"
+    "lsr       x27, x28, #8" "\n"
+    "and       x27, x27, #0xff000000000000" "\n"
+    "orr       x27, x27, x28" "\n"
+    "ldrb      w27, [x27]" "\n"
+    "add       x27, x30, #48" "\n" // Compute sp at return point.
+    "pacib     x28, x27" "\n"
+#endif
     "ldr       x27, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_FP_OFFSET) "]" "\n"
-    "ldr       x28, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_PC_OFFSET) "]" "\n" // Set up the outgoing record so that we'll jump to the new PC.
     "stp       x27, x28, [x30, #" STRINGIZE_VALUE_OF(OUT_FP_OFFSET) "]" "\n"
     "mov       sp, x30" "\n"
 
@@ -531,7 +558,11 @@
     "msr       fpsr, x28" "\n"
     "ldp       x27, x28, [sp], #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n"
     "ldp       x29, x30, [sp], #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n"
+#if CPU(ARM64E)
+    "retab" "\n"
+#else
     "ret" "\n"
+#endif
 );
 #endif // COMPILER(GCC_COMPATIBLE)
 

Modified: trunk/Source/_javascript_Core/assembler/testmasm.cpp (270980 => 270981)


--- trunk/Source/_javascript_Core/assembler/testmasm.cpp	2020-12-18 19:16:16 UTC (rev 270980)
+++ trunk/Source/_javascript_Core/assembler/testmasm.cpp	2020-12-18 19:25:34 UTC (rev 270981)
@@ -2123,7 +2123,7 @@
         // Write expected values into the registers.
         jit.probe([&] (Probe::Context& context) {
             probeCallCount++;
-            context.cpu.pc() = untagCodePtr<JSEntryPtrTag>(continuation.code().executableAddress());
+            context.cpu.pc() = retagCodePtr<JSEntryPtrTag, JITProbePCPtrTag>(continuation.code().executableAddress());
         });
 
         jit.breakpoint(); // We should never get here.

Modified: trunk/Source/_javascript_Core/runtime/JSCPtrTag.h (270980 => 270981)


--- trunk/Source/_javascript_Core/runtime/JSCPtrTag.h	2020-12-18 19:16:16 UTC (rev 270980)
+++ trunk/Source/_javascript_Core/runtime/JSCPtrTag.h	2020-12-18 19:25:34 UTC (rev 270981)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -57,6 +57,7 @@
     v(HostFunctionPtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
     v(JITProbePtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
     v(JITProbeExecutorPtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
+    v(JITProbePCPtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
     v(JITProbeStackInitializationFunctionPtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
     /* Callee:JIT Caller:Native */ \
     v(NativeToJITGatePtrTag, PtrTagCalleeType::JIT, PtrTagCallerType::Native) \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to