Changeset 256498 in webkit
- Timestamp:
- Feb 12, 2020, 6:30:05 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/jit/JIT.cpp (modified) (1 diff)
-
JavaScriptCore/jit/JITCodeMap.h (modified) (1 diff)
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/MallocPtr.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r256497 r256498 1 2020-02-12 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately 4 https://bugs.webkit.org/show_bug.cgi?id=207673 5 6 Reviewed by Mark Lam. 7 8 While BytecodeIndex is 4 bytes, CodeLocation is 8 bytes. So the tuple of them "JITCodeMap::Entry" 9 becomes 16 bytes because it adds 4 bytes padding. We should store BytecodeIndex and CodeLocation separately 10 to avoid this padding. 11 12 This patch introduces JITCodeMapBuilder. We use this to build JITCodeMap data structure as a immutable final result. 13 14 * jit/JIT.cpp: 15 (JSC::JIT::link): 16 * jit/JITCodeMap.h: 17 (JSC::JITCodeMap::JITCodeMap): 18 (JSC::JITCodeMap::find const): 19 (JSC::JITCodeMap::operator bool const): 20 (JSC::JITCodeMap::codeLocations const): 21 (JSC::JITCodeMap::indexes const): 22 (JSC::JITCodeMapBuilder::append): 23 (JSC::JITCodeMapBuilder::finalize): 24 (JSC::JITCodeMap::Entry::Entry): Deleted. 25 (JSC::JITCodeMap::Entry::bytecodeIndex const): Deleted. 26 (JSC::JITCodeMap::Entry::codeLocation): Deleted. 27 (JSC::JITCodeMap::append): Deleted. 28 (JSC::JITCodeMap::finish): Deleted. 29 1 30 2020-02-12 Pavel Feldman <pavel.feldman@gmail.com> 2 31 -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r256015 r256498 913 913 } 914 914 915 JITCodeMap jitCodeMap; 916 for (unsigned bytecodeOffset = 0; bytecodeOffset < m_labels.size(); ++bytecodeOffset) { 917 if (m_labels[bytecodeOffset].isSet()) 918 jitCodeMap.append(BytecodeIndex(bytecodeOffset), patchBuffer.locationOf<JSEntryPtrTag>(m_labels[bytecodeOffset])); 919 } 920 jitCodeMap.finish(); 921 m_codeBlock->setJITCodeMap(WTFMove(jitCodeMap)); 915 { 916 JITCodeMapBuilder jitCodeMapBuilder; 917 for (unsigned bytecodeOffset = 0; bytecodeOffset < m_labels.size(); ++bytecodeOffset) { 918 if (m_labels[bytecodeOffset].isSet()) 919 jitCodeMapBuilder.append(BytecodeIndex(bytecodeOffset), patchBuffer.locationOf<JSEntryPtrTag>(m_labels[bytecodeOffset])); 920 } 921 m_codeBlock->setJITCodeMap(jitCodeMapBuilder.finalize()); 922 } 922 923 923 924 MacroAssemblerCodePtr<JSEntryPtrTag> withArityCheck = patchBuffer.locationOf<JSEntryPtrTag>(m_arityCheck); -
trunk/Source/JavaScriptCore/jit/JITCodeMap.h
r251468 r256498 35 35 36 36 class JITCodeMap { 37 private:38 struct Entry {39 Entry() { }40 41 Entry(BytecodeIndex bytecodeIndex, CodeLocationLabel<JSEntryPtrTag> codeLocation)42 : m_bytecodeIndex(bytecodeIndex)43 , m_codeLocation(codeLocation)44 { }45 46 inline BytecodeIndex bytecodeIndex() const { return m_bytecodeIndex; }47 inline CodeLocationLabel<JSEntryPtrTag> codeLocation() { return m_codeLocation; }48 49 private:50 BytecodeIndex m_bytecodeIndex;51 CodeLocationLabel<JSEntryPtrTag> m_codeLocation;52 };53 54 37 public: 55 void append(BytecodeIndex bytecodeIndex, CodeLocationLabel<JSEntryPtrTag> codeLocation) 38 static_assert(std::is_trivially_destructible_v<BytecodeIndex>); 39 static_assert(std::is_trivially_destructible_v<CodeLocationLabel<JSEntryPtrTag>>); 40 static_assert(alignof(CodeLocationLabel<JSEntryPtrTag>) >= alignof(BytecodeIndex), "Putting CodeLocationLabel vector first since we can avoid alignment consideration of BytecodeIndex vector"); 41 JITCodeMap() = default; 42 JITCodeMap(Vector<BytecodeIndex>&& indexes, Vector<CodeLocationLabel<JSEntryPtrTag>>&& codeLocations) 43 : m_size(indexes.size()) 56 44 { 57 m_entries.append({ bytecodeIndex, codeLocation }); 45 ASSERT(indexes.size() == codeLocations.size()); 46 m_pointer = MallocPtr<uint8_t>::malloc(sizeof(CodeLocationLabel<JSEntryPtrTag>) * m_size + sizeof(BytecodeIndex) * m_size); 47 std::copy(codeLocations.begin(), codeLocations.end(), this->codeLocations()); 48 std::copy(indexes.begin(), indexes.end(), this->indexes()); 58 49 } 59 60 void finish() { m_entries.shrinkToFit(); }61 50 62 51 CodeLocationLabel<JSEntryPtrTag> find(BytecodeIndex bytecodeIndex) const 63 52 { 64 auto* entry = 65 binarySearch<Entry, BytecodeIndex>(m_entries, 66 m_entries.size(), bytecodeIndex, [] (Entry* entry) { 67 return entry->bytecodeIndex(); 68 }); 69 if (!entry) 53 auto* index = binarySearch<BytecodeIndex, BytecodeIndex>(indexes(), m_size, bytecodeIndex, [] (BytecodeIndex* index) { return *index; }); 54 if (!index) 70 55 return CodeLocationLabel<JSEntryPtrTag>(); 71 return entry->codeLocation();56 return codeLocations()[index - indexes()]; 72 57 } 73 58 74 explicit operator bool() const { return m_ entries.size(); }59 explicit operator bool() const { return m_size; } 75 60 76 61 private: 77 Vector<Entry> m_entries; 62 CodeLocationLabel<JSEntryPtrTag>* codeLocations() const 63 { 64 return bitwise_cast<CodeLocationLabel<JSEntryPtrTag>*>(m_pointer.get()); 65 } 66 67 BytecodeIndex* indexes() const 68 { 69 return bitwise_cast<BytecodeIndex*>(m_pointer.get() + sizeof(CodeLocationLabel<JSEntryPtrTag>) * m_size); 70 } 71 72 MallocPtr<uint8_t> m_pointer; 73 unsigned m_size { 0 }; 74 }; 75 76 class JITCodeMapBuilder { 77 WTF_MAKE_NONCOPYABLE(JITCodeMapBuilder); 78 public: 79 JITCodeMapBuilder() = default; 80 void append(BytecodeIndex bytecodeIndex, CodeLocationLabel<JSEntryPtrTag> codeLocation) 81 { 82 m_indexes.append(bytecodeIndex); 83 m_codeLocations.append(codeLocation); 84 } 85 86 JITCodeMap finalize() 87 { 88 return JITCodeMap(WTFMove(m_indexes), WTFMove(m_codeLocations)); 89 } 90 91 private: 92 Vector<BytecodeIndex> m_indexes; 93 Vector<CodeLocationLabel<JSEntryPtrTag>> m_codeLocations; 78 94 }; 79 95 -
trunk/Source/WTF/ChangeLog
r256493 r256498 1 2020-02-12 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately 4 https://bugs.webkit.org/show_bug.cgi?id=207673 5 6 Reviewed by Mark Lam. 7 8 * wtf/MallocPtr.h: 9 1 10 2020-02-12 Ryan Haddad <ryanhaddad@apple.com> 2 11 -
trunk/Source/WTF/wtf/MallocPtr.h
r253987 r256498 27 27 28 28 #include <wtf/FastMalloc.h> 29 #include <wtf/Noncopyable.h> 29 30 30 31 // MallocPtr is a smart pointer class that calls fastFree in its destructor. … … 35 36 36 37 template<typename T, typename Malloc = FastMalloc> class MallocPtr { 38 WTF_MAKE_NONCOPYABLE(MallocPtr); 37 39 public: 38 40 MallocPtr() = default;
Note:
See TracChangeset
for help on using the changeset viewer.