Changeset 294287 in webkit
- Timestamp:
- May 16, 2022, 10:21:53 PM (3 years ago)
- Location:
- trunk/Source
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r294284 r294287 1 2022-05-16 Mark Lam <mark.lam@apple.com> 2 3 Add ARM64 disassembler support for symbolic dumping of some well known constants. 4 https://bugs.webkit.org/show_bug.cgi?id=240443 5 6 Reviewed by Yusuke Suzuki. 7 8 1. Added a Options::needDisassemblySupport() option. This option is true if 9 any of the JSC disassembly options are enabled. This allows us to trivially 10 check if we need to enable additional infrastructure (like those added in this 11 patch) to support disassembly. 12 13 2. Refactor the Disassembler's thunkLabelMap into a more generic labelMap. It 14 can now map a pointer to a CString or a const char* label. 15 16 3. Enable JITOperationList infrastructure when ENABLE(JIT_OPERATION_DISASSEMBLY) 17 is true. This adds a name to the JITOperationAnnotation record. Since this is 18 guarded by ENABLE(JIT_OPERATION_DISASSEMBLY), we can trivially turn this part 19 off later if adding this name adds too much size burden (or if any unexpected 20 issues arise). Turning this off will only disable disassembly of JIT operation 21 names. Disassembly of other constants (see below) will still be supported. 22 23 If Options::needDisassemblySupport() is true, the JITOperationList will 24 register all JIT operations (and the LLInt ones as well) with the Disassembler 25 labelMap. 26 27 4. Removed the < > brackets around branch target labels except for internal pc 28 index labels (e.g. <716>) and <unknown> (when we don't know what the branch 29 target is). The < > notation takes up space and doesn't add any info. The 30 branch targets now look like this: 31 32 <32> 0x1180102c0: b.ne 0x1180101c0 -> thunk: native Tail With Saved Tags Call trampoline 33 <92> 0x11801c87c: b 0x118008980 -> thunk: LLInt function for call jump to prologue thunk 34 <3508> 0x1198e16b4: b 0x1198bc1a0 -> JIT PC 35 36 Internal pc index labels will still use the < > brackets: 37 38 <3476> 0x1198e1694: b.eq 0x1198e16a0 -> <3488> 39 40 5. Added ARM64 disassembler support to compute the value of a constant being 41 loaded into a register using "MoveWide" instructions e.g. movz and movk. 42 43 When the disassembler sees a movz or movn or mov (of the MoveWide variety), 44 the disassembler initializes a m_builtConstant value. With each subsequent 45 movk instruction with the same destination register, the disassembler splices 46 in the corresponding 16-bit immediate. 47 48 After disassembling a MoveWide instruction, it will check if the next 49 instruction is also a MoveWide instruction targeting the same destination 50 register. If so, the constant is still being build: hence, it does nothing and 51 continues. 52 53 If the next instruction is (a) a MoveWide instruction targeting a different 54 register, (b) not a MoveWide instruction, or (c) we've reached the end of the 55 LinkBuffer (i.e. there's no next instruction), then the constant building for 56 the current target register is complete. 57 58 6. Added ARM64 disassembler support for looking up constants (built in (5) above) 59 and printing symbolic info / names of those constants. 60 61 With ENABLE(JIT_OPERATION_DISASSEMBLY), we now have JIT operation names e.g. 62 63 <176> 0x118010270: movk x3, #0x9f6e, lsl #48 -> 0x102dc8950 operationVMHandleException 64 <164> 0x1180180a4: movk x8, #0xe5c, lsl #48 -> 0x102db9420 operationVirtualCall 65 66 Apart from looking up the constant in the Disassembler labelMap, it also looks 67 up some commonly used constants e.g. 68 69 a. VM pointers: 70 71 <156> 0x11801105c: movk x0, #0x1, lsl #32 -> 0x139435000 vm 72 73 b. Some VM internal pointers (more can be added later as needed): 74 75 <24> 0x118014d18: movk x17, #0x1, lsl #32 -> 0x13943ee78 vm +40568: vm.topCallFrame 76 <76> 0x118014d4c: movk x17, #0x1, lsl #32 -> 0x139441a10 vm +51728: vm.m_exception 77 <196> 0x118011244: movk x17, #0x1, lsl #32 -> 0x1394417d0 vm +51152: vm.targetMachinePCForThrow 78 <208> 0x1198e09d0: movk x17, #0x1, lsl #32 -> 0x104432cc0 vm +52416: vm.m_doesGC 79 80 c. VM related pointers (only 1 for now; not VM fields, but hangs off of VM): 81 82 <12> 0x11801938c: movk x1, #0x1, lsl #32 -> 0x1052cd3c8 vm scratchBuffer.m_buffer 83 84 d. Well known PtrTags: 85 86 <204> 0x11801124c: movz x16, #0x6f9b -> 0x6f9b ExceptionHandlerPtrTag ? 87 <212> 0x1180150d4: movz x16, #0x593 -> 0x593 JSEntryPtrTag ? 88 <168> 0x1180183a8: movz lr, #0xb389 -> 0xb389 OperationPtrTag ? 89 90 * the ? is because we cannot be certain that the 16-bit constant is a PtrTag. 91 It may just be a coincidence that the value is the same. However, the user 92 can trivially look at the surrounding disassembled code, and be able to 93 tell if the value is used as a PtrTag. 94 95 For constants that are not found in the known sets: 96 97 e. Small 16-bit constant (prints decimal value for convenience): 98 99 <200> 0x1198e09c8: movz x17, #0x2cc0 -> 11456 100 101 f. Unknown pointers that aren't in the JIT and LLINT regions will simply print 102 the pointer / constant: 103 104 <88> 0x1198e0958: movz x17, #0x2088 105 <92> 0x1198e095c: movk x17, #0x30d, lsl #16 106 <96> 0x1198e0960: movk x17, #0x1, lsl #32 -> 0x1030d2088 107 108 <unknown> is only used in relative branches. 109 110 7. Enhanced the Integrity::isSanePointer() check to reject pointer values that 111 are less than 4G on CPU(ADDRESS64) targets for OS(DARWIN). No sane pointer 112 should be in the lowest 4G address region. 113 114 This also helps the disassembler more quickly filter out constant values that 115 aren't pointers. 116 117 This change affects DFG's speculationFromCell(), which is the only place that 118 may affect user facing performance. However, I think the impact should be 119 insignificant (since the added check is cheap). 120 121 * assembler/JITOperationList.cpp: 122 (JSC::JITOperationList::populatePointersInJavaScriptCore): 123 (JSC::llintOperations): 124 (JSC::JITOperationList::populatePointersInJavaScriptCoreForLLInt): 125 (JSC::JITOperationList::addDisassemblyLabels): 126 (JSC::JITOperationList::populateDisassemblyLabelsInJavaScriptCore): 127 (JSC::JITOperationList::populateDisassemblyLabelsInJavaScriptCoreForLLInt): 128 (JSC::JITOperationList::populateDisassemblyLabelsInEmbedder): 129 * assembler/JITOperationList.h: 130 (JSC::JITOperationList::populatePointersInJavaScriptCore): 131 (JSC::JITOperationList::populatePointersInJavaScriptCoreForLLInt): 132 * assembler/JITOperationValidation.h: 133 * assembler/LinkBuffer.cpp: 134 (JSC::LinkBuffer::finalizeCodeWithDisassemblyImpl): 135 * b3/testb3_1.cpp: 136 (main): 137 * disassembler/ARM64/A64DOpcode.cpp: 138 (JSC::ARM64Disassembler::A64DOpcode::appendPCRelativeOffset): 139 (JSC::ARM64Disassembler::MoveWideFormatTrait::rejectedResult): 140 (JSC::ARM64Disassembler::MoveWideFormatTrait::acceptedResult): 141 (JSC::ARM64Disassembler::MoveWideIsValidTrait::rejectedResult): 142 (JSC::ARM64Disassembler::MoveWideIsValidTrait::acceptedResult): 143 (JSC::ARM64Disassembler::A64DOpcodeMoveWide::handlePotentialDataPointer): 144 (JSC::ARM64Disassembler::A64DOpcodeMoveWide::handlePotentialPtrTag): 145 (JSC::ARM64Disassembler::A64DOpcodeMoveWide::parse): 146 (JSC::ARM64Disassembler::A64DOpcodeMoveWide::format): 147 (JSC::ARM64Disassembler::A64DOpcodeMoveWide::isValid): 148 * disassembler/ARM64/A64DOpcode.h: 149 (JSC::ARM64Disassembler::A64DOpcodeMoveWide::baseFormat): 150 (JSC::ARM64Disassembler::A64DOpcodeMoveWide::formatBuffer): 151 * disassembler/Disassembler.cpp: 152 (JSC::Disassembler::ensureLabelMap): 153 (JSC::registerLabel): 154 (JSC::labelFor): 155 (JSC::ensureThunkLabelMap): Deleted. 156 (JSC::registerThunkLabel): Deleted. 157 (JSC::labelForThunk): Deleted. 158 * disassembler/Disassembler.h: 159 * jsc.cpp: 160 (jscmain): 161 * runtime/Gate.h: 162 * runtime/JSCPtrTag.cpp: 163 (JSC::ptrTagName): 164 * runtime/JSCPtrTag.h: 165 * runtime/Options.cpp: 166 (JSC::Options::recomputeDependentOptions): 167 * runtime/OptionsList.h: 168 * runtime/VM.cpp: 169 (JSC::VM::isScratchBuffer): 170 * runtime/VM.h: 171 * tools/Integrity.h: 172 (JSC::Integrity::isSanePointer): 173 1 174 2022-05-16 Saam Barati <sbarati@apple.com> 2 175 -
trunk/Source/JavaScriptCore/assembler/JITOperationList.cpp
r290873 r294287 1 1 /* 2 * Copyright (C) 2020-202 1Apple Inc. All rights reserved.2 * Copyright (C) 2020-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #include "JITOperationList.h" 28 28 29 #include "Disassembler.h" 29 30 #include "Gate.h" 30 31 #include "JITOperationValidation.h" 31 32 #include "LLIntData.h" 32 33 #include "Opcode.h" 34 #include "Options.h" 33 35 34 36 namespace JSC { 35 37 36 #if ENABLE(JIT_OPERATION_VALIDATION) 38 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 37 39 38 40 LazyNeverDestroyed<JITOperationList> jitOperationList; … … 45 47 jitOperationList.construct(); 46 48 } 49 50 #if ENABLE(JIT_OPERATION_VALIDATION) 47 51 48 52 #if JIT_OPERATION_VALIDATION_ASSERT_ENABLED … … 86 90 if (Options::useJIT()) 87 91 jitOperationList->addPointers(&startOfJITOperationsInJSC, &endOfJITOperationsInJSC); 88 }); 89 } 92 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 93 if (UNLIKELY(Options::needDisassemblySupport())) 94 populateDisassemblyLabelsInJavaScriptCore(); 95 #endif 96 }); 97 } 98 99 #endif // ENABLE(JIT_OPERATION_VALIDATION) 90 100 91 101 LLINT_DECLARE_ROUTINE_VALIDATE(llint_function_for_call_prologue); … … 105 115 LLINT_DECLARE_ROUTINE_VALIDATE(fuzzer_return_early_from_loop_hint); 106 116 107 void JITOperationList::populatePointersInJavaScriptCoreForLLInt() 108 { 109 static std::once_flag onceKey; 110 std::call_once(onceKey, [] { 117 #if ENABLE(JIT_OPERATION_VALIDATION) && ENABLE(JIT_OPERATION_DISASSEMBLY) 118 #define LLINT_OP_EXTRAS(validateLabel, nameStr) bitwise_cast<void*>(validateLabel), nameStr 119 #elif ENABLE(JIT_OPERATION_VALIDATION) 120 #define LLINT_OP_EXTRAS(validateLabel, nameStr) bitwise_cast<void*>(validateLabel) 121 #else // ENABLE(JIT_OPERATION_DISASSEMBLY) 122 #define LLINT_OP_EXTRAS(validateLabel, nameStr) nameStr 123 #endif 111 124 112 125 #define LLINT_ROUTINE(functionName) { \ 113 126 bitwise_cast<void*>(LLInt::getCodeFunctionPtr<CFunctionPtrTag>(functionName)), \ 114 bitwise_cast<void*>(LLINT_ROUTINE_VALIDATE(functionName)) \127 LLINT_OP_EXTRAS(LLINT_ROUTINE_VALIDATE(functionName), #functionName) \ 115 128 }, 116 129 117 130 #define LLINT_OP(name) { \ 118 131 bitwise_cast<void*>(LLInt::getCodeFunctionPtr<CFunctionPtrTag>(name)), \ 119 bitwise_cast<void*>(LLINT_RETURN_VALIDATE(name)) \132 LLINT_OP_EXTRAS(LLINT_RETURN_VALIDATE(name), #name) \ 120 133 }, { \ 121 134 bitwise_cast<void*>(LLInt::getWide16CodeFunctionPtr<CFunctionPtrTag>(name)), \ 122 bitwise_cast<void*>(LLINT_RETURN_WIDE16_VALIDATE(name)) \135 LLINT_OP_EXTRAS(LLINT_RETURN_WIDE16_VALIDATE(name), #name " [wide16]") \ 123 136 }, { \ 124 137 bitwise_cast<void*>(LLInt::getWide32CodeFunctionPtr<CFunctionPtrTag>(name)), \ 125 bitwise_cast<void*>(LLINT_RETURN_WIDE32_VALIDATE(name)) \138 LLINT_OP_EXTRAS(LLINT_RETURN_WIDE32_VALIDATE(name), #name " [wide32]") \ 126 139 }, 127 140 … … 129 142 LLINT_OP(name##_return_location) 130 143 131 const JITOperationAnnotation operations[] = { 144 struct LLIntOperations { 145 const JITOperationAnnotation* operations; 146 size_t numberOfOperations; 147 }; 148 149 static LLIntOperations llintOperations() 150 { 151 static const JITOperationAnnotation* operations = nullptr; 152 static size_t numberOfOperations = 0; 153 static std::once_flag onceKey; 154 std::call_once(onceKey, [&] { 155 static const JITOperationAnnotation operationsStorage[] = { 132 156 LLINT_ROUTINE(llint_function_for_call_prologue) 133 157 LLINT_ROUTINE(llint_function_for_construct_prologue) … … 161 185 JSC_WASM_GATE_OPCODES(LLINT_RETURN_LOCATION) 162 186 }; 163 if (Options::useJIT()) 164 jitOperationList->addPointers(operations, operations + WTF_ARRAY_LENGTH(operations)); 187 operations = operationsStorage; 188 numberOfOperations = WTF_ARRAY_LENGTH(operationsStorage); 189 }); 190 return { operations, numberOfOperations }; 191 } 192 165 193 #undef LLINT_ROUTINE 166 194 #undef LLINT_OP 167 195 #undef LLINT_RETURN_LOCATION 168 }); 169 } 170 196 #undef LLINT_OP_EXTRAS 197 198 #if ENABLE(JIT_OPERATION_VALIDATION) 199 200 void JITOperationList::populatePointersInJavaScriptCoreForLLInt() 201 { 202 static std::once_flag onceKey; 203 std::call_once(onceKey, [] { 204 if (Options::useJIT()) { 205 auto list = llintOperations(); 206 jitOperationList->addPointers(list.operations, list.operations + list.numberOfOperations); 207 } 208 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 209 if (UNLIKELY(Options::needDisassemblySupport())) 210 JITOperationList::populateDisassemblyLabelsInJavaScriptCoreForLLInt(); 211 #endif 212 }); 213 } 171 214 172 215 void JITOperationList::populatePointersInEmbedder(const JITOperationAnnotation* beginOperations, const JITOperationAnnotation* endOperations) … … 178 221 #endif // ENABLE(JIT_OPERATION_VALIDATION) 179 222 223 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 224 225 SUPPRESS_ASAN void JITOperationList::addDisassemblyLabels(const JITOperationAnnotation* begin, const JITOperationAnnotation* end) 226 { 227 RELEASE_ASSERT(Options::needDisassemblySupport()); 228 for (const auto* current = begin; current != end; ++current) { 229 #if ENABLE(JIT_OPERATION_VALIDATION) 230 auto* operation = current->operationWithValidation; 231 #else 232 auto* operation = current->operation; 233 #endif 234 registerLabel(removeCodePtrTag(operation), current->name); 235 } 236 } 237 238 void JITOperationList::populateDisassemblyLabelsInJavaScriptCore() 239 { 240 ASSERT(Options::needDisassemblySupport()); 241 static std::once_flag onceKey; 242 std::call_once(onceKey, [] { 243 if (Options::useJIT()) 244 addDisassemblyLabels(&startOfJITOperationsInJSC, &endOfJITOperationsInJSC); 245 }); 246 } 247 248 void JITOperationList::populateDisassemblyLabelsInJavaScriptCoreForLLInt() 249 { 250 ASSERT(Options::needDisassemblySupport()); 251 static std::once_flag onceKey; 252 std::call_once(onceKey, [] { 253 if (Options::useJIT()) { 254 auto list = llintOperations(); 255 addDisassemblyLabels(list.operations, list.operations + list.numberOfOperations); 256 } 257 }); 258 } 259 260 void JITOperationList::populateDisassemblyLabelsInEmbedder(const JITOperationAnnotation* beginOperations, const JITOperationAnnotation* endOperations) 261 { 262 if (LIKELY(!Options::needDisassemblySupport())) 263 return; 264 if (Options::useJIT()) 265 addDisassemblyLabels(beginOperations, endOperations); 266 } 267 268 #endif // ENABLE(JIT_OPERATION_DISASSEMBLY) 269 270 #endif // ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 271 180 272 } // namespace JSC -
trunk/Source/JavaScriptCore/assembler/JITOperationList.h
r281910 r294287 1 1 /* 2 * Copyright (C) 2020-202 1Apple Inc. All rights reserved.2 * Copyright (C) 2020-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 namespace JSC { 34 34 35 #if ENABLE(JIT_OPERATION_VALIDATION) 35 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 36 36 37 37 // This indirection is provided so that we can manually force on assertions for … … 46 46 static void initialize(); 47 47 48 #if ENABLE(JIT_OPERATION_VALIDATION) 48 49 template<typename PtrType> 49 50 void* map(PtrType pointer) const … … 59 60 } 60 61 #endif 62 #endif // ENABLE(JIT_OPERATION_VALIDATION) 61 63 62 64 static void populatePointersInJavaScriptCore(); … … 64 66 65 67 JS_EXPORT_PRIVATE static void populatePointersInEmbedder(const JITOperationAnnotation* beginOperations, const JITOperationAnnotation* endOperations); 68 69 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 70 JS_EXPORT_PRIVATE static void populateDisassemblyLabelsInEmbedder(const JITOperationAnnotation* beginOperations, const JITOperationAnnotation* endOperations); 71 #endif 66 72 67 73 template<typename T> static void assertIsJITOperation(T function) … … 82 88 83 89 private: 90 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 91 static void populateDisassemblyLabelsInJavaScriptCore(); 92 static void populateDisassemblyLabelsInJavaScriptCoreForLLInt(); 93 static void addDisassemblyLabels(const JITOperationAnnotation* begin, const JITOperationAnnotation* end); 94 #endif 95 96 #if ENABLE(JIT_OPERATION_VALIDATION) 84 97 ALWAYS_INLINE void addPointers(const JITOperationAnnotation* begin, const JITOperationAnnotation* end); 85 98 … … 92 105 HashMap<void*, void*> m_validatedOperationsInverseMap; 93 106 #endif 107 #endif // ENABLE(JIT_OPERATION_VALIDATION) 94 108 }; 109 110 #if ENABLE(JIT_OPERATION_VALIDATION) 95 111 96 112 JS_EXPORT_PRIVATE extern LazyNeverDestroyed<JITOperationList> jitOperationList; … … 102 118 103 119 #else // not ENABLE(JIT_OPERATION_VALIDATION) 120 121 ALWAYS_INLINE void JITOperationList::populatePointersInJavaScriptCore() 122 { 123 if (UNLIKELY(Options::needDisassemblySupport())) 124 populateDisassemblyLabelsInJavaScriptCore(); 125 } 126 127 ALWAYS_INLINE void JITOperationList::populatePointersInJavaScriptCoreForLLInt() 128 { 129 if (UNLIKELY(Options::needDisassemblySupport())) 130 populateDisassemblyLabelsInJavaScriptCoreForLLInt(); 131 } 132 133 #endif // ENABLE(JIT_OPERATION_VALIDATION) 134 135 #else // not ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 104 136 105 137 class JITOperationList { … … 114 146 }; 115 147 116 #endif // ENABLE(JIT_OPERATION_VALIDATION) 148 #endif // ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 117 149 118 150 } // namespace JSC -
trunk/Source/JavaScriptCore/assembler/JITOperationValidation.h
r281910 r294287 1 1 /* 2 * Copyright (C) 2021 Apple Inc. All rights reserved.2 * Copyright (C) 2021-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 48 48 namespace JSC { 49 49 50 #if ENABLE(JIT_OPERATION_VALIDATION)51 52 50 struct JITOperationAnnotation { 53 51 void* operation; 52 #if ENABLE(JIT_OPERATION_VALIDATION) 54 53 void* operationWithValidation; 54 #endif 55 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 56 const char* name; 57 #endif 55 58 }; 59 60 #if ENABLE(JIT_OPERATION_VALIDATION) 56 61 57 62 #ifndef JSC_DECLARE_JIT_OPERATION_VALIDATION -
trunk/Source/JavaScriptCore/assembler/LinkBuffer.cpp
r294180 r294287 83 83 va_end(preflightArgs); 84 84 85 const char prefix[] = "thunk: "; 85 86 char* buffer = 0; 86 CString label = CString::newUninitialized(stringLength + 1, buffer); 87 vsnprintf(buffer, stringLength + 1, format, argList); 88 buffer[stringLength] = '\0'; 87 size_t length = stringLength + sizeof(prefix); 88 CString label = CString::newUninitialized(length, buffer); 89 snprintf(buffer, length, "%s", prefix); 90 vsnprintf(buffer + sizeof(prefix) - 1, stringLength + 1, format, argList); 89 91 out.printf("%s", buffer); 90 92 91 register ThunkLabel(result.code().untaggedExecutableAddress(), WTFMove(label));93 registerLabel(result.code().untaggedExecutableAddress(), WTFMove(label)); 92 94 } else 93 95 out.vprintf(format, argList); -
trunk/Source/JavaScriptCore/b3/testb3_1.cpp
r292475 r294287 1 1 /* 2 * Copyright (C) 2015-202 1Apple Inc. All rights reserved.2 * Copyright (C) 2015-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 904 904 #endif // ENABLE(B3_JIT) 905 905 906 #if ENABLE(JIT_OPERATION_VALIDATION) 906 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 907 907 extern const JSC::JITOperationAnnotation startOfJITOperationsInTestB3 __asm("section$start$__DATA_CONST$__jsc_ops"); 908 908 extern const JSC::JITOperationAnnotation endOfJITOperationsInTestB3 __asm("section$end$__DATA_CONST$__jsc_ops"); … … 931 931 JSC::JITOperationList::populatePointersInEmbedder(&startOfJITOperationsInTestB3, &endOfJITOperationsInTestB3); 932 932 #endif 933 933 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 934 if (UNLIKELY(JSC::Options::needDisassemblySupport())) 935 JSC::JITOperationList::populateDisassemblyLabelsInEmbedder(&startOfJITOperationsInTestB3, &endOfJITOperationsInTestB3); 936 #endif 937 934 938 for (unsigned i = 0; i <= 2; ++i) { 935 939 JSC::Options::defaultB3OptLevel() = i; -
trunk/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.cpp
r294180 r294287 33 33 #include "ExecutableAllocator.h" 34 34 #include "GPRInfo.h" 35 #include "Integrity.h" 36 #include "JSCJSValue.h" 35 37 #include "LLIntPCRanges.h" 38 #include "PureNaN.h" 39 #include "VMInspector.h" 36 40 #include <stdarg.h> 37 41 #include <stdint.h> 38 42 #include <stdio.h> 43 #include <wtf/PtrTag.h> 44 #include <wtf/Range.h> 39 45 40 46 namespace JSC { namespace ARM64Disassembler { … … 202 208 else if (targetPC >= m_startPC && targetPC < m_endPC) 203 209 snprintf(buffer, bufferSize - 1, " -> <%u>", static_cast<unsigned>((targetPC - m_startPC) * sizeof(uint32_t))); 204 else if (const char* thunkLabel = labelForThunk(targetPC))205 snprintf(buffer, bufferSize - 1, " -> <thunk: %s>", thunkLabel);210 else if (const char* label = labelFor(targetPC)) 211 snprintf(buffer, bufferSize - 1, " -> %s", label); 206 212 else if (isJITPC(targetPC)) 207 targetInfo = " -> <JIT PC>";213 targetInfo = " -> JIT PC"; 208 214 else if (LLInt::isLLIntPC(targetPC)) 209 targetInfo = " -> <LLInt PC>";215 targetInfo = " -> LLInt PC"; 210 216 else 211 217 targetInfo = " -> <unknown>"; … … 1571 1577 const char* const A64DOpcodeMoveWide::s_opNames[4] = { "movn", 0, "movz", "movk" }; 1572 1578 1573 const char* A64DOpcodeMoveWide::format() 1579 class MoveWideFormatTrait { 1580 public: 1581 using ResultType = const char*; 1582 static constexpr bool returnEarlyIfAccepted = false; 1583 1584 ALWAYS_INLINE static const char* rejectedResult(A64DOpcodeMoveWide* opcode) { return opcode->baseFormat(); } 1585 ALWAYS_INLINE static const char* acceptedResult(A64DOpcodeMoveWide* opcode) { return opcode->formatBuffer(); } 1586 }; 1587 1588 class MoveWideIsValidTrait { 1589 public: 1590 using ResultType = bool; 1591 static constexpr bool returnEarlyIfAccepted = true; 1592 1593 static constexpr bool rejectedResult(A64DOpcodeMoveWide*) { return false; } 1594 static constexpr bool acceptedResult(A64DOpcodeMoveWide*) { return true; } 1595 }; 1596 1597 bool A64DOpcodeMoveWide::handlePotentialDataPointer(void* ptr) 1598 { 1599 ASSERT(Integrity::isSanePointer(ptr)); 1600 1601 bool handled = false; 1602 VMInspector::forEachVM([&] (VM& vm) { 1603 if (ptr == &vm) { 1604 bufferPrintf(" vm"); 1605 handled = true; 1606 return IterationStatus::Done; 1607 } 1608 1609 if (!vm.isInService()) 1610 return IterationStatus::Continue; 1611 1612 auto* vmStart = reinterpret_cast<uint8_t*>(&vm); 1613 auto* vmEnd = vmStart + sizeof(VM); 1614 auto* u8Ptr = reinterpret_cast<uint8_t*>(ptr); 1615 Range vmRange(vmStart, vmEnd); 1616 if (vmRange.contains(u8Ptr)) { 1617 unsigned offset = u8Ptr - vmStart; 1618 bufferPrintf(" vm +%u", offset); 1619 1620 const char* description = nullptr; 1621 if (ptr == &vm.topCallFrame) 1622 description = "vm.topCallFrame"; 1623 else if (offset == VM::topEntryFrameOffset()) 1624 description = "vm.topEntryFrame"; 1625 else if (offset == VM::exceptionOffset()) 1626 description = "vm.m_exception"; 1627 else if (offset == VM::offsetOfHeapBarrierThreshold()) 1628 description = "vm.heap.m_barrierThreshold"; 1629 else if (offset == VM::callFrameForCatchOffset()) 1630 description = "vm.callFrameForCatch"; 1631 else if (ptr == vm.addressOfSoftStackLimit()) 1632 description = "vm.m_softStackLimit"; 1633 else if (ptr == &vm.osrExitIndex) 1634 description = "vm.osrExitIndex"; 1635 else if (ptr == &vm.osrExitJumpDestination) 1636 description = "vm.osrExitJumpDestination"; 1637 else if (ptr == vm.smallStrings.singleCharacterStrings()) 1638 description = "vm.smallStrings.m_singleCharacterStrings"; 1639 else if (ptr == &vm.targetMachinePCForThrow) 1640 description = "vm.targetMachinePCForThrow"; 1641 else if (ptr == vm.traps().trapBitsAddress()) 1642 description = "vm.m_traps.m_trapBits"; 1643 #if ENABLE(DFG_DOES_GC_VALIDATION) 1644 else if (ptr == vm.addressOfDoesGC()) 1645 description = "vm.m_doesGC"; 1646 #endif 1647 if (description) 1648 bufferPrintf(": %s", description); 1649 1650 handled = true; 1651 return IterationStatus::Done; 1652 } 1653 1654 if (vm.isScratchBuffer(ptr)) { 1655 bufferPrintf(" vm scratchBuffer.m_buffer"); 1656 handled = true; 1657 return IterationStatus::Done; 1658 } 1659 return IterationStatus::Continue; 1660 }); 1661 return handled; 1662 } 1663 1664 #if CPU(ARM64E) 1665 bool A64DOpcodeMoveWide::handlePotentialPtrTag(uintptr_t value) 1666 { 1667 if (!value || value > 0xffff) 1668 return false; 1669 1670 PtrTag tag = static_cast<PtrTag>(value); 1671 #if ENABLE(PTRTAG_DEBUGGING) 1672 const char* name = WTF::ptrTagName(tag); 1673 if (name[0] == '<') 1674 return false; // Only result that starts with '<' is "<unknown>". 1675 #else 1676 // Without ENABLE(PTRTAG_DEBUGGING), not all PtrTags are registeredf for 1677 // printing. So, we'll just do the minimum with only the JSC specific tags. 1678 const char* name = ptrTagName(tag); 1679 if (!name) 1680 return false; 1681 #endif 1682 1683 // Also print '?' to indicate that this is a maybe. We do not know for certain 1684 // if the constant is meant to be used as a PtrTag. 1685 bufferPrintf(" -> %p %s ?", reinterpret_cast<void*>(value), name); 1686 return true; 1687 } 1688 #endif 1689 1690 template<typename Trait> 1691 typename Trait::ResultType A64DOpcodeMoveWide::parse() 1574 1692 { 1575 1693 if (opc() == 1) 1576 return A64DOpcode::format();1694 return Trait::rejectedResult(this); 1577 1695 if (!is64Bit() && hw() >= 2) 1578 return A64DOpcode::format(); 1696 return Trait::rejectedResult(this); 1697 1698 if constexpr (Trait::returnEarlyIfAccepted) 1699 return Trait::acceptedResult(this); 1579 1700 1580 1701 if (!opc() && (!immediate16() || !hw()) && (is64Bit() || immediate16() != 0xffff)) { … … 1588 1709 amount = ~amount; 1589 1710 appendSignedImmediate64(amount); 1711 m_builtConstant = static_cast<intptr_t>(amount); 1590 1712 } else { 1591 1713 int32_t amount = immediate16() << (hw() * 16); 1592 1714 amount = ~amount; 1593 1715 appendSignedImmediate(amount); 1716 m_builtConstant = static_cast<intptr_t>(amount); 1594 1717 } 1595 1718 } else { … … 1602 1725 appendShiftAmount(hw()); 1603 1726 } 1604 } 1605 1606 return m_formatBuffer; 1607 } 1727 1728 if (opc() == 2) // Encoding for movz 1729 m_builtConstant = 0; 1730 1731 unsigned shift = hw() * 16; 1732 uintptr_t value = static_cast<uintptr_t>(immediate16()) << shift; 1733 uintptr_t mask = ~(static_cast<uintptr_t>(0xffff) << shift); 1734 m_builtConstant &= mask; 1735 m_builtConstant |= value; 1736 } 1737 1738 auto dumpConstantData = [&] { 1739 uint32_t* nextPC = m_currentPC + 1; 1740 bool doneBuildingConstant = false; 1741 1742 if (nextPC >= m_endPC) 1743 doneBuildingConstant = true; 1744 else { 1745 A64DOpcode nextOpcodeBase(m_startPC, m_endPC); 1746 A64DOpcodeMoveWide& nextOpcode = *reinterpret_cast<A64DOpcodeMoveWide*>(&nextOpcodeBase); 1747 nextOpcode.setPCAndOpcode(nextPC, *nextPC); 1748 1749 bool nextIsMoveWideGroup = opcodeGroupNumber(m_opcode) == opcodeGroupNumber(*nextPC); 1750 1751 if (!nextIsMoveWideGroup || !nextOpcode.isValid() || nextOpcode.rd() != rd()) 1752 doneBuildingConstant = true; 1753 } 1754 if (!doneBuildingConstant) 1755 return; 1756 1757 void* ptr = removeCodePtrTag(bitwise_cast<void*>(m_builtConstant)); 1758 if (!ptr) 1759 return; 1760 1761 if (Integrity::isSanePointer(ptr)) { 1762 bufferPrintf(" -> %p", ptr); 1763 if (const char* label = labelFor(ptr)) 1764 return bufferPrintf(" %s", label); 1765 if (isJITPC(ptr)) 1766 return bufferPrintf(" JIT PC"); 1767 if (LLInt::isLLIntPC(ptr)) 1768 return bufferPrintf(" LLInt PC"); 1769 handlePotentialDataPointer(ptr); 1770 return; 1771 } 1772 #if CPU(ARM64E) 1773 if (handlePotentialPtrTag(m_builtConstant)) 1774 return; 1775 #endif 1776 if (m_builtConstant < 0x10000) 1777 bufferPrintf(" -> %u", static_cast<unsigned>(m_builtConstant)); 1778 else 1779 bufferPrintf(" -> %p", reinterpret_cast<void*>(m_builtConstant)); 1780 }; 1781 1782 if (m_startPC) 1783 dumpConstantData(); 1784 1785 return Trait::acceptedResult(this); 1786 } 1787 1788 const char* A64DOpcodeMoveWide::format() { return parse<MoveWideFormatTrait>(); } 1789 bool A64DOpcodeMoveWide::isValid() { return parse<MoveWideIsValidTrait>(); } 1608 1790 1609 1791 const char* A64DOpcodeTestAndBranchImmediate::format() -
trunk/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h
r294180 r294287 195 195 } 196 196 197 static constexpr int bufferSize = 81;197 static constexpr int bufferSize = 101; 198 198 199 199 char m_formatBuffer[bufferSize]; … … 203 203 uint32_t m_opcode; 204 204 int m_bufferOffset; 205 uintptr_t m_builtConstant { 0 }; 205 206 206 207 private: … … 873 874 874 875 const char* format(); 876 bool isValid(); 875 877 876 878 const char* opName() { return s_opNames[opc()]; } … … 878 880 unsigned hw() { return (m_opcode >> 21) & 0x3; } 879 881 unsigned immediate16() { return (m_opcode >> 5) & 0xffff; } 882 883 private: 884 template<typename Trait> typename Trait::ResultType parse(); 885 bool handlePotentialDataPointer(void*); 886 bool handlePotentialPtrTag(uintptr_t); 887 888 // These forwarding functions are needed for MoveWideFormatTrait only. 889 const char* baseFormat() { return A64DOpcode::format(); } 890 const char* formatBuffer() { return m_formatBuffer; } 891 892 friend class MoveWideFormatTrait; 893 friend class MoveWideIsValidTrait; 880 894 }; 881 895 -
trunk/Source/JavaScriptCore/disassembler/Disassembler.cpp
r294180 r294287 28 28 29 29 #include "MacroAssemblerCodeRef.h" 30 #include <variant> 30 31 #include <wtf/Condition.h> 31 32 #include <wtf/DataLog.h> … … 37 38 namespace JSC { 38 39 39 using ThunkLabelMap = HashMap<void*, CString>; 40 LazyNeverDestroyed<ThunkLabelMap> thunkLabelMap; 40 namespace Disassembler { 41 42 Lock labelMapLock; 43 44 using LabelMap = HashMap<void*, std::variant<CString, const char*>>; 45 LazyNeverDestroyed<LabelMap> labelMap; 46 47 static LabelMap& ensureLabelMap() WTF_REQUIRES_LOCK(labelMapLock) 48 { 49 static std::once_flag onceKey; 50 std::call_once(onceKey, [] { 51 labelMap.construct(); 52 }); 53 return labelMap.get(); 54 } 55 56 } // namespace Disassembler 41 57 42 58 void disassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, void* codeStart, void* codeEnd, const char* prefix, PrintStream& out) … … 158 174 } 159 175 160 static ThunkLabelMap& ensureThunkLabelMap() 161 { 162 static std::once_flag onceKey; 163 std::call_once(onceKey, [] { 164 thunkLabelMap.construct(); 165 }); 166 return thunkLabelMap.get(); 167 } 168 169 void registerThunkLabel(void* thunkAddress, CString&& label) 170 { 171 ensureThunkLabelMap().add(thunkAddress, WTFMove(label)); 172 } 173 174 const char* labelForThunk(void* thunkAddress) 175 { 176 auto& map = ensureThunkLabelMap(); 176 void registerLabel(void* thunkAddress, CString&& label) 177 { 178 Locker lock { Disassembler::labelMapLock }; 179 Disassembler::ensureLabelMap().add(thunkAddress, WTFMove(label)); 180 } 181 182 void registerLabel(void* address, const char* label) 183 { 184 Locker lock { Disassembler::labelMapLock }; 185 Disassembler::ensureLabelMap().add(address, label); 186 } 187 188 const char* labelFor(void* thunkAddress) 189 { 190 Locker lock { Disassembler::labelMapLock }; 191 auto& map = Disassembler::ensureLabelMap(); 177 192 auto it = map.find(thunkAddress); 178 193 if (it == map.end()) 179 194 return nullptr; 180 return it->value.data(); 195 if (std::holds_alternative<CString>(it->value)) 196 return std::get<CString>(it->value).data(); 197 return std::get<const char*>(it->value); 181 198 } 182 199 -
trunk/Source/JavaScriptCore/disassembler/Disassembler.h
r294180 r294287 62 62 JS_EXPORT_PRIVATE void waitForAsynchronousDisassembly(); 63 63 64 void registerThunkLabel(void* thunkAddress, CString&& label); 65 const char* labelForThunk(void* thunkAddress); 64 void registerLabel(void* thunkAddress, CString&& label); 65 void registerLabel(void* thunkAddress, const char* label); 66 const char* labelFor(void* thunkAddress); 66 67 67 68 } // namespace JSC -
trunk/Source/JavaScriptCore/jsc.cpp
r293879 r294287 3757 3757 } 3758 3758 3759 #if ENABLE(JIT_OPERATION_VALIDATION) 3759 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 3760 3760 extern const JITOperationAnnotation startOfJITOperationsInShell __asm("section$start$__DATA_CONST$__jsc_ops"); 3761 3761 extern const JITOperationAnnotation endOfJITOperationsInShell __asm("section$end$__DATA_CONST$__jsc_ops"); … … 3784 3784 JSC::JITOperationList::populatePointersInEmbedder(&startOfJITOperationsInShell, &endOfJITOperationsInShell); 3785 3785 #endif 3786 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 3787 if (UNLIKELY(Options::needDisassemblySupport())) 3788 JSC::JITOperationList::populateDisassemblyLabelsInEmbedder(&startOfJITOperationsInShell, &endOfJITOperationsInShell); 3789 #endif 3790 3786 3791 initializeTimeoutIfNeeded(); 3787 3792 -
trunk/Source/JavaScriptCore/runtime/ArrayBuffer.h
r291331 r294287 73 73 }; 74 74 75 class ArrayBufferContents {75 class ArrayBufferContents { 76 76 WTF_MAKE_NONCOPYABLE(ArrayBufferContents); 77 77 public: -
trunk/Source/JavaScriptCore/runtime/Gate.h
r285795 r294287 1 1 /* 2 * Copyright (C) 2020 Apple Inc. All rights reserved.2 * Copyright (C) 2020-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 namespace JSC { 29 29 30 #if ENABLE(JIT_OPERATION_VALIDATION) || CPU(ARM64E)30 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) || CPU(ARM64E) 31 31 32 32 #define JSC_UTILITY_GATES(v) \ … … 92 92 #undef JSC_COUNT 93 93 #undef JSC_OPCODE_COUNT 94 #else 94 95 #else // not (ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) || CPU(ARM64E)) 96 95 97 // Keep it non-zero to make JSCConfig's array not [0]. 96 98 static constexpr unsigned numberOfGates = 1; 97 #endif98 99 99 } 100 #endif // ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) || CPU(ARM64E) 101 102 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSCPtrTag.cpp
r269353 r294287 1 1 /* 2 * Copyright (C) 2018-202 0Apple Inc. All rights reserved.2 * Copyright (C) 2018-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 namespace JSC { 38 38 39 #if CPU(ARM64E) && ENABLE(PTRTAG_DEBUGGING)39 #if ENABLE(JIT_OPERATION_DISASSEMBLY) || (CPU(ARM64E) && ENABLE(PTRTAG_DEBUGGING)) 40 40 41 const char* ptrTagName(PtrTag tag) 42 { 43 #define RETURN_PTRTAG_NAME(_tagName, calleeType, callerType) case _tagName: return #_tagName; 44 switch (static_cast<unsigned>(tag)) { 45 FOR_EACH_JSC_PTRTAG(RETURN_PTRTAG_NAME) 46 } 47 #undef RETURN_PTRTAG_NAME 48 return nullptr; // Matching tag not found. 49 } 50 51 #if ENABLE(PTRTAG_DEBUGGING) 41 52 static const char* tagForPtr(const void* ptr) 42 53 { … … 51 62 } 52 63 53 static const char* ptrTagName(PtrTag tag)54 {55 #define RETURN_PTRTAG_NAME(_tagName, calleeType, callerType) case _tagName: return #_tagName;56 switch (static_cast<unsigned>(tag)) {57 FOR_EACH_JSC_PTRTAG(RETURN_PTRTAG_NAME)58 }59 #undef RETURN_PTRTAG_NAME60 return nullptr; // Matching tag not found.61 }62 63 64 void initializePtrTagLookup() 64 65 { … … 67 68 WTF::registerPtrTagLookup(&lookup); 68 69 } 69 70 #endif // CPU(ARM64E) && ENABLE(PTRTAG_DEBUGGING)70 #endif // ENABLE(PTRTAG_DEBUGGING) 71 #endif // ENABLE(JIT_OPERATION_DISASSEMBLY) || (CPU(ARM64E) && ENABLE(PTRTAG_DEBUGGING)) 71 72 72 73 #if CPU(ARM64E) -
trunk/Source/JavaScriptCore/runtime/JSCPtrTag.h
r286891 r294287 1 1 /* 2 * Copyright (C) 2018-202 1Apple Inc. All rights reserved.2 * Copyright (C) 2018-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 249 249 #endif 250 250 251 #if ENABLE(JIT_OPERATION_DISASSEMBLY) || (CPU(ARM64E) && ENABLE(PTRTAG_DEBUGGING)) 252 const char* ptrTagName(PtrTag); 253 #endif 254 251 255 } // namespace JSC 252 256 namespace WTF { -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r293484 r294287 466 466 Options::useFastTLSForWasmContext() = false; 467 467 468 if (Options:: logJIT()469 || Options:: dumpDisassembly()468 if (Options::dumpDisassembly() 469 || Options::asyncDisassembly() 470 470 || Options::dumpDFGDisassembly() 471 471 || Options::dumpFTLDisassembly() 472 || Options::dumpRegExpDisassembly() 473 || Options::dumpWasmDisassembly() 474 || Options::dumpBBQDisassembly() 475 || Options::dumpOMGDisassembly()) 476 Options::needDisassemblySupport() = true; 477 478 if (Options::logJIT() 479 || Options::needDisassemblySupport() 472 480 || Options::dumpBytecodeAtDFGTime() 473 481 || Options::dumpGraphAtEachPhase() -
trunk/Source/JavaScriptCore/runtime/OptionsList.h
r293473 r294287 128 128 v(Bool, useOSLog, false, Normal, "Log dataLog()s to os_log instead of stderr") \ 129 129 /* dumpDisassembly implies dumpDFGDisassembly. */ \ 130 v(Bool, needDisassemblySupport, false, Normal, nullptr) \ 130 131 v(Bool, dumpDisassembly, false, Normal, "dumps disassembly of all JIT compiled code upon compilation") \ 131 132 v(Bool, asyncDisassembly, false, Normal, nullptr) \ -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r294017 r294287 1410 1410 } 1411 1411 1412 bool VM::isScratchBuffer(void* ptr) 1413 { 1414 Locker locker { m_scratchBufferLock }; 1415 for (auto* scratchBuffer : m_scratchBuffers) { 1416 if (scratchBuffer->dataBuffer() == ptr) 1417 return true; 1418 } 1419 return false; 1420 } 1421 1412 1422 void VM::ensureShadowChicken() 1413 1423 { -
trunk/Source/JavaScriptCore/runtime/VM.h
r294017 r294287 686 686 ScratchBuffer* scratchBufferForSize(size_t size); 687 687 void clearScratchBuffers(); 688 bool isScratchBuffer(void*); 688 689 689 690 EncodedJSValue* exceptionFuzzingBuffer(size_t size) -
trunk/Source/JavaScriptCore/tools/Integrity.h
r294017 r294287 95 95 #if CPU(ADDRESS64) 96 96 uintptr_t pointerAsInt = bitwise_cast<uintptr_t>(pointer); 97 #if OS(DARWIN) 98 constexpr uintptr_t oneAbove4G = (static_cast<uintptr_t>(1) << 32); 99 if (pointerAsInt < oneAbove4G) 100 return false; 101 #endif 97 102 uintptr_t canonicalPointerBits = pointerAsInt << (64 - OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH)); 98 103 uintptr_t nonCanonicalPointerBits = pointerAsInt >> OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH); … … 101 106 UNUSED_PARAM(pointer); 102 107 return true; 103 #endif 108 #endif // CPU(ADDRESS64) 104 109 } 105 110 -
trunk/Source/WTF/ChangeLog
r294272 r294287 1 2022-05-16 Mark Lam <mark.lam@apple.com> 2 3 Add ARM64 disassembler support for symbolic dumping of some well known constants. 4 https://bugs.webkit.org/show_bug.cgi?id=240443 5 6 Reviewed by Yusuke Suzuki. 7 8 1. Added a ENABLE(JIT_OPERATION_DISASSEMBLY) flag. 9 Currently, this feature relies on an USE(APPLE_INTERNAL_SDK) for enumerating 10 JIT operations similar to ENABLE(JIT_OPERATION_VALIDATION). It is also 11 restricted to ENABLE(DISASSEMBLER) && CPU(ARM64E). 12 13 * wtf/PlatformCallingConventions.h: 14 * wtf/PlatformEnable.h: 15 1 16 2022-05-16 Brent Fulgham <bfulgham@apple.com> 2 17 -
trunk/Source/WTF/wtf/PlatformCallingConventions.h
r281910 r294287 1 1 /* 2 * Copyright (C) 2006-202 1Apple Inc. All rights reserved.2 * Copyright (C) 2006-2022 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007-2009 Torch Mobile, Inc. 4 4 * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved. … … 85 85 #endif 86 86 87 #if ENABLE(JIT_OPERATION_VALIDATION) 87 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 88 89 #if ENABLE(JIT_OPERATION_VALIDATION) && ENABLE(JIT_OPERATION_DISASSEMBLY) 90 #define JSC_ANNOTATE_JIT_OPERATION_EXTRAS(validateFunction, name) (void*)validateFunction, name 91 #elif ENABLE(JIT_OPERATION_VALIDATION) 92 #define JSC_ANNOTATE_JIT_OPERATION_EXTRAS(validateFunction, name) (void*)validateFunction 93 #else // ENABLE(JIT_OPERATION_DISASSEMBLY) 94 #define JSC_ANNOTATE_JIT_OPERATION_EXTRAS(validateFunction, name) name 95 #endif 96 88 97 #define JSC_ANNOTATE_JIT_OPERATION_INTERNAL(function) \ 89 constexpr JSC::JITOperationAnnotation _JITTargetID_##function __attribute__((used, section("__DATA_CONST,__jsc_ops"))) = { (void*)function, (void*)function##Validate};98 constexpr JSC::JITOperationAnnotation _JITTargetID_##function __attribute__((used, section("__DATA_CONST,__jsc_ops"))) = { (void*)function, JSC_ANNOTATE_JIT_OPERATION_EXTRAS(function##Validate, #function) }; 90 99 91 100 #define JSC_ANNOTATE_JIT_OPERATION(function) \ … … 101 110 JSC_ANNOTATE_JIT_OPERATION_INTERNAL(function) 102 111 103 #else 112 #else // not (ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY)) 113 104 114 #define JSC_ANNOTATE_JIT_OPERATION(function) 105 115 #define JSC_ANNOTATE_JIT_OPERATION_PROBE(function) 106 116 #define JSC_ANNOTATE_JIT_OPERATION_RETURN(function) 107 #endif108 117 118 #endif // ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 109 119 110 120 #define JSC_DEFINE_JIT_OPERATION_WITHOUT_VARIABLE(functionName, returnType, parameters) \ -
trunk/Source/WTF/wtf/PlatformEnable.h
r292870 r294287 1 1 /* 2 * Copyright (C) 2006-202 1Apple Inc. All rights reserved.2 * Copyright (C) 2006-2022 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007-2009 Torch Mobile, Inc. 4 4 * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved. … … 850 850 #endif 851 851 852 #if USE(APPLE_INTERNAL_SDK) && ENABLE(DISASSEMBLER) && CPU(ARM64E) 853 #define ENABLE_JIT_OPERATION_DISASSEMBLY 1 854 #endif 855 852 856 #if !defined(ENABLE_BINDING_INTEGRITY) && !OS(WINDOWS) 853 857 #define ENABLE_BINDING_INTEGRITY 1 -
trunk/Source/WebCore/ChangeLog
r294281 r294287 1 2022-05-16 Mark Lam <mark.lam@apple.com> 2 3 Add ARM64 disassembler support for symbolic dumping of some well known constants. 4 https://bugs.webkit.org/show_bug.cgi?id=240443 5 6 Reviewed by Yusuke Suzuki. 7 8 * bindings/js/WebCoreJITOperations.cpp: 9 (WebCore::populateJITOperations): 10 (WebCore::populateDisassemblyLabels): 11 * bindings/js/WebCoreJITOperations.h: 12 (WebCore::populateDisassemblyLabels): 13 (WebCore::populateJITOperations): 14 * testing/js/WebCoreTestSupport.cpp: 15 (WebCoreTestSupport::populateJITOperations): 16 (WebCoreTestSupport::populateDisassemblyLabels): 17 * testing/js/WebCoreTestSupport.h: 18 (WebCoreTestSupport::populateDisassemblyLabels): 19 (WebCoreTestSupport::populateJITOperations): 20 1 21 2022-05-16 Gabriel Nava Marino <gnavamarino@apple.com> 2 22 -
trunk/Source/WebCore/bindings/js/WebCoreJITOperations.cpp
r281910 r294287 1 1 /* 2 * Copyright (C) 2020-202 1Apple Inc. All rights reserved.2 * Copyright (C) 2020-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 namespace WebCore { 32 32 33 #if ENABLE(JIT_OPERATION_VALIDATION) 33 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 34 34 35 extern const JSC::JITOperationAnnotation startOfJITOperationsInWebCore __asm("section$start$__DATA_CONST$__jsc_ops"); 35 36 extern const JSC::JITOperationAnnotation endOfJITOperationsInWebCore __asm("section$end$__DATA_CONST$__jsc_ops"); 36 37 38 #if ENABLE(JIT_OPERATION_VALIDATION) 37 39 void populateJITOperations() 38 40 { … … 41 43 JSC::JITOperationList::populatePointersInEmbedder(&startOfJITOperationsInWebCore, &endOfJITOperationsInWebCore); 42 44 }); 45 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 46 if (UNLIKELY(JSC::Options::needDisassemblySupport())) 47 populateDisassemblyLabels(); 48 #endif 43 49 } 44 50 #endif // ENABLE(JIT_OPERATION_VALIDATION) 45 51 52 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 53 void populateDisassemblyLabels() 54 { 55 static std::once_flag onceKey; 56 std::call_once(onceKey, [] { 57 JSC::JITOperationList::populateDisassemblyLabelsInEmbedder(&startOfJITOperationsInWebCore, &endOfJITOperationsInWebCore); 58 }); 46 59 } 60 #endif // ENABLE(JIT_OPERATION_DISASSEMBLY) 61 62 #endif // ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 63 64 } -
trunk/Source/WebCore/bindings/js/WebCoreJITOperations.h
r281544 r294287 1 1 /* 2 * Copyright (C) 2020-202 1Apple Inc. All rights reserved.2 * Copyright (C) 2020-2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 namespace WebCore { 29 29 30 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 31 32 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 33 WEBCORE_EXPORT void populateDisassemblyLabels(); 34 #else 35 inline void populateDisassemblyLabels() { } 36 #endif 37 30 38 #if ENABLE(JIT_OPERATION_VALIDATION) 31 39 WEBCORE_EXPORT void populateJITOperations(); 32 40 #else 33 inline void populateJITOperations() { }41 inline void populateJITOperations() { populateDisassemblyLabels(); } 34 42 #endif 35 43 44 #else 45 inline void populateJITOperations() { } 46 #endif // ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 47 36 48 } -
trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp
r292793 r294287 1 1 /* 2 2 * Copyright (C) 2011, 2015 Google Inc. All rights reserved. 3 * Copyright (C) 2016-202 1Apple Inc. All rights reserved.3 * Copyright (C) 2016-2022 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 242 242 #endif 243 243 244 #if ENABLE(JIT_OPERATION_VALIDATION) 244 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 245 245 246 extern const JSC::JITOperationAnnotation startOfJITOperationsInWebCoreTestSupport __asm("section$start$__DATA_CONST$__jsc_ops"); 246 247 extern const JSC::JITOperationAnnotation endOfJITOperationsInWebCoreTestSupport __asm("section$end$__DATA_CONST$__jsc_ops"); 248 249 #if ENABLE(JIT_OPERATION_VALIDATION) 247 250 248 251 void populateJITOperations() … … 252 255 JSC::JITOperationList::populatePointersInEmbedder(&startOfJITOperationsInWebCoreTestSupport, &endOfJITOperationsInWebCoreTestSupport); 253 256 }); 257 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 258 if (UNLIKELY(JSC::Options::needDisassemblySupport())) 259 populateDisassemblyLabels(); 260 #endif 254 261 } 255 262 #endif // ENABLE(JIT_OPERATION_VALIDATION) 256 263 257 } 264 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 265 void populateDisassemblyLabels() 266 { 267 static std::once_flag onceKey; 268 std::call_once(onceKey, [] { 269 JSC::JITOperationList::populateDisassemblyLabelsInEmbedder(&startOfJITOperationsInWebCoreTestSupport, &endOfJITOperationsInWebCoreTestSupport); 270 }); 271 } 272 #endif // ENABLE(JIT_OPERATION_DISASSEMBLY) 273 274 #endif // ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 275 276 } // namespace WebCoreTestSupport -
trunk/Source/WebCore/testing/js/WebCoreTestSupport.h
r284857 r294287 1 1 /* 2 2 * Copyright (C) 2011, 2015 Google Inc. All rights reserved. 3 * Copyright (C) 2016-202 1Apple Inc. All rights reserved.3 * Copyright (C) 2016-2022 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 68 68 void setAdditionalSupportedImageTypesForTesting(const String&) TEST_SUPPORT_EXPORT; 69 69 70 #if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 71 #if ENABLE(JIT_OPERATION_DISASSEMBLY) 72 void populateDisassemblyLabels() TEST_SUPPORT_EXPORT; 73 #else 74 inline void populateDisassemblyLabels() { } 75 #endif 76 70 77 #if ENABLE(JIT_OPERATION_VALIDATION) 71 78 void populateJITOperations() TEST_SUPPORT_EXPORT; 72 79 #else 73 inline void populateJITOperations() { }80 inline void populateJITOperations() { populateDisassemblyLabels(); } 74 81 #endif 75 82 83 #else 84 inline void populateJITOperations() { } 85 #endif // ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY) 86 76 87 } // namespace WebCoreTestSupport
Note:
See TracChangeset
for help on using the changeset viewer.