Changeset 236534 in webkit
- Timestamp:
- Sep 26, 2018, 5:14:16 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
assembler/ARM64Assembler.h (modified) (13 diffs)
-
assembler/LinkBuffer.cpp (modified) (3 diffs)
-
jit/ExecutableAllocator.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r236520 r236534 1 2018-09-26 Mark Lam <mark.lam@apple.com> 2 3 Assert that performJITMemcpy() is always called with instruction size aligned addresses on ARM64. 4 https://bugs.webkit.org/show_bug.cgi?id=190016 5 <rdar://problem/44802875> 6 7 Reviewed by Saam Barati. 8 9 Also assert in performJITMemcpy() that the entire buffer to be copied will fit in 10 JIT memory. 11 12 * assembler/ARM64Assembler.h: 13 (JSC::ARM64Assembler::fillNops): 14 (JSC::ARM64Assembler::replaceWithVMHalt): 15 (JSC::ARM64Assembler::replaceWithJump): 16 (JSC::ARM64Assembler::replaceWithLoad): 17 (JSC::ARM64Assembler::replaceWithAddressComputation): 18 (JSC::ARM64Assembler::setPointer): 19 (JSC::ARM64Assembler::repatchInt32): 20 (JSC::ARM64Assembler::repatchCompact): 21 (JSC::ARM64Assembler::linkJumpOrCall): 22 (JSC::ARM64Assembler::linkCompareAndBranch): 23 (JSC::ARM64Assembler::linkConditionalBranch): 24 (JSC::ARM64Assembler::linkTestAndBranch): 25 * assembler/LinkBuffer.cpp: 26 (JSC::LinkBuffer::copyCompactAndLinkCode): 27 (JSC::LinkBuffer::linkCode): 28 * jit/ExecutableAllocator.h: 29 (JSC::performJITMemcpy): 30 1 31 2018-09-25 Keith Miller <keith_miller@apple.com> 2 32 -
trunk/Source/JavaScriptCore/assembler/ARM64Assembler.h
r236450 r236534 267 267 class ARM64Assembler { 268 268 public: 269 static constexpr size_t instructionSize = sizeof(unsigned); 270 269 271 typedef ARM64Registers::RegisterID RegisterID; 270 272 typedef ARM64Registers::SPRegisterID SPRegisterID; … … 1563 1565 for (int32_t* ptr = static_cast<int32_t*>(base); n--;) { 1564 1566 int insn = nopPseudo(); 1565 if (isCopyingToExecutableMemory) 1567 if (isCopyingToExecutableMemory) { 1568 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(ptr) == ptr); 1566 1569 performJITMemcpy(ptr++, &insn, sizeof(int)); 1567 else1570 } else 1568 1571 memcpy(ptr++, &insn, sizeof(int)); 1569 1572 } … … 2637 2640 // This should try to write to null which should always Segfault. 2638 2641 int insn = dataCacheZeroVirtualAddress(ARM64Registers::zr); 2642 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(where) == where); 2639 2643 performJITMemcpy(where, &insn, sizeof(int)); 2640 2644 cacheFlush(where, sizeof(int)); … … 2646 2650 ASSERT(static_cast<int>(offset) == offset); 2647 2651 int insn = unconditionalBranchImmediate(false, static_cast<int>(offset)); 2652 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(where) == where); 2648 2653 performJITMemcpy(where, &insn, sizeof(int)); 2649 2654 cacheFlush(where, sizeof(int)); … … 2676 2681 ASSERT(!(imm12 & ~0xff8)); 2677 2682 int insn = loadStoreRegisterUnsignedImmediate(MemOpSize_64, false, MemOp_LOAD, encodePositiveImmediate<64>(imm12), rn, rd); 2683 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(where) == where); 2678 2684 performJITMemcpy(where, &insn, sizeof(int)); 2679 2685 cacheFlush(where, sizeof(int)); … … 2710 2716 ASSERT(!(imm12 & ~0x1ff)); 2711 2717 int insn = addSubtractImmediate(Datasize_64, AddOp_ADD, DontSetFlags, 0, imm12 * sizeof(void*), rn, rt); 2718 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(where) == where); 2712 2719 performJITMemcpy(where, &insn, sizeof(int)); 2713 2720 cacheFlush(where, sizeof(int)); … … 2744 2751 buffer[1] = moveWideImediate(Datasize_64, MoveWideOp_K, 1, getHalfword(value, 1), rd); 2745 2752 buffer[2] = moveWideImediate(Datasize_64, MoveWideOp_K, 2, getHalfword(value, 2), rd); 2753 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(address) == address); 2746 2754 performJITMemcpy(address, buffer, sizeof(int) * 3); 2747 2755 … … 2771 2779 buffer[1] = moveWideImediate(Datasize_32, MoveWideOp_K, 1, getHalfword(value, 1), rd); 2772 2780 } 2781 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(where) == where); 2773 2782 performJITMemcpy(where, &buffer, sizeof(int) * 2); 2774 2783 … … 2846 2855 imm12 = encodePositiveImmediate<64>(value); 2847 2856 int insn = loadStoreRegisterUnsignedImmediate(size, V, opc, imm12, rn, rt); 2857 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(where) == where); 2848 2858 performJITMemcpy(where, &insn, sizeof(int)); 2849 2859 … … 3049 3059 3050 3060 int insn = unconditionalBranchImmediate(isCall, static_cast<int>(offset)); 3061 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from); 3051 3062 performJITMemcpy(from, &insn, sizeof(int)); 3052 3063 } … … 3065 3076 if (useDirect || isDirect) { 3066 3077 int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, condition == ConditionNE, static_cast<int>(offset), rt); 3078 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from); 3067 3079 performJITMemcpy(from, &insn, sizeof(int)); 3068 3080 if (!isDirect) { 3069 3081 insn = nopPseudo(); 3082 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from + 1) == (from + 1)); 3070 3083 performJITMemcpy(from + 1, &insn, sizeof(int)); 3071 3084 } 3072 3085 } else { 3073 3086 int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, invert(condition) == ConditionNE, 2, rt); 3087 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from); 3074 3088 performJITMemcpy(from, &insn, sizeof(int)); 3075 3089 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to); … … 3090 3104 if (useDirect || isDirect) { 3091 3105 int insn = conditionalBranchImmediate(static_cast<int>(offset), condition); 3106 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from); 3092 3107 performJITMemcpy(from, &insn, sizeof(int)); 3093 3108 if (!isDirect) { 3094 3109 insn = nopPseudo(); 3110 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from + 1) == (from + 1)); 3095 3111 performJITMemcpy(from + 1, &insn, sizeof(int)); 3096 3112 } 3097 3113 } else { 3098 3114 int insn = conditionalBranchImmediate(2, invert(condition)); 3115 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from); 3099 3116 performJITMemcpy(from, &insn, sizeof(int)); 3100 3117 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to); … … 3116 3133 if (useDirect || isDirect) { 3117 3134 int insn = testAndBranchImmediate(condition == ConditionNE, static_cast<int>(bitNumber), static_cast<int>(offset), rt); 3135 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from); 3118 3136 performJITMemcpy(from, &insn, sizeof(int)); 3119 3137 if (!isDirect) { 3120 3138 insn = nopPseudo(); 3139 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from + 1) == (from + 1)); 3121 3140 performJITMemcpy(from + 1, &insn, sizeof(int)); 3122 3141 } 3123 3142 } else { 3124 3143 int insn = testAndBranchImmediate(invert(condition) == ConditionNE, static_cast<int>(bitNumber), 2, rt); 3144 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from); 3125 3145 performJITMemcpy(from, &insn, sizeof(int)); 3126 3146 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to); -
trunk/Source/JavaScriptCore/assembler/LinkBuffer.cpp
r231175 r236534 114 114 uint8_t* outData = reinterpret_cast<uint8_t*>(outBuffer.buffer()); 115 115 uint8_t* codeOutData = m_code.dataLocation<uint8_t*>(); 116 #if CPU(ARM64) 117 RELEASE_ASSERT(roundUpToMultipleOf<sizeof(unsigned)>(outData) == outData); 118 RELEASE_ASSERT(roundUpToMultipleOf<sizeof(unsigned)>(codeOutData) == codeOutData); 119 #endif 116 120 117 121 int readPtr = 0; … … 214 218 #if CPU(ARM_TRADITIONAL) 215 219 macroAssembler.m_assembler.prepareExecutableCopy(code); 220 #elif CPU(ARM64) 221 RELEASE_ASSERT(roundUpToMultipleOf<Assembler::instructionSize>(code) == code); 216 222 #endif 217 223 performJITMemcpy(code, buffer.data(), buffer.codeSize()); … … 336 342 337 343 #endif // ENABLE(ASSEMBLER) 338 339 -
trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h
r236381 r236534 89 89 static inline void* performJITMemcpy(void *dst, const void *src, size_t n) 90 90 { 91 #if CPU(ARM64) 92 static constexpr size_t instructionSize = sizeof(unsigned); 93 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(dst) == dst); 94 RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(src) == src); 95 #endif 91 96 if (dst >= startOfFixedExecutableMemoryPool() && dst < endOfFixedExecutableMemoryPool()) { 97 RELEASE_ASSERT(reinterpret_cast<uint8_t*>(dst) + n <= endOfFixedExecutableMemoryPool()); 92 98 #if ENABLE(FAST_JIT_PERMISSIONS) 93 99 if (useFastPermisionsJITCopy) {
Note:
See TracChangeset
for help on using the changeset viewer.