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,
StoreObjectFieldNoWriteBarrier(
memento, AllocationMemento::kAllocationSiteOffset, allocation_site);
if (FLAG_allocation_site_pretenuring) {
TNode<Smi> count = CAST(LoadObjectField(
allocation_site, AllocationSite::kPretenureCreateCountOffset));
TNode<Smi> incremented_count = SmiAdd(count, SmiConstant(1));
StoreObjectFieldNoWriteBarrier(allocation_site,
AllocationSite::kPretenureCreateCountOffset,
incremented_count);
TNode<Int32T> count = UncheckedCast<Int32T>(LoadObjectField(
allocation_site, AllocationSite::kPretenureCreateCountOffset,
MachineType::Int32()));
TNode<Int32T> incremented_count = Int32Add(count, Int32Constant(1));
StoreObjectFieldNoWriteBarrier(
allocation_site, AllocationSite::kPretenureCreateCountOffset,
incremented_count, MachineRepresentation::kWord32);
}
Comment("]");
}
......@@ -9438,11 +9440,13 @@ TNode<AllocationSite> CodeStubAssembler::CreateAllocationSiteInFeedbackVector(
// Pretenuring calculation field.
StoreObjectFieldNoWriteBarrier(site, AllocationSite::kPretenureDataOffset,
zero);
Int32Constant(0),
MachineRepresentation::kWord32);
// Pretenuring memento creation count field.
StoreObjectFieldNoWriteBarrier(
site, AllocationSite::kPretenureCreateCountOffset, zero);
site, AllocationSite::kPretenureCreateCountOffset, Int32Constant(0),
MachineRepresentation::kWord32);
// Store an empty fixed array for the code dependency.
StoreObjectFieldRoot(site, AllocationSite::kDependentCodeOffset,
......
......@@ -152,25 +152,44 @@ class JSFunction::BodyDescriptor final : public BodyDescriptorBase {
template <bool includeWeakNext>
class AllocationSite::BodyDescriptorImpl final : public BodyDescriptorBase {
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) {
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>
static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
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) {
return map->instance_size();
}
private:
static inline int GetEndOffset(Map* map) {
return includeWeakNext ? map->instance_size()
: AllocationSite::kSizeWithoutWeakNext;
}
};
class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase {
......
......@@ -1233,7 +1233,7 @@ AllocationSite::PretenureDecision AllocationSite::pretenure_decision() const {
}
void AllocationSite::set_pretenure_decision(PretenureDecision decision) {
int value = pretenure_data();
int32_t value = pretenure_data();
set_pretenure_data(PretenureDecisionBits::update(value, decision));
}
......@@ -1242,7 +1242,7 @@ bool AllocationSite::deopt_dependent_code() const {
}
void AllocationSite::set_deopt_dependent_code(bool deopt) {
int value = pretenure_data();
int32_t value = pretenure_data();
set_pretenure_data(DeoptDependentCodeBit::update(value, deopt));
}
......@@ -1251,7 +1251,7 @@ int AllocationSite::memento_found_count() const {
}
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
// new space collection.
DCHECK((GetHeap()->MaxSemiSpaceSize() /
......@@ -2449,9 +2449,9 @@ void AllocationSite::set_transition_info(int value) {
}
ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset)
SMI_ACCESSORS(AllocationSite, pretenure_data, kPretenureDataOffset)
SMI_ACCESSORS(AllocationSite, pretenure_create_count,
kPretenureCreateCountOffset)
INT32_ACCESSORS(AllocationSite, pretenure_data, kPretenureDataOffset)
INT32_ACCESSORS(AllocationSite, pretenure_create_count,
kPretenureCreateCountOffset)
ACCESSORS(AllocationSite, dependent_code, DependentCode,
kDependentCodeOffset)
ACCESSORS_CHECKED(AllocationSite, weak_next, Object, kWeakNextOffset,
......
......@@ -3950,9 +3950,9 @@ class AllocationSite: public Struct {
DECL_ACCESSORS(nested_site, Object)
// 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)
// heap->allocation_site_list() points to the last AllocationSite which form
......@@ -4039,12 +4039,15 @@ class AllocationSite: public Struct {
static inline bool CanTrack(InstanceType type);
// Layout description.
// AllocationSite has to start with TransitionInfoOrboilerPlateOffset
// and end with WeakNext field.
#define ALLOCATION_SITE_FIELDS(V) \
V(kTransitionInfoOrBoilerplateOffset, kPointerSize) \
V(kNestedSiteOffset, kPointerSize) \
V(kPretenureDataOffset, kPointerSize) \
V(kPretenureCreateCountOffset, kPointerSize) \
V(kDependentCodeOffset, kPointerSize) \
V(kCommonPointerFieldEndOffset, 0) \
V(kPretenureDataOffset, kInt32Size) \
V(kPretenureCreateCountOffset, kInt32Size) \
/* Size of AllocationSite without WeakNext field */ \
V(kSizeWithoutWeakNext, 0) \
V(kWeakNextOffset, kPointerSize) \
......@@ -4058,10 +4061,11 @@ class AllocationSite: public Struct {
template <bool includeWeakNext>
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;
// BodyDescriptorWeak is used to traverse all the pointers
// BodyDescriptorWeak is used to traverse all the pointer fields
// except for weak_next
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