Commit dbe1b9d8 authored by Mythri A's avatar Mythri A Committed by Commit Bot

[cleanup] TNodify StoreJSTypedArrayElementFromTagged

Bug: v8:6949, v8:11074
Change-Id: I05326fd514ea33ccaa783f5964a338d84b370e84
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2550781Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71313}
parent 52fa3d37
...@@ -429,14 +429,14 @@ void TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromNumeric( ...@@ -429,14 +429,14 @@ void TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromNumeric(
} }
} }
void TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromTagged( template <typename TValue>
void TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromPreparedValue(
TNode<Context> context, TNode<JSTypedArray> typed_array, TNode<Context> context, TNode<JSTypedArray> typed_array,
TNode<UintPtrT> index, TNode<Object> value, ElementsKind elements_kind, TNode<UintPtrT> index, TNode<TValue> prepared_value,
Label* if_detached) { ElementsKind elements_kind, Label* if_detached) {
// |prepared_value| is Word32T or Float64T or Float32T or BigInt. static_assert(std::is_same<TValue, UntaggedT>::value ||
Node* prepared_value = std::is_same<TValue, BigInt>::value,
PrepareValueForWriteToTypedArray(value, elements_kind, context); "Only UntaggedT or BigInt values are allowed");
// ToNumber/ToBigInt may execute JavaScript code, which could detach // ToNumber/ToBigInt may execute JavaScript code, which could detach
// the array's buffer. // the array's buffer.
TNode<JSArrayBuffer> buffer = LoadJSArrayBufferViewBuffer(typed_array); TNode<JSArrayBuffer> buffer = LoadJSArrayBufferViewBuffer(typed_array);
...@@ -446,6 +446,27 @@ void TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromTagged( ...@@ -446,6 +446,27 @@ void TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromTagged(
StoreElement(data_ptr, elements_kind, index, prepared_value); StoreElement(data_ptr, elements_kind, index, prepared_value);
} }
void TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromTagged(
TNode<Context> context, TNode<JSTypedArray> typed_array,
TNode<UintPtrT> index, TNode<Object> value, ElementsKind elements_kind,
Label* if_detached) {
if (elements_kind == BIGINT64_ELEMENTS ||
elements_kind == BIGUINT64_ELEMENTS) {
TNode<BigInt> prepared_value =
PrepareValueForWriteToTypedArray<BigInt>(value, elements_kind, context);
StoreJSTypedArrayElementFromPreparedValue(context, typed_array, index,
prepared_value, elements_kind,
if_detached);
} else {
TNode<UntaggedT> prepared_value =
PrepareValueForWriteToTypedArray<UntaggedT>(value, elements_kind,
context);
StoreJSTypedArrayElementFromPreparedValue(context, typed_array, index,
prepared_value, elements_kind,
if_detached);
}
}
// ES #sec-get-%typedarray%.prototype-@@tostringtag // ES #sec-get-%typedarray%.prototype-@@tostringtag
TF_BUILTIN(TypedArrayPrototypeToStringTag, TypedArrayBuiltinsAssembler) { TF_BUILTIN(TypedArrayPrototypeToStringTag, TypedArrayBuiltinsAssembler) {
auto receiver = Parameter<Object>(Descriptor::kReceiver); auto receiver = Parameter<Object>(Descriptor::kReceiver);
......
...@@ -95,6 +95,11 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler { ...@@ -95,6 +95,11 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler {
TNode<Object> value, TNode<Object> value,
ElementsKind elements_kind, ElementsKind elements_kind,
Label* if_detached); Label* if_detached);
template <typename TValue>
void StoreJSTypedArrayElementFromPreparedValue(
TNode<Context> context, TNode<JSTypedArray> typed_array,
TNode<UintPtrT> index_node, TNode<TValue> value,
ElementsKind elements_kind, Label* if_detached);
}; };
} // namespace internal } // namespace internal
......
...@@ -9999,6 +9999,40 @@ TNode<Float64T> CodeStubAssembler::PrepareValueForWriteToTypedArray<Float64T>( ...@@ -9999,6 +9999,40 @@ TNode<Float64T> CodeStubAssembler::PrepareValueForWriteToTypedArray<Float64T>(
return var_result.value(); return var_result.value();
} }
template <>
TNode<BigInt> CodeStubAssembler::PrepareValueForWriteToTypedArray<BigInt>(
TNode<Object> input, ElementsKind elements_kind, TNode<Context> context) {
DCHECK(elements_kind == BIGINT64_ELEMENTS ||
elements_kind == BIGUINT64_ELEMENTS);
return ToBigInt(context, input);
}
template <>
TNode<UntaggedT> CodeStubAssembler::PrepareValueForWriteToTypedArray(
TNode<Object> input, ElementsKind elements_kind, TNode<Context> context) {
DCHECK(IsTypedArrayElementsKind(elements_kind));
switch (elements_kind) {
case UINT8_ELEMENTS:
case INT8_ELEMENTS:
case UINT16_ELEMENTS:
case INT16_ELEMENTS:
case UINT32_ELEMENTS:
case INT32_ELEMENTS:
case UINT8_CLAMPED_ELEMENTS:
return PrepareValueForWriteToTypedArray<Word32T>(input, elements_kind,
context);
case FLOAT32_ELEMENTS:
return PrepareValueForWriteToTypedArray<Float32T>(input, elements_kind,
context);
case FLOAT64_ELEMENTS:
return PrepareValueForWriteToTypedArray<Float64T>(input, elements_kind,
context);
default:
UNREACHABLE();
}
}
Node* CodeStubAssembler::PrepareValueForWriteToTypedArray( Node* CodeStubAssembler::PrepareValueForWriteToTypedArray(
TNode<Object> input, ElementsKind elements_kind, TNode<Context> context) { TNode<Object> input, ElementsKind elements_kind, TNode<Context> context) {
DCHECK(IsTypedArrayElementsKind(elements_kind)); DCHECK(IsTypedArrayElementsKind(elements_kind));
......
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