Commit 6b6d0819 authored by Creddy's avatar Creddy Committed by Commit Bot

Make PretenureDataOffset and PretenureCreateCount as Int32 fields instead of IntPtr

in AllocationSite

Change-Id: I2efaa698c35b4c0212248b4b1c08e017c2ead708

Bug: v8:7787, chromium:818642
Change-Id: I2efaa698c35b4c0212248b4b1c08e017c2ead708
Reviewed-on: https://chromium-review.googlesource.com/1103575
Commit-Queue: Chandan Reddy <chandanreddy@google.com>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54030}
parent edec05ea
...@@ -4300,12 +4300,14 @@ void CodeStubAssembler::InitializeAllocationMemento(Node* base, ...@@ -4300,12 +4300,14 @@ void CodeStubAssembler::InitializeAllocationMemento(Node* base,
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(
memento, AllocationMemento::kAllocationSiteOffset, allocation_site); memento, AllocationMemento::kAllocationSiteOffset, allocation_site);
if (FLAG_allocation_site_pretenuring) { if (FLAG_allocation_site_pretenuring) {
TNode<Smi> count = CAST(LoadObjectField( TNode<Int32T> count = UncheckedCast<Int32T>(LoadObjectField(
allocation_site, AllocationSite::kPretenureCreateCountOffset)); allocation_site, AllocationSite::kPretenureCreateCountOffset,
TNode<Smi> incremented_count = SmiAdd(count, SmiConstant(1)); MachineType::Int32()));
StoreObjectFieldNoWriteBarrier(allocation_site,
AllocationSite::kPretenureCreateCountOffset, TNode<Int32T> incremented_count = Int32Add(count, Int32Constant(1));
incremented_count); StoreObjectFieldNoWriteBarrier(
allocation_site, AllocationSite::kPretenureCreateCountOffset,
incremented_count, MachineRepresentation::kWord32);
} }
Comment("]"); Comment("]");
} }
...@@ -9438,11 +9440,13 @@ TNode<AllocationSite> CodeStubAssembler::CreateAllocationSiteInFeedbackVector( ...@@ -9438,11 +9440,13 @@ TNode<AllocationSite> CodeStubAssembler::CreateAllocationSiteInFeedbackVector(
// Pretenuring calculation field. // Pretenuring calculation field.
StoreObjectFieldNoWriteBarrier(site, AllocationSite::kPretenureDataOffset, StoreObjectFieldNoWriteBarrier(site, AllocationSite::kPretenureDataOffset,
zero); Int32Constant(0),
MachineRepresentation::kWord32);
// Pretenuring memento creation count field. // Pretenuring memento creation count field.
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(
site, AllocationSite::kPretenureCreateCountOffset, zero); site, AllocationSite::kPretenureCreateCountOffset, Int32Constant(0),
MachineRepresentation::kWord32);
// Store an empty fixed array for the code dependency. // Store an empty fixed array for the code dependency.
StoreObjectFieldRoot(site, AllocationSite::kDependentCodeOffset, StoreObjectFieldRoot(site, AllocationSite::kDependentCodeOffset,
......
...@@ -152,25 +152,44 @@ class JSFunction::BodyDescriptor final : public BodyDescriptorBase { ...@@ -152,25 +152,44 @@ class JSFunction::BodyDescriptor final : public BodyDescriptorBase {
template <bool includeWeakNext> template <bool includeWeakNext>
class AllocationSite::BodyDescriptorImpl final : public BodyDescriptorBase { class AllocationSite::BodyDescriptorImpl final : public BodyDescriptorBase {
public: public:
STATIC_ASSERT(AllocationSite::kCommonPointerFieldEndOffset ==
AllocationSite::kPretenureDataOffset);
STATIC_ASSERT(AllocationSite::kPretenureDataOffset + kInt32Size ==
AllocationSite::kPretenureCreateCountOffset);
STATIC_ASSERT(AllocationSite::kPretenureCreateCountOffset + kInt32Size ==
AllocationSite::kWeakNextOffset);
static bool IsValidSlot(Map* map, HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return offset >= AllocationSite::kStartOffset && offset < GetEndOffset(map); if (offset >= AllocationSite::kStartOffset &&
offset < AllocationSite::kCommonPointerFieldEndOffset) {
return true;
}
// check for weak_next offset
if (includeWeakNext &&
map->instance_size() == AllocationSite::kSizeWithWeakNext &&
offset == AllocationSite::kWeakNextOffset) {
return true;
}
return false;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(Map* map, HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IteratePointers(obj, AllocationSite::kStartOffset, GetEndOffset(map), v); // Iterate over all the common pointer fields
IteratePointers(obj, AllocationSite::kStartOffset,
AllocationSite::kCommonPointerFieldEndOffset, v);
// Skip PretenureDataOffset and PretenureCreateCount which are Int32 fields
// Visit weak_next only for full body descriptor and if it has weak_next
// field
if (includeWeakNext && object_size == AllocationSite::kSizeWithWeakNext)
IteratePointers(obj, AllocationSite::kWeakNextOffset,
AllocationSite::kSizeWithWeakNext, v);
} }
static inline int SizeOf(Map* map, HeapObject* object) { static inline int SizeOf(Map* map, HeapObject* object) {
return map->instance_size(); return map->instance_size();
} }
private:
static inline int GetEndOffset(Map* map) {
return includeWeakNext ? map->instance_size()
: AllocationSite::kSizeWithoutWeakNext;
}
}; };
class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase {
......
...@@ -1233,7 +1233,7 @@ AllocationSite::PretenureDecision AllocationSite::pretenure_decision() const { ...@@ -1233,7 +1233,7 @@ AllocationSite::PretenureDecision AllocationSite::pretenure_decision() const {
} }
void AllocationSite::set_pretenure_decision(PretenureDecision decision) { void AllocationSite::set_pretenure_decision(PretenureDecision decision) {
int value = pretenure_data(); int32_t value = pretenure_data();
set_pretenure_data(PretenureDecisionBits::update(value, decision)); set_pretenure_data(PretenureDecisionBits::update(value, decision));
} }
...@@ -1242,7 +1242,7 @@ bool AllocationSite::deopt_dependent_code() const { ...@@ -1242,7 +1242,7 @@ bool AllocationSite::deopt_dependent_code() const {
} }
void AllocationSite::set_deopt_dependent_code(bool deopt) { void AllocationSite::set_deopt_dependent_code(bool deopt) {
int value = pretenure_data(); int32_t value = pretenure_data();
set_pretenure_data(DeoptDependentCodeBit::update(value, deopt)); set_pretenure_data(DeoptDependentCodeBit::update(value, deopt));
} }
...@@ -1251,7 +1251,7 @@ int AllocationSite::memento_found_count() const { ...@@ -1251,7 +1251,7 @@ int AllocationSite::memento_found_count() const {
} }
inline void AllocationSite::set_memento_found_count(int count) { inline void AllocationSite::set_memento_found_count(int count) {
int value = pretenure_data(); int32_t value = pretenure_data();
// Verify that we can count more mementos than we can possibly find in one // Verify that we can count more mementos than we can possibly find in one
// new space collection. // new space collection.
DCHECK((GetHeap()->MaxSemiSpaceSize() / DCHECK((GetHeap()->MaxSemiSpaceSize() /
...@@ -2449,8 +2449,8 @@ void AllocationSite::set_transition_info(int value) { ...@@ -2449,8 +2449,8 @@ void AllocationSite::set_transition_info(int value) {
} }
ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset) ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset)
SMI_ACCESSORS(AllocationSite, pretenure_data, kPretenureDataOffset) INT32_ACCESSORS(AllocationSite, pretenure_data, kPretenureDataOffset)
SMI_ACCESSORS(AllocationSite, pretenure_create_count, INT32_ACCESSORS(AllocationSite, pretenure_create_count,
kPretenureCreateCountOffset) kPretenureCreateCountOffset)
ACCESSORS(AllocationSite, dependent_code, DependentCode, ACCESSORS(AllocationSite, dependent_code, DependentCode,
kDependentCodeOffset) kDependentCodeOffset)
......
...@@ -3950,9 +3950,9 @@ class AllocationSite: public Struct { ...@@ -3950,9 +3950,9 @@ class AllocationSite: public Struct {
DECL_ACCESSORS(nested_site, Object) DECL_ACCESSORS(nested_site, Object)
// Bitfield containing pretenuring information. // Bitfield containing pretenuring information.
DECL_INT_ACCESSORS(pretenure_data) DECL_INT32_ACCESSORS(pretenure_data)
DECL_INT_ACCESSORS(pretenure_create_count) DECL_INT32_ACCESSORS(pretenure_create_count)
DECL_ACCESSORS(dependent_code, DependentCode) DECL_ACCESSORS(dependent_code, DependentCode)
// heap->allocation_site_list() points to the last AllocationSite which form // heap->allocation_site_list() points to the last AllocationSite which form
...@@ -4039,12 +4039,15 @@ class AllocationSite: public Struct { ...@@ -4039,12 +4039,15 @@ class AllocationSite: public Struct {
static inline bool CanTrack(InstanceType type); static inline bool CanTrack(InstanceType type);
// Layout description. // Layout description.
// AllocationSite has to start with TransitionInfoOrboilerPlateOffset
// and end with WeakNext field.
#define ALLOCATION_SITE_FIELDS(V) \ #define ALLOCATION_SITE_FIELDS(V) \
V(kTransitionInfoOrBoilerplateOffset, kPointerSize) \ V(kTransitionInfoOrBoilerplateOffset, kPointerSize) \
V(kNestedSiteOffset, kPointerSize) \ V(kNestedSiteOffset, kPointerSize) \
V(kPretenureDataOffset, kPointerSize) \
V(kPretenureCreateCountOffset, kPointerSize) \
V(kDependentCodeOffset, kPointerSize) \ V(kDependentCodeOffset, kPointerSize) \
V(kCommonPointerFieldEndOffset, 0) \
V(kPretenureDataOffset, kInt32Size) \
V(kPretenureCreateCountOffset, kInt32Size) \
/* Size of AllocationSite without WeakNext field */ \ /* Size of AllocationSite without WeakNext field */ \
V(kSizeWithoutWeakNext, 0) \ V(kSizeWithoutWeakNext, 0) \
V(kWeakNextOffset, kPointerSize) \ V(kWeakNextOffset, kPointerSize) \
...@@ -4058,10 +4061,11 @@ class AllocationSite: public Struct { ...@@ -4058,10 +4061,11 @@ class AllocationSite: public Struct {
template <bool includeWeakNext> template <bool includeWeakNext>
class BodyDescriptorImpl; class BodyDescriptorImpl;
// BodyDescriptor is used to traverse all the fields including weak_next // BodyDescriptor is used to traverse all the pointer fields including
// weak_next
typedef BodyDescriptorImpl<true> BodyDescriptor; typedef BodyDescriptorImpl<true> BodyDescriptor;
// BodyDescriptorWeak is used to traverse all the pointers // BodyDescriptorWeak is used to traverse all the pointer fields
// except for weak_next // except for weak_next
typedef BodyDescriptorImpl<false> BodyDescriptorWeak; typedef BodyDescriptorImpl<false> BodyDescriptorWeak;
......
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