Title: [257340] releases/WebKitGTK/webkit-2.28/Source
- Revision
- 257340
- Author
- carlo...@webkit.org
- Date
- 2020-02-25 08:02:17 -0800 (Tue, 25 Feb 2020)
Log Message
Merge r256498 - [JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately
https://bugs.webkit.org/show_bug.cgi?id=207673
Reviewed by Mark Lam.
Source/_javascript_Core:
While BytecodeIndex is 4 bytes, CodeLocation is 8 bytes. So the tuple of them "JITCodeMap::Entry"
becomes 16 bytes because it adds 4 bytes padding. We should store BytecodeIndex and CodeLocation separately
to avoid this padding.
This patch introduces JITCodeMapBuilder. We use this to build JITCodeMap data structure as a immutable final result.
* jit/JIT.cpp:
(JSC::JIT::link):
* jit/JITCodeMap.h:
(JSC::JITCodeMap::JITCodeMap):
(JSC::JITCodeMap::find const):
(JSC::JITCodeMap::operator bool const):
(JSC::JITCodeMap::codeLocations const):
(JSC::JITCodeMap::indexes const):
(JSC::JITCodeMapBuilder::append):
(JSC::JITCodeMapBuilder::finalize):
(JSC::JITCodeMap::Entry::Entry): Deleted.
(JSC::JITCodeMap::Entry::bytecodeIndex const): Deleted.
(JSC::JITCodeMap::Entry::codeLocation): Deleted.
(JSC::JITCodeMap::append): Deleted.
(JSC::JITCodeMap::finish): Deleted.
Source/WTF:
* wtf/MallocPtr.h:
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/ChangeLog (257339 => 257340)
--- releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/ChangeLog 2020-02-25 16:02:12 UTC (rev 257339)
+++ releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/ChangeLog 2020-02-25 16:02:17 UTC (rev 257340)
@@ -1,5 +1,34 @@
2020-02-12 Yusuke Suzuki <ysuz...@apple.com>
+ [JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately
+ https://bugs.webkit.org/show_bug.cgi?id=207673
+
+ Reviewed by Mark Lam.
+
+ While BytecodeIndex is 4 bytes, CodeLocation is 8 bytes. So the tuple of them "JITCodeMap::Entry"
+ becomes 16 bytes because it adds 4 bytes padding. We should store BytecodeIndex and CodeLocation separately
+ to avoid this padding.
+
+ This patch introduces JITCodeMapBuilder. We use this to build JITCodeMap data structure as a immutable final result.
+
+ * jit/JIT.cpp:
+ (JSC::JIT::link):
+ * jit/JITCodeMap.h:
+ (JSC::JITCodeMap::JITCodeMap):
+ (JSC::JITCodeMap::find const):
+ (JSC::JITCodeMap::operator bool const):
+ (JSC::JITCodeMap::codeLocations const):
+ (JSC::JITCodeMap::indexes const):
+ (JSC::JITCodeMapBuilder::append):
+ (JSC::JITCodeMapBuilder::finalize):
+ (JSC::JITCodeMap::Entry::Entry): Deleted.
+ (JSC::JITCodeMap::Entry::bytecodeIndex const): Deleted.
+ (JSC::JITCodeMap::Entry::codeLocation): Deleted.
+ (JSC::JITCodeMap::append): Deleted.
+ (JSC::JITCodeMap::finish): Deleted.
+
+2020-02-12 Yusuke Suzuki <ysuz...@apple.com>
+
[JSC] Compact StructureTransitionTable
https://bugs.webkit.org/show_bug.cgi?id=207616
Modified: releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/jit/JIT.cpp (257339 => 257340)
--- releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/jit/JIT.cpp 2020-02-25 16:02:12 UTC (rev 257339)
+++ releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/jit/JIT.cpp 2020-02-25 16:02:17 UTC (rev 257340)
@@ -912,13 +912,14 @@
patchBuffer.locationOfNearCall<JSInternalPtrTag>(compilationInfo.hotPathOther));
}
- JITCodeMap jitCodeMap;
- for (unsigned bytecodeOffset = 0; bytecodeOffset < m_labels.size(); ++bytecodeOffset) {
- if (m_labels[bytecodeOffset].isSet())
- jitCodeMap.append(BytecodeIndex(bytecodeOffset), patchBuffer.locationOf<JSEntryPtrTag>(m_labels[bytecodeOffset]));
+ {
+ JITCodeMapBuilder jitCodeMapBuilder;
+ for (unsigned bytecodeOffset = 0; bytecodeOffset < m_labels.size(); ++bytecodeOffset) {
+ if (m_labels[bytecodeOffset].isSet())
+ jitCodeMapBuilder.append(BytecodeIndex(bytecodeOffset), patchBuffer.locationOf<JSEntryPtrTag>(m_labels[bytecodeOffset]));
+ }
+ m_codeBlock->setJITCodeMap(jitCodeMapBuilder.finalize());
}
- jitCodeMap.finish();
- m_codeBlock->setJITCodeMap(WTFMove(jitCodeMap));
MacroAssemblerCodePtr<JSEntryPtrTag> withArityCheck = patchBuffer.locationOf<JSEntryPtrTag>(m_arityCheck);
Modified: releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/jit/JITCodeMap.h (257339 => 257340)
--- releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/jit/JITCodeMap.h 2020-02-25 16:02:12 UTC (rev 257339)
+++ releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/jit/JITCodeMap.h 2020-02-25 16:02:17 UTC (rev 257340)
@@ -34,47 +34,63 @@
namespace JSC {
class JITCodeMap {
+public:
+ static_assert(std::is_trivially_destructible_v<BytecodeIndex>);
+ static_assert(std::is_trivially_destructible_v<CodeLocationLabel<JSEntryPtrTag>>);
+ static_assert(alignof(CodeLocationLabel<JSEntryPtrTag>) >= alignof(BytecodeIndex), "Putting CodeLocationLabel vector first since we can avoid alignment consideration of BytecodeIndex vector");
+ JITCodeMap() = default;
+ JITCodeMap(Vector<BytecodeIndex>&& indexes, Vector<CodeLocationLabel<JSEntryPtrTag>>&& codeLocations)
+ : m_size(indexes.size())
+ {
+ ASSERT(indexes.size() == codeLocations.size());
+ m_pointer = MallocPtr<uint8_t>::malloc(sizeof(CodeLocationLabel<JSEntryPtrTag>) * m_size + sizeof(BytecodeIndex) * m_size);
+ std::copy(codeLocations.begin(), codeLocations.end(), this->codeLocations());
+ std::copy(indexes.begin(), indexes.end(), this->indexes());
+ }
+
+ CodeLocationLabel<JSEntryPtrTag> find(BytecodeIndex bytecodeIndex) const
+ {
+ auto* index = binarySearch<BytecodeIndex, BytecodeIndex>(indexes(), m_size, bytecodeIndex, [] (BytecodeIndex* index) { return *index; });
+ if (!index)
+ return CodeLocationLabel<JSEntryPtrTag>();
+ return codeLocations()[index - indexes()];
+ }
+
+ explicit operator bool() const { return m_size; }
+
private:
- struct Entry {
- Entry() { }
+ CodeLocationLabel<JSEntryPtrTag>* codeLocations() const
+ {
+ return bitwise_cast<CodeLocationLabel<JSEntryPtrTag>*>(m_pointer.get());
+ }
- Entry(BytecodeIndex bytecodeIndex, CodeLocationLabel<JSEntryPtrTag> codeLocation)
- : m_bytecodeIndex(bytecodeIndex)
- , m_codeLocation(codeLocation)
- { }
+ BytecodeIndex* indexes() const
+ {
+ return bitwise_cast<BytecodeIndex*>(m_pointer.get() + sizeof(CodeLocationLabel<JSEntryPtrTag>) * m_size);
+ }
- inline BytecodeIndex bytecodeIndex() const { return m_bytecodeIndex; }
- inline CodeLocationLabel<JSEntryPtrTag> codeLocation() { return m_codeLocation; }
+ MallocPtr<uint8_t> m_pointer;
+ unsigned m_size { 0 };
+};
- private:
- BytecodeIndex m_bytecodeIndex;
- CodeLocationLabel<JSEntryPtrTag> m_codeLocation;
- };
-
+class JITCodeMapBuilder {
+ WTF_MAKE_NONCOPYABLE(JITCodeMapBuilder);
public:
+ JITCodeMapBuilder() = default;
void append(BytecodeIndex bytecodeIndex, CodeLocationLabel<JSEntryPtrTag> codeLocation)
{
- m_entries.append({ bytecodeIndex, codeLocation });
+ m_indexes.append(bytecodeIndex);
+ m_codeLocations.append(codeLocation);
}
- void finish() { m_entries.shrinkToFit(); }
-
- CodeLocationLabel<JSEntryPtrTag> find(BytecodeIndex bytecodeIndex) const
+ JITCodeMap finalize()
{
- auto* entry =
- binarySearch<Entry, BytecodeIndex>(m_entries,
- m_entries.size(), bytecodeIndex, [] (Entry* entry) {
- return entry->bytecodeIndex();
- });
- if (!entry)
- return CodeLocationLabel<JSEntryPtrTag>();
- return entry->codeLocation();
+ return JITCodeMap(WTFMove(m_indexes), WTFMove(m_codeLocations));
}
- explicit operator bool() const { return m_entries.size(); }
-
private:
- Vector<Entry> m_entries;
+ Vector<BytecodeIndex> m_indexes;
+ Vector<CodeLocationLabel<JSEntryPtrTag>> m_codeLocations;
};
} // namespace JSC
Modified: releases/WebKitGTK/webkit-2.28/Source/WTF/ChangeLog (257339 => 257340)
--- releases/WebKitGTK/webkit-2.28/Source/WTF/ChangeLog 2020-02-25 16:02:12 UTC (rev 257339)
+++ releases/WebKitGTK/webkit-2.28/Source/WTF/ChangeLog 2020-02-25 16:02:17 UTC (rev 257340)
@@ -1,5 +1,14 @@
2020-02-12 Yusuke Suzuki <ysuz...@apple.com>
+ [JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately
+ https://bugs.webkit.org/show_bug.cgi?id=207673
+
+ Reviewed by Mark Lam.
+
+ * wtf/MallocPtr.h:
+
+2020-02-12 Yusuke Suzuki <ysuz...@apple.com>
+
Shrink CachedResource
https://bugs.webkit.org/show_bug.cgi?id=207618
Modified: releases/WebKitGTK/webkit-2.28/Source/WTF/wtf/MallocPtr.h (257339 => 257340)
--- releases/WebKitGTK/webkit-2.28/Source/WTF/wtf/MallocPtr.h 2020-02-25 16:02:12 UTC (rev 257339)
+++ releases/WebKitGTK/webkit-2.28/Source/WTF/wtf/MallocPtr.h 2020-02-25 16:02:17 UTC (rev 257340)
@@ -26,6 +26,7 @@
#pragma once
#include <wtf/FastMalloc.h>
+#include <wtf/Noncopyable.h>
// MallocPtr is a smart pointer class that calls fastFree in its destructor.
// It is intended to be used for pointers where the C++ lifetime semantics
@@ -34,6 +35,7 @@
namespace WTF {
template<typename T, typename Malloc = FastMalloc> class MallocPtr {
+ WTF_MAKE_NONCOPYABLE(MallocPtr);
public:
MallocPtr() = default;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes