|
@@ -118,6 +118,7 @@ void AtomicsObject::initialize(GlobalObject& global_object)
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
define_native_function(vm.names.add, add, 3, attr);
|
|
define_native_function(vm.names.add, add, 3, attr);
|
|
|
|
+ define_native_function(vm.names.load, load, 2, attr);
|
|
|
|
|
|
// 25.4.15 Atomics [ @@toStringTag ], https://tc39.es/ecma262/#sec-atomics-@@tostringtag
|
|
// 25.4.15 Atomics [ @@toStringTag ], https://tc39.es/ecma262/#sec-atomics-@@tostringtag
|
|
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Atomics"), Attribute::Configurable);
|
|
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Atomics"), Attribute::Configurable);
|
|
@@ -141,4 +142,27 @@ JS_DEFINE_NATIVE_FUNCTION(AtomicsObject::add)
|
|
VERIFY_NOT_REACHED();
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 25.4.8 Atomics.load ( typedArray, index ), https://tc39.es/ecma262/#sec-atomics.load
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(AtomicsObject::load)
|
|
|
|
+{
|
|
|
|
+ auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
|
|
|
+ if (!typed_array)
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ validate_integer_typed_array(global_object, *typed_array);
|
|
|
|
+ if (vm.exception())
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ auto indexed_position = validate_atomic_access(global_object, *typed_array, vm.argument(1));
|
|
|
|
+ if (!indexed_position.has_value())
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ if (typed_array->viewed_array_buffer()->is_detached()) {
|
|
|
|
+ vm.throw_exception<TypeError>(global_object, ErrorType::DetachedArrayBuffer);
|
|
|
|
+ return {};
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return typed_array->get_value_from_buffer(*indexed_position, ArrayBuffer::Order::SeqCst, true);
|
|
|
|
+}
|
|
|
|
+
|
|
}
|
|
}
|