Title: [271030] branches/safari-610-branch
Revision
271030
Author
[email protected]
Date
2020-12-21 11:24:18 -0800 (Mon, 21 Dec 2020)

Log Message

Cherry-pick r270981. rdar://problem/72552976

    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:

Modified Paths

Property Changed

Diff

Index: branches/safari-610-branch =================================================================== --- branches/safari-610-branch 2020-12-21 18:48:28 UTC (rev 271029) +++ branches/safari-610-branch 2020-12-21 19:24:18 UTC (rev 271030)

Property changes: branches/safari-610-branch


Modified: svn:mergeinfo

-/trunk:53455,270686 \ No newline at end of property +/trunk:53455,270686,270981 \ No newline at end of property

Modified: branches/safari-610-branch/Source/_javascript_Core/ChangeLog (271029 => 271030)


--- branches/safari-610-branch/Source/_javascript_Core/ChangeLog	2020-12-21 18:48:28 UTC (rev 271029)
+++ branches/safari-610-branch/Source/_javascript_Core/ChangeLog	2020-12-21 19:24:18 UTC (rev 271030)
@@ -1,3 +1,20 @@
+2020-12-16  Mark Lam  <[email protected]>
+
+        Cherry-pick r270981. rdar://problem/72552976
+
+    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-21  Alan Coon  <[email protected]>
 
         Cherry-pick r270993. rdar://problem/72552973

Modified: branches/safari-610-branch/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp (271029 => 271030)


--- branches/safari-610-branch/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp	2020-12-21 18:48:28 UTC (rev 271029)
+++ branches/safari-610-branch/Source/_javascript_Core/assembler/MacroAssemblerARM64.cpp	2020-12-21 19:24:18 UTC (rev 271030)
@@ -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
@@ -299,8 +299,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
@@ -359,9 +361,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).
@@ -495,7 +500,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"
 
@@ -508,6 +512,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"
@@ -519,8 +536,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"
 
@@ -530,7 +557,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: branches/safari-610-branch/Source/_javascript_Core/assembler/testmasm.cpp (271029 => 271030)


--- branches/safari-610-branch/Source/_javascript_Core/assembler/testmasm.cpp	2020-12-21 18:48:28 UTC (rev 271029)
+++ branches/safari-610-branch/Source/_javascript_Core/assembler/testmasm.cpp	2020-12-21 19:24:18 UTC (rev 271030)
@@ -2123,7 +2123,7 @@
         // Write expected values into the registers.
         jit.probe([&] (Probe::Context& context) {
             probeCallCount++;
-            context.cpu.pc() = untagCodePtr(continuation.code().executableAddress(), JSEntryPtrTag);
+            context.cpu.pc() = retagCodePtr(continuation.code().executableAddress(), JSEntryPtrTag, JITProbePCPtrTag);
         });
 
         jit.breakpoint(); // We should never get here.

Modified: branches/safari-610-branch/Source/_javascript_Core/runtime/JSCPtrTag.h (271029 => 271030)


--- branches/safari-610-branch/Source/_javascript_Core/runtime/JSCPtrTag.h	2020-12-21 18:48:28 UTC (rev 271029)
+++ branches/safari-610-branch/Source/_javascript_Core/runtime/JSCPtrTag.h	2020-12-21 19:24:18 UTC (rev 271030)
@@ -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
@@ -42,6 +42,7 @@
     v(JITProbePtrTag) \
     v(JITProbeTrampolinePtrTag) \
     v(JITProbeExecutorPtrTag) \
+    v(JITProbePCPtrTag) \
     v(JITProbeStackInitializationFunctionPtrTag) \
     v(JITThunkPtrTag) \
     v(JITStubRoutinePtrTag) \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to