[csa][cleanup] TNodify LoadElementAndPrepareForStore's return value
Bug: v8:6949, v8:11384 Change-Id: Ief5a14e5c4327adb8fe9c12fd4af72596a1ba20a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2692209 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org> Cr-Commit-Position: refs/heads/master@{#72703}
This commit is contained in:
parent
3393378b3b
commit
b309b9ae7f
@ -4867,19 +4867,24 @@ void CodeStubAssembler::CopyFixedArrayElements(
|
||||
if_hole = nullptr;
|
||||
}
|
||||
|
||||
Node* value = LoadElementAndPrepareForStore(
|
||||
from_array, var_from_offset.value(), from_kind, to_kind, if_hole);
|
||||
|
||||
if (needs_write_barrier) {
|
||||
CHECK_EQ(to_array, to_array_adjusted);
|
||||
Store(to_array_adjusted, to_offset, value);
|
||||
} else if (to_double_elements) {
|
||||
if (to_double_elements) {
|
||||
DCHECK(!needs_write_barrier);
|
||||
TNode<Float64T> value = LoadElementAndPrepareForStore<Float64T>(
|
||||
from_array, var_from_offset.value(), from_kind, to_kind, if_hole);
|
||||
StoreNoWriteBarrier(MachineRepresentation::kFloat64, to_array_adjusted,
|
||||
to_offset, value);
|
||||
} else {
|
||||
UnsafeStoreNoWriteBarrier(MachineRepresentation::kTagged,
|
||||
to_array_adjusted, to_offset, value);
|
||||
TNode<Object> value = LoadElementAndPrepareForStore<Object>(
|
||||
from_array, var_from_offset.value(), from_kind, to_kind, if_hole);
|
||||
if (needs_write_barrier) {
|
||||
CHECK_EQ(to_array, to_array_adjusted);
|
||||
Store(to_array_adjusted, to_offset, value);
|
||||
} else {
|
||||
UnsafeStoreNoWriteBarrier(MachineRepresentation::kTagged,
|
||||
to_array_adjusted, to_offset, value);
|
||||
}
|
||||
}
|
||||
|
||||
Goto(&next_iter);
|
||||
|
||||
if (if_hole == &store_double_hole) {
|
||||
@ -4991,33 +4996,46 @@ TNode<FixedArrayBase> CodeStubAssembler::CloneFixedArray(
|
||||
base::Optional<TNode<BInt>>(base::nullopt), flags);
|
||||
}
|
||||
|
||||
Node* CodeStubAssembler::LoadElementAndPrepareForStore(
|
||||
template <>
|
||||
TNode<Object> CodeStubAssembler::LoadElementAndPrepareForStore(
|
||||
TNode<FixedArrayBase> array, TNode<IntPtrT> offset, ElementsKind from_kind,
|
||||
ElementsKind to_kind, Label* if_hole) {
|
||||
CSA_ASSERT(this, IsFixedArrayWithKind(array, from_kind));
|
||||
DCHECK(!IsDoubleElementsKind(to_kind));
|
||||
if (IsDoubleElementsKind(from_kind)) {
|
||||
TNode<Float64T> value =
|
||||
LoadDoubleWithHoleCheck(array, offset, if_hole, MachineType::Float64());
|
||||
if (!IsDoubleElementsKind(to_kind)) {
|
||||
return AllocateHeapNumberWithValue(value);
|
||||
}
|
||||
return value;
|
||||
|
||||
return AllocateHeapNumberWithValue(value);
|
||||
} else {
|
||||
TNode<Object> value = Load<Object>(array, offset);
|
||||
if (if_hole) {
|
||||
GotoIf(TaggedEqual(value, TheHoleConstant()), if_hole);
|
||||
}
|
||||
if (IsDoubleElementsKind(to_kind)) {
|
||||
if (IsSmiElementsKind(from_kind)) {
|
||||
return SmiToFloat64(CAST(value));
|
||||
}
|
||||
return LoadHeapNumberValue(CAST(value));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TNode<Float64T> CodeStubAssembler::LoadElementAndPrepareForStore(
|
||||
TNode<FixedArrayBase> array, TNode<IntPtrT> offset, ElementsKind from_kind,
|
||||
ElementsKind to_kind, Label* if_hole) {
|
||||
CSA_ASSERT(this, IsFixedArrayWithKind(array, from_kind));
|
||||
DCHECK(IsDoubleElementsKind(to_kind));
|
||||
if (IsDoubleElementsKind(from_kind)) {
|
||||
return LoadDoubleWithHoleCheck(array, offset, if_hole,
|
||||
MachineType::Float64());
|
||||
} else {
|
||||
TNode<Object> value = Load<Object>(array, offset);
|
||||
if (if_hole) {
|
||||
GotoIf(TaggedEqual(value, TheHoleConstant()), if_hole);
|
||||
}
|
||||
if (IsSmiElementsKind(from_kind)) {
|
||||
return SmiToFloat64(CAST(value));
|
||||
}
|
||||
return LoadHeapNumberValue(CAST(value));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TIndex>
|
||||
TNode<TIndex> CodeStubAssembler::CalculateNewElementsCapacity(
|
||||
TNode<TIndex> old_capacity) {
|
||||
|
@ -2168,10 +2168,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
|
||||
// (NOTE: not index!), does a hole check if |if_hole| is provided and
|
||||
// converts the value so that it becomes ready for storing to array of
|
||||
// |to_kind| elements.
|
||||
Node* LoadElementAndPrepareForStore(TNode<FixedArrayBase> array,
|
||||
TNode<IntPtrT> offset,
|
||||
ElementsKind from_kind,
|
||||
ElementsKind to_kind, Label* if_hole);
|
||||
template <typename TResult>
|
||||
TNode<TResult> LoadElementAndPrepareForStore(TNode<FixedArrayBase> array,
|
||||
TNode<IntPtrT> offset,
|
||||
ElementsKind from_kind,
|
||||
ElementsKind to_kind,
|
||||
Label* if_hole);
|
||||
|
||||
template <typename TIndex>
|
||||
TNode<TIndex> CalculateNewElementsCapacity(TNode<TIndex> old_capacity);
|
||||
|
Loading…
Reference in New Issue
Block a user