Commit 74aa3ad0 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Add trivial BodyDescriptorWeak for objects without weak fields.

This patch also changes the visitor of BytecodeArray to use
BytecodeArray::BodyDescriptor.

BUG=chromium:733159

Change-Id: I2ac72c97ec51996b5b100c447b543895180f4f78
Reviewed-on: https://chromium-review.googlesource.com/535674Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45955}
parent 8b5fe28c
...@@ -158,7 +158,7 @@ void StaticMarkingVisitor<StaticVisitor>::Initialize() { ...@@ -158,7 +158,7 @@ void StaticMarkingVisitor<StaticVisitor>::Initialize() {
table_.Register( table_.Register(
kVisitAllocationSite, kVisitAllocationSite,
&FixedBodyVisitor<StaticVisitor, AllocationSite::MarkingBodyDescriptor, &FixedBodyVisitor<StaticVisitor, AllocationSite::BodyDescriptorWeak,
void>::Visit); void>::Visit);
table_.Register(kVisitByteArray, &DataObjectVisitor::Visit); table_.Register(kVisitByteArray, &DataObjectVisitor::Visit);
...@@ -295,8 +295,8 @@ void StaticMarkingVisitor<StaticVisitor>::VisitCodeAgeSequence( ...@@ -295,8 +295,8 @@ void StaticMarkingVisitor<StaticVisitor>::VisitCodeAgeSequence(
template <typename StaticVisitor> template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::VisitBytecodeArray( void StaticMarkingVisitor<StaticVisitor>::VisitBytecodeArray(
Map* map, HeapObject* object) { Map* map, HeapObject* object) {
FixedBodyVisitor<StaticVisitor, BytecodeArray::MarkingBodyDescriptor, FlexibleBodyVisitor<StaticVisitor, BytecodeArray::BodyDescriptor,
void>::Visit(map, object); void>::Visit(map, object);
BytecodeArray::cast(object)->MakeOlder(); BytecodeArray::cast(object)->MakeOlder();
} }
......
...@@ -370,7 +370,7 @@ class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase { ...@@ -370,7 +370,7 @@ class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase {
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
if (body_visiting_policy == kVisitStrong) { if (body_visiting_policy == kIgnoreWeakness) {
IterateBodyImpl(obj, kPropertiesOffset, object_size, v); IterateBodyImpl(obj, kPropertiesOffset, object_size, v);
} else { } else {
IteratePointers(obj, kPropertiesOffset, kTableOffset, v); IteratePointers(obj, kPropertiesOffset, kTableOffset, v);
...@@ -381,7 +381,7 @@ class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase { ...@@ -381,7 +381,7 @@ class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase {
template <typename StaticVisitor> template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj, int object_size) { static inline void IterateBody(HeapObject* obj, int object_size) {
Heap* heap = obj->GetHeap(); Heap* heap = obj->GetHeap();
if (body_visiting_policy == kVisitStrong) { if (body_visiting_policy == kIgnoreWeakness) {
IterateBodyImpl<StaticVisitor>(heap, obj, kPropertiesOffset, object_size); IterateBodyImpl<StaticVisitor>(heap, obj, kPropertiesOffset, object_size);
} else { } else {
IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset,
......
...@@ -2587,7 +2587,12 @@ class JSObject: public JSReceiver { ...@@ -2587,7 +2587,12 @@ class JSObject: public JSReceiver {
(kMaxInstanceSize - kHeaderSize) >> kPointerSizeLog2; (kMaxInstanceSize - kHeaderSize) >> kPointerSizeLog2;
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
class FastBodyDescriptor; class FastBodyDescriptor;
// No weak fields.
typedef FastBodyDescriptor FastBodyDescriptorWeak;
// Gets the number of currently used elements. // Gets the number of currently used elements.
int GetFastElementsUsage(); int GetFastElementsUsage();
...@@ -2804,6 +2809,8 @@ class FixedArray: public FixedArrayBase { ...@@ -2804,6 +2809,8 @@ class FixedArray: public FixedArrayBase {
#endif #endif
typedef FlexibleBodyDescriptor<kHeaderSize> BodyDescriptor; typedef FlexibleBodyDescriptor<kHeaderSize> BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
protected: protected:
// Set operation on FixedArray without using write barriers. Can // Set operation on FixedArray without using write barriers. Can
...@@ -2861,6 +2868,8 @@ class FixedDoubleArray: public FixedArrayBase { ...@@ -2861,6 +2868,8 @@ class FixedDoubleArray: public FixedArrayBase {
DECLARE_VERIFIER(FixedDoubleArray) DECLARE_VERIFIER(FixedDoubleArray)
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray);
...@@ -3132,6 +3141,8 @@ class ByteArray: public FixedArrayBase { ...@@ -3132,6 +3141,8 @@ class ByteArray: public FixedArrayBase {
static const int kMaxLength = kMaxSize - kHeaderSize; static const int kMaxLength = kMaxSize - kHeaderSize;
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
...@@ -3269,11 +3280,9 @@ class BytecodeArray : public FixedArrayBase { ...@@ -3269,11 +3280,9 @@ class BytecodeArray : public FixedArrayBase {
static const int kPointerFieldsBeginOffset = kConstantPoolOffset; static const int kPointerFieldsBeginOffset = kConstantPoolOffset;
static const int kPointerFieldsEndOffset = kFrameSizeOffset; static const int kPointerFieldsEndOffset = kFrameSizeOffset;
typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
kPointerFieldsEndOffset, kHeaderSize>
MarkingBodyDescriptor;
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray); DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray);
...@@ -3362,6 +3371,8 @@ class FixedTypedArrayBase: public FixedArrayBase { ...@@ -3362,6 +3371,8 @@ class FixedTypedArrayBase: public FixedArrayBase {
static const size_t kMaxLength = Smi::kMaxValue; static const size_t kMaxLength = Smi::kMaxValue;
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
inline int size(); inline int size();
...@@ -5414,6 +5425,8 @@ class JSMessageObject: public JSObject { ...@@ -5414,6 +5425,8 @@ class JSMessageObject: public JSObject {
typedef FixedBodyDescriptor<HeapObject::kMapOffset, typedef FixedBodyDescriptor<HeapObject::kMapOffset,
kStackFramesOffset + kPointerSize, kStackFramesOffset + kPointerSize,
kSize> BodyDescriptor; kSize> BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
}; };
class JSPromise; class JSPromise;
...@@ -5819,14 +5832,15 @@ class AllocationSite: public Struct { ...@@ -5819,14 +5832,15 @@ class AllocationSite: public Struct {
static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; static const int kPointerFieldsBeginOffset = kTransitionInfoOffset;
static const int kPointerFieldsEndOffset = kWeakNextOffset; static const int kPointerFieldsEndOffset = kWeakNextOffset;
typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, // Ignores weakness.
kPointerFieldsEndOffset, kSize>
MarkingBodyDescriptor;
// For other visitors, use the fixed body descriptor below.
typedef FixedBodyDescriptor<HeapObject::kHeaderSize, kSize, kSize> typedef FixedBodyDescriptor<HeapObject::kHeaderSize, kSize, kSize>
BodyDescriptor; BodyDescriptor;
// Respects weakness.
typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
kPointerFieldsEndOffset, kSize>
BodyDescriptorWeak;
private: private:
inline bool PretenuringDecisionMade(); inline bool PretenuringDecisionMade();
...@@ -5947,6 +5961,8 @@ class Oddball: public HeapObject { ...@@ -5947,6 +5961,8 @@ class Oddball: public HeapObject {
typedef FixedBodyDescriptor<kToStringOffset, kTypeOfOffset + kPointerSize, typedef FixedBodyDescriptor<kToStringOffset, kTypeOfOffset + kPointerSize,
kSize> BodyDescriptor; kSize> BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
STATIC_ASSERT(kToNumberRawOffset == HeapNumber::kValueOffset); STATIC_ASSERT(kToNumberRawOffset == HeapNumber::kValueOffset);
STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset); STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset);
...@@ -5985,6 +6001,8 @@ class Cell: public HeapObject { ...@@ -5985,6 +6001,8 @@ class Cell: public HeapObject {
typedef FixedBodyDescriptor<kValueOffset, typedef FixedBodyDescriptor<kValueOffset,
kValueOffset + kPointerSize, kValueOffset + kPointerSize,
kSize> BodyDescriptor; kSize> BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Cell); DISALLOW_IMPLICIT_CONSTRUCTORS(Cell);
...@@ -6039,6 +6057,8 @@ class PropertyCell : public HeapObject { ...@@ -6039,6 +6057,8 @@ class PropertyCell : public HeapObject {
typedef FixedBodyDescriptor<kValueOffset, typedef FixedBodyDescriptor<kValueOffset,
kSize, kSize,
kSize> BodyDescriptor; kSize> BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PropertyCell); DISALLOW_IMPLICIT_CONSTRUCTORS(PropertyCell);
...@@ -6172,6 +6192,8 @@ class JSProxy: public JSReceiver { ...@@ -6172,6 +6192,8 @@ class JSProxy: public JSReceiver {
typedef FixedBodyDescriptor<JSReceiver::kPropertiesOffset, kSize, kSize> typedef FixedBodyDescriptor<JSReceiver::kPropertiesOffset, kSize, kSize>
BodyDescriptor; BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
static Object* GetIdentityHash(Handle<JSProxy> receiver); static Object* GetIdentityHash(Handle<JSProxy> receiver);
...@@ -6340,17 +6362,17 @@ class JSWeakCollection: public JSObject { ...@@ -6340,17 +6362,17 @@ class JSWeakCollection: public JSObject {
// Visiting policy defines whether the table and next collection fields // Visiting policy defines whether the table and next collection fields
// should be visited or not. // should be visited or not.
enum BodyVisitingPolicy { kVisitStrong, kVisitWeak }; enum BodyVisitingPolicy { kIgnoreWeakness, kRespectWeakness };
// Iterates the function object according to the visiting policy. // Iterates the function object according to the visiting policy.
template <BodyVisitingPolicy> template <BodyVisitingPolicy>
class BodyDescriptorImpl; class BodyDescriptorImpl;
// Visit the whole object. // Visit the whole object.
typedef BodyDescriptorImpl<kVisitStrong> BodyDescriptor; typedef BodyDescriptorImpl<kIgnoreWeakness> BodyDescriptor;
// Don't visit table and next collection fields. // Don't visit table and next collection fields.
typedef BodyDescriptorImpl<kVisitWeak> BodyDescriptorWeak; typedef BodyDescriptorImpl<kRespectWeakness> BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection); DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection);
...@@ -6482,6 +6504,8 @@ class JSArrayBuffer: public JSObject { ...@@ -6482,6 +6504,8 @@ class JSArrayBuffer: public JSObject {
// Iterates all fields in the object including internal ones except // Iterates all fields in the object including internal ones except
// kBackingStoreOffset and kBitFieldSlot. // kBackingStoreOffset and kBitFieldSlot.
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
class IsExternal : public BitField<bool, 1, 1> {}; class IsExternal : public BitField<bool, 1, 1> {};
class IsNeuterable : public BitField<bool, 2, 1> {}; class IsNeuterable : public BitField<bool, 2, 1> {};
...@@ -6619,6 +6643,8 @@ class Foreign: public HeapObject { ...@@ -6619,6 +6643,8 @@ class Foreign: public HeapObject {
STATIC_ASSERT(kForeignAddressOffset == Internals::kForeignAddressOffset); STATIC_ASSERT(kForeignAddressOffset == Internals::kForeignAddressOffset);
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign); DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign);
......
...@@ -653,6 +653,8 @@ class SmallOrderedHashTable : public HeapObject { ...@@ -653,6 +653,8 @@ class SmallOrderedHashTable : public HeapObject {
// Iterates only fields in the DataTable. // Iterates only fields in the DataTable.
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
// Returns an SmallOrderedHashTable (possibly |table|) with enough // Returns an SmallOrderedHashTable (possibly |table|) with enough
// space to add at least one new element. // space to add at least one new element.
......
...@@ -161,6 +161,8 @@ class Symbol : public Name { ...@@ -161,6 +161,8 @@ class Symbol : public Name {
static const int kPublicBit = 2; static const int kPublicBit = 2;
typedef FixedBodyDescriptor<kNameOffset, kFlagsOffset, kSize> BodyDescriptor; typedef FixedBodyDescriptor<kNameOffset, kFlagsOffset, kSize> BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
void SymbolShortPrint(std::ostream& os); void SymbolShortPrint(std::ostream& os);
......
...@@ -468,8 +468,8 @@ class SharedFunctionInfo : public HeapObject { ...@@ -468,8 +468,8 @@ class SharedFunctionInfo : public HeapObject {
typedef FixedBodyDescriptor<kCodeOffset, kEndOfPointerFieldsOffset, kSize> typedef FixedBodyDescriptor<kCodeOffset, kEndOfPointerFieldsOffset, kSize>
BodyDescriptor; BodyDescriptor;
typedef FixedBodyDescriptor<kNameOffset, kEndOfPointerFieldsOffset, kSize> // No weak fields.
BodyDescriptorWeakCode; typedef BodyDescriptor BodyDescriptorWeak;
// Bit fields in |start_position_and_type|. // Bit fields in |start_position_and_type|.
#define START_POSITION_AND_TYPE_BIT_FIELDS(V, _) \ #define START_POSITION_AND_TYPE_BIT_FIELDS(V, _) \
......
...@@ -505,6 +505,8 @@ class SeqOneByteString : public SeqString { ...@@ -505,6 +505,8 @@ class SeqOneByteString : public SeqString {
STATIC_ASSERT((kMaxSize - kHeaderSize) >= String::kMaxLength); STATIC_ASSERT((kMaxSize - kHeaderSize) >= String::kMaxLength);
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(SeqOneByteString); DISALLOW_IMPLICIT_CONSTRUCTORS(SeqOneByteString);
...@@ -546,6 +548,8 @@ class SeqTwoByteString : public SeqString { ...@@ -546,6 +548,8 @@ class SeqTwoByteString : public SeqString {
String::kMaxLength); String::kMaxLength);
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString); DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString);
...@@ -592,6 +596,8 @@ class ConsString : public String { ...@@ -592,6 +596,8 @@ class ConsString : public String {
typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize>
BodyDescriptor; BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
DECLARE_VERIFIER(ConsString) DECLARE_VERIFIER(ConsString)
...@@ -623,6 +629,8 @@ class ThinString : public String { ...@@ -623,6 +629,8 @@ class ThinString : public String {
static const int kSize = kActualOffset + kPointerSize; static const int kSize = kActualOffset + kPointerSize;
typedef FixedBodyDescriptor<kActualOffset, kSize, kSize> BodyDescriptor; typedef FixedBodyDescriptor<kActualOffset, kSize, kSize> BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_COPY_AND_ASSIGN(ThinString); DISALLOW_COPY_AND_ASSIGN(ThinString);
...@@ -664,6 +672,8 @@ class SlicedString : public String { ...@@ -664,6 +672,8 @@ class SlicedString : public String {
typedef FixedBodyDescriptor<kParentOffset, kOffsetOffset + kPointerSize, typedef FixedBodyDescriptor<kParentOffset, kOffsetOffset + kPointerSize,
kSize> kSize>
BodyDescriptor; BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
DECLARE_VERIFIER(SlicedString) DECLARE_VERIFIER(SlicedString)
...@@ -725,6 +735,8 @@ class ExternalOneByteString : public ExternalString { ...@@ -725,6 +735,8 @@ class ExternalOneByteString : public ExternalString {
DECLARE_CAST(ExternalOneByteString) DECLARE_CAST(ExternalOneByteString)
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalOneByteString); DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalOneByteString);
...@@ -759,6 +771,8 @@ class ExternalTwoByteString : public ExternalString { ...@@ -759,6 +771,8 @@ class ExternalTwoByteString : public ExternalString {
DECLARE_CAST(ExternalTwoByteString) DECLARE_CAST(ExternalTwoByteString)
class BodyDescriptor; class BodyDescriptor;
// No weak fields.
typedef BodyDescriptor BodyDescriptorWeak;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment