Changeset 270981 in webkit


Ignore:
Timestamp:
Dec 18, 2020, 11:25:34 AM (4 years ago)
Author:
mark.lam@apple.com
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:
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r270967 r270981  
     12020-12-17  Mark Lam  <mark.lam@apple.com>
     2
     3        Add tagging to JIT probe's return address.
     4        https://bugs.webkit.org/show_bug.cgi?id=220008
     5        rdar://71279530
     6
     7        Reviewed by Keith Miller and Robin Morisset.
     8
     9        * assembler/MacroAssemblerARM64.cpp:
     10        * assembler/testmasm.cpp:
     11        (JSC::testProbeModifiesProgramCounter):
     12        * runtime/JSCPtrTag.h:
     13
    1142020-12-18  Yusuke Suzuki  <ysuzuki@apple.com>
    215
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.cpp

    r268247 r270981  
    11/*
    2  * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    301301
    302302#if CPU(ARM64E)
     303#define JIT_PROBE_PC_PTR_TAG 0xeeac
    303304#define JIT_PROBE_EXECUTOR_PTR_TAG 0x28de
    304305#define JIT_PROBE_STACK_INITIALIZATION_FUNCTION_PTR_TAG 0x315c
     306static_assert(JIT_PROBE_PC_PTR_TAG == JITProbePCPtrTag);
    305307static_assert(JIT_PROBE_EXECUTOR_PTR_TAG == JITProbeExecutorPtrTag);
    306308static_assert(JIT_PROBE_STACK_INITIALIZATION_FUNCTION_PTR_TAG == JITProbeStackInitializationFunctionPtrTag);
     
    361363    "stp       x7, x26, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_LR_OFFSET) "]" "\n" // Save values lr and sp (original sp value computed into x26 above).
    362364
     365    "add       x30, x30, #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n" // The PC after the probe is at 2 instructions past the return point.
     366#if CPU(ARM64E)
     367    "movz      x27, #" STRINGIZE_VALUE_OF(JIT_PROBE_PC_PTR_TAG) "\n"
     368    "pacib     x30, x27" "\n"
     369#endif
    363370    "str       x30, [sp, #" STRINGIZE_VALUE_OF(SAVED_PROBE_RETURN_PC_OFFSET) "]" "\n" // Save a duplicate copy of return pc (in lr).
    364 
    365     "add       x30, x30, #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n" // The PC after the probe is at 2 instructions past the return point.
    366371    "str       x30, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_PC_OFFSET) "]" "\n"
    367372
     
    497502    "ldr       x27, [sp, #" STRINGIZE_VALUE_OF(SAVED_PROBE_RETURN_PC_OFFSET) "]" "\n"
    498503    "ldr       x28, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_PC_OFFSET) "]" "\n"
    499     "add       x27, x27, #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n"
    500504    "cmp       x27, x28" "\n"
    501505    "bne     " LOCAL_LABEL_STRING(ctiMasmProbeTrampolineEnd) "\n"
     
    510514     // 3. Force the return ramp to return to the probe return site.
    511515    "ldr       x27, [sp, #" STRINGIZE_VALUE_OF(SAVED_PROBE_RETURN_PC_OFFSET) "]" "\n"
     516#if CPU(ARM64E)
     517    "movz      x28, #" STRINGIZE_VALUE_OF(JIT_PROBE_PC_PTR_TAG) "\n"
     518    "autib     x27, x28" "\n"
     519    "lsr       x28, x27, #8" "\n"
     520    "and       x28, x28, #0xff000000000000" "\n"
     521    "orr       x28, x28, x27" "\n"
     522    "ldrb      w28, [x28]" "\n"
     523#endif
     524    "sub       x27, x27, #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n" // The return point PC is at 2 instructions before the end of the probe.
     525#if CPU(ARM64E)
     526    "movz      x28, #" STRINGIZE_VALUE_OF(JIT_PROBE_PC_PTR_TAG) "\n"
     527    "pacib     x27, x28" "\n"
     528#endif
    512529    "str       x27, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_PC_OFFSET) "]" "\n"
    513530
     
    521538    "ldp       x27, x28, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_X27_OFFSET) "]" "\n"
    522539    "stp       x27, x28, [x30, #" STRINGIZE_VALUE_OF(OUT_X27_OFFSET) "]" "\n"
     540    "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.
     541#if CPU(ARM64E)
     542    "movz      x27, #" STRINGIZE_VALUE_OF(JIT_PROBE_PC_PTR_TAG) "\n"
     543    "autib     x28, x27" "\n"
     544    "lsr       x27, x28, #8" "\n"
     545    "and       x27, x27, #0xff000000000000" "\n"
     546    "orr       x27, x27, x28" "\n"
     547    "ldrb      w27, [x27]" "\n"
     548    "add       x27, x30, #48" "\n" // Compute sp at return point.
     549    "pacib     x28, x27" "\n"
     550#endif
    523551    "ldr       x27, [sp, #" STRINGIZE_VALUE_OF(PROBE_CPU_FP_OFFSET) "]" "\n"
    524     "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.
    525552    "stp       x27, x28, [x30, #" STRINGIZE_VALUE_OF(OUT_FP_OFFSET) "]" "\n"
    526553    "mov       sp, x30" "\n"
     
    532559    "ldp       x27, x28, [sp], #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n"
    533560    "ldp       x29, x30, [sp], #" STRINGIZE_VALUE_OF(2 * GPREG_SIZE) "\n"
     561#if CPU(ARM64E)
     562    "retab" "\n"
     563#else
    534564    "ret" "\n"
     565#endif
    535566);
    536567#endif // COMPILER(GCC_COMPATIBLE)
  • trunk/Source/JavaScriptCore/assembler/testmasm.cpp

    r268247 r270981  
    21242124        jit.probe([&] (Probe::Context& context) {
    21252125            probeCallCount++;
    2126             context.cpu.pc() = untagCodePtr<JSEntryPtrTag>(continuation.code().executableAddress());
     2126            context.cpu.pc() = retagCodePtr<JSEntryPtrTag, JITProbePCPtrTag>(continuation.code().executableAddress());
    21272127        });
    21282128
  • trunk/Source/JavaScriptCore/runtime/JSCPtrTag.h

    r270764 r270981  
    11/*
    2  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5858    v(JITProbePtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
    5959    v(JITProbeExecutorPtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
     60    v(JITProbePCPtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
    6061    v(JITProbeStackInitializationFunctionPtrTag, PtrTagCalleeType::Native, PtrTagCallerType::Native) \
    6162    /* Callee:JIT Caller:Native */ \
Note: See TracChangeset for help on using the changeset viewer.