Commit a786179c authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[csa][cleanup] Simplify StoreFixedArrayElement

We can remove some of the method definitions, as well as the
sloppy-ness from the method.

Bug: v8:6949, v8:11384
Change-Id: I04880daa3fcce097b79009f12bd24128a47c2c80
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2690591Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72867}
parent d112b6d6
......@@ -32,7 +32,7 @@ macro StoreElement<ElementsAccessor : type extends ElementsKind, T: type>(
StoreElement<array::FastPackedSmiElements, Smi>(implicit context: Context)(
elements: FixedArrayBase, index: Smi, value: Smi) {
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
StoreFixedArrayElement(elems, index, value, SKIP_WRITE_BARRIER);
StoreFixedArrayElement(elems, index, value);
}
StoreElement<array::FastPackedObjectElements, JSAny>(implicit context: Context)(
......
......@@ -1555,37 +1555,43 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
void StoreMapNoWriteBarrier(TNode<HeapObject> object, TNode<Map> map);
void StoreObjectFieldRoot(TNode<HeapObject> object, int offset,
RootIndex root);
// Store an array element to a FixedArray.
void StoreFixedArrayElement(
TNode<FixedArray> object, int index, SloppyTNode<Object> value,
TNode<FixedArray> object, int index, TNode<Object> value,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
CheckBounds check_bounds = CheckBounds::kAlways) {
return StoreFixedArrayElement(object, IntPtrConstant(index), value,
barrier_mode, 0, check_bounds);
}
// This doesn't emit a bounds-check. As part of the security-performance
// tradeoff, only use it if it is performance critical.
void UnsafeStoreFixedArrayElement(
TNode<FixedArray> object, int index, TNode<Object> value,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) {
return StoreFixedArrayElement(object, index, value, barrier_mode,
CheckBounds::kDebugOnly);
return StoreFixedArrayElement(object, IntPtrConstant(index), value,
barrier_mode, 0, CheckBounds::kDebugOnly);
}
void UnsafeStoreFixedArrayElement(TNode<FixedArray> object, int index,
TNode<Smi> value) {
return StoreFixedArrayElement(object, index, value,
UNSAFE_SKIP_WRITE_BARRIER,
return StoreFixedArrayElement(object, IntPtrConstant(index), value,
UNSAFE_SKIP_WRITE_BARRIER, 0,
CheckBounds::kDebugOnly);
}
void StoreFixedArrayElement(TNode<FixedArray> object, int index,
TNode<Smi> value,
CheckBounds check_bounds = CheckBounds::kAlways) {
return StoreFixedArrayElement(object, IntPtrConstant(index), value,
return StoreFixedArrayElement(object, IntPtrConstant(index),
TNode<Object>{value},
UNSAFE_SKIP_WRITE_BARRIER, 0, check_bounds);
}
template <typename TIndex>
void StoreFixedArrayElement(
TNode<FixedArray> array, TNode<TIndex> index, SloppyTNode<Object> value,
TNode<FixedArray> array, TNode<TIndex> index, TNode<Object> value,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
int additional_offset = 0,
CheckBounds check_bounds = CheckBounds::kAlways) {
......@@ -1600,6 +1606,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
StoreFixedArrayOrPropertyArrayElement(array, index, value, barrier_mode,
additional_offset);
}
// This doesn't emit a bounds-check. As part of the security-performance
// tradeoff, only use it if it is performance critical.
void UnsafeStoreFixedArrayElement(
......@@ -1624,24 +1631,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
UPDATE_WRITE_BARRIER);
}
void StoreFixedArrayElement(
TNode<FixedArray> array, TNode<Smi> index, TNode<Object> value,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) {
StoreFixedArrayElement(array, index, value, barrier_mode, 0);
}
void StoreFixedArrayElement(
TNode<FixedArray> array, TNode<IntPtrT> index, TNode<Smi> value,
WriteBarrierMode barrier_mode = SKIP_WRITE_BARRIER,
int additional_offset = 0) {
DCHECK_EQ(SKIP_WRITE_BARRIER, barrier_mode);
StoreFixedArrayElement(array, index, TNode<Object>{value},
UNSAFE_SKIP_WRITE_BARRIER, additional_offset);
}
void StoreFixedArrayElement(
TNode<FixedArray> array, TNode<Smi> index, TNode<Smi> value,
WriteBarrierMode barrier_mode = SKIP_WRITE_BARRIER,
int additional_offset = 0) {
DCHECK_EQ(SKIP_WRITE_BARRIER, barrier_mode);
template <typename TIndex>
void StoreFixedArrayElement(TNode<FixedArray> array, TNode<TIndex> index,
TNode<Smi> value, int additional_offset = 0) {
static_assert(std::is_same<TIndex, Smi>::value ||
std::is_same<TIndex, IntPtrT>::value,
"Only Smi or IntPtrT indeces is allowed");
StoreFixedArrayElement(array, index, TNode<Object>{value},
UNSAFE_SKIP_WRITE_BARRIER, additional_offset);
}
......@@ -2862,8 +2857,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
const int kKeyToDetailsOffset =
(ContainerType::kEntryDetailsIndex - ContainerType::kEntryKeyIndex) *
kTaggedSize;
StoreFixedArrayElement(container, key_index, details, SKIP_WRITE_BARRIER,
kKeyToDetailsOffset);
StoreFixedArrayElement(container, key_index, details, kKeyToDetailsOffset);
}
// Stores the value for the entry with the given key_index.
......
......@@ -211,7 +211,7 @@ Handle<Code> BuildTeardownFunction(Isolate* isolate,
Node* param = __ UntypedParameter(i + 2);
switch (parameters[i].representation()) {
case MachineRepresentation::kTagged:
__ StoreFixedArrayElement(result_array, i, param,
__ StoreFixedArrayElement(result_array, i, __ Cast(param),
UNSAFE_SKIP_WRITE_BARRIER);
break;
// Box FP values into HeapNumbers.
......
......@@ -2748,7 +2748,8 @@ TEST(CreatePromiseResolvingFunctions) {
m.NewJSPromise(context, m.UndefinedConstant());
PromiseResolvingFunctions funcs = m.CreatePromiseResolvingFunctions(
context, promise, m.BooleanConstant(false), native_context);
Node *resolve = funcs.resolve, *reject = funcs.reject;
TNode<JSFunction> resolve = funcs.resolve;
TNode<JSFunction> reject = funcs.reject;
TNode<IntPtrT> const kSize = m.IntPtrConstant(2);
TNode<FixedArray> const arr =
m.Cast(m.AllocateFixedArray(PACKED_ELEMENTS, kSize));
......
......@@ -276,7 +276,7 @@ Store<FastSmiElements>(
const object = UnsafeCast<JSObject>(sortState.receiver);
const elements = UnsafeCast<FixedArray>(object.elements);
const value = UnsafeCast<Smi>(value);
StoreFixedArrayElement(elements, index, value, SKIP_WRITE_BARRIER);
StoreFixedArrayElement(elements, index, value);
return kSuccess;
}
......
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