233 auto maybe_array_or_shared_object =
234 Parameter<Object>(Descriptor::kArrayOrSharedObject);
235 auto index_or_field_name = Parameter<JSAny>(Descriptor::kIndexOrFieldName);
236 auto context = Parameter<Context>(Descriptor::kContext);
239 Label detached_or_out_of_bounds(
this), is_shared_struct_or_shared_array(
this);
243 maybe_array_or_shared_object, context, &elements_kind, &backing_store,
244 &detached_or_out_of_bounds, &is_shared_struct_or_shared_array);
256 CheckJSTypedArrayIndex(array, index_word, &detached_or_out_of_bounds);
261 Label i8(
this), u8(
this), i16(
this), u16(
this), i32(
this), u32(
this),
262 i64(
this), u64(
this), other(
this);
263 int32_t case_values[] = {
264 INT8_ELEMENTS, UINT8_ELEMENTS, INT16_ELEMENTS, UINT16_ELEMENTS,
265 INT32_ELEMENTS, UINT32_ELEMENTS, BIGINT64_ELEMENTS, BIGUINT64_ELEMENTS,
267 Label* case_labels[] = {&i8, &u8, &i16, &u16, &i32, &u32, &i64, &u64};
268 Switch(elements_kind, &other, case_values, case_labels,
273 backing_store, index_word)));
277 backing_store, index_word)));
280 Return(SmiFromInt32(AtomicLoad<Int16T>(
284 Return(SmiFromInt32(AtomicLoad<Uint16T>(
288 Return(ChangeInt32ToTagged(AtomicLoad<Int32T>(
292 Return(ChangeUint32ToTagged(AtomicLoad<Uint32T>(
295 Return(BigIntFromSigned64(AtomicLoad64<AtomicInt64>(
299 Return(BigIntFromUnsigned64(AtomicLoad64<AtomicUint64>(
306 BIND(&detached_or_out_of_bounds);
308 ThrowTypeError(context, MessageTemplate::kDetachedOperation,
312 BIND(&is_shared_struct_or_shared_array);
314 Return(
CallRuntime(Runtime::kAtomicsLoadSharedStructOrArray, context,
315 maybe_array_or_shared_object, index_or_field_name));
321 auto maybe_array_or_shared_object =
322 Parameter<Object>(Descriptor::kArrayOrSharedObject);
323 auto index_or_field_name = Parameter<JSAny>(Descriptor::kIndexOrFieldName);
324 auto value = Parameter<JSAny>(Descriptor::kValue);
325 auto context = Parameter<Context>(Descriptor::kContext);
328 Label detached_or_out_of_bounds(
this), is_shared_struct_or_shared_array(
this);
332 maybe_array_or_shared_object, context, &elements_kind, &backing_store,
333 &detached_or_out_of_bounds, &is_shared_struct_or_shared_array);
340 Label u8(
this), u16(
this), u32(
this), u64(
this), other(
this);
345 static_assert(BIGINT64_ELEMENTS > INT32_ELEMENTS);
346 static_assert(BIGUINT64_ELEMENTS > INT32_ELEMENTS);
347 GotoIf(Int32GreaterThan(elements_kind, Int32Constant(INT32_ELEMENTS)), &u64);
350 TNode<Number> value_integer = ToInteger_Inline(context, value);
357 CheckJSTypedArrayIndex(array, index_word, &detached_or_out_of_bounds);
359 TNode<Word32T> value_word32 = TruncateTaggedToWord32(context, value_integer);
361 DebugCheckAtomicIndex(array, index_word);
366 int32_t case_values[] = {
367 INT8_ELEMENTS, UINT8_ELEMENTS, INT16_ELEMENTS,
368 UINT16_ELEMENTS, INT32_ELEMENTS, UINT32_ELEMENTS,
370 Label* case_labels[] = {&u8, &u8, &u16, &u16, &u32, &u32};
371 Switch(elements_kind, &other, case_values, case_labels,
376 backing_store, index_word, value_word32);
377 Return(value_integer);
381 backing_store, WordShl(index_word, 1), value_word32);
382 Return(value_integer);
386 backing_store, WordShl(index_word, 2), value_word32);
387 Return(value_integer);
395 CheckJSTypedArrayIndex(array, index_word, &detached_or_out_of_bounds);
397 DebugCheckAtomicIndex(array, index_word);
401 BigIntToRawBytes(value_bigint, &var_low, &var_high);
404 WordShl(index_word, 3), var_low.value(), high);
405 Return(value_bigint);
411 BIND(&detached_or_out_of_bounds);
413 ThrowTypeError(context, MessageTemplate::kDetachedOperation,
417 BIND(&is_shared_struct_or_shared_array);
419 Return(
CallRuntime(Runtime::kAtomicsStoreSharedStructOrArray, context,
420 maybe_array_or_shared_object, index_or_field_name,
427 auto maybe_array_or_shared_object =
428 Parameter<Object>(Descriptor::kArrayOrSharedObject);
429 auto index_or_field_name = Parameter<JSAny>(Descriptor::kIndexOrFieldName);
430 auto value = Parameter<JSAny>(Descriptor::kValue);
431 auto context = Parameter<Context>(Descriptor::kContext);
437 Label detached_or_out_of_bounds(
this), is_shared_struct_or_shared_array(
this);
441 maybe_array_or_shared_object, context, &elements_kind, &backing_store,
442 &detached_or_out_of_bounds, &is_shared_struct_or_shared_array);
449#if V8_TARGET_ARCH_MIPS64
450 TNode<Number> index_number = ChangeUintPtrToTagged(index_word);
451 Return(
CallRuntime(Runtime::kAtomicsExchange, context, array, index_number,
455 Label i8(
this), u8(
this), i16(
this), u16(
this), i32(
this), u32(
this),
456 i64(
this), u64(
this), big(
this), other(
this);
460 static_assert(BIGINT64_ELEMENTS > INT32_ELEMENTS);
461 static_assert(BIGUINT64_ELEMENTS > INT32_ELEMENTS);
462 GotoIf(Int32GreaterThan(elements_kind, Int32Constant(INT32_ELEMENTS)), &big);
465 TNode<Number> value_integer = ToInteger_Inline(context, value);
472 CheckJSTypedArrayIndex(array, index_word, &detached_or_out_of_bounds);
474 DebugCheckAtomicIndex(array, index_word);
476 TNode<Word32T> value_word32 = TruncateTaggedToWord32(context, value_integer);
481 int32_t case_values[] = {
482 INT8_ELEMENTS, UINT8_ELEMENTS, INT16_ELEMENTS,
483 UINT16_ELEMENTS, INT32_ELEMENTS, UINT32_ELEMENTS,
485 Label* case_labels[] = {
486 &i8, &u8, &i16, &u16, &i32, &u32,
488 Switch(elements_kind, &other, case_values, case_labels,
493 index_word, value_word32))));
497 index_word, value_word32))));
500 Return(SmiFromInt32(Signed(
502 WordShl(index_word, UintPtrConstant(1)), value_word32))));
505 Return(SmiFromInt32(Signed(
507 WordShl(index_word, UintPtrConstant(1)), value_word32))));
510 Return(ChangeInt32ToTagged(Signed(
512 WordShl(index_word, UintPtrConstant(2)), value_word32))));
515 Return(ChangeUint32ToTagged(Unsigned(
517 WordShl(index_word, UintPtrConstant(2)), value_word32))));
524 CheckJSTypedArrayIndex(array, index_word, &detached_or_out_of_bounds);
526 DebugCheckAtomicIndex(array, index_word);
530 BigIntToRawBytes(value_bigint, &var_low, &var_high);
532 GotoIf(Word32Equal(elements_kind, Int32Constant(BIGINT64_ELEMENTS)), &i64);
533 GotoIf(Word32Equal(elements_kind, Int32Constant(BIGUINT64_ELEMENTS)), &u64);
537 Return(BigIntFromSigned64(AtomicExchange64<AtomicInt64>(
538 backing_store, WordShl(index_word, UintPtrConstant(3)), var_low.value(),
542 Return(BigIntFromUnsigned64(AtomicExchange64<AtomicUint64>(
543 backing_store, WordShl(index_word, UintPtrConstant(3)), var_low.value(),
551 BIND(&detached_or_out_of_bounds);
553 ThrowTypeError(context, MessageTemplate::kDetachedOperation,
557 BIND(&is_shared_struct_or_shared_array);
559 Return(
CallRuntime(Runtime::kAtomicsExchangeSharedStructOrArray, context,
560 maybe_array_or_shared_object, index_or_field_name,
567 auto maybe_array_or_shared_object =
568 Parameter<Object>(Descriptor::kArrayOrSharedObject);
569 auto index_or_field_name = Parameter<JSAny>(Descriptor::kIndexOrFieldName);
570 auto old_value = Parameter<JSAny>(Descriptor::kOldValue);
571 auto new_value = Parameter<JSAny>(Descriptor::kNewValue);
572 auto context = Parameter<Context>(Descriptor::kContext);
575 Label detached_or_out_of_bounds(
this), is_shared_struct_or_shared_array(
this);
579 maybe_array_or_shared_object, context, &elements_kind, &backing_store,
580 &detached_or_out_of_bounds, &is_shared_struct_or_shared_array);
587#if V8_TARGET_ARCH_MIPS64
588 TNode<Number> index_number = ChangeUintPtrToTagged(index_word);
589 Return(
CallRuntime(Runtime::kAtomicsCompareExchange, context, array,
590 index_number, old_value, new_value));
592 Label i8(
this), u8(
this), i16(
this), u16(
this), i32(
this), u32(
this),
593 i64(
this), u64(
this), big(
this), other(
this);
599 static_assert(BIGINT64_ELEMENTS > INT32_ELEMENTS);
600 static_assert(BIGUINT64_ELEMENTS > INT32_ELEMENTS);
601 GotoIf(Int32GreaterThan(elements_kind, Int32Constant(INT32_ELEMENTS)), &big);
606 TNode<Number> old_value_integer = ToInteger_Inline(context, old_value);
607 TNode<Number> new_value_integer = ToInteger_Inline(context, new_value);
614 CheckJSTypedArrayIndex(array, index_word, &detached_or_out_of_bounds);
616 DebugCheckAtomicIndex(array, index_word);
619 TruncateTaggedToWord32(context, old_value_integer);
621 TruncateTaggedToWord32(context, new_value_integer);
626 int32_t case_values[] = {
627 INT8_ELEMENTS, UINT8_ELEMENTS, INT16_ELEMENTS,
628 UINT16_ELEMENTS, INT32_ELEMENTS, UINT32_ELEMENTS,
630 Label* case_labels[] = {
631 &i8, &u8, &i16, &u16, &i32, &u32,
633 Switch(elements_kind, &other, case_values, case_labels,
637 Return(SmiFromInt32(Signed(
639 old_value_word32, new_value_word32))));
642 Return(SmiFromInt32(Signed(
644 old_value_word32, new_value_word32))));
647 Return(SmiFromInt32(Signed(AtomicCompareExchange(
649 old_value_word32, new_value_word32))));
652 Return(SmiFromInt32(Signed(AtomicCompareExchange(
654 old_value_word32, new_value_word32))));
657 Return(ChangeInt32ToTagged(Signed(AtomicCompareExchange(
659 old_value_word32, new_value_word32))));
662 Return(ChangeUint32ToTagged(Unsigned(AtomicCompareExchange(
664 old_value_word32, new_value_word32))));
670 TNode<BigInt> old_value_bigint = ToBigInt(context, old_value);
671 TNode<BigInt> new_value_bigint = ToBigInt(context, new_value);
674 CheckJSTypedArrayIndex(array, index_word, &detached_or_out_of_bounds);
676 DebugCheckAtomicIndex(array, index_word);
682 BigIntToRawBytes(old_value_bigint, &var_old_low, &var_old_high);
683 BigIntToRawBytes(new_value_bigint, &var_new_low, &var_new_high);
686 GotoIf(Word32Equal(elements_kind, Int32Constant(BIGINT64_ELEMENTS)), &i64);
687 GotoIf(Word32Equal(elements_kind, Int32Constant(BIGUINT64_ELEMENTS)), &u64);
694 Return(BigIntFromSigned64(AtomicCompareExchange64<AtomicInt64>(
695 backing_store, WordShl(index_word, 3), var_old_low.value(),
696 var_new_low.value(), old_high, new_high)));
699 Return(BigIntFromUnsigned64(AtomicCompareExchange64<AtomicUint64>(
700 backing_store, WordShl(index_word, 3), var_old_low.value(),
701 var_new_low.value(), old_high, new_high)));
708 BIND(&detached_or_out_of_bounds);
710 ThrowTypeError(context, MessageTemplate::kDetachedOperation,
714 BIND(&is_shared_struct_or_shared_array);
716 Return(
CallRuntime(Runtime::kAtomicsCompareExchangeSharedStructOrArray,
717 context, maybe_array_or_shared_object,
718 index_or_field_name, old_value, new_value));
754 Label detached_or_out_of_bounds(
this);
758 &backing_store, &detached_or_out_of_bounds);
764#if V8_TARGET_ARCH_MIPS64
768 Label i8(
this), u8(
this), i16(
this), u16(
this), i32(
this), u32(
this),
769 i64(
this), u64(
this), big(
this), other(
this);
773 static_assert(BIGINT64_ELEMENTS > INT32_ELEMENTS);
774 static_assert(BIGUINT64_ELEMENTS > INT32_ELEMENTS);
778 TNode<Number> value_integer = ToInteger_Inline(context, value);
794 int32_t case_values[] = {
795 INT8_ELEMENTS, UINT8_ELEMENTS, INT16_ELEMENTS,
796 UINT16_ELEMENTS, INT32_ELEMENTS, UINT32_ELEMENTS,
798 Label* case_labels[] = {
799 &i8, &u8, &i16, &u16, &i32, &u32,
801 Switch(elements_kind, &other, case_values, case_labels,
856 BIND(&detached_or_out_of_bounds);
857 ThrowTypeError(context, MessageTemplate::kDetachedOperation, method_name);