Changeset 243254 in webkit


Ignore:
Timestamp:
Mar 20, 2019 4:32:26 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

Open source arm64e code.
https://bugs.webkit.org/show_bug.cgi?id=196012
<rdar://problem/49066237>

Reviewed by Keith Miller.

Source/JavaScriptCore:

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • assembler/ARM64EAssembler.h: Added.

(JSC::ARM64EAssembler::encodeGroup1):
(JSC::ARM64EAssembler::encodeGroup2):
(JSC::ARM64EAssembler::encodeGroup4):
(JSC::ARM64EAssembler::pacia1716):
(JSC::ARM64EAssembler::pacib1716):
(JSC::ARM64EAssembler::autia1716):
(JSC::ARM64EAssembler::autib1716):
(JSC::ARM64EAssembler::paciaz):
(JSC::ARM64EAssembler::paciasp):
(JSC::ARM64EAssembler::pacibz):
(JSC::ARM64EAssembler::pacibsp):
(JSC::ARM64EAssembler::autiaz):
(JSC::ARM64EAssembler::autiasp):
(JSC::ARM64EAssembler::autibz):
(JSC::ARM64EAssembler::autibsp):
(JSC::ARM64EAssembler::xpaclri):
(JSC::ARM64EAssembler::pacia):
(JSC::ARM64EAssembler::pacib):
(JSC::ARM64EAssembler::pacda):
(JSC::ARM64EAssembler::pacdb):
(JSC::ARM64EAssembler::autia):
(JSC::ARM64EAssembler::autib):
(JSC::ARM64EAssembler::autda):
(JSC::ARM64EAssembler::autdb):
(JSC::ARM64EAssembler::paciza):
(JSC::ARM64EAssembler::pacizb):
(JSC::ARM64EAssembler::pacdza):
(JSC::ARM64EAssembler::pacdzb):
(JSC::ARM64EAssembler::autiza):
(JSC::ARM64EAssembler::autizb):
(JSC::ARM64EAssembler::autdza):
(JSC::ARM64EAssembler::autdzb):
(JSC::ARM64EAssembler::xpaci):
(JSC::ARM64EAssembler::xpacd):
(JSC::ARM64EAssembler::pacga):
(JSC::ARM64EAssembler::braa):
(JSC::ARM64EAssembler::brab):
(JSC::ARM64EAssembler::blraa):
(JSC::ARM64EAssembler::blrab):
(JSC::ARM64EAssembler::braaz):
(JSC::ARM64EAssembler::brabz):
(JSC::ARM64EAssembler::blraaz):
(JSC::ARM64EAssembler::blrabz):
(JSC::ARM64EAssembler::retaa):
(JSC::ARM64EAssembler::retab):
(JSC::ARM64EAssembler::eretaa):
(JSC::ARM64EAssembler::eretab):
(JSC::ARM64EAssembler::linkPointer):
(JSC::ARM64EAssembler::repatchPointer):
(JSC::ARM64EAssembler::setPointer):
(JSC::ARM64EAssembler::readPointer):
(JSC::ARM64EAssembler::readCallTarget):
(JSC::ARM64EAssembler::ret):

  • assembler/MacroAssembler.cpp:
  • assembler/MacroAssembler.h:
  • assembler/MacroAssemblerARM64.cpp:
  • assembler/MacroAssemblerARM64E.h: Added.

(JSC::MacroAssemblerARM64E::tagReturnAddress):
(JSC::MacroAssemblerARM64E::untagReturnAddress):
(JSC::MacroAssemblerARM64E::tagPtr):
(JSC::MacroAssemblerARM64E::untagPtr):
(JSC::MacroAssemblerARM64E::removePtrTag):
(JSC::MacroAssemblerARM64E::callTrustedPtr):
(JSC::MacroAssemblerARM64E::call):
(JSC::MacroAssemblerARM64E::callRegister):
(JSC::MacroAssemblerARM64E::jump):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::reifyInlinedCallFrames):

  • dfg/DFGOSRExitCompilerCommon.cpp:

(JSC::DFG::reifyInlinedCallFrames):

  • ftl/FTLThunks.cpp:

(JSC::FTL::genericGenerationThunkGenerator):

  • jit/CCallHelpers.h:

(JSC::CCallHelpers::prepareForTailCallSlow):

  • jit/CallFrameShuffler.cpp:

(JSC::CallFrameShuffler::prepareForTailCall):

  • jit/ExecutableAllocator.cpp:

(JSC::ExecutableAllocator::allocate):

  • jit/ThunkGenerators.cpp:

(JSC::arityFixupGenerator):

  • llint/LLIntOfflineAsmConfig.h:
  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/ClassInfo.h:
  • runtime/InitializeThreading.cpp:

(JSC::initializeThreading):

  • runtime/JSCPtrTag.cpp: Added.

(JSC::tagForPtr):
(JSC::ptrTagName):
(JSC::initializePtrTagLookup):

  • runtime/JSCPtrTag.h:

(JSC::initializePtrTagLookup):

  • runtime/Options.cpp:

(JSC::recomputeDependentOptions):

Source/WTF:

  • WTF.xcodeproj/project.pbxproj:
  • wtf/BlockPtr.h:
  • wtf/Platform.h:
  • wtf/PlatformRegisters.cpp: Added.

(WTF::threadStateLRInternal):
(WTF::threadStatePCInternal):

  • wtf/PlatformRegisters.h:
  • wtf/PointerPreparations.h:
  • wtf/PtrTag.cpp: Added.

(WTF::tagForPtr):
(WTF::ptrTagName):
(WTF::registerPtrTagLookup):
(WTF::reportBadTag):

  • wtf/PtrTag.h:

(WTF::removeCodePtrTag):
(WTF::tagCodePtrImpl):
(WTF::tagCodePtr):
(WTF::untagCodePtrImplHelper):
(WTF::untagCodePtrImpl):
(WTF::untagCodePtr):
(WTF::retagCodePtrImplHelper):
(WTF::retagCodePtrImpl):
(WTF::retagCodePtr):
(WTF::tagCFunctionPtrImpl):
(WTF::tagCFunctionPtr):
(WTF::untagCFunctionPtrImpl):
(WTF::untagCFunctionPtr):
(WTF::tagInt):
(WTF::assertIsCFunctionPtr):
(WTF::assertIsNullOrCFunctionPtr):
(WTF::assertIsNotTagged):
(WTF::assertIsTagged):
(WTF::assertIsNullOrTagged):
(WTF::isTaggedWith):
(WTF::assertIsTaggedWith):
(WTF::assertIsNullOrTaggedWith):
(WTF::usesPointerTagging):
(WTF::registerPtrTagLookup):
(WTF::reportBadTag):
(WTF::tagForPtr): Deleted.

Location:
trunk/Source
Files:
5 added
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r243246 r243254  
     12019-03-20  Mark Lam  <mark.lam@apple.com>
     2
     3        Open source arm64e code.
     4        https://bugs.webkit.org/show_bug.cgi?id=196012
     5        <rdar://problem/49066237>
     6
     7        Reviewed by Keith Miller.
     8
     9        * JavaScriptCore.xcodeproj/project.pbxproj:
     10        * Sources.txt:
     11        * assembler/ARM64EAssembler.h: Added.
     12        (JSC::ARM64EAssembler::encodeGroup1):
     13        (JSC::ARM64EAssembler::encodeGroup2):
     14        (JSC::ARM64EAssembler::encodeGroup4):
     15        (JSC::ARM64EAssembler::pacia1716):
     16        (JSC::ARM64EAssembler::pacib1716):
     17        (JSC::ARM64EAssembler::autia1716):
     18        (JSC::ARM64EAssembler::autib1716):
     19        (JSC::ARM64EAssembler::paciaz):
     20        (JSC::ARM64EAssembler::paciasp):
     21        (JSC::ARM64EAssembler::pacibz):
     22        (JSC::ARM64EAssembler::pacibsp):
     23        (JSC::ARM64EAssembler::autiaz):
     24        (JSC::ARM64EAssembler::autiasp):
     25        (JSC::ARM64EAssembler::autibz):
     26        (JSC::ARM64EAssembler::autibsp):
     27        (JSC::ARM64EAssembler::xpaclri):
     28        (JSC::ARM64EAssembler::pacia):
     29        (JSC::ARM64EAssembler::pacib):
     30        (JSC::ARM64EAssembler::pacda):
     31        (JSC::ARM64EAssembler::pacdb):
     32        (JSC::ARM64EAssembler::autia):
     33        (JSC::ARM64EAssembler::autib):
     34        (JSC::ARM64EAssembler::autda):
     35        (JSC::ARM64EAssembler::autdb):
     36        (JSC::ARM64EAssembler::paciza):
     37        (JSC::ARM64EAssembler::pacizb):
     38        (JSC::ARM64EAssembler::pacdza):
     39        (JSC::ARM64EAssembler::pacdzb):
     40        (JSC::ARM64EAssembler::autiza):
     41        (JSC::ARM64EAssembler::autizb):
     42        (JSC::ARM64EAssembler::autdza):
     43        (JSC::ARM64EAssembler::autdzb):
     44        (JSC::ARM64EAssembler::xpaci):
     45        (JSC::ARM64EAssembler::xpacd):
     46        (JSC::ARM64EAssembler::pacga):
     47        (JSC::ARM64EAssembler::braa):
     48        (JSC::ARM64EAssembler::brab):
     49        (JSC::ARM64EAssembler::blraa):
     50        (JSC::ARM64EAssembler::blrab):
     51        (JSC::ARM64EAssembler::braaz):
     52        (JSC::ARM64EAssembler::brabz):
     53        (JSC::ARM64EAssembler::blraaz):
     54        (JSC::ARM64EAssembler::blrabz):
     55        (JSC::ARM64EAssembler::retaa):
     56        (JSC::ARM64EAssembler::retab):
     57        (JSC::ARM64EAssembler::eretaa):
     58        (JSC::ARM64EAssembler::eretab):
     59        (JSC::ARM64EAssembler::linkPointer):
     60        (JSC::ARM64EAssembler::repatchPointer):
     61        (JSC::ARM64EAssembler::setPointer):
     62        (JSC::ARM64EAssembler::readPointer):
     63        (JSC::ARM64EAssembler::readCallTarget):
     64        (JSC::ARM64EAssembler::ret):
     65        * assembler/MacroAssembler.cpp:
     66        * assembler/MacroAssembler.h:
     67        * assembler/MacroAssemblerARM64.cpp:
     68        * assembler/MacroAssemblerARM64E.h: Added.
     69        (JSC::MacroAssemblerARM64E::tagReturnAddress):
     70        (JSC::MacroAssemblerARM64E::untagReturnAddress):
     71        (JSC::MacroAssemblerARM64E::tagPtr):
     72        (JSC::MacroAssemblerARM64E::untagPtr):
     73        (JSC::MacroAssemblerARM64E::removePtrTag):
     74        (JSC::MacroAssemblerARM64E::callTrustedPtr):
     75        (JSC::MacroAssemblerARM64E::call):
     76        (JSC::MacroAssemblerARM64E::callRegister):
     77        (JSC::MacroAssemblerARM64E::jump):
     78        * dfg/DFGOSRExit.cpp:
     79        (JSC::DFG::reifyInlinedCallFrames):
     80        * dfg/DFGOSRExitCompilerCommon.cpp:
     81        (JSC::DFG::reifyInlinedCallFrames):
     82        * ftl/FTLThunks.cpp:
     83        (JSC::FTL::genericGenerationThunkGenerator):
     84        * jit/CCallHelpers.h:
     85        (JSC::CCallHelpers::prepareForTailCallSlow):
     86        * jit/CallFrameShuffler.cpp:
     87        (JSC::CallFrameShuffler::prepareForTailCall):
     88        * jit/ExecutableAllocator.cpp:
     89        (JSC::ExecutableAllocator::allocate):
     90        * jit/ThunkGenerators.cpp:
     91        (JSC::arityFixupGenerator):
     92        * llint/LLIntOfflineAsmConfig.h:
     93        * llint/LowLevelInterpreter.asm:
     94        * llint/LowLevelInterpreter64.asm:
     95        * runtime/ClassInfo.h:
     96        * runtime/InitializeThreading.cpp:
     97        (JSC::initializeThreading):
     98        * runtime/JSCPtrTag.cpp: Added.
     99        (JSC::tagForPtr):
     100        (JSC::ptrTagName):
     101        (JSC::initializePtrTagLookup):
     102        * runtime/JSCPtrTag.h:
     103        (JSC::initializePtrTagLookup):
     104        * runtime/Options.cpp:
     105        (JSC::recomputeDependentOptions):
     106
    11072019-03-20  Tadeu Zagallo  <tzagallo@apple.com>
    2108
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r242742 r243254  
    18091809                FE1BD0251E72053800134BC9 /* HeapVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1BD0231E72052F00134BC9 /* HeapVerifier.h */; };
    18101810                FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1C0FFC1B193E9800B53FCA /* Exception.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1811                FE1E2C3F2240DD5800F6B729 /* MacroAssemblerARM64E.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1E2C3E2240D30B00F6B729 /* MacroAssemblerARM64E.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1812                FE1E2C402240DD6200F6B729 /* ARM64EAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1E2C3D2240D2F600F6B729 /* ARM64EAssembler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18111813                FE20CE9E15F04A9500DF3430 /* LLIntCLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = FE20CE9C15F04A9500DF3430 /* LLIntCLoop.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18121814                FE2A87601F02381600EB31B2 /* MinimumReservedZoneSize.h in Headers */ = {isa = PBXBuildFile; fileRef = FE2A875F1F02381600EB31B2 /* MinimumReservedZoneSize.h */; };
     
    48174819                FE1C0FFC1B193E9800B53FCA /* Exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Exception.h; sourceTree = "<group>"; };
    48184820                FE1C0FFE1B194FD100B53FCA /* Exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Exception.cpp; sourceTree = "<group>"; };
     4821                FE1E2C3C2240C1EF00F6B729 /* JSCPtrTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCPtrTag.cpp; sourceTree = "<group>"; };
     4822                FE1E2C3D2240D2F600F6B729 /* ARM64EAssembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARM64EAssembler.h; sourceTree = "<group>"; };
     4823                FE1E2C3E2240D30B00F6B729 /* MacroAssemblerARM64E.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerARM64E.h; sourceTree = "<group>"; };
    48194824                FE20CE9B15F04A9500DF3430 /* LLIntCLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLIntCLoop.cpp; path = llint/LLIntCLoop.cpp; sourceTree = "<group>"; };
    48204825                FE20CE9C15F04A9500DF3430 /* LLIntCLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntCLoop.h; path = llint/LLIntCLoop.h; sourceTree = "<group>"; };
     
    68686873                                14ABB36E099C076400E2A24F /* JSCJSValue.h */,
    68696874                                865A30F0135007E100CDB49E /* JSCJSValueInlines.h */,
     6875                                FE1E2C3C2240C1EF00F6B729 /* JSCPtrTag.cpp */,
    68706876                                FE7497E5209001B00003565B /* JSCPtrTag.h */,
    68716877                                72AAF7CB1D0D318B005E60BE /* JSCustomGetterSetterFunction.cpp */,
     
    77047710                                AD412B351E7B57C0008AF157 /* AllowMacroScratchRegisterUsageIf.h */,
    77057711                                8640923B156EED3B00566CB2 /* ARM64Assembler.h */,
     7712                                FE1E2C3D2240D2F600F6B729 /* ARM64EAssembler.h */,
    77067713                                86ADD1430FDDEA980006EEC2 /* ARMv7Assembler.h */,
    77077714                                9688CB130ED12B4E001D649F /* AssemblerBuffer.h */,
     
    77177724                                FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */,
    77187725                                8640923C156EED3B00566CB2 /* MacroAssemblerARM64.h */,
     7726                                FE1E2C3E2240D30B00F6B729 /* MacroAssemblerARM64E.h */,
    77197727                                A729009B17976C6000317298 /* MacroAssemblerARMv7.cpp */,
    77207728                                86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */,
     
    85158523                                0FEC85011BDACDAC0080FF74 /* B3BasicBlock.h in Headers */,
    85168524                                0FEC85021BDACDAC0080FF74 /* B3BasicBlockInlines.h in Headers */,
     8525                                FE1E2C3F2240DD5800F6B729 /* MacroAssemblerARM64E.h in Headers */,
    85178526                                0FEC85031BDACDAC0080FF74 /* B3BasicBlockUtils.h in Headers */,
    85188527                                0F338E1C1BF286EA0013C88F /* B3BlockInsertionSet.h in Headers */,
     
    85948603                                0F4570411BE584CA0062A629 /* B3TimingScope.h in Headers */,
    85958604                                0FEC853C1BDACDAC0080FF74 /* B3Type.h in Headers */,
     8605                                FE1E2C402240DD6200F6B729 /* ARM64EAssembler.h in Headers */,
    85968606                                DCFDFBDA1D1F5D9E00FE3D72 /* B3TypeMap.h in Headers */,
    85978607                                0FEC853E1BDACDAC0080FF74 /* B3UpsilonValue.h in Headers */,
  • trunk/Source/JavaScriptCore/Sources.txt

    r242699 r243254  
    803803runtime/JSBoundFunction.cpp
    804804runtime/JSCJSValue.cpp
     805runtime/JSCPtrTag.cpp
    805806runtime/JSCallee.cpp
    806807runtime/JSCell.cpp
  • trunk/Source/JavaScriptCore/assembler/MacroAssembler.cpp

    r234082 r243254  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333#include <wtf/PrintStream.h>
    3434#include <wtf/ScopedLambda.h>
    35 
    36 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/MacroAssemblerSupport.h>)
    37 #include <WebKitAdditions/MacroAssemblerSupport.h>
    38 #endif
    3935
    4036namespace JSC {
  • trunk/Source/JavaScriptCore/assembler/MacroAssembler.h

    r240731 r243254  
    11/*
    2  * Copyright (C) 2008-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636namespace JSC { typedef MacroAssemblerARMv7 MacroAssemblerBase; };
    3737
    38 #elif CPU(ARM64E) && __has_include(<WebKitAdditions/MacroAssemblerARM64E.h>)
     38#elif CPU(ARM64E)
    3939#define TARGET_ASSEMBLER ARM64EAssembler
    4040#define TARGET_MACROASSEMBLER MacroAssemblerARM64E
    41 #include <WebKitAdditions/MacroAssemblerARM64E.h>
     41#include "MacroAssemblerARM64E.h"
    4242
    4343#elif CPU(ARM64)
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.cpp

    r237173 r243254  
    11/*
    2  * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    382382    // the caller of the probe (which is what we want in order to play nice with debuggers e.g. lldb).
    383383    "mov       x0, sp" "\n" // Set the Probe::State* arg.
    384     CALL_WITH_PTRTAG("blr", "x28", CFunctionPtrTag) // Call the probe handler.
     384#if CPU(ARM64E)
     385    "blraaz    x28" "\n" // Call the probe handler.
     386#else
     387    "blr       x28" "\n" // Call the probe handler.
     388#endif
    385389
    386390    // Make sure the Probe::State is entirely below the result stack pointer so
     
    418422
    419423    "mov       x0, x27" "\n" // Set the Probe::State* arg.
    420     CALL_WITH_PTRTAG("blr", "x2", CFunctionPtrTag) // Call the initializeStackFunction (loaded into x2 above).
     424#if CPU(ARM64E)
     425    "blraaz    x2" "\n" // Call the initializeStackFunction (loaded into x2 above).
     426#else
     427    "blr       x2" "\n" // Call the initializeStackFunction (loaded into x2 above).
     428#endif
    421429
    422430    LOCAL_LABEL_STRING(ctiMasmProbeTrampolineRestoreRegisters) ":" "\n"
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExit.cpp

    r243232 r243254  
    759759            ASSERT(inlineCallFrame->isTail());
    760760            void* returnPC = frame.get<void*>(CallFrame::returnPCOffset());
    761 #if USE(POINTER_PROFILING)
     761#if CPU(ARM64E)
    762762            void* oldEntrySP = cpu.fp<uint8_t*>() + sizeof(CallerFrameAndPC);
    763763            void* newEntrySP = cpu.fp<uint8_t*>() + inlineCallFrame->returnPCOffset() + sizeof(void*);
     
    804804
    805805            void* targetAddress = jumpTarget.executableAddress();
    806 #if USE(POINTER_PROFILING)
     806#if CPU(ARM64E)
    807807            void* newEntrySP = cpu.fp<uint8_t*>() + inlineCallFrame->returnPCOffset() + sizeof(void*);
    808808            targetAddress = retagCodePtr(targetAddress, JSInternalPtrTag, bitwise_cast<PtrTag>(newEntrySP));
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompilerCommon.cpp

    r243232 r243254  
    11/*
    2  * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    156156            ASSERT(inlineCallFrame->isTail());
    157157            jit.loadPtr(AssemblyHelpers::Address(GPRInfo::callFrameRegister, CallFrame::returnPCOffset()), GPRInfo::regT3);
    158 #if USE(POINTER_PROFILING)
     158#if CPU(ARM64E)
    159159            jit.addPtr(AssemblyHelpers::TrustedImm32(sizeof(CallerFrameAndPC)), GPRInfo::callFrameRegister, GPRInfo::regT2);
    160160            jit.untagPtr(GPRInfo::regT3, GPRInfo::regT2);
     
    207207            }
    208208
    209 #if USE(POINTER_PROFILING)
     209#if CPU(ARM64E)
    210210            jit.addPtr(AssemblyHelpers::TrustedImm32(inlineCallFrame->returnPCOffset() + sizeof(void*)), GPRInfo::callFrameRegister, GPRInfo::regT2);
    211211            jit.move(AssemblyHelpers::TrustedImmPtr(jumpTarget), GPRInfo::nonArgGPR0);
  • trunk/Source/JavaScriptCore/ftl/FTLThunks.cpp

    r230748 r243254  
    11/*
    2  * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    116116    restoreAllRegisters(jit, buffer);
    117117
    118 #if CPU(ARM64) && USE(POINTER_PROFILING)
     118#if CPU(ARM64E)
    119119    jit.untagPtr(AssemblyHelpers::linkRegister, resultTag);
    120120    jit.tagReturnAddress();
  • trunk/Source/JavaScriptCore/jit/CCallHelpers.h

    r238439 r243254  
    11/*
    2  * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    806806        loadPtr(Address(framePointerRegister, CallFrame::returnPCOffset()), linkRegister);
    807807        subPtr(TrustedImm32(2 * sizeof(void*)), newFrameSizeGPR);
    808 #if USE(POINTER_PROFILING)
     808#if CPU(ARM64E)
    809809        addPtr(TrustedImm32(sizeof(CallerFrameAndPC)), MacroAssembler::framePointerRegister, tempGPR);
    810810        untagPtr(linkRegister, tempGPR);
  • trunk/Source/JavaScriptCore/jit/CallFrameShuffler.cpp

    r239867 r243254  
    11/*
    2  * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    455455    m_jit.loadPtr(MacroAssembler::Address(MacroAssembler::framePointerRegister, CallFrame::returnPCOffset()),
    456456        MacroAssembler::linkRegister);
    457 #if USE(POINTER_PROFILING)
     457#if CPU(ARM64E)
    458458    m_jit.addPtr(MacroAssembler::TrustedImm32(sizeof(CallerFrameAndPC)), MacroAssembler::framePointerRegister);
    459459    m_jit.untagPtr(MacroAssembler::linkRegister, MacroAssembler::framePointerRegister);
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp

    r240641 r243254  
    11/*
    2  * Copyright (C) 2008-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    502502    }
    503503
    504 #if USE(POINTER_PROFILING)
     504#if CPU(ARM64E)
    505505    void* start = allocator->memoryStart();
    506506    void* end = allocator->memoryEnd();
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r242252 r243254  
    457457#  endif
    458458    jit.tagReturnAddress();
    459 #if CPU(ARM64) && USE(POINTER_PROFILING)
     459#if CPU(ARM64E)
    460460    jit.loadPtr(JSInterfaceJIT::Address(GPRInfo::callFrameRegister, CallFrame::returnPCOffset()), GPRInfo::regT3);
    461461    jit.addPtr(JSInterfaceJIT::TrustedImm32(sizeof(CallerFrameAndPC)), GPRInfo::callFrameRegister, extraTemp);
     
    513513    done.link(&jit);
    514514
    515 #if CPU(ARM64) && USE(POINTER_PROFILING)
     515#if CPU(ARM64E)
    516516    jit.loadPtr(JSInterfaceJIT::Address(GPRInfo::callFrameRegister, CallFrame::returnPCOffset()), GPRInfo::regT3);
    517517    jit.move(JSInterfaceJIT::TrustedImmPtr(tempReturnPCTag), extraTemp);
  • trunk/Source/JavaScriptCore/llint/LLIntOfflineAsmConfig.h

    r240832 r243254  
    148148#endif
    149149
    150 #if USE(POINTER_PROFILING)
    151 #define OFFLINE_ASM_POINTER_PROFILING 1
    152 #else
    153 #define OFFLINE_ASM_POINTER_PROFILING 0
    154 #endif
    155 
    156150#define OFFLINE_ASM_GIGACAGE_ENABLED GIGACAGE_ENABLED
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r243127 r243254  
    949949    end
    950950
    951     if POINTER_PROFILING
     951    if ARM64E
    952952        addp 16, cfr, temp3
    953953        untagReturnAddress temp3
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r242519 r243254  
    586586
    587587.noExtraSlot:
    588     if POINTER_PROFILING
    589         if ARM64 or ARM64E
    590             loadp 8[cfr], lr
    591         end
    592 
     588    if ARM64E
     589        loadp 8[cfr], lr
    593590        addp 16, cfr, t3
    594591        untagReturnAddress t3
     
    619616    baddinz 1, t2, .fillLoop
    620617
    621     if POINTER_PROFILING
     618    if ARM64E
    622619        addp 16, cfr, t1
    623620        tagReturnAddress t1
    624 
    625         if ARM64 or ARM64E
    626             storep lr, 8[cfr]
    627         end
     621        storep lr, 8[cfr]
    628622    end
    629623
  • trunk/Source/JavaScriptCore/runtime/ClassInfo.h

    r233765 r243254  
    22 *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
    33 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
    4  *  Copyright (C) 2003-2018 Apple Inc. All rights reserved.
     4 *  Copyright (C) 2003-2019 Apple Inc. All rights reserved.
    55 *
    66 *  This library is free software; you can redistribute it and/or
     
    2727#include "JSCast.h"
    2828
     29#if CPU(ARM64E)
     30#include <ptrauth.h>
     31#endif
     32
    2933namespace WTF {
    3034class PrintStream;
     
    3741class Snippet;
    3842struct HashTable;
     43
     44#if CPU(ARM64E)
     45#define WTF_METHOD_TABLE_ENTRY(method) \
     46    __ptrauth(ptrauth_key_process_independent_code, true, ptrauth_string_discriminator("MethodTable." #method)) method
     47#else
     48#define WTF_METHOD_TABLE_ENTRY(method) method
     49#endif
    3950
    4051struct MethodTable {
  • trunk/Source/JavaScriptCore/runtime/InitializeThreading.cpp

    r242123 r243254  
    3434#include "Heap.h"
    3535#include "Identifier.h"
     36#include "JSCPtrTag.h"
    3637#include "JSDateMath.h"
    3738#include "JSGlobalObject.h"
     
    6162        WTF::initializeThreading();
    6263        Options::initialize();
     64
     65        initializePtrTagLookup();
    6366
    6467#if ENABLE(WRITE_BARRIER_PROFILING)
  • trunk/Source/JavaScriptCore/runtime/JSCPtrTag.h

    r236576 r243254  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4848    v(OSREntryPtrTag) \
    4949    v(OSRExitPtrTag) \
    50     v(PlatformRegistersLRPtrTag) \
    51     v(PlatformRegistersPCPtrTag) \
    5250    v(SlowPathPtrTag) \
    5351    v(WasmEntryPtrTag) \
     
    6967#endif
    7068
     69void initializePtrTagLookup();
     70
     71#if !CPU(ARM64E)
     72inline void initializePtrTagLookup() { }
     73#endif
     74
    7175} // namespace JSC
    7276
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r242713 r243254  
    11/*
    2  * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    420420        Options::useJIT() = false;
    421421#endif
    422 
    423     WTF_SET_POINTER_PREPARATION_OPTIONS();
    424422
    425423    if (!Options::useJIT())
  • trunk/Source/WTF/ChangeLog

    r243230 r243254  
     12019-03-20  Mark Lam  <mark.lam@apple.com>
     2
     3        Open source arm64e code.
     4        https://bugs.webkit.org/show_bug.cgi?id=196012
     5        <rdar://problem/49066237>
     6
     7        Reviewed by Keith Miller.
     8
     9        * WTF.xcodeproj/project.pbxproj:
     10        * wtf/BlockPtr.h:
     11        * wtf/Platform.h:
     12        * wtf/PlatformRegisters.cpp: Added.
     13        (WTF::threadStateLRInternal):
     14        (WTF::threadStatePCInternal):
     15        * wtf/PlatformRegisters.h:
     16        * wtf/PointerPreparations.h:
     17        * wtf/PtrTag.cpp: Added.
     18        (WTF::tagForPtr):
     19        (WTF::ptrTagName):
     20        (WTF::registerPtrTagLookup):
     21        (WTF::reportBadTag):
     22        * wtf/PtrTag.h:
     23        (WTF::removeCodePtrTag):
     24        (WTF::tagCodePtrImpl):
     25        (WTF::tagCodePtr):
     26        (WTF::untagCodePtrImplHelper):
     27        (WTF::untagCodePtrImpl):
     28        (WTF::untagCodePtr):
     29        (WTF::retagCodePtrImplHelper):
     30        (WTF::retagCodePtrImpl):
     31        (WTF::retagCodePtr):
     32        (WTF::tagCFunctionPtrImpl):
     33        (WTF::tagCFunctionPtr):
     34        (WTF::untagCFunctionPtrImpl):
     35        (WTF::untagCFunctionPtr):
     36        (WTF::tagInt):
     37        (WTF::assertIsCFunctionPtr):
     38        (WTF::assertIsNullOrCFunctionPtr):
     39        (WTF::assertIsNotTagged):
     40        (WTF::assertIsTagged):
     41        (WTF::assertIsNullOrTagged):
     42        (WTF::isTaggedWith):
     43        (WTF::assertIsTaggedWith):
     44        (WTF::assertIsNullOrTaggedWith):
     45        (WTF::usesPointerTagging):
     46        (WTF::registerPtrTagLookup):
     47        (WTF::reportBadTag):
     48        (WTF::tagForPtr): Deleted.
     49
    1502019-03-20  Keith Rollin  <krollin@apple.com>
    251
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r242901 r243254  
    168168                E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
    169169                FE05FAFF1FE5007500093230 /* WTFAssertions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE05FAFE1FE5007500093230 /* WTFAssertions.cpp */; };
     170                FE1E2C3B2240C06600F6B729 /* PtrTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1E2C392240C05400F6B729 /* PtrTag.cpp */; };
     171                FE1E2C42224187C600F6B729 /* PlatformRegisters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1E2C41224187C600F6B729 /* PlatformRegisters.cpp */; };
    170172                FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; };
    171173                FEEA4DF9216D7BE400AC0602 /* StackPointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEEA4DF8216D7BE400AC0602 /* StackPointer.cpp */; };
     
    677679                FE05FAE61FDB214300093230 /* DumbPtrTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumbPtrTraits.h; sourceTree = "<group>"; };
    678680                FE05FAFE1FE5007500093230 /* WTFAssertions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WTFAssertions.cpp; sourceTree = "<group>"; };
     681                FE1E2C392240C05400F6B729 /* PtrTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PtrTag.cpp; sourceTree = "<group>"; };
     682                FE1E2C41224187C600F6B729 /* PlatformRegisters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformRegisters.cpp; sourceTree = "<group>"; };
    679683                FE7497E4208FFCAA0003565B /* PtrTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PtrTag.h; sourceTree = "<group>"; };
    680684                FE7497ED209163060003565B /* MetaAllocatorPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaAllocatorPtr.h; sourceTree = "<group>"; };
     
    10641068                                0F824A651B7443A0002E345D /* ParkingLot.h */,
    10651069                                A876DBD7151816E500DADB95 /* Platform.h */,
     1070                                FE1E2C41224187C600F6B729 /* PlatformRegisters.cpp */,
    10661071                                E3200AB41E9A536D003B59D2 /* PlatformRegisters.h */,
    10671072                                0FF860941BCCBD740045127F /* PointerComparison.h */,
     
    10731078                                7AF023B42061E16F00A8EFD6 /* ProcessPrivilege.cpp */,
    10741079                                7AF023B32061E16C00A8EFD6 /* ProcessPrivilege.h */,
     1080                                FE1E2C392240C05400F6B729 /* PtrTag.cpp */,
    10751081                                FE7497E4208FFCAA0003565B /* PtrTag.h */,
    10761082                                143F611D1565F0F900DB514A /* RAMSize.cpp */,
     
    15281534                                0F9D3360165DBA73005AD387 /* FilePrintStream.cpp in Sources */,
    15291535                                A331D95B21F24992009F02AA /* FileSystem.cpp in Sources */,
     1536                                FE1E2C42224187C600F6B729 /* PlatformRegisters.cpp in Sources */,
    15301537                                A331D95D21F249E4009F02AA /* FileSystemCF.cpp in Sources */,
    15311538                                A331D95F21F249F6009F02AA /* FileSystemCocoa.mm in Sources */,
     
    16211628                                1C181C911D307AB800F5FA16 /* UTextProviderLatin1.cpp in Sources */,
    16221629                                1C181C931D307AB800F5FA16 /* UTextProviderUTF16.cpp in Sources */,
     1630                                FE1E2C3B2240C06600F6B729 /* PtrTag.cpp in Sources */,
    16231631                                A8A47469151A825B004123FF /* UTF8Conversion.cpp in Sources */,
    16241632                                7AFEC6B11EB22B5900DADE36 /* UUID.cpp in Sources */,
  • trunk/Source/WTF/wtf/BlockPtr.h

    r239078 r243254  
    11/*
    2  * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#include <wtf/StdLibExtras.h>
    3232
    33 #if CPU(ARM64E)
    34 #include <WebKitAdditions/BlockQualifiers.h>
     33#if __has_include(<ptrauth.h>)
     34#include <ptrauth.h>
     35#define WTF_COPY_FUNCTION_POINTER_QUALIFIER __ptrauth_block_copy_helper
     36#define WTF_DISPOSE_FUNCTION_POINTER_QUALIFIER __ptrauth_block_destroy_helper
     37#define WTF_INVOKE_FUNCTION_POINTER_QUALIFIER __ptrauth_block_invocation_pointer
    3538#else
    3639#define WTF_COPY_FUNCTION_POINTER_QUALIFIER
  • trunk/Source/WTF/wtf/Platform.h

    r243230 r243254  
    10511051#endif
    10521052
    1053 #if !defined(USE_POINTER_PROFILING) || USE(JSVALUE32_64) || !ENABLE(JIT)
    1054 #undef USE_POINTER_PROFILING
    1055 #define USE_POINTER_PROFILING 0
    1056 #endif
    1057 
    10581053/* CSS Selector JIT Compiler */
    10591054#if !defined(ENABLE_CSS_SELECTOR_JIT)
  • trunk/Source/WTF/wtf/PlatformRegisters.h

    r218080 r243254  
    11/*
    22 * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
     3 * Copyright (C) 2019 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    9293} // namespace WTF
    9394
     95#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
     96#if CPU(ARM64E)
     97
     98namespace WTF {
     99
     100extern void* threadStateLRInternal(PlatformRegisters&);
     101extern void* threadStatePCInternal(PlatformRegisters&);
     102
     103} // namespace WTF
     104
     105using WTF::threadStateLRInternal;
     106using WTF::threadStatePCInternal;
     107
     108#else // not CPU(ARM64E)
     109
     110#define threadStateLRInternal(regs) bitwise_cast<void*>(arm_thread_state64_get_lr(regs))
     111#define threadStatePCInternal(regs) bitwise_cast<void*>(arm_thread_state64_get_pc(regs))
     112
     113#endif // CPU(ARM64E)
     114
     115#define WTF_READ_PLATFORM_REGISTERS_SP_WITH_PROFILE(regs) \
     116    reinterpret_cast<void*>(arm_thread_state64_get_sp(const_cast<PlatformRegisters&>(regs)))
     117
     118#define WTF_WRITE_PLATFORM_REGISTERS_SP_WITH_PROFILE(regs, newPointer) \
     119    arm_thread_state64_set_sp(regs, reinterpret_cast<uintptr_t>(newPointer))
     120
     121#define WTF_READ_PLATFORM_REGISTERS_FP_WITH_PROFILE(regs) \
     122    reinterpret_cast<void*>(arm_thread_state64_get_fp(const_cast<PlatformRegisters&>(regs)))
     123
     124#define WTF_WRITE_PLATFORM_REGISTERS_FP_WITH_PROFILE(regs, newPointer) \
     125    arm_thread_state64_set_fp(regs, reinterpret_cast<uintptr_t>(newPointer))
     126
     127#define WTF_READ_PLATFORM_REGISTERS_LR_WITH_PROFILE(regs) \
     128    threadStateLRInternal(const_cast<PlatformRegisters&>(regs))
     129
     130#define WTF_WRITE_PLATFORM_REGISTERS_LR_WITH_PROFILE(regs, newPointer) \
     131    arm_thread_state64_set_lr_fptr(regs, newPointer)
     132
     133#define WTF_READ_PLATFORM_REGISTERS_PC_WITH_PROFILE(regs) \
     134    threadStatePCInternal(const_cast<PlatformRegisters&>(regs))
     135
     136#define WTF_WRITE_PLATFORM_REGISTERS_PC_WITH_PROFILE(regs, newPointer) \
     137    arm_thread_state64_set_pc_fptr(regs, newPointer)
     138
     139#define WTF_READ_MACHINE_CONTEXT_SP_WITH_PROFILE(machineContext) \
     140    WTF_READ_PLATFORM_REGISTERS_SP_WITH_PROFILE(machineContext->__ss)
     141
     142#define WTF_WRITE_MACHINE_CONTEXT_SP_WITH_PROFILE(machineContext, newPointer) \
     143    WTF_WRITE_PLATFORM_REGISTERS_SP_WITH_PROFILE(machineContext->__ss, newPointer)
     144
     145#define WTF_READ_MACHINE_CONTEXT_FP_WITH_PROFILE(machineContext) \
     146    WTF_READ_PLATFORM_REGISTERS_FP_WITH_PROFILE(machineContext->__ss)
     147
     148#define WTF_WRITE_MACHINE_CONTEXT_FP_WITH_PROFILE(machineContext, newPointer) \
     149    WTF_WRITE_PLATFORM_REGISTERS_FP_WITH_PROFILE(machineContext->__ss, newPointer)
     150
     151#define WTF_WRITE_MACHINE_CONTEXT_LR_WITH_PROFILE(machineContext, newPointer) \
     152    WTF_WRITE_PLATFORM_REGISTERS_LR_WITH_PROFILE(machineContext->__ss, newPointer)
     153
     154#define WTF_READ_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext) \
     155    WTF_READ_PLATFORM_REGISTERS_PC_WITH_PROFILE(machineContext->__ss)
     156
     157#define WTF_WRITE_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext, newPointer) \
     158    WTF_WRITE_PLATFORM_REGISTERS_PC_WITH_PROFILE(machineContext->__ss, newPointer)
     159
     160#endif // USE(PLATFORM_REGISTERS_WITH_PROFILE)
     161
    94162using WTF::PlatformRegisters;
  • trunk/Source/WTF/wtf/PointerPreparations.h

    r230455 r243254  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PointerPreparations.h>)
    29 #include <WebKitAdditions/PointerPreparations.h>
    30 #endif
     28namespace WTF {
    3129
    32 #ifndef WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION
     30#if CPU(ARM64E)
     31#include <ptrauth.h>
     32
     33#define WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(vtblPtr) \
     34    (reinterpret_cast<void*>(ptrauth_sign_unauthenticated(vtblPtr, ptrauth_key_cxx_vtable_pointer, 0)))
     35
     36#else // not CPU(ARM64E)
     37
    3338#define WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(vtblPtr) (reinterpret_cast<void*>(vtblPtr))
    34 #endif
    3539
    36 #ifndef WTF_SET_POINTER_PREPARATION_OPTIONS
    37 #define WTF_SET_POINTER_PREPARATION_OPTIONS() do { } while (false)
    38 #endif
     40#endif // not CPU(ARM64E)
    3941
    40 #ifndef WTF_METHOD_TABLE_ENTRY
    41 #define WTF_METHOD_TABLE_ENTRY(method) method
    42 #endif
     42} // namespace WTF
  • trunk/Source/WTF/wtf/PtrTag.h

    r237429 r243254  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include <wtf/PointerPreparations.h>
     28#include <wtf/Assertions.h>
     29#include <wtf/DataLog.h>
    2930
    3031namespace WTF {
     
    3738    v(FreeSpacePtrTag) \
    3839    v(HandleMemoryPtrTag) \
     40    v(PlatformRegistersLRPtrTag) \
     41    v(PlatformRegistersPCPtrTag) \
    3942
    4043#define FOR_EACH_WTF_PTRTAG(v) \
     
    4750};
    4851
    49 #ifndef WTF_PTRTAG_HASH
     52#if CPU(ARM64E)
     53#define WTF_PTRTAG_HASH(tag) ptrauth_string_discriminator(#tag)
     54
     55#else // not CPU(ARM64E)
     56
    5057template<size_t N>
    5158constexpr uintptr_t makePtrTagHash(const char (&str)[N])
     
    5865
    5966#define WTF_PTRTAG_HASH(tag) WTF::makePtrTagHash(#tag)
    60 #endif
     67#endif // not CPU(ARM64E)
    6168
    6269#define WTF_DECLARE_PTRTAG(tag) \
     
    7885#endif
    7986
    80 #if !USE(POINTER_PROFILING)
    81 
    82 inline const char* tagForPtr(const void*) { return "<no tag>"; }
     87struct PtrTagLookup {
     88    const char* (*tagForPtr)(const void*);
     89    const char* (*ptrTagName)(PtrTag);
     90    PtrTagLookup* next { nullptr };
     91};
     92
     93#if CPU(ARM64E)
     94
     95enum class PtrTagAction {
     96    ReleaseAssert,
     97    DebugAssert,
     98    NoAssert,
     99};
     100
     101constexpr PtrTag AnyPtrTag = static_cast<PtrTag>(-1); // Only used for assertion messages.
     102
     103WTF_EXPORT_PRIVATE void registerPtrTagLookup(PtrTagLookup*);
     104WTF_EXPORT_PRIVATE void reportBadTag(const void*, PtrTag expectedTag);
     105
     106#if ASSERT_DISABLED
     107constexpr bool enablePtrTagDebugAssert = false;
     108#else
     109constexpr bool enablePtrTagDebugAssert = true;
     110#endif
     111
     112#define WTF_PTRTAG_ASSERT(action, ptr, expectedTag, assertion) \
     113    do { \
     114        if (action == PtrTagAction::ReleaseAssert \
     115            || (WTF::enablePtrTagDebugAssert && action == PtrTagAction::DebugAssert)) { \
     116            bool passed = (assertion); \
     117            if (UNLIKELY(!passed)) { \
     118                reportBadTag(reinterpret_cast<const void*>(ptr), expectedTag); \
     119            } \
     120            RELEASE_ASSERT(passed && #assertion); \
     121        } \
     122    } while (false)
     123
     124template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>>
     125inline constexpr T removeCodePtrTag(PtrType ptr)
     126{
     127    return bitwise_cast<T>(ptrauth_strip(ptr, ptrauth_key_process_dependent_code));
     128}
     129
     130template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     131inline constexpr PtrType removeCodePtrTag(PtrType ptr)
     132{
     133    return ptrauth_strip(ptr, ptrauth_key_process_dependent_code);
     134}
     135
     136template<PtrTagAction tagAction, typename PtrType>
     137inline PtrType tagCodePtrImpl(PtrType ptr, PtrTag tag)
     138{
     139    if (!ptr)
     140        return nullptr;
     141    WTF_PTRTAG_ASSERT(tagAction, ptr, NoPtrTag, removeCodePtrTag(ptr) == ptr);
     142    if (tag == NoPtrTag)
     143        return ptr;
     144    if (tag == CFunctionPtrTag)
     145        return ptrauth_sign_unauthenticated(ptr, ptrauth_key_function_pointer, 0);
     146    return ptrauth_sign_unauthenticated(ptr, ptrauth_key_process_dependent_code, tag);
     147}
     148
     149template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>>
     150inline T tagCodePtr(PtrType ptr, PtrTag tag)
     151{
     152    return bitwise_cast<T>(tagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, tag));
     153}
     154
     155template<typename T, PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     156inline T tagCodePtr(PtrType ptr)
     157{
     158    return bitwise_cast<T>(tagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, tag));
     159}
     160
     161template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     162inline PtrType tagCodePtr(PtrType ptr, PtrTag tag)
     163{
     164    return tagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, tag);
     165}
     166
     167template<PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     168inline PtrType tagCodePtr(PtrType ptr) { return tagCodePtr(ptr, tag); }
     169
     170template<typename PtrType>
     171inline PtrType untagCodePtrImplHelper(PtrType ptr, PtrTag tag)
     172{
     173    if (tag == NoPtrTag)
     174        return ptr;
     175    if (tag == CFunctionPtrTag)
     176        return __builtin_ptrauth_auth(ptr, ptrauth_key_function_pointer, 0);
     177    return __builtin_ptrauth_auth(ptr, ptrauth_key_process_dependent_code, tag);
     178}
     179
     180template<PtrTagAction tagAction, typename PtrType>
     181inline PtrType untagCodePtrImpl(PtrType ptr, PtrTag tag)
     182{
     183    if (!ptr)
     184        return nullptr;
     185    PtrType result = untagCodePtrImplHelper(ptr, tag);
     186    WTF_PTRTAG_ASSERT(tagAction, ptr, tag, removeCodePtrTag(ptr) == result);
     187    return result;
     188}
     189
     190template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>>
     191inline T untagCodePtr(PtrType ptr, PtrTag tag)
     192{
     193    return bitwise_cast<T>(untagCodePtrImpl<PtrTagAction::ReleaseAssert>(ptr, tag));
     194}
     195
     196template<typename T, PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     197inline T untagCodePtr(PtrType ptr)
     198{
     199    return bitwise_cast<T>(untagCodePtrImpl<PtrTagAction::ReleaseAssert>(ptr, tag));
     200}
     201
     202template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     203inline PtrType untagCodePtr(PtrType ptr, PtrTag tag)
     204{
     205    return untagCodePtrImpl<PtrTagAction::ReleaseAssert>(ptr, tag);
     206}
     207
     208template<PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     209inline PtrType untagCodePtr(PtrType ptr) { return untagCodePtr(ptr, tag); }
     210
     211template<PtrTagAction tagAction, typename PtrType>
     212inline PtrType retagCodePtrImplHelper(PtrType ptr, PtrTag oldTag, PtrTag newTag)
     213{
     214    if (oldTag == newTag || (oldTag == NoPtrTag && newTag == NoPtrTag))
     215        return ptr;
     216    if (newTag == NoPtrTag)
     217        return untagCodePtrImpl<tagAction>(ptr, oldTag);
     218    if (oldTag == NoPtrTag)
     219        return tagCodePtrImpl<tagAction>(ptr, newTag);
     220    if (oldTag == CFunctionPtrTag)
     221        return ptrauth_auth_and_resign(ptr, ptrauth_key_function_pointer, 0, ptrauth_key_process_dependent_code, newTag);
     222    if (newTag == CFunctionPtrTag)
     223        return ptrauth_auth_and_resign(ptr, ptrauth_key_process_dependent_code, oldTag, ptrauth_key_function_pointer, 0);
     224    return ptrauth_auth_and_resign(ptr, ptrauth_key_process_dependent_code, oldTag, ptrauth_key_process_dependent_code, newTag);
     225}
     226
     227template<PtrTagAction tagAction, typename PtrType>
     228inline PtrType retagCodePtrImpl(PtrType ptr, PtrTag oldTag, PtrTag newTag)
     229{
     230    if (!ptr)
     231        return nullptr;
     232    PtrTagAction untagAction = (tagAction == PtrTagAction::NoAssert) ? PtrTagAction::NoAssert : PtrTagAction::ReleaseAssert;
     233    WTF_PTRTAG_ASSERT(untagAction, ptr, oldTag, removeCodePtrTag(ptr) == untagCodePtrImpl<PtrTagAction::NoAssert>(ptr, oldTag));
     234    PtrType result = retagCodePtrImplHelper<tagAction>(ptr, oldTag, newTag);
     235    WTF_PTRTAG_ASSERT(tagAction, ptr, newTag, result == tagCodePtrImpl<PtrTagAction::NoAssert>(removeCodePtrTag(ptr), newTag));
     236    return result;
     237}
     238
     239template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>>
     240inline T retagCodePtr(PtrType ptr, PtrTag oldTag, PtrTag newTag)
     241{
     242    return bitwise_cast<T>(retagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, oldTag, newTag));
     243}
     244
     245template<typename T, PtrTag oldTag, PtrTag newTag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     246inline T retagCodePtr(PtrType ptr)
     247{
     248    return bitwise_cast<T>(retagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, oldTag, newTag));
     249}
     250
     251template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     252inline PtrType retagCodePtr(PtrType ptr, PtrTag oldTag, PtrTag newTag)
     253{
     254    return retagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, oldTag, newTag);
     255}
     256
     257template<PtrTag oldTag, PtrTag newTag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     258inline PtrType retagCodePtr(PtrType ptr) { return retagCodePtr(ptr, oldTag, newTag); }
     259
     260template<PtrTagAction tagAction, typename PtrType>
     261inline PtrType tagCFunctionPtrImpl(PtrType ptr, PtrTag tag)
     262{
     263    if (!ptr)
     264        return nullptr;
     265    WTF_PTRTAG_ASSERT(tagAction, ptr, CFunctionPtrTag, removeCodePtrTag(ptr) == untagCodePtrImpl<PtrTagAction::NoAssert>(ptr, CFunctionPtrTag));
     266    return retagCodePtrImpl<tagAction>(ptr, CFunctionPtrTag, tag);
     267}
     268
     269template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>>
     270inline T tagCFunctionPtr(PtrType ptr, PtrTag tag)
     271{
     272    return bitwise_cast<T>(tagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag));
     273}
     274
     275template<typename T, PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     276inline T tagCFunctionPtr(PtrType ptr)
     277{
     278    return bitwise_cast<T>(tagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag));
     279}
     280
     281template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     282inline PtrType tagCFunctionPtr(PtrType ptr, PtrTag tag)
     283{
     284    return tagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag);
     285}
     286
     287template<PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     288inline PtrType tagCFunctionPtr(PtrType ptr) { return tagCFunctionPtr(ptr, tag); }
     289
     290template<PtrTagAction tagAction, typename PtrType>
     291inline PtrType untagCFunctionPtrImpl(PtrType ptr, PtrTag tag)
     292{
     293    if (!ptr)
     294        return nullptr;
     295    WTF_PTRTAG_ASSERT(tagAction, ptr, tag, removeCodePtrTag(ptr) == untagCodePtrImpl<PtrTagAction::NoAssert>(ptr, tag));
     296    return retagCodePtrImpl<tagAction>(ptr, tag, CFunctionPtrTag);
     297}
     298
     299template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>>
     300inline T untagCFunctionPtr(PtrType ptr, PtrTag tag)
     301{
     302    return bitwise_cast<T>(untagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag));
     303}
     304
     305template<typename T, PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     306inline T untagCFunctionPtr(PtrType ptr)
     307{
     308    return bitwise_cast<T>(untagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag));
     309}
     310
     311template<typename T, PtrTag tag, PtrTagAction tagAction, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     312inline T untagCFunctionPtr(PtrType ptr)
     313{
     314    return bitwise_cast<T>(untagCFunctionPtrImpl<tagAction>(ptr, tag));
     315}
     316
     317template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     318inline PtrType untagCFunctionPtr(PtrType ptr, PtrTag tag)
     319{
     320    return untagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag);
     321}
     322
     323template<PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
     324inline PtrType untagCFunctionPtr(PtrType ptr) { return untagCFunctionPtr(ptr, tag); }
     325
     326template <typename IntType>
     327inline IntType tagInt(IntType ptrInt, PtrTag tag)
     328{
     329    static_assert(sizeof(IntType) == sizeof(uintptr_t), "");
     330    return bitwise_cast<IntType>(ptrauth_sign_unauthenticated(bitwise_cast<void*>(ptrInt), ptrauth_key_process_dependent_data, tag));
     331}
     332
     333template<typename PtrType>
     334void assertIsCFunctionPtr(PtrType value)
     335{
     336    void* ptr = bitwise_cast<void*>(value);
     337    WTF_PTRTAG_ASSERT(PtrTagAction::ReleaseAssert, ptr, CFunctionPtrTag, untagCodePtrImpl<PtrTagAction::NoAssert>(ptr, CFunctionPtrTag) == removeCodePtrTag(ptr));
     338}
     339
     340template<typename PtrType>
     341void assertIsNullOrCFunctionPtr(PtrType ptr)
     342{
     343    if (ptr)
     344        assertIsCFunctionPtr(ptr);
     345}
     346
     347template<typename PtrType>
     348void assertIsNotTagged(PtrType value)
     349{
     350    void* ptr = bitwise_cast<void*>(value);
     351    WTF_PTRTAG_ASSERT(PtrTagAction::ReleaseAssert, ptr, NoPtrTag, ptr == removeCodePtrTag(ptr));
     352}
     353
     354template<typename PtrType>
     355void assertIsTagged(PtrType value)
     356{
     357    void* ptr = bitwise_cast<void*>(value);
     358    WTF_PTRTAG_ASSERT(PtrTagAction::ReleaseAssert, ptr, AnyPtrTag, ptr != removeCodePtrTag(ptr));
     359}
     360
     361template<typename PtrType>
     362void assertIsNullOrTagged(PtrType ptr)
     363{
     364    if (ptr)
     365        assertIsTagged(ptr);
     366}
     367
     368template<typename PtrType>
     369bool isTaggedWith(PtrType value, PtrTag tag)
     370{
     371    void* ptr = bitwise_cast<void*>(value);
     372    if (tag == NoPtrTag)
     373        return ptr == removeCodePtrTag(ptr);
     374    return untagCodePtrImpl<PtrTagAction::NoAssert>(ptr, tag) == removeCodePtrTag(ptr);
     375}
     376
     377template<typename PtrType>
     378void assertIsTaggedWith(PtrType value, PtrTag tag)
     379{
     380    WTF_PTRTAG_ASSERT(PtrTagAction::ReleaseAssert, value, tag, isTaggedWith(value, tag));
     381}
     382
     383template<typename PtrType>
     384void assertIsNullOrTaggedWith(PtrType ptr, PtrTag tag)
     385{
     386    if (ptr)
     387        assertIsTaggedWith(ptr, tag);
     388}
     389
     390inline bool usesPointerTagging() { return true; }
     391
     392#else // not CPU(ARM64E)
     393
     394inline void registerPtrTagLookup(PtrTagLookup*) { }
     395inline void reportBadTag(const void*, PtrTag) { }
    83396
    84397template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>>
     
    169482inline bool usesPointerTagging() { return false; }
    170483
    171 #define CALL_WITH_PTRTAG(callInstructionString, targetRegisterString, tag) \
    172     callInstructionString " " targetRegisterString "\n"
    173 
    174 #endif // !USE(POINTER_PROFILING)
     484#endif // CPU(ARM64E)
    175485
    176486} // namespace WTF
     
    178488using WTF::CFunctionPtrTag;
    179489using WTF::NoPtrTag;
     490using WTF::PlatformRegistersLRPtrTag;
     491using WTF::PlatformRegistersPCPtrTag;
    180492using WTF::PtrTag;
    181493
    182 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PtrTagSupport.h>)
    183 #include <WebKitAdditions/PtrTagSupport.h>
    184 #endif
    185 
    186 using WTF::tagForPtr;
     494using WTF::reportBadTag;
    187495
    188496using WTF::tagCodePtr;
Note: See TracChangeset for help on using the changeset viewer.