Commit 71267cf2 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Refactor BodyDescriptor to avoid redundant map loads.

Almost all callers of BodyDescriptor already have the map of the object
and should pass it to IterateBody and IsValidSlot functions.

This removes redundant load and makes the function consistent with the
SizeOf function.

Change-Id: Ie47a9bb05af23fbf0576dff99f2ec69625e057fc
Reviewed-on: https://chromium-review.googlesource.com/979436
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52218}
parent c4766f68
...@@ -245,7 +245,7 @@ class ConcurrentMarkingVisitor final ...@@ -245,7 +245,7 @@ class ConcurrentMarkingVisitor final
DCHECK(length->IsSmi()); DCHECK(length->IsSmi());
int size = FixedArray::SizeFor(Smi::ToInt(length)); int size = FixedArray::SizeFor(Smi::ToInt(length));
VisitMapPointer(object, object->map_slot()); VisitMapPointer(object, object->map_slot());
FixedArray::BodyDescriptor::IterateBody(object, size, this); FixedArray::BodyDescriptor::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -266,7 +266,7 @@ class ConcurrentMarkingVisitor final ...@@ -266,7 +266,7 @@ class ConcurrentMarkingVisitor final
if (!ShouldVisit(object)) return 0; if (!ShouldVisit(object)) return 0;
int size = BytecodeArray::BodyDescriptorWeak::SizeOf(map, object); int size = BytecodeArray::BodyDescriptorWeak::SizeOf(map, object);
VisitMapPointer(object, object->map_slot()); VisitMapPointer(object, object->map_slot());
BytecodeArray::BodyDescriptorWeak::IterateBody(object, size, this); BytecodeArray::BodyDescriptorWeak::IterateBody(map, object, size, this);
object->MakeOlder(); object->MakeOlder();
return size; return size;
} }
...@@ -275,7 +275,7 @@ class ConcurrentMarkingVisitor final ...@@ -275,7 +275,7 @@ class ConcurrentMarkingVisitor final
if (!ShouldVisit(object)) return 0; if (!ShouldVisit(object)) return 0;
int size = AllocationSite::BodyDescriptorWeak::SizeOf(map, object); int size = AllocationSite::BodyDescriptorWeak::SizeOf(map, object);
VisitMapPointer(object, object->map_slot()); VisitMapPointer(object, object->map_slot());
AllocationSite::BodyDescriptorWeak::IterateBody(object, size, this); AllocationSite::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -283,7 +283,7 @@ class ConcurrentMarkingVisitor final ...@@ -283,7 +283,7 @@ class ConcurrentMarkingVisitor final
if (!ShouldVisit(object)) return 0; if (!ShouldVisit(object)) return 0;
int size = CodeDataContainer::BodyDescriptorWeak::SizeOf(map, object); int size = CodeDataContainer::BodyDescriptorWeak::SizeOf(map, object);
VisitMapPointer(object, object->map_slot()); VisitMapPointer(object, object->map_slot());
CodeDataContainer::BodyDescriptorWeak::IterateBody(object, size, this); CodeDataContainer::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -291,7 +291,7 @@ class ConcurrentMarkingVisitor final ...@@ -291,7 +291,7 @@ class ConcurrentMarkingVisitor final
if (!ShouldVisit(object)) return 0; if (!ShouldVisit(object)) return 0;
int size = JSFunction::BodyDescriptorWeak::SizeOf(map, object); int size = JSFunction::BodyDescriptorWeak::SizeOf(map, object);
VisitMapPointer(object, object->map_slot()); VisitMapPointer(object, object->map_slot());
JSFunction::BodyDescriptorWeak::IterateBody(object, size, this); JSFunction::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -317,7 +317,7 @@ class ConcurrentMarkingVisitor final ...@@ -317,7 +317,7 @@ class ConcurrentMarkingVisitor final
if (!ShouldVisit(object)) return 0; if (!ShouldVisit(object)) return 0;
int size = Context::BodyDescriptorWeak::SizeOf(map, object); int size = Context::BodyDescriptorWeak::SizeOf(map, object);
VisitMapPointer(object, object->map_slot()); VisitMapPointer(object, object->map_slot());
Context::BodyDescriptorWeak::IterateBody(object, size, this); Context::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -325,7 +325,7 @@ class ConcurrentMarkingVisitor final ...@@ -325,7 +325,7 @@ class ConcurrentMarkingVisitor final
if (!ShouldVisit(array)) return 0; if (!ShouldVisit(array)) return 0;
VisitMapPointer(array, array->map_slot()); VisitMapPointer(array, array->map_slot());
int size = TransitionArray::BodyDescriptor::SizeOf(map, array); int size = TransitionArray::BodyDescriptor::SizeOf(map, array);
TransitionArray::BodyDescriptor::IterateBody(array, size, this); TransitionArray::BodyDescriptor::IterateBody(map, array, size, this);
weak_objects_->transition_arrays.Push(task_id_, array); weak_objects_->transition_arrays.Push(task_id_, array);
return size; return size;
} }
...@@ -405,7 +405,7 @@ class ConcurrentMarkingVisitor final ...@@ -405,7 +405,7 @@ class ConcurrentMarkingVisitor final
SlotSnapshottingVisitor visitor(&slot_snapshot_); SlotSnapshottingVisitor visitor(&slot_snapshot_);
visitor.VisitPointer(object, visitor.VisitPointer(object,
reinterpret_cast<Object**>(object->map_slot())); reinterpret_cast<Object**>(object->map_slot()));
T::BodyDescriptor::IterateBody(object, size, &visitor); T::BodyDescriptor::IterateBody(map, object, size, &visitor);
return slot_snapshot_; return slot_snapshot_;
} }
ConcurrentMarking::MarkingWorklist::View shared_; ConcurrentMarking::MarkingWorklist::View shared_;
......
...@@ -61,7 +61,7 @@ bool InvalidatedSlotsFilter::IsValid(Address slot) { ...@@ -61,7 +61,7 @@ bool InvalidatedSlotsFilter::IsValid(Address slot) {
// we can return true here. // we can return true here.
return true; return true;
} }
return invalidated_object_->IsValidSlot(offset); return invalidated_object_->IsValidSlot(invalidated_object_->map(), offset);
} }
} // namespace internal } // namespace internal
......
...@@ -28,7 +28,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, ...@@ -28,7 +28,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitAllocationSite(Map* map, MarkingState>::VisitAllocationSite(Map* map,
AllocationSite* object) { AllocationSite* object) {
int size = AllocationSite::BodyDescriptorWeak::SizeOf(map, object); int size = AllocationSite::BodyDescriptorWeak::SizeOf(map, object);
AllocationSite::BodyDescriptorWeak::IterateBody(object, size, this); AllocationSite::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -38,7 +38,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, ...@@ -38,7 +38,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitBytecodeArray(Map* map, MarkingState>::VisitBytecodeArray(Map* map,
BytecodeArray* array) { BytecodeArray* array) {
int size = BytecodeArray::BodyDescriptor::SizeOf(map, array); int size = BytecodeArray::BodyDescriptor::SizeOf(map, array);
BytecodeArray::BodyDescriptor::IterateBody(array, size, this); BytecodeArray::BodyDescriptor::IterateBody(map, array, size, this);
array->MakeOlder(); array->MakeOlder();
return size; return size;
} }
...@@ -48,7 +48,7 @@ template <FixedArrayVisitationMode fixed_array_mode, ...@@ -48,7 +48,7 @@ template <FixedArrayVisitationMode fixed_array_mode,
int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>:: int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>::
VisitCodeDataContainer(Map* map, CodeDataContainer* object) { VisitCodeDataContainer(Map* map, CodeDataContainer* object) {
int size = CodeDataContainer::BodyDescriptorWeak::SizeOf(map, object); int size = CodeDataContainer::BodyDescriptorWeak::SizeOf(map, object);
CodeDataContainer::BodyDescriptorWeak::IterateBody(object, size, this); CodeDataContainer::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -71,7 +71,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, ...@@ -71,7 +71,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
heap_->TracePossibleWrapper(object); heap_->TracePossibleWrapper(object);
} }
int size = JSObject::BodyDescriptor::SizeOf(map, object); int size = JSObject::BodyDescriptor::SizeOf(map, object);
JSObject::BodyDescriptor::IterateBody(object, size, this); JSObject::BodyDescriptor::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -81,7 +81,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, ...@@ -81,7 +81,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitJSFunction(Map* map, MarkingState>::VisitJSFunction(Map* map,
JSFunction* object) { JSFunction* object) {
int size = JSFunction::BodyDescriptorWeak::SizeOf(map, object); int size = JSFunction::BodyDescriptorWeak::SizeOf(map, object);
JSFunction::BodyDescriptorWeak::IterateBody(object, size, this); JSFunction::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size; return size;
} }
...@@ -98,7 +98,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>:: ...@@ -98,7 +98,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>::
// Skip visiting the backing hash table containing the mappings and the // Skip visiting the backing hash table containing the mappings and the
// pointer to the other enqueued weak collections, both are post-processed. // pointer to the other enqueued weak collections, both are post-processed.
int size = JSWeakCollection::BodyDescriptorWeak::SizeOf(map, weak_collection); int size = JSWeakCollection::BodyDescriptorWeak::SizeOf(map, weak_collection);
JSWeakCollection::BodyDescriptorWeak::IterateBody(weak_collection, size, JSWeakCollection::BodyDescriptorWeak::IterateBody(map, weak_collection, size,
this); this);
// Partially initialized weak collection is enqueued, but table is ignored. // Partially initialized weak collection is enqueued, but table is ignored.
...@@ -135,7 +135,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, ...@@ -135,7 +135,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitNativeContext(Map* map, MarkingState>::VisitNativeContext(Map* map,
Context* context) { Context* context) {
int size = Context::BodyDescriptorWeak::SizeOf(map, context); int size = Context::BodyDescriptorWeak::SizeOf(map, context);
Context::BodyDescriptorWeak::IterateBody(context, size, this); Context::BodyDescriptorWeak::IterateBody(map, context, size, this);
return size; return size;
} }
...@@ -145,7 +145,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, ...@@ -145,7 +145,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitTransitionArray(Map* map, MarkingState>::VisitTransitionArray(Map* map,
TransitionArray* array) { TransitionArray* array) {
int size = TransitionArray::BodyDescriptor::SizeOf(map, array); int size = TransitionArray::BodyDescriptor::SizeOf(map, array);
TransitionArray::BodyDescriptor::IterateBody(array, size, this); TransitionArray::BodyDescriptor::IterateBody(map, array, size, this);
collector_->AddTransitionArray(array); collector_->AddTransitionArray(array);
return size; return size;
} }
...@@ -327,7 +327,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>:: ...@@ -327,7 +327,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>::
} }
} }
} else { } else {
FixedArray::BodyDescriptor::IterateBody(object, object_size, this); FixedArray::BodyDescriptor::IterateBody(map, object, object_size, this);
} }
return object_size; return object_size;
} }
......
...@@ -1443,16 +1443,14 @@ class EvacuateVisitorBase : public HeapObjectVisitor { ...@@ -1443,16 +1443,14 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
base->heap_->CopyBlock(dst_addr, src_addr, size); base->heap_->CopyBlock(dst_addr, src_addr, size);
if (mode != MigrationMode::kFast) if (mode != MigrationMode::kFast)
base->ExecuteMigrationObservers(dest, src, dst, size); base->ExecuteMigrationObservers(dest, src, dst, size);
dst->IterateBodyFast(dst->map()->instance_type(), size, dst->IterateBodyFast(dst->map(), size, base->record_visitor_);
base->record_visitor_);
} else if (dest == CODE_SPACE) { } else if (dest == CODE_SPACE) {
DCHECK_CODEOBJECT_SIZE(size, base->heap_->code_space()); DCHECK_CODEOBJECT_SIZE(size, base->heap_->code_space());
base->heap_->CopyBlock(dst_addr, src_addr, size); base->heap_->CopyBlock(dst_addr, src_addr, size);
Code::cast(dst)->Relocate(dst_addr - src_addr); Code::cast(dst)->Relocate(dst_addr - src_addr);
if (mode != MigrationMode::kFast) if (mode != MigrationMode::kFast)
base->ExecuteMigrationObservers(dest, src, dst, size); base->ExecuteMigrationObservers(dest, src, dst, size);
dst->IterateBodyFast(dst->map()->instance_type(), size, dst->IterateBodyFast(dst->map(), size, base->record_visitor_);
base->record_visitor_);
} else { } else {
DCHECK_OBJECT_SIZE(size); DCHECK_OBJECT_SIZE(size);
DCHECK(dest == NEW_SPACE); DCHECK(dest == NEW_SPACE);
...@@ -1771,7 +1769,7 @@ void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { ...@@ -1771,7 +1769,7 @@ void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) {
if (it.frame()->type() == StackFrame::OPTIMIZED) { if (it.frame()->type() == StackFrame::OPTIMIZED) {
Code* code = it.frame()->LookupCode(); Code* code = it.frame()->LookupCode();
if (!code->CanDeoptAt(it.frame()->pc())) { if (!code->CanDeoptAt(it.frame()->pc())) {
Code::BodyDescriptor::IterateBody(code, visitor); Code::BodyDescriptor::IterateBody(code->map(), code, visitor);
} }
return; return;
} }
...@@ -3717,7 +3715,7 @@ class ToSpaceUpdatingItem : public UpdatingItem { ...@@ -3717,7 +3715,7 @@ class ToSpaceUpdatingItem : public UpdatingItem {
HeapObject* object = HeapObject::FromAddress(cur); HeapObject* object = HeapObject::FromAddress(cur);
Map* map = object->map(); Map* map = object->map();
int size = object->SizeFromMap(map); int size = object->SizeFromMap(map);
object->IterateBody(map->instance_type(), size, &visitor); object->IterateBody(map, size, &visitor);
cur += size; cur += size;
} }
} }
......
...@@ -80,7 +80,7 @@ void HeapVisitor<ResultType, ConcreteVisitor>::VisitMapPointer( ...@@ -80,7 +80,7 @@ void HeapVisitor<ResultType, ConcreteVisitor>::VisitMapPointer(
int size = type::BodyDescriptor::SizeOf(map, object); \ int size = type::BodyDescriptor::SizeOf(map, object); \
if (visitor->ShouldVisitMapPointer()) \ if (visitor->ShouldVisitMapPointer()) \
visitor->VisitMapPointer(object, object->map_slot()); \ visitor->VisitMapPointer(object, object->map_slot()); \
type::BodyDescriptor::IterateBody(object, size, visitor); \ type::BodyDescriptor::IterateBody(map, object, size, visitor); \
return static_cast<ResultType>(size); \ return static_cast<ResultType>(size); \
} }
TYPED_VISITOR_ID_LIST(VISIT) TYPED_VISITOR_ID_LIST(VISIT)
...@@ -100,7 +100,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitNativeContext( ...@@ -100,7 +100,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitNativeContext(
int size = Context::BodyDescriptor::SizeOf(map, object); int size = Context::BodyDescriptor::SizeOf(map, object);
if (visitor->ShouldVisitMapPointer()) if (visitor->ShouldVisitMapPointer())
visitor->VisitMapPointer(object, object->map_slot()); visitor->VisitMapPointer(object, object->map_slot());
Context::BodyDescriptor::IterateBody(object, size, visitor); Context::BodyDescriptor::IterateBody(map, object, size, visitor);
return static_cast<ResultType>(size); return static_cast<ResultType>(size);
} }
...@@ -123,7 +123,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSObjectFast( ...@@ -123,7 +123,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSObjectFast(
int size = JSObject::FastBodyDescriptor::SizeOf(map, object); int size = JSObject::FastBodyDescriptor::SizeOf(map, object);
if (visitor->ShouldVisitMapPointer()) if (visitor->ShouldVisitMapPointer())
visitor->VisitMapPointer(object, object->map_slot()); visitor->VisitMapPointer(object, object->map_slot());
JSObject::FastBodyDescriptor::IterateBody(object, size, visitor); JSObject::FastBodyDescriptor::IterateBody(map, object, size, visitor);
return static_cast<ResultType>(size); return static_cast<ResultType>(size);
} }
...@@ -135,7 +135,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSApiObject( ...@@ -135,7 +135,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSApiObject(
int size = JSObject::BodyDescriptor::SizeOf(map, object); int size = JSObject::BodyDescriptor::SizeOf(map, object);
if (visitor->ShouldVisitMapPointer()) if (visitor->ShouldVisitMapPointer())
visitor->VisitMapPointer(object, object->map_slot()); visitor->VisitMapPointer(object, object->map_slot());
JSObject::BodyDescriptor::IterateBody(object, size, visitor); JSObject::BodyDescriptor::IterateBody(map, object, size, visitor);
return static_cast<ResultType>(size); return static_cast<ResultType>(size);
} }
...@@ -147,7 +147,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitStruct( ...@@ -147,7 +147,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitStruct(
int size = map->instance_size(); int size = map->instance_size();
if (visitor->ShouldVisitMapPointer()) if (visitor->ShouldVisitMapPointer())
visitor->VisitMapPointer(object, object->map_slot()); visitor->VisitMapPointer(object, object->map_slot());
StructBodyDescriptor::IterateBody(object, size, visitor); StructBodyDescriptor::IterateBody(map, object, size, visitor);
return static_cast<ResultType>(size); return static_cast<ResultType>(size);
} }
...@@ -166,7 +166,7 @@ int NewSpaceVisitor<ConcreteVisitor>::VisitJSFunction(Map* map, ...@@ -166,7 +166,7 @@ int NewSpaceVisitor<ConcreteVisitor>::VisitJSFunction(Map* map,
JSFunction* object) { JSFunction* object) {
ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this);
int size = JSFunction::BodyDescriptorWeak::SizeOf(map, object); int size = JSFunction::BodyDescriptorWeak::SizeOf(map, object);
JSFunction::BodyDescriptorWeak::IterateBody(object, size, visitor); JSFunction::BodyDescriptorWeak::IterateBody(map, object, size, visitor);
return size; return size;
} }
...@@ -175,7 +175,7 @@ int NewSpaceVisitor<ConcreteVisitor>::VisitNativeContext(Map* map, ...@@ -175,7 +175,7 @@ int NewSpaceVisitor<ConcreteVisitor>::VisitNativeContext(Map* map,
Context* object) { Context* object) {
ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this);
int size = Context::BodyDescriptor::SizeOf(map, object); int size = Context::BodyDescriptor::SizeOf(map, object);
Context::BodyDescriptor::IterateBody(object, size, visitor); Context::BodyDescriptor::IterateBody(map, object, size, visitor);
return size; return size;
} }
......
...@@ -103,7 +103,7 @@ void Scavenger::IterateAndScavengePromotedObject(HeapObject* target, int size) { ...@@ -103,7 +103,7 @@ void Scavenger::IterateAndScavengePromotedObject(HeapObject* target, int size) {
is_compacting_ && is_compacting_ &&
heap()->incremental_marking()->atomic_marking_state()->IsBlack(target); heap()->incremental_marking()->atomic_marking_state()->IsBlack(target);
IterateAndScavengePromotedObjectsVisitor visitor(heap(), this, record_slots); IterateAndScavengePromotedObjectsVisitor visitor(heap(), this, record_slots);
target->IterateBody(target->map()->instance_type(), size, &visitor); target->IterateBody(target->map(), size, &visitor);
} }
void Scavenger::AddPageToSweeperIfNecessary(MemoryChunk* page) { void Scavenger::AddPageToSweeperIfNecessary(MemoryChunk* page) {
......
...@@ -1930,7 +1930,7 @@ void PagedSpace::Verify(ObjectVisitor* visitor) { ...@@ -1930,7 +1930,7 @@ void PagedSpace::Verify(ObjectVisitor* visitor) {
// All the interior pointers should be contained in the heap. // All the interior pointers should be contained in the heap.
int size = object->Size(); int size = object->Size();
object->IterateBody(map->instance_type(), size, visitor); object->IterateBody(map, size, visitor);
CHECK(object->address() + size <= top); CHECK(object->address() + size <= top);
end_of_previous_object = object->address() + size; end_of_previous_object = object->address() + size;
} }
...@@ -2382,7 +2382,7 @@ void NewSpace::Verify() { ...@@ -2382,7 +2382,7 @@ void NewSpace::Verify() {
// All the interior pointers should be contained in the heap. // All the interior pointers should be contained in the heap.
VerifyPointersVisitor visitor; VerifyPointersVisitor visitor;
int size = object->Size(); int size = object->Size();
object->IterateBody(map->instance_type(), size, &visitor); object->IterateBody(map, size, &visitor);
current += size; current += size;
} else { } else {
...@@ -3473,7 +3473,7 @@ void LargeObjectSpace::Verify() { ...@@ -3473,7 +3473,7 @@ void LargeObjectSpace::Verify() {
// Byte arrays and strings don't have interior pointers. // Byte arrays and strings don't have interior pointers.
if (object->IsAbstractCode()) { if (object->IsAbstractCode()) {
VerifyPointersVisitor code_visitor; VerifyPointersVisitor code_visitor;
object->IterateBody(map->instance_type(), object->Size(), &code_visitor); object->IterateBody(map, object->Size(), &code_visitor);
} else if (object->IsFixedArray()) { } else if (object->IsFixedArray()) {
FixedArray* array = FixedArray::cast(object); FixedArray* array = FixedArray::cast(object);
for (int j = 0; j < array->length(); j++) { for (int j = 0; j < array->length(); j++) {
......
...@@ -20,30 +20,32 @@ int FlexibleBodyDescriptor<start_offset>::SizeOf(Map* map, HeapObject* object) { ...@@ -20,30 +20,32 @@ int FlexibleBodyDescriptor<start_offset>::SizeOf(Map* map, HeapObject* object) {
return object->SizeFromMap(map); return object->SizeFromMap(map);
} }
bool BodyDescriptorBase::IsValidSlotImpl(HeapObject* obj, int offset) { bool BodyDescriptorBase::IsValidSlotImpl(Map* map, HeapObject* obj,
if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { int offset) {
if (!FLAG_unbox_double_fields || map->HasFastPointerLayout()) {
return true; return true;
} else { } else {
DCHECK(FLAG_unbox_double_fields); DCHECK(FLAG_unbox_double_fields);
DCHECK(IsAligned(offset, kPointerSize)); DCHECK(IsAligned(offset, kPointerSize));
LayoutDescriptorHelper helper(obj->map()); LayoutDescriptorHelper helper(map);
DCHECK(!helper.all_fields_tagged()); DCHECK(!helper.all_fields_tagged());
return helper.IsTagged(offset); return helper.IsTagged(offset);
} }
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, void BodyDescriptorBase::IterateBodyImpl(Map* map, HeapObject* obj,
int end_offset, ObjectVisitor* v) { int start_offset, int end_offset,
if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { ObjectVisitor* v) {
if (!FLAG_unbox_double_fields || map->HasFastPointerLayout()) {
IteratePointers(obj, start_offset, end_offset, v); IteratePointers(obj, start_offset, end_offset, v);
} else { } else {
DCHECK(FLAG_unbox_double_fields); DCHECK(FLAG_unbox_double_fields);
DCHECK(IsAligned(start_offset, kPointerSize) && DCHECK(IsAligned(start_offset, kPointerSize) &&
IsAligned(end_offset, kPointerSize)); IsAligned(end_offset, kPointerSize));
LayoutDescriptorHelper helper(obj->map()); LayoutDescriptorHelper helper(map);
DCHECK(!helper.all_fields_tagged()); DCHECK(!helper.all_fields_tagged());
for (int offset = start_offset; offset < end_offset;) { for (int offset = start_offset; offset < end_offset;) {
int end_of_region_offset; int end_of_region_offset;
...@@ -87,15 +89,15 @@ class JSObject::BodyDescriptor final : public BodyDescriptorBase { ...@@ -87,15 +89,15 @@ class JSObject::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static const int kStartOffset = JSReceiver::kPropertiesOrHashOffset; static const int kStartOffset = JSReceiver::kPropertiesOrHashOffset;
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
if (offset < kStartOffset) return false; if (offset < kStartOffset) return false;
return IsValidSlotImpl(obj, offset); return IsValidSlotImpl(map, obj, offset);
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IterateBodyImpl(obj, kStartOffset, object_size, v); IterateBodyImpl(map, obj, kStartOffset, object_size, v);
} }
static inline int SizeOf(Map* map, HeapObject* object) { static inline int SizeOf(Map* map, HeapObject* object) {
...@@ -107,12 +109,12 @@ class JSObject::FastBodyDescriptor final : public BodyDescriptorBase { ...@@ -107,12 +109,12 @@ class JSObject::FastBodyDescriptor final : public BodyDescriptorBase {
public: public:
static const int kStartOffset = JSReceiver::kPropertiesOrHashOffset; static const int kStartOffset = JSReceiver::kPropertiesOrHashOffset;
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return offset >= kStartOffset; return offset >= kStartOffset;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IteratePointers(obj, kStartOffset, object_size, v); IteratePointers(obj, kStartOffset, object_size, v);
} }
...@@ -124,20 +126,21 @@ class JSObject::FastBodyDescriptor final : public BodyDescriptorBase { ...@@ -124,20 +126,21 @@ class JSObject::FastBodyDescriptor final : public BodyDescriptorBase {
class JSFunction::BodyDescriptor final : public BodyDescriptorBase { class JSFunction::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
if (offset < kSizeWithoutPrototype) return true; if (offset < kSizeWithoutPrototype) return true;
if (offset < kSizeWithPrototype && obj->map()->has_prototype_slot()) { if (offset < kSizeWithPrototype && map->has_prototype_slot()) {
return true; return true;
} }
return IsValidSlotImpl(obj, offset); return IsValidSlotImpl(map, obj, offset);
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
int header_size = JSFunction::cast(obj)->GetHeaderSize(); int header_size = JSFunction::GetHeaderSize(map->has_prototype_slot());
DCHECK_EQ(header_size, JSObject::GetHeaderSize(map));
IteratePointers(obj, kPropertiesOrHashOffset, header_size, v); IteratePointers(obj, kPropertiesOrHashOffset, header_size, v);
IterateBodyImpl(obj, header_size, object_size, v); IterateBodyImpl(map, obj, header_size, object_size, v);
} }
static inline int SizeOf(Map* map, HeapObject* object) { static inline int SizeOf(Map* map, HeapObject* object) {
...@@ -151,20 +154,20 @@ class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { ...@@ -151,20 +154,20 @@ class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase {
STATIC_ASSERT(kBackingStoreOffset + kPointerSize == kBitFieldSlot); STATIC_ASSERT(kBackingStoreOffset + kPointerSize == kBitFieldSlot);
STATIC_ASSERT(kBitFieldSlot + kPointerSize == kSize); STATIC_ASSERT(kBitFieldSlot + kPointerSize == kSize);
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
if (offset < kBitFieldSlot) return true; if (offset < kBitFieldSlot) return true;
if (offset < kSize) return false; if (offset < kSize) return false;
return IsValidSlotImpl(obj, offset); return IsValidSlotImpl(map, obj, offset);
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
// Array buffers contain raw pointers that the GC does not know about. These // Array buffers contain raw pointers that the GC does not know about. These
// are stored at kBackStoreOffset and later, so we do not iterate over // are stored at kBackStoreOffset and later, so we do not iterate over
// those. // those.
IteratePointers(obj, kPropertiesOrHashOffset, kBackingStoreOffset, v); IteratePointers(obj, kPropertiesOrHashOffset, kBackingStoreOffset, v);
IterateBodyImpl(obj, kSize, object_size, v); IterateBodyImpl(map, obj, kSize, object_size, v);
} }
static inline int SizeOf(Map* map, HeapObject* object) { static inline int SizeOf(Map* map, HeapObject* object) {
...@@ -176,14 +179,14 @@ template <typename Derived> ...@@ -176,14 +179,14 @@ template <typename Derived>
class SmallOrderedHashTable<Derived>::BodyDescriptor final class SmallOrderedHashTable<Derived>::BodyDescriptor final
: public BodyDescriptorBase { : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
Derived* table = reinterpret_cast<Derived*>(obj); Derived* table = reinterpret_cast<Derived*>(obj);
if (offset < table->GetDataTableStartOffset()) return false; if (offset < table->GetDataTableStartOffset()) return false;
return IsValidSlotImpl(obj, offset); return IsValidSlotImpl(map, obj, offset);
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
Derived* table = reinterpret_cast<Derived*>(obj); Derived* table = reinterpret_cast<Derived*>(obj);
int start = table->GetDataTableStartOffset(); int start = table->GetDataTableStartOffset();
...@@ -200,10 +203,12 @@ class SmallOrderedHashTable<Derived>::BodyDescriptor final ...@@ -200,10 +203,12 @@ class SmallOrderedHashTable<Derived>::BodyDescriptor final
class ByteArray::BodyDescriptor final : public BodyDescriptorBase { class ByteArray::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) {} ObjectVisitor* v) {}
static inline int SizeOf(Map* map, HeapObject* obj) { static inline int SizeOf(Map* map, HeapObject* obj) {
...@@ -213,13 +218,13 @@ class ByteArray::BodyDescriptor final : public BodyDescriptorBase { ...@@ -213,13 +218,13 @@ class ByteArray::BodyDescriptor final : public BodyDescriptorBase {
class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return offset >= kConstantPoolOffset && return offset >= kConstantPoolOffset &&
offset <= kSourcePositionTableOffset; offset <= kSourcePositionTableOffset;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IteratePointer(obj, kConstantPoolOffset, v); IteratePointer(obj, kConstantPoolOffset, v);
IteratePointer(obj, kHandlerTableOffset, v); IteratePointer(obj, kHandlerTableOffset, v);
...@@ -234,10 +239,12 @@ class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { ...@@ -234,10 +239,12 @@ class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase {
class BigInt::BodyDescriptor final : public BodyDescriptorBase { class BigInt::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) {} ObjectVisitor* v) {}
static inline int SizeOf(Map* map, HeapObject* obj) { static inline int SizeOf(Map* map, HeapObject* obj) {
...@@ -247,10 +254,12 @@ class BigInt::BodyDescriptor final : public BodyDescriptorBase { ...@@ -247,10 +254,12 @@ class BigInt::BodyDescriptor final : public BodyDescriptorBase {
class FixedDoubleArray::BodyDescriptor final : public BodyDescriptorBase { class FixedDoubleArray::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) {} ObjectVisitor* v) {}
static inline int SizeOf(Map* map, HeapObject* obj) { static inline int SizeOf(Map* map, HeapObject* obj) {
...@@ -261,12 +270,12 @@ class FixedDoubleArray::BodyDescriptor final : public BodyDescriptorBase { ...@@ -261,12 +270,12 @@ class FixedDoubleArray::BodyDescriptor final : public BodyDescriptorBase {
class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase { class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return offset == kBasePointerOffset; return offset == kBasePointerOffset;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IteratePointer(obj, kBasePointerOffset, v); IteratePointer(obj, kBasePointerOffset, v);
} }
...@@ -278,12 +287,12 @@ class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase { ...@@ -278,12 +287,12 @@ class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase {
class WeakFixedArray::BodyDescriptor final : public BodyDescriptorBase { class WeakFixedArray::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return offset >= kHeaderSize; return offset >= kHeaderSize;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IterateMaybeWeakPointers(obj, kHeaderSize, object_size, v); IterateMaybeWeakPointers(obj, kHeaderSize, object_size, v);
} }
...@@ -295,10 +304,12 @@ class WeakFixedArray::BodyDescriptor final : public BodyDescriptorBase { ...@@ -295,10 +304,12 @@ class WeakFixedArray::BodyDescriptor final : public BodyDescriptorBase {
class FeedbackMetadata::BodyDescriptor final : public BodyDescriptorBase { class FeedbackMetadata::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) {} ObjectVisitor* v) {}
static inline int SizeOf(Map* map, HeapObject* obj) { static inline int SizeOf(Map* map, HeapObject* obj) {
...@@ -309,13 +320,13 @@ class FeedbackMetadata::BodyDescriptor final : public BodyDescriptorBase { ...@@ -309,13 +320,13 @@ class FeedbackMetadata::BodyDescriptor final : public BodyDescriptorBase {
class FeedbackVector::BodyDescriptor final : public BodyDescriptorBase { class FeedbackVector::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return offset == kSharedFunctionInfoOffset || return offset == kSharedFunctionInfoOffset ||
offset == kOptimizedCodeOffset || offset >= kFeedbackSlotsOffset; offset == kOptimizedCodeOffset || offset >= kFeedbackSlotsOffset;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IteratePointer(obj, kSharedFunctionInfoOffset, v); IteratePointer(obj, kSharedFunctionInfoOffset, v);
IterateMaybeWeakPointer(obj, kOptimizedCodeOffset, v); IterateMaybeWeakPointer(obj, kOptimizedCodeOffset, v);
...@@ -333,18 +344,18 @@ class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase { ...@@ -333,18 +344,18 @@ class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase {
STATIC_ASSERT(kTableOffset + kPointerSize == kNextOffset); STATIC_ASSERT(kTableOffset + kPointerSize == kNextOffset);
STATIC_ASSERT(kNextOffset + kPointerSize == kSize); STATIC_ASSERT(kNextOffset + kPointerSize == kSize);
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return IsValidSlotImpl(obj, offset); return IsValidSlotImpl(map, obj, offset);
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
if (body_visiting_policy == kIgnoreWeakness) { if (body_visiting_policy == kIgnoreWeakness) {
IterateBodyImpl(obj, kPropertiesOrHashOffset, object_size, v); IterateBodyImpl(map, obj, kPropertiesOrHashOffset, object_size, v);
} else { } else {
IteratePointers(obj, kPropertiesOrHashOffset, kTableOffset, v); IteratePointers(obj, kPropertiesOrHashOffset, kTableOffset, v);
IterateBodyImpl(obj, kSize, object_size, v); IterateBodyImpl(map, obj, kSize, object_size, v);
} }
} }
...@@ -355,10 +366,12 @@ class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase { ...@@ -355,10 +366,12 @@ class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase {
class Foreign::BodyDescriptor final : public BodyDescriptorBase { class Foreign::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
v->VisitExternalReference(Foreign::cast(obj), v->VisitExternalReference(Foreign::cast(obj),
reinterpret_cast<Address*>(HeapObject::RawField( reinterpret_cast<Address*>(HeapObject::RawField(
...@@ -370,24 +383,26 @@ class Foreign::BodyDescriptor final : public BodyDescriptorBase { ...@@ -370,24 +383,26 @@ class Foreign::BodyDescriptor final : public BodyDescriptorBase {
class ExternalOneByteString::BodyDescriptor final : public BodyDescriptorBase { class ExternalOneByteString::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {}
}
static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } static inline int SizeOf(Map* map, HeapObject* object) { return kSize; }
}; };
class ExternalTwoByteString::BodyDescriptor final : public BodyDescriptorBase { class ExternalTwoByteString::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {}
}
static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } static inline int SizeOf(Map* map, HeapObject* object) { return kSize; }
}; };
...@@ -402,13 +417,13 @@ class Code::BodyDescriptor final : public BodyDescriptorBase { ...@@ -402,13 +417,13 @@ class Code::BodyDescriptor final : public BodyDescriptorBase {
kCodeDataContainerOffset); kCodeDataContainerOffset);
STATIC_ASSERT(kCodeDataContainerOffset + kPointerSize == kDataStart); STATIC_ASSERT(kCodeDataContainerOffset + kPointerSize == kDataStart);
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
// Slots in code can't be invalid because we never trim code objects. // Slots in code can't be invalid because we never trim code objects.
return true; return true;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) { static inline void IterateBody(Map* map, HeapObject* obj, ObjectVisitor* v) {
int mode_mask = RelocInfo::kCodeTargetMask | int mode_mask = RelocInfo::kCodeTargetMask |
RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
...@@ -427,9 +442,9 @@ class Code::BodyDescriptor final : public BodyDescriptorBase { ...@@ -427,9 +442,9 @@ class Code::BodyDescriptor final : public BodyDescriptorBase {
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IterateBody(obj, v); IterateBody(map, obj, v);
} }
static inline int SizeOf(Map* map, HeapObject* object) { static inline int SizeOf(Map* map, HeapObject* object) {
...@@ -439,10 +454,12 @@ class Code::BodyDescriptor final : public BodyDescriptorBase { ...@@ -439,10 +454,12 @@ class Code::BodyDescriptor final : public BodyDescriptorBase {
class SeqOneByteString::BodyDescriptor final : public BodyDescriptorBase { class SeqOneByteString::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) {} ObjectVisitor* v) {}
static inline int SizeOf(Map* map, HeapObject* obj) { static inline int SizeOf(Map* map, HeapObject* obj) {
...@@ -453,10 +470,12 @@ class SeqOneByteString::BodyDescriptor final : public BodyDescriptorBase { ...@@ -453,10 +470,12 @@ class SeqOneByteString::BodyDescriptor final : public BodyDescriptorBase {
class SeqTwoByteString::BodyDescriptor final : public BodyDescriptorBase { class SeqTwoByteString::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { return false; } static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return false;
}
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) {} ObjectVisitor* v) {}
static inline int SizeOf(Map* map, HeapObject* obj) { static inline int SizeOf(Map* map, HeapObject* obj) {
...@@ -467,17 +486,17 @@ class SeqTwoByteString::BodyDescriptor final : public BodyDescriptorBase { ...@@ -467,17 +486,17 @@ class SeqTwoByteString::BodyDescriptor final : public BodyDescriptorBase {
class WasmInstanceObject::BodyDescriptor final : public BodyDescriptorBase { class WasmInstanceObject::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
if (offset < kMemoryStartOffset) return true; if (offset < kMemoryStartOffset) return true;
if (offset < kCompiledModuleOffset) return false; if (offset < kCompiledModuleOffset) return false;
return IsValidSlotImpl(obj, offset); return IsValidSlotImpl(map, obj, offset);
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IteratePointers(obj, kPropertiesOrHashOffset, kFirstUntaggedOffset, v); IteratePointers(obj, kPropertiesOrHashOffset, kFirstUntaggedOffset, v);
IterateBodyImpl(obj, kSize, object_size, v); IterateBodyImpl(map, obj, kSize, object_size, v);
} }
static inline int SizeOf(Map* map, HeapObject* object) { static inline int SizeOf(Map* map, HeapObject* object) {
...@@ -486,25 +505,25 @@ class WasmInstanceObject::BodyDescriptor final : public BodyDescriptorBase { ...@@ -486,25 +505,25 @@ class WasmInstanceObject::BodyDescriptor final : public BodyDescriptorBase {
}; };
template <typename Op, typename ReturnType, typename T1, typename T2, template <typename Op, typename ReturnType, typename T1, typename T2,
typename T3> typename T3, typename T4>
ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) { ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
if (type < FIRST_NONSTRING_TYPE) { if (type < FIRST_NONSTRING_TYPE) {
switch (type & kStringRepresentationMask) { switch (type & kStringRepresentationMask) {
case kSeqStringTag: case kSeqStringTag:
return ReturnType(); return ReturnType();
case kConsStringTag: case kConsStringTag:
return Op::template apply<ConsString::BodyDescriptor>(p1, p2, p3); return Op::template apply<ConsString::BodyDescriptor>(p1, p2, p3, p4);
case kThinStringTag: case kThinStringTag:
return Op::template apply<ThinString::BodyDescriptor>(p1, p2, p3); return Op::template apply<ThinString::BodyDescriptor>(p1, p2, p3, p4);
case kSlicedStringTag: case kSlicedStringTag:
return Op::template apply<SlicedString::BodyDescriptor>(p1, p2, p3); return Op::template apply<SlicedString::BodyDescriptor>(p1, p2, p3, p4);
case kExternalStringTag: case kExternalStringTag:
if ((type & kStringEncodingMask) == kOneByteStringTag) { if ((type & kStringEncodingMask) == kOneByteStringTag) {
return Op::template apply<ExternalOneByteString::BodyDescriptor>( return Op::template apply<ExternalOneByteString::BodyDescriptor>(
p1, p2, p3); p1, p2, p3, p4);
} else { } else {
return Op::template apply<ExternalTwoByteString::BodyDescriptor>( return Op::template apply<ExternalTwoByteString::BodyDescriptor>(
p1, p2, p3); p1, p2, p3, p4);
} }
} }
UNREACHABLE(); UNREACHABLE();
...@@ -524,23 +543,26 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) { ...@@ -524,23 +543,26 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) {
case NATIVE_CONTEXT_TYPE: case NATIVE_CONTEXT_TYPE:
case SCRIPT_CONTEXT_TYPE: case SCRIPT_CONTEXT_TYPE:
case WITH_CONTEXT_TYPE: case WITH_CONTEXT_TYPE:
return Op::template apply<FixedArray::BodyDescriptor>(p1, p2, p3); return Op::template apply<FixedArray::BodyDescriptor>(p1, p2, p3, p4);
case WEAK_FIXED_ARRAY_TYPE: case WEAK_FIXED_ARRAY_TYPE:
return Op::template apply<WeakFixedArray::BodyDescriptor>(p1, p2, p3); return Op::template apply<WeakFixedArray::BodyDescriptor>(p1, p2, p3, p4);
case FIXED_DOUBLE_ARRAY_TYPE: case FIXED_DOUBLE_ARRAY_TYPE:
return ReturnType(); return ReturnType();
case FEEDBACK_METADATA_TYPE: case FEEDBACK_METADATA_TYPE:
return Op::template apply<FeedbackMetadata::BodyDescriptor>(p1, p2, p3); return Op::template apply<FeedbackMetadata::BodyDescriptor>(p1, p2, p3,
p4);
case PROPERTY_ARRAY_TYPE: case PROPERTY_ARRAY_TYPE:
return Op::template apply<PropertyArray::BodyDescriptor>(p1, p2, p3); return Op::template apply<PropertyArray::BodyDescriptor>(p1, p2, p3, p4);
case DESCRIPTOR_ARRAY_TYPE: case DESCRIPTOR_ARRAY_TYPE:
return Op::template apply<DescriptorArray::BodyDescriptor>(p1, p2, p3); return Op::template apply<DescriptorArray::BodyDescriptor>(p1, p2, p3,
p4);
case TRANSITION_ARRAY_TYPE: case TRANSITION_ARRAY_TYPE:
return Op::template apply<TransitionArray::BodyDescriptor>(p1, p2, p3); return Op::template apply<TransitionArray::BodyDescriptor>(p1, p2, p3,
p4);
case FEEDBACK_CELL_TYPE: case FEEDBACK_CELL_TYPE:
return Op::template apply<FeedbackCell::BodyDescriptor>(p1, p2, p3); return Op::template apply<FeedbackCell::BodyDescriptor>(p1, p2, p3, p4);
case FEEDBACK_VECTOR_TYPE: case FEEDBACK_VECTOR_TYPE:
return Op::template apply<FeedbackVector::BodyDescriptor>(p1, p2, p3); return Op::template apply<FeedbackVector::BodyDescriptor>(p1, p2, p3, p4);
case JS_OBJECT_TYPE: case JS_OBJECT_TYPE:
case JS_ERROR_TYPE: case JS_ERROR_TYPE:
case JS_ARGUMENTS_TYPE: case JS_ARGUMENTS_TYPE:
...@@ -574,46 +596,49 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) { ...@@ -574,46 +596,49 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) {
case WASM_MEMORY_TYPE: case WASM_MEMORY_TYPE:
case WASM_MODULE_TYPE: case WASM_MODULE_TYPE:
case WASM_TABLE_TYPE: case WASM_TABLE_TYPE:
return Op::template apply<JSObject::BodyDescriptor>(p1, p2, p3); return Op::template apply<JSObject::BodyDescriptor>(p1, p2, p3, p4);
case WASM_INSTANCE_TYPE: case WASM_INSTANCE_TYPE:
return Op::template apply<WasmInstanceObject::BodyDescriptor>(p1, p2, p3); return Op::template apply<WasmInstanceObject::BodyDescriptor>(p1, p2, p3,
p4);
case JS_WEAK_MAP_TYPE: case JS_WEAK_MAP_TYPE:
case JS_WEAK_SET_TYPE: case JS_WEAK_SET_TYPE:
return Op::template apply<JSWeakCollection::BodyDescriptor>(p1, p2, p3); return Op::template apply<JSWeakCollection::BodyDescriptor>(p1, p2, p3,
p4);
case JS_ARRAY_BUFFER_TYPE: case JS_ARRAY_BUFFER_TYPE:
return Op::template apply<JSArrayBuffer::BodyDescriptor>(p1, p2, p3); return Op::template apply<JSArrayBuffer::BodyDescriptor>(p1, p2, p3, p4);
case JS_FUNCTION_TYPE: case JS_FUNCTION_TYPE:
return Op::template apply<JSFunction::BodyDescriptor>(p1, p2, p3); return Op::template apply<JSFunction::BodyDescriptor>(p1, p2, p3, p4);
case ODDBALL_TYPE: case ODDBALL_TYPE:
return Op::template apply<Oddball::BodyDescriptor>(p1, p2, p3); return Op::template apply<Oddball::BodyDescriptor>(p1, p2, p3, p4);
case JS_PROXY_TYPE: case JS_PROXY_TYPE:
return Op::template apply<JSProxy::BodyDescriptor>(p1, p2, p3); return Op::template apply<JSProxy::BodyDescriptor>(p1, p2, p3, p4);
case FOREIGN_TYPE: case FOREIGN_TYPE:
return Op::template apply<Foreign::BodyDescriptor>(p1, p2, p3); return Op::template apply<Foreign::BodyDescriptor>(p1, p2, p3, p4);
case MAP_TYPE: case MAP_TYPE:
return Op::template apply<Map::BodyDescriptor>(p1, p2, p3); return Op::template apply<Map::BodyDescriptor>(p1, p2, p3, p4);
case CODE_TYPE: case CODE_TYPE:
return Op::template apply<Code::BodyDescriptor>(p1, p2, p3); return Op::template apply<Code::BodyDescriptor>(p1, p2, p3, p4);
case CELL_TYPE: case CELL_TYPE:
return Op::template apply<Cell::BodyDescriptor>(p1, p2, p3); return Op::template apply<Cell::BodyDescriptor>(p1, p2, p3, p4);
case PROPERTY_CELL_TYPE: case PROPERTY_CELL_TYPE:
return Op::template apply<PropertyCell::BodyDescriptor>(p1, p2, p3); return Op::template apply<PropertyCell::BodyDescriptor>(p1, p2, p3, p4);
case WEAK_CELL_TYPE: case WEAK_CELL_TYPE:
return Op::template apply<WeakCell::BodyDescriptor>(p1, p2, p3); return Op::template apply<WeakCell::BodyDescriptor>(p1, p2, p3, p4);
case SYMBOL_TYPE: case SYMBOL_TYPE:
return Op::template apply<Symbol::BodyDescriptor>(p1, p2, p3); return Op::template apply<Symbol::BodyDescriptor>(p1, p2, p3, p4);
case BYTECODE_ARRAY_TYPE: case BYTECODE_ARRAY_TYPE:
return Op::template apply<BytecodeArray::BodyDescriptor>(p1, p2, p3); return Op::template apply<BytecodeArray::BodyDescriptor>(p1, p2, p3, p4);
case SMALL_ORDERED_HASH_SET_TYPE: case SMALL_ORDERED_HASH_SET_TYPE:
return Op::template apply< return Op::template apply<
SmallOrderedHashTable<SmallOrderedHashSet>::BodyDescriptor>(p1, p2, SmallOrderedHashTable<SmallOrderedHashSet>::BodyDescriptor>(p1, p2,
p3); p3, p4);
case SMALL_ORDERED_HASH_MAP_TYPE: case SMALL_ORDERED_HASH_MAP_TYPE:
return Op::template apply< return Op::template apply<
SmallOrderedHashTable<SmallOrderedHashMap>::BodyDescriptor>(p1, p2, SmallOrderedHashTable<SmallOrderedHashMap>::BodyDescriptor>(p1, p2,
p3); p3, p4);
case CODE_DATA_CONTAINER_TYPE: case CODE_DATA_CONTAINER_TYPE:
return Op::template apply<CodeDataContainer::BodyDescriptor>(p1, p2, p3); return Op::template apply<CodeDataContainer::BodyDescriptor>(p1, p2, p3,
p4);
case HEAP_NUMBER_TYPE: case HEAP_NUMBER_TYPE:
case MUTABLE_HEAP_NUMBER_TYPE: case MUTABLE_HEAP_NUMBER_TYPE:
case FILLER_TYPE: case FILLER_TYPE:
...@@ -624,25 +649,28 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) { ...@@ -624,25 +649,28 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) {
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case FIXED_##TYPE##_ARRAY_TYPE: \ case FIXED_##TYPE##_ARRAY_TYPE: \
return Op::template apply<FixedTypedArrayBase::BodyDescriptor>(p1, p2, p3); return Op::template apply<FixedTypedArrayBase::BodyDescriptor>(p1, p2, p3, \
p4);
TYPED_ARRAYS(TYPED_ARRAY_CASE) TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE #undef TYPED_ARRAY_CASE
case SHARED_FUNCTION_INFO_TYPE: { case SHARED_FUNCTION_INFO_TYPE: {
return Op::template apply<SharedFunctionInfo::BodyDescriptor>(p1, p2, p3); return Op::template apply<SharedFunctionInfo::BodyDescriptor>(p1, p2, p3,
p4);
} }
#define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE:
STRUCT_LIST(MAKE_STRUCT_CASE) STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE #undef MAKE_STRUCT_CASE
if (type == ALLOCATION_SITE_TYPE) { if (type == ALLOCATION_SITE_TYPE) {
return Op::template apply<AllocationSite::BodyDescriptor>(p1, p2, p3); return Op::template apply<AllocationSite::BodyDescriptor>(p1, p2, p3,
p4);
} else { } else {
return Op::template apply<StructBodyDescriptor>(p1, p2, p3); return Op::template apply<StructBodyDescriptor>(p1, p2, p3, p4);
} }
case LOAD_HANDLER_TYPE: case LOAD_HANDLER_TYPE:
case STORE_HANDLER_TYPE: case STORE_HANDLER_TYPE:
return Op::template apply<StructBodyDescriptor>(p1, p2, p3); return Op::template apply<StructBodyDescriptor>(p1, p2, p3, p4);
default: default:
PrintF("Unknown type: %d\n", type); PrintF("Unknown type: %d\n", type);
UNREACHABLE(); UNREACHABLE();
...@@ -660,21 +688,22 @@ void HeapObject::IterateFast(ObjectVisitor* v) { ...@@ -660,21 +688,22 @@ void HeapObject::IterateFast(ObjectVisitor* v) {
template <typename ObjectVisitor> template <typename ObjectVisitor>
void HeapObject::IterateBodyFast(ObjectVisitor* v) { void HeapObject::IterateBodyFast(ObjectVisitor* v) {
Map* m = map(); Map* m = map();
IterateBodyFast(m->instance_type(), SizeFromMap(m), v); IterateBodyFast(m, SizeFromMap(m), v);
} }
struct CallIterateBody { struct CallIterateBody {
template <typename BodyDescriptor, typename ObjectVisitor> template <typename BodyDescriptor, typename ObjectVisitor>
static void apply(HeapObject* obj, int object_size, ObjectVisitor* v) { static void apply(Map* map, HeapObject* obj, int object_size,
BodyDescriptor::IterateBody(obj, object_size, v); ObjectVisitor* v) {
BodyDescriptor::IterateBody(map, obj, object_size, v);
} }
}; };
template <typename ObjectVisitor> template <typename ObjectVisitor>
void HeapObject::IterateBodyFast(InstanceType type, int object_size, void HeapObject::IterateBodyFast(Map* map, int object_size, ObjectVisitor* v) {
ObjectVisitor* v) { BodyDescriptorApply<CallIterateBody, void>(map->instance_type(), map, this,
BodyDescriptorApply<CallIterateBody, void>(type, this, object_size, v); object_size, v);
} }
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -18,13 +18,13 @@ namespace internal { ...@@ -18,13 +18,13 @@ namespace internal {
// It is used for invalid slots filtering. If the offset points outside // It is used for invalid slots filtering. If the offset points outside
// of the object or to the map word, the result is UNDEFINED (!!!). // of the object or to the map word, the result is UNDEFINED (!!!).
// //
// static bool IsValidSlot(HeapObject* obj, int offset); // static bool IsValidSlot(Map* map, HeapObject* obj, int offset);
// //
// //
// 2) Iterate object's body using stateful object visitor. // 2) Iterate object's body using stateful object visitor.
// //
// template <typename ObjectVisitor> // template <typename ObjectVisitor>
// static inline void IterateBody(HeapObject* obj, int object_size, // static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
// ObjectVisitor* v); // ObjectVisitor* v);
class BodyDescriptorBase BASE_EMBEDDED { class BodyDescriptorBase BASE_EMBEDDED {
public: public:
...@@ -46,12 +46,13 @@ class BodyDescriptorBase BASE_EMBEDDED { ...@@ -46,12 +46,13 @@ class BodyDescriptorBase BASE_EMBEDDED {
protected: protected:
// Returns true for all header and embedder fields. // Returns true for all header and embedder fields.
static inline bool IsValidSlotImpl(HeapObject* obj, int offset); static inline bool IsValidSlotImpl(Map* map, HeapObject* obj, int offset);
// Treats all header and embedder fields in the range as tagged. // Treats all header and embedder fields in the range as tagged.
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBodyImpl(HeapObject* obj, int start_offset, static inline void IterateBodyImpl(Map* map, HeapObject* obj,
int end_offset, ObjectVisitor* v); int start_offset, int end_offset,
ObjectVisitor* v);
}; };
...@@ -65,19 +66,19 @@ class FixedBodyDescriptor final : public BodyDescriptorBase { ...@@ -65,19 +66,19 @@ class FixedBodyDescriptor final : public BodyDescriptorBase {
static const int kEndOffset = end_offset; static const int kEndOffset = end_offset;
static const int kSize = size; static const int kSize = size;
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return offset >= kStartOffset && offset < kEndOffset; return offset >= kStartOffset && offset < kEndOffset;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) { static inline void IterateBody(Map* map, HeapObject* obj, ObjectVisitor* v) {
IteratePointers(obj, start_offset, end_offset, v); IteratePointers(obj, start_offset, end_offset, v);
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IterateBody(obj, v); IterateBody(map, obj, v);
} }
static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } static inline int SizeOf(Map* map, HeapObject* object) { return kSize; }
...@@ -92,12 +93,12 @@ class FlexibleBodyDescriptor final : public BodyDescriptorBase { ...@@ -92,12 +93,12 @@ class FlexibleBodyDescriptor final : public BodyDescriptorBase {
public: public:
static const int kStartOffset = start_offset; static const int kStartOffset = start_offset;
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
return (offset >= kStartOffset); return (offset >= kStartOffset);
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(Map* map, HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IteratePointers(obj, start_offset, object_size, v); IteratePointers(obj, start_offset, object_size, v);
} }
......
...@@ -1341,8 +1341,7 @@ int JSObject::GetHeaderSize(InstanceType type, ...@@ -1341,8 +1341,7 @@ int JSObject::GetHeaderSize(InstanceType type,
case JS_BOUND_FUNCTION_TYPE: case JS_BOUND_FUNCTION_TYPE:
return JSBoundFunction::kSize; return JSBoundFunction::kSize;
case JS_FUNCTION_TYPE: case JS_FUNCTION_TYPE:
return function_has_prototype_slot ? JSFunction::kSizeWithPrototype return JSFunction::GetHeaderSize(function_has_prototype_slot);
: JSFunction::kSizeWithoutPrototype;
case JS_VALUE_TYPE: case JS_VALUE_TYPE:
return JSValue::kSize; return JSValue::kSize;
case JS_DATE_TYPE: case JS_DATE_TYPE:
...@@ -3479,27 +3478,24 @@ void HeapObject::Iterate(ObjectVisitor* v) { IterateFast<ObjectVisitor>(v); } ...@@ -3479,27 +3478,24 @@ void HeapObject::Iterate(ObjectVisitor* v) { IterateFast<ObjectVisitor>(v); }
void HeapObject::IterateBody(ObjectVisitor* v) { void HeapObject::IterateBody(ObjectVisitor* v) {
Map* m = map(); Map* m = map();
IterateBodyFast<ObjectVisitor>(m->instance_type(), SizeFromMap(m), v); IterateBodyFast<ObjectVisitor>(m, SizeFromMap(m), v);
} }
void HeapObject::IterateBody(Map* map, int object_size, ObjectVisitor* v) {
void HeapObject::IterateBody(InstanceType type, int object_size, IterateBodyFast<ObjectVisitor>(map, object_size, v);
ObjectVisitor* v) {
IterateBodyFast<ObjectVisitor>(type, object_size, v);
} }
struct CallIsValidSlot { struct CallIsValidSlot {
template <typename BodyDescriptor> template <typename BodyDescriptor>
static bool apply(HeapObject* obj, int offset, int) { static bool apply(Map* map, HeapObject* obj, int offset, int) {
return BodyDescriptor::IsValidSlot(obj, offset); return BodyDescriptor::IsValidSlot(map, obj, offset);
} }
}; };
bool HeapObject::IsValidSlot(Map* map, int offset) {
bool HeapObject::IsValidSlot(int offset) {
DCHECK_NE(0, offset); DCHECK_NE(0, offset);
return BodyDescriptorApply<CallIsValidSlot, bool>(map()->instance_type(), return BodyDescriptorApply<CallIsValidSlot, bool>(map->instance_type(), map,
this, offset, 0); this, offset, 0);
} }
......
...@@ -1750,19 +1750,18 @@ class HeapObject: public Object { ...@@ -1750,19 +1750,18 @@ class HeapObject: public Object {
// If it's not performance critical iteration use the non-templatized // If it's not performance critical iteration use the non-templatized
// version. // version.
void IterateBody(ObjectVisitor* v); void IterateBody(ObjectVisitor* v);
void IterateBody(InstanceType type, int object_size, ObjectVisitor* v); void IterateBody(Map* map, int object_size, ObjectVisitor* v);
template <typename ObjectVisitor> template <typename ObjectVisitor>
inline void IterateBodyFast(ObjectVisitor* v); inline void IterateBodyFast(ObjectVisitor* v);
template <typename ObjectVisitor> template <typename ObjectVisitor>
inline void IterateBodyFast(InstanceType type, int object_size, inline void IterateBodyFast(Map* map, int object_size, ObjectVisitor* v);
ObjectVisitor* v);
// Returns true if the object contains a tagged value at given offset. // Returns true if the object contains a tagged value at given offset.
// It is used for invalid slots filtering. If the offset points outside // It is used for invalid slots filtering. If the offset points outside
// of the object or to the map word, the result is UNDEFINED (!!!). // of the object or to the map word, the result is UNDEFINED (!!!).
bool IsValidSlot(int offset); bool IsValidSlot(Map* map, int offset);
// Returns the heap object's size in bytes // Returns the heap object's size in bytes
inline int Size() const; inline int Size() const;
...@@ -3445,6 +3444,11 @@ class JSFunction: public JSObject { ...@@ -3445,6 +3444,11 @@ class JSFunction: public JSObject {
// Returns if this function has been compiled to native code yet. // Returns if this function has been compiled to native code yet.
inline bool is_compiled(); inline bool is_compiled();
static int GetHeaderSize(bool function_has_prototype_slot) {
return function_has_prototype_slot ? JSFunction::kSizeWithPrototype
: JSFunction::kSizeWithoutPrototype;
}
// Prints the name of the function using PrintF. // Prints the name of the function using PrintF.
void PrintName(FILE* out = stdout); void PrintName(FILE* out = stdout);
......
...@@ -667,12 +667,12 @@ void Serializer<AllocatorT>::ObjectSerializer::SerializeContent(Map* map, ...@@ -667,12 +667,12 @@ void Serializer<AllocatorT>::ObjectSerializer::SerializeContent(Map* map,
// For code objects, output raw bytes first. // For code objects, output raw bytes first.
OutputCode(size); OutputCode(size);
// Then iterate references via reloc info. // Then iterate references via reloc info.
object_->IterateBody(map->instance_type(), size, this); object_->IterateBody(map, size, this);
// Finally skip to the end. // Finally skip to the end.
serializer_->FlushSkip(SkipTo(object_->address() + size)); serializer_->FlushSkip(SkipTo(object_->address() + size));
} else { } else {
// For other objects, iterate references first. // For other objects, iterate references first.
object_->IterateBody(map->instance_type(), size, this); object_->IterateBody(map, size, this);
// Then output data payload, if any. // Then output data payload, if any.
OutputRawData(object_->address() + size); OutputRawData(object_->address() + size);
} }
......
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