Changeset 243254 in webkit
- Timestamp:
- Mar 20, 2019 4:32:26 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r243246 r243254 1 2019-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 1 107 2019-03-20 Tadeu Zagallo <tzagallo@apple.com> 2 108 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r242742 r243254 1809 1809 FE1BD0251E72053800134BC9 /* HeapVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1BD0231E72052F00134BC9 /* HeapVerifier.h */; }; 1810 1810 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, ); }; }; 1811 1813 FE20CE9E15F04A9500DF3430 /* LLIntCLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = FE20CE9C15F04A9500DF3430 /* LLIntCLoop.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1812 1814 FE2A87601F02381600EB31B2 /* MinimumReservedZoneSize.h in Headers */ = {isa = PBXBuildFile; fileRef = FE2A875F1F02381600EB31B2 /* MinimumReservedZoneSize.h */; }; … … 4817 4819 FE1C0FFC1B193E9800B53FCA /* Exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Exception.h; sourceTree = "<group>"; }; 4818 4820 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>"; }; 4819 4824 FE20CE9B15F04A9500DF3430 /* LLIntCLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLIntCLoop.cpp; path = llint/LLIntCLoop.cpp; sourceTree = "<group>"; }; 4820 4825 FE20CE9C15F04A9500DF3430 /* LLIntCLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntCLoop.h; path = llint/LLIntCLoop.h; sourceTree = "<group>"; }; … … 6868 6873 14ABB36E099C076400E2A24F /* JSCJSValue.h */, 6869 6874 865A30F0135007E100CDB49E /* JSCJSValueInlines.h */, 6875 FE1E2C3C2240C1EF00F6B729 /* JSCPtrTag.cpp */, 6870 6876 FE7497E5209001B00003565B /* JSCPtrTag.h */, 6871 6877 72AAF7CB1D0D318B005E60BE /* JSCustomGetterSetterFunction.cpp */, … … 7704 7710 AD412B351E7B57C0008AF157 /* AllowMacroScratchRegisterUsageIf.h */, 7705 7711 8640923B156EED3B00566CB2 /* ARM64Assembler.h */, 7712 FE1E2C3D2240D2F600F6B729 /* ARM64EAssembler.h */, 7706 7713 86ADD1430FDDEA980006EEC2 /* ARMv7Assembler.h */, 7707 7714 9688CB130ED12B4E001D649F /* AssemblerBuffer.h */, … … 7717 7724 FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */, 7718 7725 8640923C156EED3B00566CB2 /* MacroAssemblerARM64.h */, 7726 FE1E2C3E2240D30B00F6B729 /* MacroAssemblerARM64E.h */, 7719 7727 A729009B17976C6000317298 /* MacroAssemblerARMv7.cpp */, 7720 7728 86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */, … … 8515 8523 0FEC85011BDACDAC0080FF74 /* B3BasicBlock.h in Headers */, 8516 8524 0FEC85021BDACDAC0080FF74 /* B3BasicBlockInlines.h in Headers */, 8525 FE1E2C3F2240DD5800F6B729 /* MacroAssemblerARM64E.h in Headers */, 8517 8526 0FEC85031BDACDAC0080FF74 /* B3BasicBlockUtils.h in Headers */, 8518 8527 0F338E1C1BF286EA0013C88F /* B3BlockInsertionSet.h in Headers */, … … 8594 8603 0F4570411BE584CA0062A629 /* B3TimingScope.h in Headers */, 8595 8604 0FEC853C1BDACDAC0080FF74 /* B3Type.h in Headers */, 8605 FE1E2C402240DD6200F6B729 /* ARM64EAssembler.h in Headers */, 8596 8606 DCFDFBDA1D1F5D9E00FE3D72 /* B3TypeMap.h in Headers */, 8597 8607 0FEC853E1BDACDAC0080FF74 /* B3UpsilonValue.h in Headers */, -
trunk/Source/JavaScriptCore/Sources.txt
r242699 r243254 803 803 runtime/JSBoundFunction.cpp 804 804 runtime/JSCJSValue.cpp 805 runtime/JSCPtrTag.cpp 805 806 runtime/JSCallee.cpp 806 807 runtime/JSCell.cpp -
trunk/Source/JavaScriptCore/assembler/MacroAssembler.cpp
r234082 r243254 1 1 /* 2 * Copyright (C) 2012-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include <wtf/PrintStream.h> 34 34 #include <wtf/ScopedLambda.h> 35 36 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/MacroAssemblerSupport.h>)37 #include <WebKitAdditions/MacroAssemblerSupport.h>38 #endif39 35 40 36 namespace JSC { -
trunk/Source/JavaScriptCore/assembler/MacroAssembler.h
r240731 r243254 1 1 /* 2 * Copyright (C) 2008-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2008-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 namespace JSC { typedef MacroAssemblerARMv7 MacroAssemblerBase; }; 37 37 38 #elif CPU(ARM64E) && __has_include(<WebKitAdditions/MacroAssemblerARM64E.h>)38 #elif CPU(ARM64E) 39 39 #define TARGET_ASSEMBLER ARM64EAssembler 40 40 #define TARGET_MACROASSEMBLER MacroAssemblerARM64E 41 #include <WebKitAdditions/MacroAssemblerARM64E.h>41 #include "MacroAssemblerARM64E.h" 42 42 43 43 #elif CPU(ARM64) -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.cpp
r237173 r243254 1 1 /* 2 * Copyright (C) 2013-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 382 382 // the caller of the probe (which is what we want in order to play nice with debuggers e.g. lldb). 383 383 "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 385 389 386 390 // Make sure the Probe::State is entirely below the result stack pointer so … … 418 422 419 423 "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 421 429 422 430 LOCAL_LABEL_STRING(ctiMasmProbeTrampolineRestoreRegisters) ":" "\n" -
trunk/Source/JavaScriptCore/dfg/DFGOSRExit.cpp
r243232 r243254 759 759 ASSERT(inlineCallFrame->isTail()); 760 760 void* returnPC = frame.get<void*>(CallFrame::returnPCOffset()); 761 #if USE(POINTER_PROFILING)761 #if CPU(ARM64E) 762 762 void* oldEntrySP = cpu.fp<uint8_t*>() + sizeof(CallerFrameAndPC); 763 763 void* newEntrySP = cpu.fp<uint8_t*>() + inlineCallFrame->returnPCOffset() + sizeof(void*); … … 804 804 805 805 void* targetAddress = jumpTarget.executableAddress(); 806 #if USE(POINTER_PROFILING)806 #if CPU(ARM64E) 807 807 void* newEntrySP = cpu.fp<uint8_t*>() + inlineCallFrame->returnPCOffset() + sizeof(void*); 808 808 targetAddress = retagCodePtr(targetAddress, JSInternalPtrTag, bitwise_cast<PtrTag>(newEntrySP)); -
trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompilerCommon.cpp
r243232 r243254 1 1 /* 2 * Copyright (C) 2013-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 156 156 ASSERT(inlineCallFrame->isTail()); 157 157 jit.loadPtr(AssemblyHelpers::Address(GPRInfo::callFrameRegister, CallFrame::returnPCOffset()), GPRInfo::regT3); 158 #if USE(POINTER_PROFILING)158 #if CPU(ARM64E) 159 159 jit.addPtr(AssemblyHelpers::TrustedImm32(sizeof(CallerFrameAndPC)), GPRInfo::callFrameRegister, GPRInfo::regT2); 160 160 jit.untagPtr(GPRInfo::regT3, GPRInfo::regT2); … … 207 207 } 208 208 209 #if USE(POINTER_PROFILING)209 #if CPU(ARM64E) 210 210 jit.addPtr(AssemblyHelpers::TrustedImm32(inlineCallFrame->returnPCOffset() + sizeof(void*)), GPRInfo::callFrameRegister, GPRInfo::regT2); 211 211 jit.move(AssemblyHelpers::TrustedImmPtr(jumpTarget), GPRInfo::nonArgGPR0); -
trunk/Source/JavaScriptCore/ftl/FTLThunks.cpp
r230748 r243254 1 1 /* 2 * Copyright (C) 2013-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 116 116 restoreAllRegisters(jit, buffer); 117 117 118 #if CPU(ARM64 ) && USE(POINTER_PROFILING)118 #if CPU(ARM64E) 119 119 jit.untagPtr(AssemblyHelpers::linkRegister, resultTag); 120 120 jit.tagReturnAddress(); -
trunk/Source/JavaScriptCore/jit/CCallHelpers.h
r238439 r243254 1 1 /* 2 * Copyright (C) 2011-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2011-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 806 806 loadPtr(Address(framePointerRegister, CallFrame::returnPCOffset()), linkRegister); 807 807 subPtr(TrustedImm32(2 * sizeof(void*)), newFrameSizeGPR); 808 #if USE(POINTER_PROFILING)808 #if CPU(ARM64E) 809 809 addPtr(TrustedImm32(sizeof(CallerFrameAndPC)), MacroAssembler::framePointerRegister, tempGPR); 810 810 untagPtr(linkRegister, tempGPR); -
trunk/Source/JavaScriptCore/jit/CallFrameShuffler.cpp
r239867 r243254 1 1 /* 2 * Copyright (C) 2015-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 455 455 m_jit.loadPtr(MacroAssembler::Address(MacroAssembler::framePointerRegister, CallFrame::returnPCOffset()), 456 456 MacroAssembler::linkRegister); 457 #if USE(POINTER_PROFILING)457 #if CPU(ARM64E) 458 458 m_jit.addPtr(MacroAssembler::TrustedImm32(sizeof(CallerFrameAndPC)), MacroAssembler::framePointerRegister); 459 459 m_jit.untagPtr(MacroAssembler::linkRegister, MacroAssembler::framePointerRegister); -
trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp
r240641 r243254 1 1 /* 2 * Copyright (C) 2008-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2008-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 502 502 } 503 503 504 #if USE(POINTER_PROFILING)504 #if CPU(ARM64E) 505 505 void* start = allocator->memoryStart(); 506 506 void* end = allocator->memoryEnd(); -
trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp
r242252 r243254 457 457 # endif 458 458 jit.tagReturnAddress(); 459 #if CPU(ARM64 ) && USE(POINTER_PROFILING)459 #if CPU(ARM64E) 460 460 jit.loadPtr(JSInterfaceJIT::Address(GPRInfo::callFrameRegister, CallFrame::returnPCOffset()), GPRInfo::regT3); 461 461 jit.addPtr(JSInterfaceJIT::TrustedImm32(sizeof(CallerFrameAndPC)), GPRInfo::callFrameRegister, extraTemp); … … 513 513 done.link(&jit); 514 514 515 #if CPU(ARM64 ) && USE(POINTER_PROFILING)515 #if CPU(ARM64E) 516 516 jit.loadPtr(JSInterfaceJIT::Address(GPRInfo::callFrameRegister, CallFrame::returnPCOffset()), GPRInfo::regT3); 517 517 jit.move(JSInterfaceJIT::TrustedImmPtr(tempReturnPCTag), extraTemp); -
trunk/Source/JavaScriptCore/llint/LLIntOfflineAsmConfig.h
r240832 r243254 148 148 #endif 149 149 150 #if USE(POINTER_PROFILING)151 #define OFFLINE_ASM_POINTER_PROFILING 1152 #else153 #define OFFLINE_ASM_POINTER_PROFILING 0154 #endif155 156 150 #define OFFLINE_ASM_GIGACAGE_ENABLED GIGACAGE_ENABLED -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r243127 r243254 949 949 end 950 950 951 if POINTER_PROFILING951 if ARM64E 952 952 addp 16, cfr, temp3 953 953 untagReturnAddress temp3 -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r242519 r243254 586 586 587 587 .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 593 590 addp 16, cfr, t3 594 591 untagReturnAddress t3 … … 619 616 baddinz 1, t2, .fillLoop 620 617 621 if POINTER_PROFILING618 if ARM64E 622 619 addp 16, cfr, t1 623 620 tagReturnAddress t1 624 625 if ARM64 or ARM64E 626 storep lr, 8[cfr] 627 end 621 storep lr, 8[cfr] 628 622 end 629 623 -
trunk/Source/JavaScriptCore/runtime/ClassInfo.h
r233765 r243254 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2003-201 8Apple Inc. All rights reserved.4 * Copyright (C) 2003-2019 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 27 27 #include "JSCast.h" 28 28 29 #if CPU(ARM64E) 30 #include <ptrauth.h> 31 #endif 32 29 33 namespace WTF { 30 34 class PrintStream; … … 37 41 class Snippet; 38 42 struct 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 39 50 40 51 struct MethodTable { -
trunk/Source/JavaScriptCore/runtime/InitializeThreading.cpp
r242123 r243254 34 34 #include "Heap.h" 35 35 #include "Identifier.h" 36 #include "JSCPtrTag.h" 36 37 #include "JSDateMath.h" 37 38 #include "JSGlobalObject.h" … … 61 62 WTF::initializeThreading(); 62 63 Options::initialize(); 64 65 initializePtrTagLookup(); 63 66 64 67 #if ENABLE(WRITE_BARRIER_PROFILING) -
trunk/Source/JavaScriptCore/runtime/JSCPtrTag.h
r236576 r243254 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 48 48 v(OSREntryPtrTag) \ 49 49 v(OSRExitPtrTag) \ 50 v(PlatformRegistersLRPtrTag) \51 v(PlatformRegistersPCPtrTag) \52 50 v(SlowPathPtrTag) \ 53 51 v(WasmEntryPtrTag) \ … … 69 67 #endif 70 68 69 void initializePtrTagLookup(); 70 71 #if !CPU(ARM64E) 72 inline void initializePtrTagLookup() { } 73 #endif 74 71 75 } // namespace JSC 72 76 -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r242713 r243254 1 1 /* 2 * Copyright (C) 2011-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2011-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 420 420 Options::useJIT() = false; 421 421 #endif 422 423 WTF_SET_POINTER_PREPARATION_OPTIONS();424 422 425 423 if (!Options::useJIT()) -
trunk/Source/WTF/ChangeLog
r243230 r243254 1 2019-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 1 50 2019-03-20 Keith Rollin <krollin@apple.com> 2 51 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r242901 r243254 168 168 E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; }; 169 169 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 */; }; 170 172 FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; }; 171 173 FEEA4DF9216D7BE400AC0602 /* StackPointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEEA4DF8216D7BE400AC0602 /* StackPointer.cpp */; }; … … 677 679 FE05FAE61FDB214300093230 /* DumbPtrTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumbPtrTraits.h; sourceTree = "<group>"; }; 678 680 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>"; }; 679 683 FE7497E4208FFCAA0003565B /* PtrTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PtrTag.h; sourceTree = "<group>"; }; 680 684 FE7497ED209163060003565B /* MetaAllocatorPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaAllocatorPtr.h; sourceTree = "<group>"; }; … … 1064 1068 0F824A651B7443A0002E345D /* ParkingLot.h */, 1065 1069 A876DBD7151816E500DADB95 /* Platform.h */, 1070 FE1E2C41224187C600F6B729 /* PlatformRegisters.cpp */, 1066 1071 E3200AB41E9A536D003B59D2 /* PlatformRegisters.h */, 1067 1072 0FF860941BCCBD740045127F /* PointerComparison.h */, … … 1073 1078 7AF023B42061E16F00A8EFD6 /* ProcessPrivilege.cpp */, 1074 1079 7AF023B32061E16C00A8EFD6 /* ProcessPrivilege.h */, 1080 FE1E2C392240C05400F6B729 /* PtrTag.cpp */, 1075 1081 FE7497E4208FFCAA0003565B /* PtrTag.h */, 1076 1082 143F611D1565F0F900DB514A /* RAMSize.cpp */, … … 1528 1534 0F9D3360165DBA73005AD387 /* FilePrintStream.cpp in Sources */, 1529 1535 A331D95B21F24992009F02AA /* FileSystem.cpp in Sources */, 1536 FE1E2C42224187C600F6B729 /* PlatformRegisters.cpp in Sources */, 1530 1537 A331D95D21F249E4009F02AA /* FileSystemCF.cpp in Sources */, 1531 1538 A331D95F21F249F6009F02AA /* FileSystemCocoa.mm in Sources */, … … 1621 1628 1C181C911D307AB800F5FA16 /* UTextProviderLatin1.cpp in Sources */, 1622 1629 1C181C931D307AB800F5FA16 /* UTextProviderUTF16.cpp in Sources */, 1630 FE1E2C3B2240C06600F6B729 /* PtrTag.cpp in Sources */, 1623 1631 A8A47469151A825B004123FF /* UTF8Conversion.cpp in Sources */, 1624 1632 7AFEC6B11EB22B5900DADE36 /* UUID.cpp in Sources */, -
trunk/Source/WTF/wtf/BlockPtr.h
r239078 r243254 1 1 /* 2 * Copyright (C) 2016-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include <wtf/StdLibExtras.h> 32 32 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 35 38 #else 36 39 #define WTF_COPY_FUNCTION_POINTER_QUALIFIER -
trunk/Source/WTF/wtf/Platform.h
r243230 r243254 1051 1051 #endif 1052 1052 1053 #if !defined(USE_POINTER_PROFILING) || USE(JSVALUE32_64) || !ENABLE(JIT)1054 #undef USE_POINTER_PROFILING1055 #define USE_POINTER_PROFILING 01056 #endif1057 1058 1053 /* CSS Selector JIT Compiler */ 1059 1054 #if !defined(ENABLE_CSS_SELECTOR_JIT) -
trunk/Source/WTF/wtf/PlatformRegisters.h
r218080 r243254 1 1 /* 2 2 * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com> 3 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 92 93 } // namespace WTF 93 94 95 #if USE(PLATFORM_REGISTERS_WITH_PROFILE) 96 #if CPU(ARM64E) 97 98 namespace WTF { 99 100 extern void* threadStateLRInternal(PlatformRegisters&); 101 extern void* threadStatePCInternal(PlatformRegisters&); 102 103 } // namespace WTF 104 105 using WTF::threadStateLRInternal; 106 using 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 94 162 using WTF::PlatformRegisters; -
trunk/Source/WTF/wtf/PointerPreparations.h
r230455 r243254 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PointerPreparations.h>) 29 #include <WebKitAdditions/PointerPreparations.h> 30 #endif 28 namespace WTF { 31 29 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 33 38 #define WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(vtblPtr) (reinterpret_cast<void*>(vtblPtr)) 34 #endif35 39 36 #ifndef WTF_SET_POINTER_PREPARATION_OPTIONS 37 #define WTF_SET_POINTER_PREPARATION_OPTIONS() do { } while (false) 38 #endif 40 #endif // not CPU(ARM64E) 39 41 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 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include <wtf/PointerPreparations.h> 28 #include <wtf/Assertions.h> 29 #include <wtf/DataLog.h> 29 30 30 31 namespace WTF { … … 37 38 v(FreeSpacePtrTag) \ 38 39 v(HandleMemoryPtrTag) \ 40 v(PlatformRegistersLRPtrTag) \ 41 v(PlatformRegistersPCPtrTag) \ 39 42 40 43 #define FOR_EACH_WTF_PTRTAG(v) \ … … 47 50 }; 48 51 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 50 57 template<size_t N> 51 58 constexpr uintptr_t makePtrTagHash(const char (&str)[N]) … … 58 65 59 66 #define WTF_PTRTAG_HASH(tag) WTF::makePtrTagHash(#tag) 60 #endif 67 #endif // not CPU(ARM64E) 61 68 62 69 #define WTF_DECLARE_PTRTAG(tag) \ … … 78 85 #endif 79 86 80 #if !USE(POINTER_PROFILING) 81 82 inline const char* tagForPtr(const void*) { return "<no tag>"; } 87 struct PtrTagLookup { 88 const char* (*tagForPtr)(const void*); 89 const char* (*ptrTagName)(PtrTag); 90 PtrTagLookup* next { nullptr }; 91 }; 92 93 #if CPU(ARM64E) 94 95 enum class PtrTagAction { 96 ReleaseAssert, 97 DebugAssert, 98 NoAssert, 99 }; 100 101 constexpr PtrTag AnyPtrTag = static_cast<PtrTag>(-1); // Only used for assertion messages. 102 103 WTF_EXPORT_PRIVATE void registerPtrTagLookup(PtrTagLookup*); 104 WTF_EXPORT_PRIVATE void reportBadTag(const void*, PtrTag expectedTag); 105 106 #if ASSERT_DISABLED 107 constexpr bool enablePtrTagDebugAssert = false; 108 #else 109 constexpr 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 124 template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>> 125 inline constexpr T removeCodePtrTag(PtrType ptr) 126 { 127 return bitwise_cast<T>(ptrauth_strip(ptr, ptrauth_key_process_dependent_code)); 128 } 129 130 template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 131 inline constexpr PtrType removeCodePtrTag(PtrType ptr) 132 { 133 return ptrauth_strip(ptr, ptrauth_key_process_dependent_code); 134 } 135 136 template<PtrTagAction tagAction, typename PtrType> 137 inline 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 149 template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>> 150 inline T tagCodePtr(PtrType ptr, PtrTag tag) 151 { 152 return bitwise_cast<T>(tagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, tag)); 153 } 154 155 template<typename T, PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 156 inline T tagCodePtr(PtrType ptr) 157 { 158 return bitwise_cast<T>(tagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, tag)); 159 } 160 161 template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 162 inline PtrType tagCodePtr(PtrType ptr, PtrTag tag) 163 { 164 return tagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, tag); 165 } 166 167 template<PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 168 inline PtrType tagCodePtr(PtrType ptr) { return tagCodePtr(ptr, tag); } 169 170 template<typename PtrType> 171 inline 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 180 template<PtrTagAction tagAction, typename PtrType> 181 inline 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 190 template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>> 191 inline T untagCodePtr(PtrType ptr, PtrTag tag) 192 { 193 return bitwise_cast<T>(untagCodePtrImpl<PtrTagAction::ReleaseAssert>(ptr, tag)); 194 } 195 196 template<typename T, PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 197 inline T untagCodePtr(PtrType ptr) 198 { 199 return bitwise_cast<T>(untagCodePtrImpl<PtrTagAction::ReleaseAssert>(ptr, tag)); 200 } 201 202 template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 203 inline PtrType untagCodePtr(PtrType ptr, PtrTag tag) 204 { 205 return untagCodePtrImpl<PtrTagAction::ReleaseAssert>(ptr, tag); 206 } 207 208 template<PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 209 inline PtrType untagCodePtr(PtrType ptr) { return untagCodePtr(ptr, tag); } 210 211 template<PtrTagAction tagAction, typename PtrType> 212 inline 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 227 template<PtrTagAction tagAction, typename PtrType> 228 inline 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 239 template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>> 240 inline T retagCodePtr(PtrType ptr, PtrTag oldTag, PtrTag newTag) 241 { 242 return bitwise_cast<T>(retagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, oldTag, newTag)); 243 } 244 245 template<typename T, PtrTag oldTag, PtrTag newTag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 246 inline T retagCodePtr(PtrType ptr) 247 { 248 return bitwise_cast<T>(retagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, oldTag, newTag)); 249 } 250 251 template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 252 inline PtrType retagCodePtr(PtrType ptr, PtrTag oldTag, PtrTag newTag) 253 { 254 return retagCodePtrImpl<PtrTagAction::DebugAssert>(ptr, oldTag, newTag); 255 } 256 257 template<PtrTag oldTag, PtrTag newTag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 258 inline PtrType retagCodePtr(PtrType ptr) { return retagCodePtr(ptr, oldTag, newTag); } 259 260 template<PtrTagAction tagAction, typename PtrType> 261 inline 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 269 template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>> 270 inline T tagCFunctionPtr(PtrType ptr, PtrTag tag) 271 { 272 return bitwise_cast<T>(tagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag)); 273 } 274 275 template<typename T, PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 276 inline T tagCFunctionPtr(PtrType ptr) 277 { 278 return bitwise_cast<T>(tagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag)); 279 } 280 281 template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 282 inline PtrType tagCFunctionPtr(PtrType ptr, PtrTag tag) 283 { 284 return tagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag); 285 } 286 287 template<PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 288 inline PtrType tagCFunctionPtr(PtrType ptr) { return tagCFunctionPtr(ptr, tag); } 289 290 template<PtrTagAction tagAction, typename PtrType> 291 inline 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 299 template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>> 300 inline T untagCFunctionPtr(PtrType ptr, PtrTag tag) 301 { 302 return bitwise_cast<T>(untagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag)); 303 } 304 305 template<typename T, PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 306 inline T untagCFunctionPtr(PtrType ptr) 307 { 308 return bitwise_cast<T>(untagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag)); 309 } 310 311 template<typename T, PtrTag tag, PtrTagAction tagAction, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 312 inline T untagCFunctionPtr(PtrType ptr) 313 { 314 return bitwise_cast<T>(untagCFunctionPtrImpl<tagAction>(ptr, tag)); 315 } 316 317 template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 318 inline PtrType untagCFunctionPtr(PtrType ptr, PtrTag tag) 319 { 320 return untagCFunctionPtrImpl<PtrTagAction::DebugAssert>(ptr, tag); 321 } 322 323 template<PtrTag tag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>> 324 inline PtrType untagCFunctionPtr(PtrType ptr) { return untagCFunctionPtr(ptr, tag); } 325 326 template <typename IntType> 327 inline 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 333 template<typename PtrType> 334 void 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 340 template<typename PtrType> 341 void assertIsNullOrCFunctionPtr(PtrType ptr) 342 { 343 if (ptr) 344 assertIsCFunctionPtr(ptr); 345 } 346 347 template<typename PtrType> 348 void assertIsNotTagged(PtrType value) 349 { 350 void* ptr = bitwise_cast<void*>(value); 351 WTF_PTRTAG_ASSERT(PtrTagAction::ReleaseAssert, ptr, NoPtrTag, ptr == removeCodePtrTag(ptr)); 352 } 353 354 template<typename PtrType> 355 void assertIsTagged(PtrType value) 356 { 357 void* ptr = bitwise_cast<void*>(value); 358 WTF_PTRTAG_ASSERT(PtrTagAction::ReleaseAssert, ptr, AnyPtrTag, ptr != removeCodePtrTag(ptr)); 359 } 360 361 template<typename PtrType> 362 void assertIsNullOrTagged(PtrType ptr) 363 { 364 if (ptr) 365 assertIsTagged(ptr); 366 } 367 368 template<typename PtrType> 369 bool 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 377 template<typename PtrType> 378 void assertIsTaggedWith(PtrType value, PtrTag tag) 379 { 380 WTF_PTRTAG_ASSERT(PtrTagAction::ReleaseAssert, value, tag, isTaggedWith(value, tag)); 381 } 382 383 template<typename PtrType> 384 void assertIsNullOrTaggedWith(PtrType ptr, PtrTag tag) 385 { 386 if (ptr) 387 assertIsTaggedWith(ptr, tag); 388 } 389 390 inline bool usesPointerTagging() { return true; } 391 392 #else // not CPU(ARM64E) 393 394 inline void registerPtrTagLookup(PtrTagLookup*) { } 395 inline void reportBadTag(const void*, PtrTag) { } 83 396 84 397 template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>> … … 169 482 inline bool usesPointerTagging() { return false; } 170 483 171 #define CALL_WITH_PTRTAG(callInstructionString, targetRegisterString, tag) \ 172 callInstructionString " " targetRegisterString "\n" 173 174 #endif // !USE(POINTER_PROFILING) 484 #endif // CPU(ARM64E) 175 485 176 486 } // namespace WTF … … 178 488 using WTF::CFunctionPtrTag; 179 489 using WTF::NoPtrTag; 490 using WTF::PlatformRegistersLRPtrTag; 491 using WTF::PlatformRegistersPCPtrTag; 180 492 using WTF::PtrTag; 181 493 182 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PtrTagSupport.h>) 183 #include <WebKitAdditions/PtrTagSupport.h> 184 #endif 185 186 using WTF::tagForPtr; 494 using WTF::reportBadTag; 187 495 188 496 using WTF::tagCodePtr;
Note: See TracChangeset
for help on using the changeset viewer.