[ptr-compr] Introduce MemsetTagged() for initializing on-heap kTaggedSize-sized slots
Bug: v8:8518 Change-Id: I39db0adbd84627491bcb653b90de724eb988d383 Reviewed-on: https://chromium-review.googlesource.com/c/1363145 Commit-Queue: Igor Sheludko <ishell@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#58057}
This commit is contained in:
parent
32a79b2b30
commit
014eb84f1f
@ -148,7 +148,7 @@ void CopyObjectToObjectElements(Isolate* isolate, FixedArrayBase from_base,
|
||||
int start = to_start + copy_size;
|
||||
int length = to_base->length() - start;
|
||||
if (length > 0) {
|
||||
MemsetPointer(FixedArray::cast(to_base)->RawFieldOfElementAt(start),
|
||||
MemsetTagged(FixedArray::cast(to_base)->RawFieldOfElementAt(start),
|
||||
roots.the_hole_value(), length);
|
||||
}
|
||||
}
|
||||
@ -186,7 +186,7 @@ static void CopyDictionaryToObjectElements(
|
||||
int start = to_start + copy_size;
|
||||
int length = to_base->length() - start;
|
||||
if (length > 0) {
|
||||
MemsetPointer(FixedArray::cast(to_base)->RawFieldOfElementAt(start),
|
||||
MemsetTagged(FixedArray::cast(to_base)->RawFieldOfElementAt(start),
|
||||
ReadOnlyRoots(isolate).the_hole_value(), length);
|
||||
}
|
||||
}
|
||||
@ -234,7 +234,7 @@ static void CopyDoubleToObjectElements(Isolate* isolate,
|
||||
int start = to_start;
|
||||
int length = to_base->length() - start;
|
||||
if (length > 0) {
|
||||
MemsetPointer(FixedArray::cast(to_base)->RawFieldOfElementAt(start),
|
||||
MemsetTagged(FixedArray::cast(to_base)->RawFieldOfElementAt(start),
|
||||
ReadOnlyRoots(isolate).the_hole_value(), length);
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ Handle<PropertyArray> Factory::NewPropertyArray(int length,
|
||||
result->set_map_after_allocation(*property_array_map(), SKIP_WRITE_BARRIER);
|
||||
Handle<PropertyArray> array(PropertyArray::cast(result), isolate());
|
||||
array->initialize_length(length);
|
||||
MemsetPointer(array->data_start(), *undefined_value(), length);
|
||||
MemsetTagged(array->data_start(), *undefined_value(), length);
|
||||
return array;
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ Handle<FixedArray> Factory::NewFixedArrayWithFiller(RootIndex map_root_index,
|
||||
result->set_map_after_allocation(map, SKIP_WRITE_BARRIER);
|
||||
Handle<FixedArray> array(FixedArray::cast(result), isolate());
|
||||
array->set_length(length);
|
||||
MemsetPointer(array->data_start(), filler, length);
|
||||
MemsetTagged(array->data_start(), filler, length);
|
||||
return array;
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ Handle<T> Factory::NewWeakFixedArrayWithMap(RootIndex map_root_index,
|
||||
|
||||
Handle<WeakFixedArray> array(WeakFixedArray::cast(result), isolate());
|
||||
array->set_length(length);
|
||||
MemsetPointer(ObjectSlot(array->data_start()), *undefined_value(), length);
|
||||
MemsetTagged(ObjectSlot(array->data_start()), *undefined_value(), length);
|
||||
|
||||
return Handle<T>::cast(array);
|
||||
}
|
||||
@ -361,7 +361,7 @@ Handle<WeakFixedArray> Factory::NewWeakFixedArray(int length,
|
||||
result->set_map_after_allocation(*weak_fixed_array_map(), SKIP_WRITE_BARRIER);
|
||||
Handle<WeakFixedArray> array(WeakFixedArray::cast(result), isolate());
|
||||
array->set_length(length);
|
||||
MemsetPointer(ObjectSlot(array->data_start()), *undefined_value(), length);
|
||||
MemsetTagged(ObjectSlot(array->data_start()), *undefined_value(), length);
|
||||
return array;
|
||||
}
|
||||
|
||||
@ -383,7 +383,7 @@ MaybeHandle<FixedArray> Factory::TryNewFixedArray(int length,
|
||||
result->set_map_after_allocation(*fixed_array_map(), SKIP_WRITE_BARRIER);
|
||||
Handle<FixedArray> array(FixedArray::cast(result), isolate());
|
||||
array->set_length(length);
|
||||
MemsetPointer(array->data_start(), ReadOnlyRoots(heap).undefined_value(),
|
||||
MemsetTagged(array->data_start(), ReadOnlyRoots(heap).undefined_value(),
|
||||
length);
|
||||
return array;
|
||||
}
|
||||
@ -426,7 +426,7 @@ Handle<FeedbackVector> Factory::NewFeedbackVector(
|
||||
vector->set_profiler_ticks(0);
|
||||
vector->set_deopt_count(0);
|
||||
// TODO(leszeks): Initialize based on the feedback metadata.
|
||||
MemsetPointer(ObjectSlot(vector->slots_start()), *undefined_value(), length);
|
||||
MemsetTagged(ObjectSlot(vector->slots_start()), *undefined_value(), length);
|
||||
return vector;
|
||||
}
|
||||
|
||||
@ -444,7 +444,7 @@ Handle<EmbedderDataArray> Factory::NewEmbedderDataArray(
|
||||
ObjectSlot start(array->slots_start());
|
||||
ObjectSlot end(array->slots_end());
|
||||
size_t slot_count = end - start;
|
||||
MemsetPointer(start, *undefined_value(), slot_count);
|
||||
MemsetTagged(start, *undefined_value(), slot_count);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
@ -1418,7 +1418,7 @@ Handle<Context> Factory::NewContext(RootIndex map_root_index, int size,
|
||||
ObjectSlot start = context->RawField(Context::kTodoHeaderSize);
|
||||
ObjectSlot end = context->RawField(size);
|
||||
size_t slot_count = end - start;
|
||||
MemsetPointer(start, *undefined_value(), slot_count);
|
||||
MemsetTagged(start, *undefined_value(), slot_count);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
@ -2126,7 +2126,7 @@ Handle<T> Factory::CopyArrayAndGrow(Handle<T> src, int grow_by,
|
||||
DisallowHeapAllocation no_gc;
|
||||
WriteBarrierMode mode = obj->GetWriteBarrierMode(no_gc);
|
||||
for (int i = 0; i < old_len; i++) result->set(i, src->get(i), mode);
|
||||
MemsetPointer(result->data_start() + old_len, *undefined_value(), grow_by);
|
||||
MemsetTagged(result->data_start() + old_len, *undefined_value(), grow_by);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2159,7 +2159,7 @@ Handle<WeakFixedArray> Factory::CopyWeakFixedArrayAndGrow(
|
||||
DisallowHeapAllocation no_gc;
|
||||
WriteBarrierMode mode = obj->GetWriteBarrierMode(no_gc);
|
||||
for (int i = 0; i < old_len; i++) result->Set(i, src->Get(i), mode);
|
||||
MemsetPointer(ObjectSlot(result->RawFieldOfElementAt(old_len)),
|
||||
MemsetTagged(ObjectSlot(result->RawFieldOfElementAt(old_len)),
|
||||
ReadOnlyRoots(isolate()).undefined_value(), grow_by);
|
||||
return Handle<WeakFixedArray>(result, isolate());
|
||||
}
|
||||
@ -2180,7 +2180,7 @@ Handle<WeakArrayList> Factory::CopyWeakArrayListAndGrow(
|
||||
DisallowHeapAllocation no_gc;
|
||||
WriteBarrierMode mode = obj->GetWriteBarrierMode(no_gc);
|
||||
for (int i = 0; i < old_capacity; i++) result->Set(i, src->Get(i), mode);
|
||||
MemsetPointer(ObjectSlot(result->data_start() + old_capacity),
|
||||
MemsetTagged(ObjectSlot(result->data_start() + old_capacity),
|
||||
ReadOnlyRoots(isolate()).undefined_value(), grow_by);
|
||||
return Handle<WeakArrayList>(result, isolate());
|
||||
}
|
||||
@ -2628,7 +2628,7 @@ Handle<PreParsedScopeData> Factory::NewPreParsedScopeData(int length) {
|
||||
isolate());
|
||||
result->set_scope_data(PodArray<uint8_t>::cast(*empty_byte_array()));
|
||||
result->set_length(length);
|
||||
MemsetPointer(result->child_data_start(), *null_value(), length);
|
||||
MemsetTagged(result->child_data_start(), *null_value(), length);
|
||||
|
||||
result->clear_padding();
|
||||
return result;
|
||||
|
@ -2631,9 +2631,9 @@ FixedArrayBase Heap::LeftTrimFixedArray(FixedArrayBase object,
|
||||
// we need pointer granularity writes to avoid race with the concurrent
|
||||
// marking.
|
||||
if (filler->Size() > FreeSpace::kSize) {
|
||||
MemsetPointer(HeapObject::RawField(filler, FreeSpace::kSize),
|
||||
MemsetTagged(HeapObject::RawField(filler, FreeSpace::kSize),
|
||||
ReadOnlyRoots(this).undefined_value(),
|
||||
(filler->Size() - FreeSpace::kSize) / kPointerSize);
|
||||
(filler->Size() - FreeSpace::kSize) / kTaggedSize);
|
||||
}
|
||||
}
|
||||
// Notify the heap profiler of change in object layout.
|
||||
|
@ -10758,7 +10758,7 @@ void DescriptorArray::Initialize(EnumCache* enum_cache,
|
||||
set_number_of_marked_descriptors(0);
|
||||
set_filler16bits(0);
|
||||
set_enum_cache(enum_cache);
|
||||
MemsetPointer(GetDescriptorSlot(0), undefined_value,
|
||||
MemsetTagged(GetDescriptorSlot(0), undefined_value,
|
||||
number_of_all_descriptors() * kEntrySize);
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ void SmallOrderedHashTable<Derived>::Initialize(Isolate* isolate,
|
||||
num_buckets + num_chains);
|
||||
|
||||
if (Heap::InNewSpace(*this)) {
|
||||
MemsetPointer(RawField(kDataTableStartOffset),
|
||||
MemsetTagged(RawField(kDataTableStartOffset),
|
||||
ReadOnlyRoots(isolate).the_hole_value(),
|
||||
capacity * Derived::kEntrySize);
|
||||
} else {
|
||||
|
@ -117,6 +117,15 @@ void FullHeapObjectSlot::store(HeapObjectReference value) const {
|
||||
// Utils.
|
||||
//
|
||||
|
||||
// Sets |counter| number of kTaggedSize-sized values starting at |start| slot.
|
||||
inline void MemsetTagged(ObjectSlot start, Object* value, size_t counter) {
|
||||
// TODO(ishell): revisit this implementation, maybe use "rep stosl"
|
||||
STATIC_ASSERT(kTaggedSize == kSystemPointerSize);
|
||||
MemsetPointer(start.location(), reinterpret_cast<Address>(value), counter);
|
||||
}
|
||||
|
||||
// Sets |counter| number of kSystemPointerSize-sized values starting at |start|
|
||||
// slot.
|
||||
inline void MemsetPointer(FullObjectSlot start, Object* value, size_t counter) {
|
||||
MemsetPointer(start.location(), reinterpret_cast<Address>(value), counter);
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ RUNTIME_FUNCTION(Runtime_StringToArray) {
|
||||
position = CopyCachedOneByteCharsToArray(isolate->heap(), chars.start(),
|
||||
*elements, length);
|
||||
} else {
|
||||
MemsetPointer(elements->data_start(),
|
||||
MemsetTagged(elements->data_start(),
|
||||
ReadOnlyRoots(isolate).undefined_value(), length);
|
||||
}
|
||||
} else {
|
||||
|
@ -461,7 +461,7 @@ Map TransitionsAccessor::GetMigrationTarget() {
|
||||
}
|
||||
|
||||
void TransitionArray::Zap(Isolate* isolate) {
|
||||
MemsetPointer(ObjectSlot(data_start() + kPrototypeTransitionsIndex),
|
||||
MemsetTagged(ObjectSlot(RawFieldOfElementAt(kPrototypeTransitionsIndex)),
|
||||
ReadOnlyRoots(isolate).the_hole_value(),
|
||||
length() - kPrototypeTransitionsIndex);
|
||||
SetNumberOfTransitions(0);
|
||||
|
@ -126,7 +126,7 @@ AllocationResult HeapTester::AllocateFixedArrayForTest(
|
||||
SKIP_WRITE_BARRIER);
|
||||
FixedArray array = FixedArray::cast(obj);
|
||||
array->set_length(length);
|
||||
MemsetPointer(array->data_start(), ReadOnlyRoots(heap).undefined_value(),
|
||||
MemsetTagged(array->data_start(), ReadOnlyRoots(heap).undefined_value(),
|
||||
length);
|
||||
return array;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user