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