Commit 036525d1 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[elements] Use HeapObject::GetWriteBarrierMode

Bug: v8:11263
Change-Id: I2261d31c491c809599c787e7edbc18ba55c0f14e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2797282Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73756}
parent b1a8df5d
......@@ -154,10 +154,11 @@ MaybeHandle<Object> ThrowArrayLengthRangeError(Isolate* isolate) {
Object);
}
WriteBarrierMode GetWriteBarrierMode(ElementsKind kind) {
WriteBarrierMode GetWriteBarrierMode(FixedArrayBase elements, ElementsKind kind,
const DisallowGarbageCollection& promise) {
if (IsSmiElementsKind(kind)) return SKIP_WRITE_BARRIER;
if (IsDoubleElementsKind(kind)) return SKIP_WRITE_BARRIER;
return UPDATE_WRITE_BARRIER;
return elements.GetWriteBarrierMode(promise);
}
// If kCopyToEndAndInitializeToHole is specified as the copy_size to
......@@ -226,7 +227,7 @@ void CopyDictionaryToObjectElements(Isolate* isolate, FixedArrayBase from_base,
if (to_start + copy_size > to_length) {
copy_size = to_length - to_start;
}
WriteBarrierMode write_barrier_mode = GetWriteBarrierMode(to_kind);
WriteBarrierMode write_barrier_mode = GetWriteBarrierMode(to, to_kind, no_gc);
for (int i = 0; i < copy_size; i++) {
InternalIndex entry = from.FindEntry(isolate, i + from_start);
if (entry.is_found()) {
......@@ -2113,25 +2114,26 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
Handle<FixedArrayBase> backing_store, int dst_index,
int src_index, int len, int hole_start,
int hole_end) {
Handle<BackingStore> dst_elms = Handle<BackingStore>::cast(backing_store);
DisallowGarbageCollection no_gc;
BackingStore dst_elms = BackingStore::cast(*backing_store);
if (len > JSArray::kMaxCopyElements && dst_index == 0 &&
isolate->heap()->CanMoveObjectStart(*dst_elms)) {
isolate->heap()->CanMoveObjectStart(dst_elms)) {
dst_elms = BackingStore::cast(
isolate->heap()->LeftTrimFixedArray(dst_elms, src_index));
// Update all the copies of this backing_store handle.
*dst_elms.location() =
BackingStore::cast(
isolate->heap()->LeftTrimFixedArray(*dst_elms, src_index))
.ptr();
receiver->set_elements(*dst_elms);
*backing_store.location() = dst_elms.ptr();
receiver->set_elements(dst_elms);
// Adjust the hole offset as the array has been shrunk.
hole_end -= src_index;
DCHECK_LE(hole_start, backing_store->length());
DCHECK_LE(hole_end, backing_store->length());
} else if (len != 0) {
WriteBarrierMode mode = GetWriteBarrierMode(KindTraits::Kind);
dst_elms->MoveElements(isolate, dst_index, src_index, len, mode);
WriteBarrierMode mode =
GetWriteBarrierMode(dst_elms, KindTraits::Kind, no_gc);
dst_elms.MoveElements(isolate, dst_index, src_index, len, mode);
}
if (hole_start != hole_end) {
dst_elms->FillWithHoles(hole_start, hole_end);
dst_elms.FillWithHoles(hole_start, hole_end);
}
}
......
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