- Revision
- 247843
- Author
- [email protected]
- Date
- 2019-07-25 15:51:28 -0700 (Thu, 25 Jul 2019)
Log Message
[JSC] Ensure PackedCellPtr only takes non-large-allocation pointers
https://bugs.webkit.org/show_bug.cgi?id=200139
Reviewed by Mark Lam.
PackedCellPtr will compact a pointer by leveraging the fact that JSCell pointers are 16byte aligned.
But this fact only holds when the JSCell is not large allocation. Currently, we are using PackedCellPtr
only for the cell types which meets the above requirement. But we would like to ensure that statically.
In this patch, we add additional static/runtime assertions to ensure this invariant. We accept a cell
type of either (1) it is "final" annotated and sizeof(T) is <= MarkedSpace::largeCutoff or (2) it
is allocated from IsoSubspace.
This patch does not change any behaviors. It just adds extra static/runtime assertions.
* bytecode/CodeBlock.h:
(JSC::CodeBlock::subspaceFor):
* bytecode/CodeBlockJettisoningWatchpoint.h:
* bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h:
* dfg/DFGAdaptiveStructureWatchpoint.h:
* heap/IsoSubspace.h:
* heap/PackedCellPtr.h:
(JSC::PackedCellPtr::PackedCellPtr):
* runtime/FunctionRareData.h:
(JSC::FunctionRareData::createAllocationProfileClearingWatchpoint):
* runtime/ObjectToStringAdaptiveStructureWatchpoint.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (247842 => 247843)
--- trunk/Source/_javascript_Core/ChangeLog 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-07-25 22:51:28 UTC (rev 247843)
@@ -1,5 +1,34 @@
2019-07-25 Yusuke Suzuki <[email protected]>
+ [JSC] Ensure PackedCellPtr only takes non-large-allocation pointers
+ https://bugs.webkit.org/show_bug.cgi?id=200139
+
+ Reviewed by Mark Lam.
+
+ PackedCellPtr will compact a pointer by leveraging the fact that JSCell pointers are 16byte aligned.
+ But this fact only holds when the JSCell is not large allocation. Currently, we are using PackedCellPtr
+ only for the cell types which meets the above requirement. But we would like to ensure that statically.
+
+ In this patch, we add additional static/runtime assertions to ensure this invariant. We accept a cell
+ type of either (1) it is "final" annotated and sizeof(T) is <= MarkedSpace::largeCutoff or (2) it
+ is allocated from IsoSubspace.
+
+ This patch does not change any behaviors. It just adds extra static/runtime assertions.
+
+ * bytecode/CodeBlock.h:
+ (JSC::CodeBlock::subspaceFor):
+ * bytecode/CodeBlockJettisoningWatchpoint.h:
+ * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h:
+ * dfg/DFGAdaptiveStructureWatchpoint.h:
+ * heap/IsoSubspace.h:
+ * heap/PackedCellPtr.h:
+ (JSC::PackedCellPtr::PackedCellPtr):
+ * runtime/FunctionRareData.h:
+ (JSC::FunctionRareData::createAllocationProfileClearingWatchpoint):
+ * runtime/ObjectToStringAdaptiveStructureWatchpoint.h:
+
+2019-07-25 Yusuke Suzuki <[email protected]>
+
[JSC] Make visitChildren implementation more idiomatic
https://bugs.webkit.org/show_bug.cgi?id=200121
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (247842 => 247843)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2019-07-25 22:51:28 UTC (rev 247843)
@@ -115,7 +115,7 @@
static const bool needsDestruction = true;
template<typename, SubspaceAccess>
- static void subspaceFor(VM&) { }
+ static IsoSubspace* subspaceFor(VM&) { return nullptr; }
DECLARE_INFO;
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlockJettisoningWatchpoint.h (247842 => 247843)
--- trunk/Source/_javascript_Core/bytecode/CodeBlockJettisoningWatchpoint.h 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlockJettisoningWatchpoint.h 2019-07-25 22:51:28 UTC (rev 247843)
@@ -25,13 +25,12 @@
#pragma once
+#include "CodeBlock.h"
#include "PackedCellPtr.h"
#include "Watchpoint.h"
namespace JSC {
-class CodeBlock;
-
class CodeBlockJettisoningWatchpoint final : public Watchpoint {
public:
CodeBlockJettisoningWatchpoint(CodeBlock* codeBlock)
Modified: trunk/Source/_javascript_Core/bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h (247842 => 247843)
--- trunk/Source/_javascript_Core/bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h 2019-07-25 22:51:28 UTC (rev 247843)
@@ -26,6 +26,7 @@
#pragma once
#include "BytecodeStructs.h"
+#include "CodeBlock.h"
#include "ObjectPropertyCondition.h"
#include "PackedCellPtr.h"
#include "Watchpoint.h"
Modified: trunk/Source/_javascript_Core/dfg/DFGAdaptiveStructureWatchpoint.h (247842 => 247843)
--- trunk/Source/_javascript_Core/dfg/DFGAdaptiveStructureWatchpoint.h 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/dfg/DFGAdaptiveStructureWatchpoint.h 2019-07-25 22:51:28 UTC (rev 247843)
@@ -27,6 +27,7 @@
#if ENABLE(DFG_JIT)
+#include "CodeBlock.h"
#include "ObjectPropertyCondition.h"
#include "PackedCellPtr.h"
#include "Watchpoint.h"
Modified: trunk/Source/_javascript_Core/heap/IsoSubspace.h (247842 => 247843)
--- trunk/Source/_javascript_Core/heap/IsoSubspace.h 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/heap/IsoSubspace.h 2019-07-25 22:51:28 UTC (rev 247843)
@@ -27,6 +27,7 @@
#include "BlockDirectory.h"
#include "Subspace.h"
+#include "SubspaceAccess.h"
#include <wtf/SinglyLinkedListWithTail.h>
namespace JSC {
@@ -69,5 +70,10 @@
#define ISO_SUBSPACE_INIT(heap, heapCellType, type) ("Isolated " #type " Space", (heap), (heapCellType), sizeof(type))
+template<typename T>
+struct isAllocatedFromIsoSubspace {
+ static constexpr bool value = std::is_same<std::invoke_result_t<decltype(T::template subspaceFor<T, SubspaceAccess::OnMainThread>), VM&>, IsoSubspace*>::value;
+};
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/heap/PackedCellPtr.h (247842 => 247843)
--- trunk/Source/_javascript_Core/heap/PackedCellPtr.h 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/heap/PackedCellPtr.h 2019-07-25 22:51:28 UTC (rev 247843)
@@ -25,12 +25,23 @@
#pragma once
+#include "IsoSubspace.h"
#include "MarkedBlock.h"
+#include "MarkedSpace.h"
#include <wtf/Packed.h>
namespace JSC {
template<typename T>
-using PackedCellPtr = PackedAlignedPtr<T, MarkedBlock::atomSize>;
+class PackedCellPtr : public PackedAlignedPtr<T, MarkedBlock::atomSize> {
+public:
+ using Base = PackedAlignedPtr<T, MarkedBlock::atomSize>;
+ PackedCellPtr(T* pointer)
+ : Base(pointer)
+ {
+ static_assert((sizeof(T) <= MarkedSpace::largeCutoff && std::is_final<T>::value) || isAllocatedFromIsoSubspace<T>::value, "LargeAllocation does not have 16byte alignment");
+ ASSERT(!(bitwise_cast<uintptr_t>(pointer) & (16 - 1)));
+ }
+};
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/FunctionRareData.h (247842 => 247843)
--- trunk/Source/_javascript_Core/runtime/FunctionRareData.h 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/runtime/FunctionRareData.h 2019-07-25 22:51:28 UTC (rev 247843)
@@ -107,27 +107,9 @@
void setHasReifiedName() { m_hasReifiedName = true; }
bool hasAllocationProfileClearingWatchpoint() const { return !!m_allocationProfileClearingWatchpoint; }
- Watchpoint* createAllocationProfileClearingWatchpoint()
- {
- RELEASE_ASSERT(!hasAllocationProfileClearingWatchpoint());
- m_allocationProfileClearingWatchpoint = std::make_unique<AllocationProfileClearingWatchpoint>(this);
- return m_allocationProfileClearingWatchpoint.get();
- }
+ Watchpoint* createAllocationProfileClearingWatchpoint();
+ class AllocationProfileClearingWatchpoint;
- class AllocationProfileClearingWatchpoint final : public Watchpoint {
- public:
- AllocationProfileClearingWatchpoint(FunctionRareData* rareData)
- : Watchpoint(Watchpoint::Type::FunctionRareDataAllocationProfileClearing)
- , m_rareData(rareData)
- { }
-
- void fireInternal(VM&, const FireDetail&);
-
- private:
- // Own destructor may not be called. Keep members trivially destructible.
- JSC_WATCHPOINT_FIELD(PackedCellPtr<FunctionRareData>, m_rareData);
- };
-
protected:
FunctionRareData(VM&);
~FunctionRareData();
@@ -157,4 +139,25 @@
bool m_hasReifiedName { false };
};
+class FunctionRareData::AllocationProfileClearingWatchpoint final : public Watchpoint {
+public:
+ AllocationProfileClearingWatchpoint(FunctionRareData* rareData)
+ : Watchpoint(Watchpoint::Type::FunctionRareDataAllocationProfileClearing)
+ , m_rareData(rareData)
+ { }
+
+ void fireInternal(VM&, const FireDetail&);
+
+private:
+ // Own destructor may not be called. Keep members trivially destructible.
+ JSC_WATCHPOINT_FIELD(PackedCellPtr<FunctionRareData>, m_rareData);
+};
+
+inline Watchpoint* FunctionRareData::createAllocationProfileClearingWatchpoint()
+{
+ RELEASE_ASSERT(!hasAllocationProfileClearingWatchpoint());
+ m_allocationProfileClearingWatchpoint = std::make_unique<AllocationProfileClearingWatchpoint>(this);
+ return m_allocationProfileClearingWatchpoint.get();
+}
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/ObjectToStringAdaptiveStructureWatchpoint.h (247842 => 247843)
--- trunk/Source/_javascript_Core/runtime/ObjectToStringAdaptiveStructureWatchpoint.h 2019-07-25 22:25:15 UTC (rev 247842)
+++ trunk/Source/_javascript_Core/runtime/ObjectToStringAdaptiveStructureWatchpoint.h 2019-07-25 22:51:28 UTC (rev 247843)
@@ -27,6 +27,7 @@
#include "ObjectPropertyCondition.h"
#include "PackedCellPtr.h"
+#include "StructureRareData.h"
#include "Watchpoint.h"
namespace JSC {