Changeset 237470 in webkit
- Timestamp:
- Oct 26, 2018, 11:51:19 AM (8 years ago)
- Location:
- branches/safari-606-branch
- Files:
-
- 14 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/assembler/ARM64Assembler.h (modified) (13 diffs)
-
Source/JavaScriptCore/assembler/ARMAssembler.h (modified) (1 diff)
-
Source/JavaScriptCore/assembler/ARMv7Assembler.h (modified) (4 diffs)
-
Source/JavaScriptCore/assembler/AbstractMacroAssembler.h (modified) (4 diffs)
-
Source/JavaScriptCore/assembler/AssemblerBuffer.h (modified) (11 diffs)
-
Source/JavaScriptCore/assembler/LinkBuffer.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/assembler/MIPSAssembler.h (modified) (1 diff)
-
Source/JavaScriptCore/assembler/MacroAssemblerARM64.h (modified) (1 diff)
-
Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h (modified) (1 diff)
-
Source/JavaScriptCore/assembler/X86Assembler.h (modified) (1 diff)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/PtrTag.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-606-branch/JSTests/ChangeLog
r237439 r237470 1 2018-10-23 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r236589. rdar://problem/45285669 4 5 Verify the contents of AssemblerBuffer on arm64e 6 https://bugs.webkit.org/show_bug.cgi?id=190057 7 <rdar://problem/38916630> 8 9 Reviewed by Mark Lam. 10 11 JSTests: 12 13 * stress/regress-189132.js: 14 15 Source/JavaScriptCore: 16 17 * assembler/ARM64Assembler.h: 18 (JSC::ARM64Assembler::ARM64Assembler): 19 (JSC::ARM64Assembler::fillNops): 20 (JSC::ARM64Assembler::link): 21 (JSC::ARM64Assembler::linkJumpOrCall): 22 (JSC::ARM64Assembler::linkCompareAndBranch): 23 (JSC::ARM64Assembler::linkConditionalBranch): 24 (JSC::ARM64Assembler::linkTestAndBranch): 25 (JSC::ARM64Assembler::unlinkedCode): Deleted. 26 * assembler/ARMAssembler.h: 27 (JSC::ARMAssembler::fillNops): 28 * assembler/ARMv7Assembler.h: 29 (JSC::ARMv7Assembler::unlinkedCode): Deleted. 30 * assembler/AbstractMacroAssembler.h: 31 (JSC::AbstractMacroAssembler::emitNops): 32 (JSC::AbstractMacroAssembler::AbstractMacroAssembler): 33 * assembler/AssemblerBuffer.h: 34 (JSC::ARM64EHash::ARM64EHash): 35 (JSC::ARM64EHash::update): 36 (JSC::ARM64EHash::hash const): 37 (JSC::ARM64EHash::randomSeed const): 38 (JSC::AssemblerBuffer::AssemblerBuffer): 39 (JSC::AssemblerBuffer::putShort): 40 (JSC::AssemblerBuffer::putIntUnchecked): 41 (JSC::AssemblerBuffer::putInt): 42 (JSC::AssemblerBuffer::hash const): 43 (JSC::AssemblerBuffer::data const): 44 (JSC::AssemblerBuffer::putIntegralUnchecked): 45 (JSC::AssemblerBuffer::append): Deleted. 46 * assembler/LinkBuffer.cpp: 47 (JSC::LinkBuffer::copyCompactAndLinkCode): 48 * assembler/MIPSAssembler.h: 49 (JSC::MIPSAssembler::fillNops): 50 * assembler/MacroAssemblerARM64.h: 51 (JSC::MacroAssemblerARM64::jumpsToLink): 52 (JSC::MacroAssemblerARM64::link): 53 (JSC::MacroAssemblerARM64::unlinkedCode): Deleted. 54 * assembler/MacroAssemblerARMv7.h: 55 (JSC::MacroAssemblerARMv7::jumpsToLink): 56 (JSC::MacroAssemblerARMv7::unlinkedCode): Deleted. 57 * assembler/X86Assembler.h: 58 (JSC::X86Assembler::fillNops): 59 60 Source/WTF: 61 62 * wtf/PtrTag.h: 63 (WTF::tagInt): 64 65 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236589 268f45cc-cd09-0410-ab3c-d52691b4dbfc 66 67 2018-09-27 Saam barati <sbarati@apple.com> 68 69 Verify the contents of AssemblerBuffer on arm64e 70 https://bugs.webkit.org/show_bug.cgi?id=190057 71 <rdar://problem/38916630> 72 73 Reviewed by Mark Lam. 74 75 * stress/regress-189132.js: 76 1 77 2018-10-25 Kocsen Chung <kocsen_chung@apple.com> 2 78 -
branches/safari-606-branch/Source/JavaScriptCore/ChangeLog
r237439 r237470 1 2018-10-23 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r236589. rdar://problem/45285669 4 5 Verify the contents of AssemblerBuffer on arm64e 6 https://bugs.webkit.org/show_bug.cgi?id=190057 7 <rdar://problem/38916630> 8 9 Reviewed by Mark Lam. 10 11 JSTests: 12 13 * stress/regress-189132.js: 14 15 Source/JavaScriptCore: 16 17 * assembler/ARM64Assembler.h: 18 (JSC::ARM64Assembler::ARM64Assembler): 19 (JSC::ARM64Assembler::fillNops): 20 (JSC::ARM64Assembler::link): 21 (JSC::ARM64Assembler::linkJumpOrCall): 22 (JSC::ARM64Assembler::linkCompareAndBranch): 23 (JSC::ARM64Assembler::linkConditionalBranch): 24 (JSC::ARM64Assembler::linkTestAndBranch): 25 (JSC::ARM64Assembler::unlinkedCode): Deleted. 26 * assembler/ARMAssembler.h: 27 (JSC::ARMAssembler::fillNops): 28 * assembler/ARMv7Assembler.h: 29 (JSC::ARMv7Assembler::unlinkedCode): Deleted. 30 * assembler/AbstractMacroAssembler.h: 31 (JSC::AbstractMacroAssembler::emitNops): 32 (JSC::AbstractMacroAssembler::AbstractMacroAssembler): 33 * assembler/AssemblerBuffer.h: 34 (JSC::ARM64EHash::ARM64EHash): 35 (JSC::ARM64EHash::update): 36 (JSC::ARM64EHash::hash const): 37 (JSC::ARM64EHash::randomSeed const): 38 (JSC::AssemblerBuffer::AssemblerBuffer): 39 (JSC::AssemblerBuffer::putShort): 40 (JSC::AssemblerBuffer::putIntUnchecked): 41 (JSC::AssemblerBuffer::putInt): 42 (JSC::AssemblerBuffer::hash const): 43 (JSC::AssemblerBuffer::data const): 44 (JSC::AssemblerBuffer::putIntegralUnchecked): 45 (JSC::AssemblerBuffer::append): Deleted. 46 * assembler/LinkBuffer.cpp: 47 (JSC::LinkBuffer::copyCompactAndLinkCode): 48 * assembler/MIPSAssembler.h: 49 (JSC::MIPSAssembler::fillNops): 50 * assembler/MacroAssemblerARM64.h: 51 (JSC::MacroAssemblerARM64::jumpsToLink): 52 (JSC::MacroAssemblerARM64::link): 53 (JSC::MacroAssemblerARM64::unlinkedCode): Deleted. 54 * assembler/MacroAssemblerARMv7.h: 55 (JSC::MacroAssemblerARMv7::jumpsToLink): 56 (JSC::MacroAssemblerARMv7::unlinkedCode): Deleted. 57 * assembler/X86Assembler.h: 58 (JSC::X86Assembler::fillNops): 59 60 Source/WTF: 61 62 * wtf/PtrTag.h: 63 (WTF::tagInt): 64 65 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236589 268f45cc-cd09-0410-ab3c-d52691b4dbfc 66 67 2018-09-27 Saam barati <sbarati@apple.com> 68 69 Verify the contents of AssemblerBuffer on arm64e 70 https://bugs.webkit.org/show_bug.cgi?id=190057 71 <rdar://problem/38916630> 72 73 Reviewed by Mark Lam. 74 75 * assembler/ARM64Assembler.h: 76 (JSC::ARM64Assembler::ARM64Assembler): 77 (JSC::ARM64Assembler::fillNops): 78 (JSC::ARM64Assembler::link): 79 (JSC::ARM64Assembler::linkJumpOrCall): 80 (JSC::ARM64Assembler::linkCompareAndBranch): 81 (JSC::ARM64Assembler::linkConditionalBranch): 82 (JSC::ARM64Assembler::linkTestAndBranch): 83 (JSC::ARM64Assembler::unlinkedCode): Deleted. 84 * assembler/ARMAssembler.h: 85 (JSC::ARMAssembler::fillNops): 86 * assembler/ARMv7Assembler.h: 87 (JSC::ARMv7Assembler::unlinkedCode): Deleted. 88 * assembler/AbstractMacroAssembler.h: 89 (JSC::AbstractMacroAssembler::emitNops): 90 (JSC::AbstractMacroAssembler::AbstractMacroAssembler): 91 * assembler/AssemblerBuffer.h: 92 (JSC::ARM64EHash::ARM64EHash): 93 (JSC::ARM64EHash::update): 94 (JSC::ARM64EHash::hash const): 95 (JSC::ARM64EHash::randomSeed const): 96 (JSC::AssemblerBuffer::AssemblerBuffer): 97 (JSC::AssemblerBuffer::putShort): 98 (JSC::AssemblerBuffer::putIntUnchecked): 99 (JSC::AssemblerBuffer::putInt): 100 (JSC::AssemblerBuffer::hash const): 101 (JSC::AssemblerBuffer::data const): 102 (JSC::AssemblerBuffer::putIntegralUnchecked): 103 (JSC::AssemblerBuffer::append): Deleted. 104 * assembler/LinkBuffer.cpp: 105 (JSC::LinkBuffer::copyCompactAndLinkCode): 106 * assembler/MIPSAssembler.h: 107 (JSC::MIPSAssembler::fillNops): 108 * assembler/MacroAssemblerARM64.h: 109 (JSC::MacroAssemblerARM64::jumpsToLink): 110 (JSC::MacroAssemblerARM64::link): 111 (JSC::MacroAssemblerARM64::unlinkedCode): Deleted. 112 * assembler/MacroAssemblerARMv7.h: 113 (JSC::MacroAssemblerARMv7::jumpsToLink): 114 (JSC::MacroAssemblerARMv7::unlinkedCode): Deleted. 115 * assembler/X86Assembler.h: 116 (JSC::X86Assembler::fillNops): 117 1 118 2018-10-25 Kocsen Chung <kocsen_chung@apple.com> 2 119 -
branches/safari-606-branch/Source/JavaScriptCore/assembler/ARM64Assembler.h
r237439 r237470 319 319 320 320 public: 321 ARM64Assembler() 321 ARM64Assembler( 322 #if CPU(ARM64E) 323 unsigned randomNumber 324 #endif 325 ) 322 326 : m_indexOfLastWatchpoint(INT_MIN) 323 327 , m_indexOfTailOfLastWatchpoint(INT_MIN) 328 #if CPU(ARM64E) 329 , m_buffer(randomNumber) 330 #endif 331 324 332 { 325 333 } … … 1555 1563 } 1556 1564 1557 static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory) 1565 template <typename CopyFunction> 1566 static void fillNops(void* base, size_t size, CopyFunction copy) 1558 1567 { 1559 1568 RELEASE_ASSERT(!(size % sizeof(int32_t))); … … 1561 1570 for (int32_t* ptr = static_cast<int32_t*>(base); n--;) { 1562 1571 int insn = nopPseudo(); 1563 if (isCopyingToExecutableMemory) 1564 performJITMemcpy(ptr++, &insn, sizeof(int)); 1565 else 1566 memcpy(ptr++, &insn, sizeof(int)); 1572 copy(ptr++, &insn, sizeof(int)); 1567 1573 } 1568 1574 } … … 2569 2575 } 2570 2576 2571 void* unlinkedCode() { return m_buffer.data(); }2572 2577 size_t codeSize() const { return m_buffer.codeSize(); } 2573 2578 … … 2607 2612 } 2608 2613 2609 void linkJump(AssemblerLabel from, void* executableCode, AssemblerLabel to)2610 {2611 ASSERT(from.isSet());2612 ASSERT(to.isSet());2613 relinkJumpOrCall<false>(addressOf(from), addressOf(executableCode, from), addressOf(to));2614 }2615 2616 2614 static void linkJump(void* code, AssemblerLabel from, void* to) 2617 2615 { … … 2966 2964 } 2967 2965 2968 static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to) 2966 typedef void* (*CopyFunction)(void*, const void*, size_t); 2967 2968 static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to, CopyFunction copy) 2969 2969 { 2970 2970 const int* fromInstruction = reinterpret_cast<const int*>(fromInstruction8); 2971 2971 switch (record.linkType()) { 2972 2972 case LinkJumpNoCondition: 2973 linkJumpOrCall<false>(reinterpret_cast<int*>(from), fromInstruction, to );2973 linkJumpOrCall<false>(reinterpret_cast<int*>(from), fromInstruction, to, copy); 2974 2974 break; 2975 2975 case LinkJumpConditionDirect: 2976 linkConditionalBranch<true>(record.condition(), reinterpret_cast<int*>(from), fromInstruction, to );2976 linkConditionalBranch<true>(record.condition(), reinterpret_cast<int*>(from), fromInstruction, to, copy); 2977 2977 break; 2978 2978 case LinkJumpCondition: 2979 linkConditionalBranch<false>(record.condition(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to );2979 linkConditionalBranch<false>(record.condition(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy); 2980 2980 break; 2981 2981 case LinkJumpCompareAndBranchDirect: 2982 linkCompareAndBranch<true>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to );2982 linkCompareAndBranch<true>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to, copy); 2983 2983 break; 2984 2984 case LinkJumpCompareAndBranch: 2985 linkCompareAndBranch<false>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to );2985 linkCompareAndBranch<false>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy); 2986 2986 break; 2987 2987 case LinkJumpTestBitDirect: 2988 linkTestAndBranch<true>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to );2988 linkTestAndBranch<true>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to, copy); 2989 2989 break; 2990 2990 case LinkJumpTestBit: 2991 linkTestAndBranch<false>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to );2991 linkTestAndBranch<false>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy); 2992 2992 break; 2993 2993 default: … … 3031 3031 3032 3032 template<bool isCall> 3033 static void linkJumpOrCall(int* from, const int* fromInstruction, void* to )3033 static void linkJumpOrCall(int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy) 3034 3034 { 3035 3035 bool link; … … 3047 3047 3048 3048 int insn = unconditionalBranchImmediate(isCall, static_cast<int>(offset)); 3049 performJITMemcpy(from, &insn, sizeof(int));3049 copy(from, &insn, sizeof(int)); 3050 3050 } 3051 3051 3052 3052 template<bool isDirect> 3053 static void linkCompareAndBranch(Condition condition, bool is64Bit, RegisterID rt, int* from, const int* fromInstruction, void* to )3053 static void linkCompareAndBranch(Condition condition, bool is64Bit, RegisterID rt, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy) 3054 3054 { 3055 3055 ASSERT(!(reinterpret_cast<intptr_t>(from) & 3)); … … 3063 3063 if (useDirect || isDirect) { 3064 3064 int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, condition == ConditionNE, static_cast<int>(offset), rt); 3065 performJITMemcpy(from, &insn, sizeof(int));3065 copy(from, &insn, sizeof(int)); 3066 3066 if (!isDirect) { 3067 3067 insn = nopPseudo(); 3068 performJITMemcpy(from + 1, &insn, sizeof(int));3068 copy(from + 1, &insn, sizeof(int)); 3069 3069 } 3070 3070 } else { 3071 3071 int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, invert(condition) == ConditionNE, 2, rt); 3072 performJITMemcpy(from, &insn, sizeof(int));3073 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to );3072 copy(from, &insn, sizeof(int)); 3073 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy); 3074 3074 } 3075 3075 } 3076 3076 3077 3077 template<bool isDirect> 3078 static void linkConditionalBranch(Condition condition, int* from, const int* fromInstruction, void* to )3078 static void linkConditionalBranch(Condition condition, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy) 3079 3079 { 3080 3080 ASSERT(!(reinterpret_cast<intptr_t>(from) & 3)); … … 3088 3088 if (useDirect || isDirect) { 3089 3089 int insn = conditionalBranchImmediate(static_cast<int>(offset), condition); 3090 performJITMemcpy(from, &insn, sizeof(int));3090 copy(from, &insn, sizeof(int)); 3091 3091 if (!isDirect) { 3092 3092 insn = nopPseudo(); 3093 performJITMemcpy(from + 1, &insn, sizeof(int));3093 copy(from + 1, &insn, sizeof(int)); 3094 3094 } 3095 3095 } else { 3096 3096 int insn = conditionalBranchImmediate(2, invert(condition)); 3097 performJITMemcpy(from, &insn, sizeof(int));3098 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to );3097 copy(from, &insn, sizeof(int)); 3098 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy); 3099 3099 } 3100 3100 } 3101 3101 3102 3102 template<bool isDirect> 3103 static void linkTestAndBranch(Condition condition, unsigned bitNumber, RegisterID rt, int* from, const int* fromInstruction, void* to )3103 static void linkTestAndBranch(Condition condition, unsigned bitNumber, RegisterID rt, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy) 3104 3104 { 3105 3105 ASSERT(!(reinterpret_cast<intptr_t>(from) & 3)); … … 3114 3114 if (useDirect || isDirect) { 3115 3115 int insn = testAndBranchImmediate(condition == ConditionNE, static_cast<int>(bitNumber), static_cast<int>(offset), rt); 3116 performJITMemcpy(from, &insn, sizeof(int));3116 copy(from, &insn, sizeof(int)); 3117 3117 if (!isDirect) { 3118 3118 insn = nopPseudo(); 3119 performJITMemcpy(from + 1, &insn, sizeof(int));3119 copy(from + 1, &insn, sizeof(int)); 3120 3120 } 3121 3121 } else { 3122 3122 int insn = testAndBranchImmediate(invert(condition) == ConditionNE, static_cast<int>(bitNumber), 2, rt); 3123 performJITMemcpy(from, &insn, sizeof(int));3124 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to );3123 copy(from, &insn, sizeof(int)); 3124 linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy); 3125 3125 } 3126 3126 } … … 3178 3178 { 3179 3179 return reinterpret_cast<int*>(static_cast<char*>(code) + label.m_offset); 3180 }3181 3182 int* addressOf(AssemblerLabel label)3183 {3184 return addressOf(m_buffer.data(), label);3185 3180 } 3186 3181 … … 3760 3755 } 3761 3756 3762 AssemblerBuffer m_buffer;3763 3757 Vector<LinkRecord, 0, UnsafeVectorOverflow> m_jumpsToLink; 3764 3758 int m_indexOfLastWatchpoint; 3765 3759 int m_indexOfTailOfLastWatchpoint; 3760 AssemblerBuffer m_buffer; 3766 3761 3767 3762 public: -
branches/safari-606-branch/Source/JavaScriptCore/assembler/ARMAssembler.h
r237439 r237470 751 751 } 752 752 753 static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory) 754 { 755 UNUSED_PARAM(isCopyingToExecutableMemory); 753 template <typename CopyFunction> 754 static void fillNops(void* base, size_t size, CopyFunction copy) 755 { 756 UNUSED_PARAM(copy); 756 757 RELEASE_ASSERT(!(size % sizeof(int32_t))); 757 758 -
branches/safari-606-branch/Source/JavaScriptCore/assembler/ARMv7Assembler.h
r237439 r237470 2056 2056 } 2057 2057 2058 static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory) 2058 template <typename CopyFunction> 2059 static void fillNops(void* base, size_t size, CopyFunction copy) 2059 2060 { 2060 2061 RELEASE_ASSERT(!(size % sizeof(int16_t))); … … 2064 2065 for (size_t i = 0; i < num32s; i++) { 2065 2066 const int32_t insn = nopPseudo32(); 2066 if (isCopyingToExecutableMemory) 2067 performJITMemcpy(ptr, &insn, sizeof(int32_t)); 2068 else 2069 memcpy(ptr, &insn, sizeof(int32_t)); 2067 copy(ptr, &insn, sizeof(int32_t)); 2070 2068 ptr += sizeof(int32_t); 2071 2069 } … … 2076 2074 if (num16s) { 2077 2075 const int16_t insn = nopPseudo16(); 2078 if (isCopyingToExecutableMemory) 2079 performJITMemcpy(ptr, &insn, sizeof(int16_t)); 2080 else 2081 memcpy(ptr, &insn, sizeof(int16_t)); 2076 copy(ptr, &insn, sizeof(int16_t)); 2082 2077 } 2083 2078 } … … 2246 2241 } 2247 2242 2248 void* unlinkedCode() { return m_formatter.data(); }2249 2243 size_t codeSize() const { return m_formatter.codeSize(); } 2250 2244 -
branches/safari-606-branch/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h
r237439 r237470 863 863 } 864 864 865 AssemblerType m_assembler;866 867 865 template<PtrTag tag> 868 866 static void linkJump(void* code, Jump jump, CodeLocationLabel<tag> target) … … 963 961 void emitNops(size_t memoryToFillWithNopsInBytes) 964 962 { 963 #if CPU(ARM64) 964 RELEASE_ASSERT(memoryToFillWithNopsInBytes % 4 == 0); 965 for (unsigned i = 0; i < memoryToFillWithNopsInBytes / 4; ++i) 966 m_assembler.nop(); 967 #else 965 968 AssemblerBuffer& buffer = m_assembler.buffer(); 966 969 size_t startCodeSize = buffer.codeSize(); 967 970 size_t targetCodeSize = startCodeSize + memoryToFillWithNopsInBytes; 968 971 buffer.ensureSpace(memoryToFillWithNopsInBytes); 969 bool isCopyingToExecutableMemory = false; 970 AssemblerType::fillNops(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes, isCopyingToExecutableMemory); 972 AssemblerType::fillNops(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes, memcpy); 971 973 buffer.setCodeSize(targetCodeSize); 974 #endif 972 975 } 973 976 … … 984 987 AbstractMacroAssembler() 985 988 : m_randomSource(0) 989 #if CPU(ARM64E) 990 , m_assembler(random()) 991 #else 992 , m_assembler() 993 #endif 986 994 { 987 995 invalidateAllTempRegisters(); … … 999 1007 bool m_randomSourceIsInitialized { false }; 1000 1008 WeakRandom m_randomSource; 1009 public: 1010 AssemblerType m_assembler; 1011 protected: 1001 1012 1002 1013 #if ENABLE(DFG_REGISTER_ALLOCATION_VALIDATION) -
branches/safari-606-branch/Source/JavaScriptCore/assembler/AssemblerBuffer.h
r237439 r237470 34 34 #include <wtf/Assertions.h> 35 35 #include <wtf/FastMalloc.h> 36 #if CPU(ARM64E) 37 #include <wtf/PtrTag.h> 38 #endif 36 39 #include <wtf/StdLibExtras.h> 37 40 38 41 namespace JSC { 42 43 class LinkBuffer; 39 44 40 45 struct AssemblerLabel { … … 141 146 }; 142 147 148 #if CPU(ARM64E) 149 class ARM64EHash { 150 public: 151 ARM64EHash(unsigned randomNumber) 152 : m_hash(randomNumber) 153 , m_randomSeed(randomNumber) 154 { } 155 ALWAYS_INLINE void update(unsigned value, uintptr_t index) 156 { 157 m_hash = tagInt((static_cast<uintptr_t>(value) + m_hash) ^ (m_hash >> 32), static_cast<PtrTag>(index)); 158 } 159 uintptr_t hash() const { return m_hash; } 160 unsigned randomSeed() const { return m_randomSeed; } 161 private: 162 uintptr_t m_hash; 163 unsigned m_randomSeed; 164 }; 165 #endif 166 143 167 class AssemblerBuffer { 144 168 public: 145 AssemblerBuffer() 169 AssemblerBuffer( 170 #if CPU(ARM64E) 171 unsigned randomNumber 172 #endif 173 ) 146 174 : m_storage() 147 175 , m_index(0) 176 #if CPU(ARM64E) 177 , m_hash(randomNumber) 178 #endif 148 179 { 149 180 } … … 165 196 } 166 197 198 #if !CPU(ARM64) 167 199 void putByteUnchecked(int8_t value) { putIntegralUnchecked(value); } 168 200 void putByte(int8_t value) { putIntegral(value); } 169 201 void putShortUnchecked(int16_t value) { putIntegralUnchecked(value); } 170 202 void putShort(int16_t value) { putIntegral(value); } 203 void putInt64Unchecked(int64_t value) { putIntegralUnchecked(value); } 204 void putInt64(int64_t value) { putIntegral(value); } 205 #endif 171 206 void putIntUnchecked(int32_t value) { putIntegralUnchecked(value); } 172 207 void putInt(int32_t value) { putIntegral(value); } 173 void putInt64Unchecked(int64_t value) { putIntegralUnchecked(value); }174 void putInt64(int64_t value) { putIntegral(value); }175 176 void* data() const177 {178 return m_storage.buffer();179 }180 208 181 209 size_t codeSize() const … … 184 212 } 185 213 214 #if !CPU(ARM64) 186 215 void setCodeSize(size_t index) 187 216 { … … 192 221 ASSERT(m_index <= m_storage.capacity()); 193 222 } 223 #endif 194 224 195 225 AssemblerLabel label() const … … 209 239 // LocalWriter *CANNOT* be mixed with other types of access to AssemblerBuffer. 210 240 // AssemblerBuffer cannot be used until its LocalWriter goes out of scope. 241 #if !CPU(ARM64) // If we ever need to use this on arm64e, we would need to make the checksum aware of this. 211 242 class LocalWriter { 212 243 public: … … 251 282 #endif 252 283 }; 284 #endif // !CPU(ARM64) 285 286 #if CPU(ARM64E) 287 ARM64EHash hash() const { return m_hash; } 288 #endif 289 290 #if !CPU(ARM64) // If we were to define this on arm64e, we'd need a way to update the hash as we write directly into the buffer. 291 void* data() const { return m_storage.buffer(); } 292 #endif 293 253 294 254 295 protected: … … 267 308 void putIntegralUnchecked(IntegralType value) 268 309 { 310 #if CPU(ARM64) 311 static_assert(sizeof(value) == 4, ""); 312 #if CPU(ARM64E) 313 m_hash.update(value, m_index); 314 #endif 315 #endif 269 316 ASSERT(isAvailable(sizeof(IntegralType))); 270 317 *reinterpret_cast_ptr<IntegralType*>(m_storage.buffer() + m_index) = value; … … 272 319 } 273 320 274 void append(const char* data, int size) 275 { 276 if (!isAvailable(size)) 277 grow(size); 278 279 memcpy(m_storage.buffer() + m_index, data, size); 280 m_index += size; 281 } 282 321 private: 283 322 void grow(int extraCapacity = 0) 284 323 { … … 286 325 } 287 326 288 private:289 327 NEVER_INLINE void outOfLineGrow() 290 328 { … … 292 330 } 293 331 332 #if !CPU(ARM64) 294 333 friend LocalWriter; 334 #endif 335 friend LinkBuffer; 295 336 296 337 AssemblerData m_storage; 297 338 unsigned m_index; 339 #if CPU(ARM64E) 340 ARM64EHash m_hash; 341 #endif 298 342 }; 299 343 -
branches/safari-606-branch/Source/JavaScriptCore/assembler/LinkBuffer.cpp
r237439 r237470 110 110 uint8_t* inData = reinterpret_cast<uint8_t*>(m_assemblerStorage.buffer()); 111 111 112 uint8_t* codeOutData = m_code.dataLocation<uint8_t*>(); 113 #if CPU(ARM64E) 114 const ARM64EHash assemblerBufferHash = macroAssembler.m_assembler.buffer().hash(); 115 ARM64EHash verifyUncompactedHash(assemblerBufferHash.randomSeed()); 116 uint8_t* outData = codeOutData; 117 #else 112 118 AssemblerData outBuffer(m_size); 113 114 119 uint8_t* outData = reinterpret_cast<uint8_t*>(outBuffer.buffer()); 115 uint8_t* codeOutData = m_code.dataLocation<uint8_t*>(); 120 #endif 116 121 117 122 int readPtr = 0; 118 123 int writePtr = 0; 119 124 unsigned jumpCount = jumpsToLink.size(); 125 126 #if CPU(ARM64E) 127 os_thread_self_restrict_rwx_to_rw(); 128 #endif 129 120 130 if (m_shouldPerformBranchCompaction) { 121 131 for (unsigned i = 0; i < jumpCount; ++i) { … … 131 141 ASSERT(!(readPtr % 2)); 132 142 ASSERT(!(writePtr % 2)); 133 while (copySource != copyEnd) 134 *copyDst++ = *copySource++; 143 #if CPU(ARM64E) 144 unsigned index = readPtr; 145 #endif 146 while (copySource != copyEnd) { 147 InstructionType insn = *copySource++; 148 #if CPU(ARM64E) 149 static_assert(sizeof(InstructionType) == 4, ""); 150 verifyUncompactedHash.update(insn, index); 151 index += sizeof(InstructionType); 152 #endif 153 *copyDst++ = insn; 154 } 135 155 recordLinkOffsets(m_assemblerStorage, readPtr, jumpsToLink[i].from(), offset); 136 156 readPtr += regionSize; … … 163 183 } 164 184 } 185 165 186 // Copy everything after the last jump 166 memcpy(outData + writePtr, inData + readPtr, initialSize - readPtr); 187 { 188 InstructionType* dst = bitwise_cast<InstructionType*>(outData + writePtr); 189 InstructionType* src = bitwise_cast<InstructionType*>(inData + readPtr); 190 size_t bytes = initialSize - readPtr; 191 192 RELEASE_ASSERT(bitwise_cast<uintptr_t>(dst) % sizeof(InstructionType) == 0); 193 RELEASE_ASSERT(bitwise_cast<uintptr_t>(src) % sizeof(InstructionType) == 0); 194 RELEASE_ASSERT(bytes % sizeof(InstructionType) == 0); 195 196 #if CPU(ARM64E) 197 unsigned index = readPtr; 198 #endif 199 200 for (size_t i = 0; i < bytes; i += sizeof(InstructionType)) { 201 InstructionType insn = *src++; 202 #if CPU(ARM64E) 203 verifyUncompactedHash.update(insn, index); 204 index += sizeof(InstructionType); 205 #endif 206 *dst++ = insn; 207 } 208 } 209 210 #if CPU(ARM64E) 211 if (verifyUncompactedHash.hash() != assemblerBufferHash.hash()) { 212 dataLogLn("Hashes don't match: ", RawPointer(bitwise_cast<void*>(verifyUncompactedHash.hash())), " ", RawPointer(bitwise_cast<void*>(assemblerBufferHash.hash()))); 213 dataLogLn("Crashing!"); 214 CRASH(); 215 } 216 #endif 217 167 218 recordLinkOffsets(m_assemblerStorage, readPtr, initialSize, readPtr - writePtr); 168 219 169 220 for (unsigned i = 0; i < jumpCount; ++i) { 221 #if CPU(ARM64E) 222 auto memcpyFunction = memcpy; 223 #else 224 auto memcpyFunction = performJITMemcpy; 225 #endif 226 170 227 uint8_t* location = codeOutData + jumpsToLink[i].from(); 171 228 uint8_t* target = codeOutData + jumpsToLink[i].to() - executableOffsetFor(jumpsToLink[i].to()); 172 MacroAssembler::link(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target); 173 } 174 175 jumpsToLink.clear(); 229 MacroAssembler::link(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target, memcpyFunction); 230 } 176 231 177 232 size_t compactSize = writePtr + initialSize - readPtr; 233 if (!m_executableMemory) { 234 size_t nopSizeInBytes = initialSize - compactSize; 235 MacroAssembler::AssemblerType_T::fillNops(outData + compactSize, nopSizeInBytes, memcpy); 236 } 237 238 #if CPU(ARM64E) 239 os_thread_self_restrict_rwx_to_rx(); 240 #endif 241 178 242 if (m_executableMemory) { 179 243 m_size = compactSize; 180 244 m_executableMemory->shrink(m_size); 181 } else { 182 size_t nopSizeInBytes = initialSize - compactSize; 183 bool isCopyingToExecutableMemory = false; 184 MacroAssembler::AssemblerType_T::fillNops(outData + compactSize, nopSizeInBytes, isCopyingToExecutableMemory); 185 } 186 245 } 246 247 #if !CPU(ARM64E) 248 ASSERT(codeOutData != outData); 187 249 performJITMemcpy(codeOutData, outData, m_size); 250 #else 251 ASSERT(codeOutData == outData); 252 #endif 253 254 jumpsToLink.clear(); 188 255 189 256 #if DUMP_LINK_STATISTICS -
branches/safari-606-branch/Source/JavaScriptCore/assembler/MIPSAssembler.h
r237439 r237470 265 265 } 266 266 267 static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory) 268 { 269 UNUSED_PARAM(isCopyingToExecutableMemory); 267 template <typename CopyFunction> 268 static void fillNops(void* base, size_t size, CopyFunction copy) 269 { 270 UNUSED_PARAM(copy); 270 271 RELEASE_ASSERT(!(size % sizeof(int32_t))); 271 272 -
branches/safari-606-branch/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h
r237439 r237470 80 80 81 81 Vector<LinkRecord, 0, UnsafeVectorOverflow>& jumpsToLink() { return m_assembler.jumpsToLink(); } 82 void* unlinkedCode() { return m_assembler.unlinkedCode(); }83 82 static bool canCompact(JumpType jumpType) { return Assembler::canCompact(jumpType); } 84 83 static JumpLinkType computeJumpType(JumpType jumpType, const uint8_t* from, const uint8_t* to) { return Assembler::computeJumpType(jumpType, from, to); } 85 84 static JumpLinkType computeJumpType(LinkRecord& record, const uint8_t* from, const uint8_t* to) { return Assembler::computeJumpType(record, from, to); } 86 85 static int jumpSizeDelta(JumpType jumpType, JumpLinkType jumpLinkType) { return Assembler::jumpSizeDelta(jumpType, jumpLinkType); } 87 static void link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction, uint8_t* to) { return Assembler::link(record, from, fromInstruction, to); } 86 template <typename CopyFunction> 87 static void link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction, uint8_t* to, CopyFunction copy) { return Assembler::link(record, from, fromInstruction, to, copy); } 88 88 89 89 static const Scale ScalePtr = TimesEight; -
branches/safari-606-branch/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h
r237439 r237470 66 66 67 67 Vector<LinkRecord, 0, UnsafeVectorOverflow>& jumpsToLink() { return m_assembler.jumpsToLink(); } 68 void* unlinkedCode() { return m_assembler.unlinkedCode(); }69 68 static bool canCompact(JumpType jumpType) { return ARMv7Assembler::canCompact(jumpType); } 70 69 static JumpLinkType computeJumpType(JumpType jumpType, const uint8_t* from, const uint8_t* to) { return ARMv7Assembler::computeJumpType(jumpType, from, to); } -
branches/safari-606-branch/Source/JavaScriptCore/assembler/X86Assembler.h
r237439 r237470 3903 3903 } 3904 3904 3905 static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory) 3906 { 3907 UNUSED_PARAM(isCopyingToExecutableMemory); 3905 template <typename CopyFunction> 3906 static void fillNops(void* base, size_t size, CopyFunction copy) 3907 { 3908 UNUSED_PARAM(copy); 3908 3909 #if CPU(X86_64) 3909 3910 static const uint8_t nops[10][10] = { -
branches/safari-606-branch/Source/WTF/ChangeLog
r237439 r237470 1 2018-10-23 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r236589. rdar://problem/45285669 4 5 Verify the contents of AssemblerBuffer on arm64e 6 https://bugs.webkit.org/show_bug.cgi?id=190057 7 <rdar://problem/38916630> 8 9 Reviewed by Mark Lam. 10 11 JSTests: 12 13 * stress/regress-189132.js: 14 15 Source/JavaScriptCore: 16 17 * assembler/ARM64Assembler.h: 18 (JSC::ARM64Assembler::ARM64Assembler): 19 (JSC::ARM64Assembler::fillNops): 20 (JSC::ARM64Assembler::link): 21 (JSC::ARM64Assembler::linkJumpOrCall): 22 (JSC::ARM64Assembler::linkCompareAndBranch): 23 (JSC::ARM64Assembler::linkConditionalBranch): 24 (JSC::ARM64Assembler::linkTestAndBranch): 25 (JSC::ARM64Assembler::unlinkedCode): Deleted. 26 * assembler/ARMAssembler.h: 27 (JSC::ARMAssembler::fillNops): 28 * assembler/ARMv7Assembler.h: 29 (JSC::ARMv7Assembler::unlinkedCode): Deleted. 30 * assembler/AbstractMacroAssembler.h: 31 (JSC::AbstractMacroAssembler::emitNops): 32 (JSC::AbstractMacroAssembler::AbstractMacroAssembler): 33 * assembler/AssemblerBuffer.h: 34 (JSC::ARM64EHash::ARM64EHash): 35 (JSC::ARM64EHash::update): 36 (JSC::ARM64EHash::hash const): 37 (JSC::ARM64EHash::randomSeed const): 38 (JSC::AssemblerBuffer::AssemblerBuffer): 39 (JSC::AssemblerBuffer::putShort): 40 (JSC::AssemblerBuffer::putIntUnchecked): 41 (JSC::AssemblerBuffer::putInt): 42 (JSC::AssemblerBuffer::hash const): 43 (JSC::AssemblerBuffer::data const): 44 (JSC::AssemblerBuffer::putIntegralUnchecked): 45 (JSC::AssemblerBuffer::append): Deleted. 46 * assembler/LinkBuffer.cpp: 47 (JSC::LinkBuffer::copyCompactAndLinkCode): 48 * assembler/MIPSAssembler.h: 49 (JSC::MIPSAssembler::fillNops): 50 * assembler/MacroAssemblerARM64.h: 51 (JSC::MacroAssemblerARM64::jumpsToLink): 52 (JSC::MacroAssemblerARM64::link): 53 (JSC::MacroAssemblerARM64::unlinkedCode): Deleted. 54 * assembler/MacroAssemblerARMv7.h: 55 (JSC::MacroAssemblerARMv7::jumpsToLink): 56 (JSC::MacroAssemblerARMv7::unlinkedCode): Deleted. 57 * assembler/X86Assembler.h: 58 (JSC::X86Assembler::fillNops): 59 60 Source/WTF: 61 62 * wtf/PtrTag.h: 63 (WTF::tagInt): 64 65 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236589 268f45cc-cd09-0410-ab3c-d52691b4dbfc 66 67 2018-09-27 Saam barati <sbarati@apple.com> 68 69 Verify the contents of AssemblerBuffer on arm64e 70 https://bugs.webkit.org/show_bug.cgi?id=190057 71 <rdar://problem/38916630> 72 73 Reviewed by Mark Lam. 74 75 * wtf/PtrTag.h: 76 (WTF::tagInt): 77 1 78 2018-10-25 Kocsen Chung <kocsen_chung@apple.com> 2 79 -
branches/safari-606-branch/Source/WTF/wtf/PtrTag.h
r237439 r237470 148 148 inline PtrType untagCFunctionPtr(PtrType ptr) { return ptr; } 149 149 150 template <typename IntType> 151 inline IntType tagInt(IntType ptrInt, PtrTag) 152 { 153 static_assert(sizeof(IntType) == sizeof(uintptr_t), ""); 154 return ptrInt; 155 } 156 150 157 template<typename PtrType> void assertIsCFunctionPtr(PtrType) { } 151 158 template<typename PtrType> void assertIsNullOrCFunctionPtr(PtrType) { } … … 185 192 using WTF::tagCFunctionPtr; 186 193 using WTF::untagCFunctionPtr; 194 using WTF::tagInt; 187 195 188 196 using WTF::assertIsCFunctionPtr;
Note:
See TracChangeset
for help on using the changeset viewer.