Truly independent web browser
LibJS: Keep Values on the thread of their VM
Shannon Booth05818b38f83b
diff --git a/Libraries/LibJS/Rust/src/bytecode/dump.rs b/Libraries/LibJS/Rust/src/bytecode/dump.rsindex 6ec4b2e40bc..5bc90330764 100644--- a/Libraries/LibJS/Rust/src/bytecode/dump.rs+++ b/Libraries/LibJS/Rust/src/bytecode/dump.rs@@ -258,15 +258,15 @@ impl BytecodeDumper<'_> {}fn append_bigint(&mut self, encoded: u64) {- Utf16View::of_string(&Value(encoded).as_bigint().to_utf16_string()).append_as_wtf8_to(self.output);+ Utf16View::of_string(&Value::from_bits(encoded).as_bigint().to_utf16_string()).append_as_wtf8_to(self.output);}fn append_string_value(&mut self, encoded: u64) {- Utf16View::of_string(&Value(encoded).as_string().utf16_string()).append_as_wtf8_to(self.output);+ Utf16View::of_string(&Value::from_bits(encoded).as_string().utf16_string()).append_as_wtf8_to(self.output);}fn append_value_fallback(&mut self, encoded: u64) {- append_value_formatted_like_ak(self.output, Value(encoded));+ append_value_formatted_like_ak(self.output, Value::from_bits(encoded));}fn append_quoted(&mut self, text: Utf16View<'_>) {diff --git a/Libraries/LibJS/Rust/src/bytecode/executable.rs b/Libraries/LibJS/Rust/src/bytecode/executable.rsindex c90a8433a52..0bf69ea4f97 100644--- a/Libraries/LibJS/Rust/src/bytecode/executable.rs+++ b/Libraries/LibJS/Rust/src/bytecode/executable.rs@@ -130,7 +130,7 @@ impl PropertyLookupCacheEntryData {}fn has_dead_cell(&self) -> bool {- (self.key != 0 && cell_is_dead(Value(self.key).as_cell()))+ (self.key != 0 && cell_is_dead(Value::from_bits(self.key).as_cell()))|| self.from_shape.is_some_and(cell_is_dead)|| self.shape.is_some_and(cell_is_dead)|| self.prototype.is_some_and(cell_is_dead)diff --git a/Libraries/LibJS/Rust/src/embedding/abi_types.rs b/Libraries/LibJS/Rust/src/embedding/abi_types.rsindex af2a7aa1d69..ccb336038ed 100644--- a/Libraries/LibJS/Rust/src/embedding/abi_types.rs+++ b/Libraries/LibJS/Rust/src/embedding/abi_types.rs@@ -259,8 +259,8 @@ pub unsafe fn completion_writing_result_to<T>(result: ThrowCompletionOr<T>, out:/// The completion an embedder's hook returned, as the runtime's own.pub fn completion_from_abi(completion: JSCompletion) -> ThrowCompletionOr<Value> {match completion.variant {- JS_COMPLETION_NORMAL => Ok(Value(completion.payload)),- JS_COMPLETION_THROW => Err(Throw::new(Value(completion.payload))),+ JS_COMPLETION_NORMAL => Ok(Value::from_bits(completion.payload)),+ JS_COMPLETION_THROW => Err(Throw::new(Value::from_bits(completion.payload))),variant => panic!("the embedder returned a completion of unknown variant {variant}"),}}@@ -270,7 +270,7 @@ pub fn value_into_abi(value: Value) -> JSValue {}pub fn value_from_abi(value: JSValue) -> Value {- Value(value)+ Value::from_bits(value)}/// A borrowed run of code units in the two storage kinds of AK::Utf16View: `data` points to `length_in_code_units`diff --git a/Libraries/LibJS/Rust/src/embedding/array.rs b/Libraries/LibJS/Rust/src/embedding/array.rsindex 2f0bebbf208..15be8073704 100644--- a/Libraries/LibJS/Rust/src/embedding/array.rs+++ b/Libraries/LibJS/Rust/src/embedding/array.rs@@ -95,7 +95,7 @@ pub unsafe extern "C" fn js_array_indexed_array_like_size(object: *mut JSObject)#[unsafe(no_mangle)]pub unsafe extern "C" fn js_array_indexed_append(object: *mut JSObject, value: JSValue) {// SAFETY: See the module documentation.- unsafe { cell_from_abi::<JSObject>(object) }.indexed_append(Value(value), DEFAULT_ATTRIBUTES);+ unsafe { cell_from_abi::<JSObject>(object) }.indexed_append(Value::from_bits(value), DEFAULT_ATTRIBUTES);}/// Removes the first element of the object's indexed storage, which must not be empty, shifting the others down, anddiff --git a/Libraries/LibJS/Rust/src/embedding/array_buffer.rs b/Libraries/LibJS/Rust/src/embedding/array_buffer.rsindex f8b152f20e0..128b4165e5f 100644--- a/Libraries/LibJS/Rust/src/embedding/array_buffer.rs+++ b/Libraries/LibJS/Rust/src/embedding/array_buffer.rs@@ -496,7 +496,7 @@ pub unsafe extern "C" fn js_array_buffer_data(buffer: *mut JSObject, out_byte_lepub unsafe extern "C" fn js_array_buffer_detach(vm: *mut JSVM, buffer: *mut JSObject, key: JSValue) -> JSCompletion {// SAFETY: The caller passes a live VM and buffer.let (vm, buffer) = unsafe { (vm_from_abi(vm), array_buffer_from_abi(buffer)) };- completion_into_abi(detach_array_buffer(vm, buffer, Some(Value(key))))+ completion_into_abi(detach_array_buffer(vm, buffer, Some(Value::from_bits(key))))}/// ArrayBuffer::detach_and_take_data_block(): detaches `buffer`, as DetachArrayBuffer(buffer) does, and describes the@@ -613,7 +613,7 @@ pub unsafe extern "C" fn js_array_buffer_detach_key(buffer: *mut JSObject) -> JS#[unsafe(no_mangle)]pub unsafe extern "C" fn js_array_buffer_set_detach_key(buffer: *mut JSObject, key: JSValue) {// SAFETY: The caller passes a live buffer.- unsafe { array_buffer_from_abi(buffer) }.set_detach_key(Value(key));+ unsafe { array_buffer_from_abi(buffer) }.set_detach_key(Value::from_bits(key));}/// DataView::create(): a view of `buffer` from `byte_offset` on, of `byte_length` bytes, or of the rest of a resizablediff --git a/Libraries/LibJS/Rust/src/embedding/collections.rs b/Libraries/LibJS/Rust/src/embedding/collections.rsindex 6ef5256d052..d15def04ced 100644--- a/Libraries/LibJS/Rust/src/embedding/collections.rs+++ b/Libraries/LibJS/Rust/src/embedding/collections.rs@@ -99,7 +99,7 @@ pub unsafe extern "C" fn js_collections_map_size(map: *mut JSObject) -> usize {pub unsafe extern "C" fn js_collections_map_set(vm: *mut JSVM, map: *mut JSObject, key: JSValue, value: JSValue) {// SAFETY: See the module documentation.let (vm, map) = unsafe { (vm_from_abi(vm), map_from_abi(map)) };- map.map_set(vm, Value(key), Value(value));+ map.map_set(vm, Value::from_bits(key), Value::from_bits(value));}/// Removes the key's entry, and returns whether there was one. Main thread only.@@ -107,7 +107,7 @@ pub unsafe extern "C" fn js_collections_map_set(vm: *mut JSVM, map: *mut JSObjecpub unsafe extern "C" fn js_collections_map_remove(vm: *mut JSVM, map: *mut JSObject, key: JSValue) -> bool {// SAFETY: See the module documentation.let (vm, map) = unsafe { (vm_from_abi(vm), map_from_abi(map)) };- map.map_remove(vm, Value(key))+ map.map_remove(vm, Value::from_bits(key))}/// Removes every entry. Main thread only.@@ -182,7 +182,7 @@ pub unsafe extern "C" fn js_collections_set_size(set: *mut JSObject) -> usize {pub unsafe extern "C" fn js_collections_set_add(vm: *mut JSVM, set: *mut JSObject, value: JSValue) {// SAFETY: See the module documentation.let (vm, set) = unsafe { (vm_from_abi(vm), set_from_abi(set)) };- set.set_add(vm, Value(value));+ set.set_add(vm, Value::from_bits(value));}/// Removes the value, and returns whether the set had it. Main thread only.@@ -190,7 +190,7 @@ pub unsafe extern "C" fn js_collections_set_add(vm: *mut JSVM, set: *mut JSObjecpub unsafe extern "C" fn js_collections_set_remove(vm: *mut JSVM, set: *mut JSObject, value: JSValue) -> bool {// SAFETY: See the module documentation.let (vm, set) = unsafe { (vm_from_abi(vm), set_from_abi(set)) };- set.set_remove(vm, Value(value))+ set.set_remove(vm, Value::from_bits(value))}/// Removes every value. Main thread only.diff --git a/Libraries/LibJS/Rust/src/embedding/console.rs b/Libraries/LibJS/Rust/src/embedding/console.rsindex 9ee3e6deaa9..dcf5a9a1609 100644--- a/Libraries/LibJS/Rust/src/embedding/console.rs+++ b/Libraries/LibJS/Rust/src/embedding/console.rs@@ -225,5 +225,5 @@ pub unsafe extern "C" fn js_console_print_value(strip_ansi,raw_strings,};- print(Value(value), &mut print_context).is_ok()+ print(Value::from_bits(value), &mut print_context).is_ok()}diff --git a/Libraries/LibJS/Rust/src/embedding/debugger.rs b/Libraries/LibJS/Rust/src/embedding/debugger.rsindex b43a148e6eb..ff0707110ed 100644--- a/Libraries/LibJS/Rust/src/embedding/debugger.rs+++ b/Libraries/LibJS/Rust/src/embedding/debugger.rs@@ -349,7 +349,7 @@ pub unsafe extern "C" fn js_debugger_set_pause_on_exceptions(vm: *mut JSVM, modepub unsafe extern "C" fn js_debugger_did_finish_exception_propagation(vm: *mut JSVM, exception: JSValue) {// SAFETY: The caller passes a live VM.let (_, debugger) = unsafe { debugger_of(vm) };- debugger.did_finish_exception_propagation(Value(exception));+ debugger.did_finish_exception_propagation(Value::from_bits(exception));}/// Debugger::add_breakpoint(filename, line, column): a breakpoint in every source code with that filename, at thediff --git a/Libraries/LibJS/Rust/src/embedding/environment.rs b/Libraries/LibJS/Rust/src/embedding/environment.rsindex 55f28eefa34..0d76a35ab31 100644--- a/Libraries/LibJS/Rust/src/embedding/environment.rs+++ b/Libraries/LibJS/Rust/src/embedding/environment.rs@@ -158,7 +158,7 @@ pub unsafe extern "C" fn js_environment_initialize_binding(completion_into_abi(environment.initialize_binding(vm,&binding_name_from_abi(name),- Value(value),+ Value::from_bits(value),initialize_binding_hint_from_abi(hint),))}@@ -180,7 +180,12 @@ pub unsafe extern "C" fn js_environment_set_mutable_binding(name.as_view(),)};- completion_into_abi(environment.set_mutable_binding(vm, &binding_name_from_abi(name), Value(value), strict))+ completion_into_abi(environment.set_mutable_binding(+ vm,+ &binding_name_from_abi(name),+ Value::from_bits(value),+ strict,+ ))}/// GetBindingValue(N, S), which throws a ReferenceError for a binding that is not initialized yet. Borrows the name.diff --git a/Libraries/LibJS/Rust/src/embedding/function.rs b/Libraries/LibJS/Rust/src/embedding/function.rsindex 2917a0be891..323b2b470ce 100644--- a/Libraries/LibJS/Rust/src/embedding/function.rs+++ b/Libraries/LibJS/Rust/src/embedding/function.rs@@ -308,7 +308,12 @@ pub unsafe extern "C" fn js_function_call() -> JSCompletion {// SAFETY: See the module documentation.let (vm, arguments) = unsafe { (vm_from_abi(vm), values_from_abi(arguments, count)) };- completion_into_abi(call(vm, Value(function), Value(this_value), arguments))+ completion_into_abi(call(+ vm,+ Value::from_bits(function),+ Value::from_bits(this_value),+ arguments,+ ))}/// Construct(F, argumentsList, newTarget), whose payload is the new object. The function must be a constructor, and@@ -344,7 +349,7 @@ pub unsafe extern "C" fn js_function_get_method() -> JSCompletion {// SAFETY: See the module documentation.let (vm, key) = unsafe { (vm_from_abi(vm), property_key_from_abi(key)) };- completion_into_abi(Value(value).get_method(vm, key))+ completion_into_abi(Value::from_bits(value).get_method(vm, key))}// Functions from source text, which hosts create outside of any scriptdiff --git a/Libraries/LibJS/Rust/src/embedding/hooks.rs b/Libraries/LibJS/Rust/src/embedding/hooks.rsindex 23e4f72d83e..3740588b65b 100644--- a/Libraries/LibJS/Rust/src/embedding/hooks.rs+++ b/Libraries/LibJS/Rust/src/embedding/hooks.rs@@ -551,7 +551,7 @@ fn get_code_for_eval(vm: &Vm, argument: &Object) -> Option<Gc<PrimitiveString>>if !call_embedder_hook!(vm, get_code_for_eval, lent_object_into_abi(argument), &raw mut code) {return None;}- let code = Value(code);+ let code = Value::from_bits(code);assert!(code.is_string(), "the code of an object for eval() is a String");Some(code.as_string())}@@ -617,7 +617,7 @@ unsafe extern "C" fn append_import_meta_property(properties: *mut c_void, key: Jclone_lent_property_key_from_abi(key),)};- properties.push((key, Value(value)));+ properties.push((key, Value::from_bits(value)));}fn get_import_meta_properties(vm: &Vm, module: Gc<SourceTextModule>) -> MarkedVec<'_, (PropertyKey, Value)> {diff --git a/Libraries/LibJS/Rust/src/embedding/host/console_client.rs b/Libraries/LibJS/Rust/src/embedding/host/console_client.rsindex 1d821e81922..a5ef0c4c2dd 100644--- a/Libraries/LibJS/Rust/src/embedding/host/console_client.rs+++ b/Libraries/LibJS/Rust/src/embedding/host/console_client.rs@@ -318,7 +318,7 @@ pub unsafe extern "C" fn js_console_client_generically_format_values(if value_count > 0 {// SAFETY: The caller guarantees that `values` points to `value_count` values.for &value in unsafe { ak::slice_from_raw_parts(values, value_count) } {- marked_values.push(Value(value));+ marked_values.push(Value::from_bits(value));}}let formatted = clientdiff --git a/Libraries/LibJS/Rust/src/embedding/host/host_array.rs b/Libraries/LibJS/Rust/src/embedding/host/host_array.rsindex fa5721967d4..ab2d2becab8 100644--- a/Libraries/LibJS/Rust/src/embedding/host/host_array.rs+++ b/Libraries/LibJS/Rust/src/embedding/host/host_array.rs@@ -236,8 +236,8 @@ pub unsafe extern "C" fn js_host_array_array_set(completion_into_abi(as_host_array(&host_array).array_set(vm,key,- Value(value),- Value(receiver),+ Value::from_bits(value),+ Value::from_bits(receiver),cache_metadata,lookup_phase_from_abi(phase),))diff --git a/Libraries/LibJS/Rust/src/embedding/host/host_object.rs b/Libraries/LibJS/Rust/src/embedding/host/host_object.rsindex 03e89111e0b..b035d7198a5 100644--- a/Libraries/LibJS/Rust/src/embedding/host/host_object.rs+++ b/Libraries/LibJS/Rust/src/embedding/host/host_object.rs@@ -253,7 +253,7 @@ unsafe fn property_descriptor_from_hook(descriptor: &JSPropertyDescriptor) -> Opconst ATTRIBUTE_FLAGS: u16 = JS_PD_WRITABLE | JS_PD_ENUMERABLE | JS_PD_CONFIGURABLE;if descriptor.flags & !ATTRIBUTE_FLAGS == COMPLETE_DATA_DESCRIPTOR_FLAGS {return Some(PropertyDescriptor {- value: Some(Value(descriptor.value)),+ value: Some(Value::from_bits(descriptor.value)),writable: Some(descriptor.flags & JS_PD_WRITABLE != 0),enumerable: Some(descriptor.flags & JS_PD_ENUMERABLE != 0),configurable: Some(descriptor.flags & JS_PD_CONFIGURABLE != 0),@@ -384,7 +384,7 @@ fn delete_through_hook(object: &Object, _vm: &Vm, key: &PropertyKey) -> ThrowComunsafe extern "C" fn append_key_to_list(keys: *mut c_void, key: JSValue) {// SAFETY: The sink's context is the rooted list of keys of the [[OwnPropertyKeys]] call that made the sink.let keys = unsafe { &*keys.cast::<MarkedVec<'_, Value>>() };- keys.push(Value(key));+ keys.push(Value::from_bits(key));}fn own_property_keys_through_hook<'vm>(object: &Object, vm: &'vm Vm) -> ThrowCompletionOr<MarkedVec<'vm, Value>> {diff --git a/Libraries/LibJS/Rust/src/embedding/iterator.rs b/Libraries/LibJS/Rust/src/embedding/iterator.rsindex f93ffb9f828..ed036a7fec4 100644--- a/Libraries/LibJS/Rust/src/embedding/iterator.rs+++ b/Libraries/LibJS/Rust/src/embedding/iterator.rs@@ -105,7 +105,7 @@ unsafe fn with_iterator_record_fields<T>(let fields = unsafe { fields.as_mut() }.expect("the embedder passes the fields of an iterator record");// SAFETY: The caller guarantees that the iterator is a live object.let iterator = unsafe { optional_cell_from_abi::<JSObject>(fields.iterator) };- let record = IteratorRecordImpl::new(iterator, Value(fields.next_method), fields.done);+ let record = IteratorRecordImpl::new(iterator, Value::from_bits(fields.next_method), fields.done);let result = operation(&record);fields.done = record.done();result@@ -123,7 +123,7 @@ pub unsafe extern "C" fn js_iterator_get_fields() -> JSCompletion {// SAFETY: See the module documentation.let vm = unsafe { vm_from_abi(vm) };- let record = get_iterator_impl(vm, Value(value), iterator_hint_from_abi(hint));+ let record = get_iterator_impl(vm, Value::from_bits(value), iterator_hint_from_abi(hint));// SAFETY: As above, `fields` is writable.unsafe { completion_writing_result_to(record.map(|record| iterator_record_fields_into_abi(&record)), fields) }}@@ -139,7 +139,7 @@ pub unsafe extern "C" fn js_iterator_get_fields_from_method() -> JSCompletion {// SAFETY: See the module documentation.let (vm, method) = unsafe { (vm_from_abi(vm), function_from_abi(method)) };- let record = get_iterator_from_method_impl(vm, Value(value), method);+ let record = get_iterator_from_method_impl(vm, Value::from_bits(value), method);// SAFETY: As above, `fields` is writable.unsafe { completion_writing_result_to(record.map(|record| iterator_record_fields_into_abi(&record)), fields) }}@@ -152,7 +152,7 @@ pub unsafe extern "C" fn js_iterator_fields_next(value: *const JSValue,) -> JSCompletion {// SAFETY: See the module documentation; `value` is null or readable.- let (vm, value) = unsafe { (vm_from_abi(vm), value.as_ref().map(|value| Value(*value))) };+ let (vm, value) = unsafe { (vm_from_abi(vm), value.as_ref().map(|value| Value::from_bits(*value))) };// SAFETY: As above, the fields are those of a record.completion_into_abi(unsafe { with_iterator_record_fields(fields, |record| iterator_next(vm, record, value)) })}@@ -202,5 +202,5 @@ pub unsafe extern "C" fn js_iterator_create_result_object() -> *mut JSObject {// SAFETY: See the module documentation.let (vm, realm) = unsafe { (vm_from_abi(vm), cell_from_abi::<JSRealm>(realm)) };- object_into_abi(create_iterator_result_object(vm, realm, Value(value), done))+ object_into_abi(create_iterator_result_object(vm, realm, Value::from_bits(value), done))}diff --git a/Libraries/LibJS/Rust/src/embedding/json.rs b/Libraries/LibJS/Rust/src/embedding/json.rsindex de473c04089..3f8bf751541 100644--- a/Libraries/LibJS/Rust/src/embedding/json.rs+++ b/Libraries/LibJS/Rust/src/embedding/json.rs@@ -43,7 +43,12 @@ pub unsafe extern "C" fn js_json_stringify() -> JSCompletion {// SAFETY: See the module documentation.let vm = unsafe { vm_from_abi(vm) };- let serialized = JSONObject::stringify_impl(vm, Value(value), Value(replacer), Value(space));+ let serialized = JSONObject::stringify_impl(+ vm,+ Value::from_bits(value),+ Value::from_bits(replacer),+ Value::from_bits(space),+ );completion_into_abi(serialized.map(|serialized| {let Some(serialized) = serialized else {return false;diff --git a/Libraries/LibJS/Rust/src/embedding/module.rs b/Libraries/LibJS/Rust/src/embedding/module.rsindex a62a670dc19..d19692540f4 100644--- a/Libraries/LibJS/Rust/src/embedding/module.rs+++ b/Libraries/LibJS/Rust/src/embedding/module.rs@@ -260,7 +260,8 @@ pub unsafe extern "C" fn js_module_create_default_export_synthetic_module() -> *mut JSModule {// SAFETY: See the module documentation.let (vm, realm, filename) = unsafe { (vm_from_abi(vm), cell_from_abi(realm), filename.as_view().to_utf8()) };- let module = SyntheticModule::create_default_export_synthetic_module(vm, realm, Value(default_export), filename);+ let module =+ SyntheticModule::create_default_export_synthetic_module(vm, realm, Value::from_bits(default_export), filename);cell_into_abi(module.upcast::<Module>())}diff --git a/Libraries/LibJS/Rust/src/embedding/object.rs b/Libraries/LibJS/Rust/src/embedding/object.rsindex 19d12afa341..303037dfff1 100644--- a/Libraries/LibJS/Rust/src/embedding/object.rs+++ b/Libraries/LibJS/Rust/src/embedding/object.rs@@ -134,7 +134,7 @@ pub(crate) unsafe fn property_descriptor_from_abi(abi_descriptor: &JSPropertyDes// SAFETY: The caller passes null or live functions as the getter and setter.let accessor_function = |function: *mut JSObject| unsafe { optional_function_from_abi(function) };Some(PropertyDescriptor {- value: has(JS_PD_HAS_VALUE).then_some(Value(abi_descriptor.value)),+ value: has(JS_PD_HAS_VALUE).then_some(Value::from_bits(abi_descriptor.value)),get: has(JS_PD_HAS_GET).then(|| accessor_function(abi_descriptor.get)),set: has(JS_PD_HAS_SET).then(|| accessor_function(abi_descriptor.set)),writable: has(JS_PD_HAS_WRITABLE).then_some(has(JS_PD_WRITABLE)),@@ -248,7 +248,7 @@ pub fn call_host_intrinsic_accessor(accessor: HostIntrinsicAccessor, realm: Gc<Runsafe { accessor(&mut value, realm) };value};- Value(value)+ Value::from_bits(value)}// Creating objects@@ -314,7 +314,7 @@ pub unsafe extern "C" fn js_object_set(} else {ShouldThrowExceptions::No};- completion_into_abi(object.set(vm, key, Value(value), throw_exceptions))+ completion_into_abi(object.set(vm, key, Value::from_bits(value), throw_exceptions))}/// HasProperty(O, P). Borrows the key. Main thread only.@@ -395,7 +395,7 @@ pub unsafe extern "C" fn js_object_create_data_property(property_key_from_abi(key),)};- completion_into_abi(object.create_data_property(vm, key, Value(value), None, None))+ completion_into_abi(object.create_data_property(vm, key, Value::from_bits(value), None, None))}/// CreateDataPropertyOrThrow(O, P, V). Borrows the key. Main thread only.@@ -414,7 +414,7 @@ pub unsafe extern "C" fn js_object_create_data_property_or_throw(property_key_from_abi(key),)};- completion_into_abi(object.create_data_property_or_throw(vm, key, Value(value)))+ completion_into_abi(object.create_data_property_or_throw(vm, key, Value::from_bits(value)))}/// SetIntegrityLevel(O, level), where the level is JS_INTEGRITY_LEVEL_SEALED or JS_INTEGRITY_LEVEL_FROZEN. Main@@ -536,7 +536,7 @@ pub unsafe extern "C" fn js_object_define_direct_property(property_key_from_abi(key),)};- object.define_direct_property(vm, key, Value(value), PropertyAttributes::new(attributes));+ object.define_direct_property(vm, key, Value::from_bits(value), PropertyAttributes::new(attributes));}/// Stores an accessor property in the object's own storage. Either function may be null; when the key already holds an@@ -928,7 +928,13 @@ pub unsafe extern "C" fn js_object_internal_get(get_cache_metadata_from_abi(cache_metadata),)};- completion_into_abi(object.internal_get(vm, key, Value(receiver), cache_metadata, lookup_phase_from_abi(phase)))+ completion_into_abi(object.internal_get(+ vm,+ key,+ Value::from_bits(receiver),+ cache_metadata,+ lookup_phase_from_abi(phase),+ ))}/// [[Get]] ( P, Receiver ) of the object as one found in the prototype chain of the lookup that@@ -952,7 +958,7 @@ pub unsafe extern "C" fn js_object_internal_get_as_prototype_of(get_cache_metadata_from_abi(metadata_for_caller),)};- completion_into_abi(object.internal_get_as_prototype_of(vm, key, Value(receiver), metadata_for_caller))+ completion_into_abi(object.internal_get_as_prototype_of(vm, key, Value::from_bits(receiver), metadata_for_caller))}/// [[Set]] ( P, V, Receiver ). `cache_metadata` is null or the metadata a [[Set]] hook received, and the phase a@@ -979,8 +985,8 @@ pub unsafe extern "C" fn js_object_internal_set(completion_into_abi(object.internal_set(vm,key,- Value(value),- Value(receiver),+ Value::from_bits(value),+ Value::from_bits(receiver),cache_metadata,lookup_phase_from_abi(phase),))@@ -1119,7 +1125,13 @@ pub unsafe extern "C" fn js_object_ordinary_get(get_cache_metadata_from_abi(cache_metadata),)};- completion_into_abi(object.ordinary_get(vm, key, Value(receiver), cache_metadata, lookup_phase_from_abi(phase)))+ completion_into_abi(object.ordinary_get(+ vm,+ key,+ Value::from_bits(receiver),+ cache_metadata,+ lookup_phase_from_abi(phase),+ ))}/// OrdinarySet ( O, P, V, Receiver ), which takes its cache metadata and phase like js_object_internal_set(). Borrows@@ -1146,8 +1158,8 @@ pub unsafe extern "C" fn js_object_ordinary_set(completion_into_abi(object.ordinary_set(vm,key,- Value(value),- Value(receiver),+ Value::from_bits(value),+ Value::from_bits(receiver),cache_metadata,lookup_phase_from_abi(phase),))@@ -1180,8 +1192,8 @@ pub unsafe extern "C" fn js_object_ordinary_set_with_own_descriptor(completion_into_abi(object.ordinary_set_with_own_descriptor(vm,key,- Value(value),- Value(receiver),+ Value::from_bits(value),+ Value::from_bits(receiver),own_descriptor,cache_metadata,lookup_phase_from_abi(phase),diff --git a/Libraries/LibJS/Rust/src/embedding/promise.rs b/Libraries/LibJS/Rust/src/embedding/promise.rsindex b1611a86b49..bdc082e900d 100644--- a/Libraries/LibJS/Rust/src/embedding/promise.rs+++ b/Libraries/LibJS/Rust/src/embedding/promise.rs@@ -118,7 +118,12 @@ pub unsafe extern "C" fn js_promise_perform_then()};promise- .perform_then(vm, Value(on_fulfilled), Value(on_rejected), result_capability)+ .perform_then(+ vm,+ Value::from_bits(on_fulfilled),+ Value::from_bits(on_rejected),+ result_capability,+ ).0}@@ -145,7 +150,9 @@ pub unsafe extern "C" fn js_promise_create_resolving_functions(pub unsafe extern "C" fn js_promise_capability_new(vm: *mut JSVM, constructor: JSValue) -> JSCompletion {// SAFETY: See the module documentation.let vm = unsafe { vm_from_abi(vm) };- completion_into_abi(new_promise_capability(vm, Value(constructor)).map(cell_into_abi::<JSPromiseCapability>))+ completion_into_abi(+ new_promise_capability(vm, Value::from_bits(constructor)).map(cell_into_abi::<JSPromiseCapability>),+ )}/// [[Promise]] of the capability, which is an object but not necessarily a Promise. Main thread only.diff --git a/Libraries/LibJS/Rust/src/embedding/regexp.rs b/Libraries/LibJS/Rust/src/embedding/regexp.rsindex 413eb5c947b..86b21ffae08 100644--- a/Libraries/LibJS/Rust/src/embedding/regexp.rs+++ b/Libraries/LibJS/Rust/src/embedding/regexp.rs@@ -38,7 +38,7 @@ unsafe fn regexp_from_abi(regexp: *mut JSObject) -> Gc<RegExpObject> {pub unsafe extern "C" fn js_regexp_create(vm: *mut JSVM, pattern: JSValue, flags: JSValue) -> JSCompletion {// SAFETY: See the module documentation.let vm = unsafe { vm_from_abi(vm) };- completion_into_abi(regexp_create(vm, Value(pattern), Value(flags)))+ completion_into_abi(regexp_create(vm, Value::from_bits(pattern), Value::from_bits(flags)))}/// [[OriginalSource]], the pattern the RegExp was created with, as an owned string. Main thread only.diff --git a/Libraries/LibJS/Rust/src/embedding/vm.rs b/Libraries/LibJS/Rust/src/embedding/vm.rsindex 88296611cab..466704b80be 100644--- a/Libraries/LibJS/Rust/src/embedding/vm.rs+++ b/Libraries/LibJS/Rust/src/embedding/vm.rs@@ -377,5 +377,10 @@ pub unsafe extern "C" fn js_vm_default_host_call_job_callback(// SAFETY: The caller passes `argument_count` values, and a Value is a JSValue.unsafe { ak::slice_from_raw_parts(arguments.cast(), argument_count) }};- completion_into_abi(call_job_callback(vm, job_callback, Value(this_value), arguments))+ completion_into_abi(call_job_callback(+ vm,+ job_callback,+ Value::from_bits(this_value),+ arguments,+ ))}diff --git a/Libraries/LibJS/Rust/src/interpreter/run.rs b/Libraries/LibJS/Rust/src/interpreter/run.rsindex dd5201844d5..90ef04e0f0c 100644--- a/Libraries/LibJS/Rust/src/interpreter/run.rs+++ b/Libraries/LibJS/Rust/src/interpreter/run.rs@@ -109,7 +109,7 @@ impl Vm {context_ref.register(register::EXCEPTION).set(throw.value());} else if let Some(result) = self.enter_jit_code_at(context, executable_ref, entry_point) {match result.status {- EntryStatus::Returned => self.return_from_running_frame(Value(result.value)),+ EntryStatus::Returned => self.return_from_running_frame(Value::from_bits(result.value)),EntryStatus::Resume => self.run_running_frame_in_interpreter(),EntryStatus::ExitInterpreter => {}}diff --git a/Libraries/LibJS/Rust/src/interpreter/slow_paths/mod.rs b/Libraries/LibJS/Rust/src/interpreter/slow_paths/mod.rsindex 5eabf9b53f6..f1fb7d250b5 100644--- a/Libraries/LibJS/Rust/src/interpreter/slow_paths/mod.rs+++ b/Libraries/LibJS/Rust/src/interpreter/slow_paths/mod.rs@@ -715,7 +715,7 @@ impl RuntimeFunctions for Runtime {fn try_get_by_id_cache(encoded_base: u64, cache_address: u64) -> u64 {// SAFETY: The interpreter passes the address of one of the running executable's property lookup caches.let cache = unsafe { &*core::ptr::with_exposed_provenance::<PropertyLookupCache>(cache_address as usize) };- property_access::try_get_by_id_cache(Value(encoded_base), cache).0+ property_access::try_get_by_id_cache(Value::from_bits(encoded_base), cache).0}fn try_get_by_value_typed_array(@@ -1260,7 +1260,7 @@ impl RuntimeFunctions for Runtime {fn helper_handle_raw_native_exception(vm: u64, encoded_exception: u64) -> u64 {let vm = vm_from_helper_argument(vm);- calls::handle_raw_native_exception(vm, Value(encoded_exception)).0 as u64+ calls::handle_raw_native_exception(vm, Value::from_bits(encoded_exception)).0 as u64}// Literals, iterators, generators and control flow: control.rs.diff --git a/Libraries/LibJS/Rust/src/interpreter/slow_paths/operators.rs b/Libraries/LibJS/Rust/src/interpreter/slow_paths/operators.rsindex feab0b7830f..c284c7607bc 100644--- a/Libraries/LibJS/Rust/src/interpreter/slow_paths/operators.rs+++ b/Libraries/LibJS/Rust/src/interpreter/slow_paths/operators.rs@@ -471,7 +471,7 @@ pub fn r#in(vm: &Vm, pc: u32, values: &mut op::InValues) -> SlowPathControl {/// Converts a value to a boolean for the jump handlers: 0 for false and 1 for true. It never throws.pub fn helper_to_boolean(encoded_value: u64) -> u64 {- let value = Value(encoded_value);+ let value = Value::from_bits(encoded_value);u64::from(value.to_boolean())}diff --git a/Libraries/LibJS/Rust/src/jit/calls.rs b/Libraries/LibJS/Rust/src/jit/calls.rsindex 0b0ce3bf491..2ea59e0edc0 100644--- a/Libraries/LibJS/Rust/src/jit/calls.rs+++ b/Libraries/LibJS/Rust/src/jit/calls.rs@@ -109,7 +109,7 @@ fn run_callee_frame_from_jit(vm: &Vm, site: &JitCallSite, callee_frame: NonNull<let result = enter_jit_code(vm, callee_frame);match result.status {EntryStatus::Returned => {- vm.return_from_running_frame(Value(result.value));+ vm.return_from_running_frame(Value::from_bits(result.value));return finish_call_from_jit(vm, site.frame, site.pc, site.return_pc);}EntryStatus::ExitInterpreter => return finish_call_from_jit(vm, site.frame, site.pc, site.return_pc),@@ -896,7 +896,7 @@ pub unsafe extern "C" fn libjs_jit_prepare_call_environment(Gc::from_non_null(NonNull::new(function.cast_mut()).expect("a function")),)};- let argument = Value(this_argument);+ let argument = Value::from_bits(this_argument);// NB: ToObject would make a wrapper of the caller's realm.if function.uses_this()&& function.this_mode() == ThisMode::Global@@ -936,7 +936,7 @@ pub extern "C" fn libjs_jit_array_push(array: &Array, value: u64) -> u64 {array.indexed_storage_kind(),IndexedStorageKind::None | IndexedStorageKind::Packed));- array.indexed_append(Value(value), DEFAULT_ATTRIBUTES);+ array.indexed_append(Value::from_bits(value), DEFAULT_ATTRIBUTES);Value::from_f64(f64::from(array.indexed_array_like_size())).0}@@ -953,7 +953,7 @@ pub extern "C" fn libjs_jit_store_holey_element(object: &Object, index: u32, valIndexedStorageKind::Holey | IndexedStorageKind::Packed));assert!(index < object.indexed_array_like_size());- object.indexed_put(index, Value(value), DEFAULT_ATTRIBUTES);+ object.indexed_put(index, Value::from_bits(value), DEFAULT_ATTRIBUTES);}/// `u64 libjs_jit_primitive_to_string(VM*, u64 primitive)`: `String(primitive)`, which is ToString of the primitive,@@ -961,7 +961,7 @@ pub extern "C" fn libjs_jit_store_holey_element(object: &Object, index: u32, val////// JIT code calls this with its VM and a primitive.pub extern "C" fn libjs_jit_primitive_to_string(vm: &Vm, primitive: u64) -> u64 {- let primitive = Value(primitive);+ let primitive = Value::from_bits(primitive);assert!(!primitive.is_object());// 22.1.1.1 String ( value ), https://tc39.es/ecma262/#sec-string-constructor-string-valueif primitive.is_symbol() {@@ -1014,7 +1014,7 @@ extern "C" fn libjs_jit_math_pow(base: f64, exponent: f64) -> f64 {////// JIT code calls this with its VM, a function object and such a primitive.pub extern "C" fn libjs_jit_to_object(vm: &Vm, primitive: u64, function: u64) -> u64 {- let (function, primitive) = (Value(function).as_object(), Value(primitive));+ let (function, primitive) = (Value::from_bits(function).as_object(), Value::from_bits(primitive));assert!(!primitive.is_object() && !primitive.is_nullish());if vm.current_realm() != Some(function.shape().realm()) {return Value::EMPTY.0;@@ -1028,7 +1028,7 @@ pub extern "C" fn libjs_jit_to_object(vm: &Vm, primitive: u64, function: u64) ->////// JIT code calls this with its VM, a length below 2^31 and a function object.pub extern "C" fn libjs_jit_array_create(vm: &Vm, length: u32, function: u64) -> u64 {- let realm = Value(function).as_object().shape().realm();+ let realm = Value::from_bits(function).as_object().shape().realm();if vm.current_realm() != Some(realm) {return Value::EMPTY.0;}diff --git a/Libraries/LibJS/Rust/src/jit/entry_exit.rs b/Libraries/LibJS/Rust/src/jit/entry_exit.rsindex bdf35b3bd46..2744960d236 100644--- a/Libraries/LibJS/Rust/src/jit/entry_exit.rs+++ b/Libraries/LibJS/Rust/src/jit/entry_exit.rs@@ -178,7 +178,7 @@ pub fn control_after_entry(vm: &Vm, result: JitResult) -> i64 {// returns from the interpreter.let frame = vm.running_execution_context_ref();let exits_interpreter = frame.caller_frame.get().is_null() || frame.returns_to_native_caller.get();- vm.return_from_running_frame(Value(result.value));+ vm.return_from_running_frame(Value::from_bits(result.value));if exits_interpreter { -1 } else { 1 }}EntryStatus::Resume => 1,@@ -201,7 +201,7 @@ pub fn helper_enter_jit_code(vm: &Vm) -> i64 {EntryStatus::Returned => {frame_of(frame).register(register::RETURN_VALUE)- .set(Value(result.value));+ .set(Value::from_bits(result.value));1}EntryStatus::Resume => 0,@@ -317,7 +317,7 @@ pub unsafe extern "C" fn libjs_jit_inlined_raw_native_exception(.expect("the native function's frame runs");assert_eq!(frame_of(native_frame).caller_frame.get(), root.as_ptr());translate::materialize_call_site_frames(vm, root, site, frame_pointer, Some(native_frame));- crate::interpreter::slow_paths::calls::handle_raw_native_exception(vm, Value(exception)).0+ crate::interpreter::slow_paths::calls::handle_raw_native_exception(vm, Value::from_bits(exception)).0}/// Called by JIT code that never created the arguments object of the frame (whose arguments are unchanged) when itdiff --git a/Libraries/LibJS/Rust/src/jit/helper_calls.rs b/Libraries/LibJS/Rust/src/jit/helper_calls.rsindex 4d24d50659d..11531e83b0a 100644--- a/Libraries/LibJS/Rust/src/jit/helper_calls.rs+++ b/Libraries/LibJS/Rust/src/jit/helper_calls.rs@@ -58,7 +58,7 @@ pub fn address(intrinsic: Intrinsic) -> u64 {/// The string of a value JIT code checked to be a string.fn string(value: u64) -> Value {- let value = Value(value);+ let value = Value::from_bits(value);assert!(value.is_string());value}@@ -157,13 +157,13 @@ extern "C" fn string_trim_end(vm: &Vm, string_value: u64) -> u64 {/// `regexp.exec(string)`, for a RegExp object `regexp` whose exec runs no code (see/// `regexp_builtin_exec_running_no_code()`).extern "C" fn regexp_exec(vm: &Vm, regexp: u64, string_value: u64) -> u64 {- regexp_builtin_exec_running_no_code(vm, Value(regexp), string(string_value).as_string())+ regexp_builtin_exec_running_no_code(vm, Value::from_bits(regexp), string(string_value).as_string()).map_or(Value::EMPTY.0, |result| result.0)}/// The Map a `this` value is, if it is one.fn map(value: u64) -> Option<crate::layout::cell::Gc<Map>> {- let value = Value(value);+ let value = Value::from_bits(value);if !value.is_object() {return None;}@@ -175,7 +175,7 @@ extern "C" fn map_get(_vm: &Vm, map_value: u64, key: u64) -> u64 {let Some(map) = map(map_value) else {return Value::EMPTY.0;};- map.map_get(canonicalize_keyed_collection_key(Value(key)))+ map.map_get(canonicalize_keyed_collection_key(Value::from_bits(key))).unwrap_or(Value::UNDEFINED).0}@@ -185,5 +185,5 @@ extern "C" fn map_has(_vm: &Vm, map_value: u64, key: u64) -> u64 {let Some(map) = map(map_value) else {return Value::EMPTY.0;};- Value::from_bool(map.map_has(canonicalize_keyed_collection_key(Value(key)))).0+ Value::from_bool(map.map_has(canonicalize_keyed_collection_key(Value::from_bits(key)))).0}diff --git a/Libraries/LibJS/Rust/src/jit/intrinsics.rs b/Libraries/LibJS/Rust/src/jit/intrinsics.rsindex 8d9e319ccb6..429b5696d42 100644--- a/Libraries/LibJS/Rust/src/jit/intrinsics.rs+++ b/Libraries/LibJS/Rust/src/jit/intrinsics.rs@@ -132,7 +132,7 @@ fn has_own_string_property(vm: &Vm, object: Gc<Object>, name: &Utf16FlyString) -////// JIT code calls this with its VM.pub extern "C" fn libjs_jit_has_own_property(vm: &Vm, object: u64, key: u64) -> u64 {- let (object, key) = (Value(object), Value(key));+ let (object, key) = (Value::from_bits(object), Value::from_bits(key));if !object.is_object() || !has_ordinary_lookups(object.as_object()) {return Value::EMPTY.0;}@@ -156,7 +156,7 @@ pub extern "C" fn libjs_jit_has_own_property(vm: &Vm, object: u64, key: u64) ->////// JIT code calls this with its VM.pub extern "C" fn libjs_jit_has_property(vm: &Vm, key: u64, object: u64) -> u64 {- let (key_value, object) = (Value(key), Value(object));+ let (key_value, object) = (Value::from_bits(key), Value::from_bits(object));let index_key = key_value.is_int32() && key_value.as_i32() >= 0;if !object.is_object() || !(key_value.is_string() || key_value.is_symbol() || index_key) {return Value::EMPTY.0;@@ -210,7 +210,7 @@ pub extern "C" fn libjs_jit_has_property(vm: &Vm, key: u64, object: u64) -> u64////// JIT code calls this with its VM.pub extern "C" fn libjs_jit_open_array_iteration(vm: &Vm, iterable: u64) -> u64 {- let iterable = Value(iterable);+ let iterable = Value::from_bits(iterable);if !iterable.is_object() {return Value::EMPTY.0;}diff --git a/Libraries/LibJS/Rust/src/jit/snapshot.rs b/Libraries/LibJS/Rust/src/jit/snapshot.rsindex 35187d22d1d..11bc3797f54 100644--- a/Libraries/LibJS/Rust/src/jit/snapshot.rs+++ b/Libraries/LibJS/Rust/src/jit/snapshot.rs@@ -482,7 +482,7 @@ impl SnapshotBuilder<'_> {prototype_chain_valid: entry.prototype_chain_validity.is_some_and(|validity| validity.is_valid()),- key: (entry.key != 0).then(|| self.cell(Value(entry.key).as_cell())),+ key: (entry.key != 0).then(|| self.cell(Value::from_bits(entry.key).as_cell())),key_value: entry.key,prototype_property: self.optional_cell(prototype_property),prototype_property_intrinsic: intrinsic_of(diff --git a/Libraries/LibJS/Rust/src/jit/translate.rs b/Libraries/LibJS/Rust/src/jit/translate.rsindex c5abd2ecff9..ec6902e35e9 100644--- a/Libraries/LibJS/Rust/src/jit/translate.rs+++ b/Libraries/LibJS/Rust/src/jit/translate.rs@@ -105,7 +105,7 @@ impl RegisterDump {/// Reads a value that is not an object the code never created.fn read_location(location: ValueLocation, dump: &RegisterDump) -> Value {let (bits, repr) = match location {- ValueLocation::Constant(bits) => return Value(bits),+ ValueLocation::Constant(bits) => return Value::from_bits(bits),ValueLocation::Register(encoding, repr) => {let bits = if repr == Repr::Float64 {dump.fprs[usize::from(encoding)]@@ -125,7 +125,7 @@ fn read_location(location: ValueLocation, dump: &RegisterDump) -> Value {}};match repr {- Repr::Tagged => Value(bits),+ Repr::Tagged => Value::from_bits(bits),Repr::Int32 => Value::from_i32(bits as i32),Repr::Float64 => Value::from_f64(f64::from_bits(bits)),Repr::Bool => Value::from_bool(bits as u32 != 0),@@ -246,7 +246,7 @@ impl<'a> SiteValues<'a> {const DEFERRED_ARGUMENT_MARKER: u64 = Value::EMPTY.0 | (1 << 47);fn deferred_argument_marker(frame_pointer: u64) -> Value {- Value(DEFERRED_ARGUMENT_MARKER | (frame_pointer & u64::from(u32::MAX)))+ Value::from_bits(DEFERRED_ARGUMENT_MARKER | (frame_pointer & u64::from(u32::MAX)))}/// The low half of the frame pointer of the JIT frame that `value` is a marker of an object of (seediff --git a/Libraries/LibJS/Rust/src/layout/value.rs b/Libraries/LibJS/Rust/src/layout/value.rsindex 725ad8c721d..5e39b9cdc6a 100644--- a/Libraries/LibJS/Rust/src/layout/value.rs+++ b/Libraries/LibJS/Rust/src/layout/value.rs@@ -4,25 +4,32 @@* SPDX-License-Identifier: BSD-2-Clause*/+use core::marker::PhantomData;+use libjs_abi::value as nan_box;-/// A NaN-boxed JS::Value. Only libjs_rust makes values from bits, as bits can name a cell that is not there.+/// A NaN-boxed JS::Value. Only libjs_rust makes values from bits, as bits can name a cell that is not there. Values+/// stay on the thread of their VM, as cells do.#[derive(Clone, Copy, PartialEq, Eq)]#[repr(transparent)]-pub struct Value(pub(crate) u64);+pub struct Value(pub(crate) u64, PhantomData<*const ()>);impl Value {- pub const EMPTY: Value = Value(nan_box::EMPTY_VALUE);- pub const UNDEFINED: Value = Value(nan_box::UNDEFINED_VALUE);- pub const NULL: Value = Value(nan_box::NULL_VALUE);- pub const FALSE: Value = Value(nan_box::FALSE_VALUE);- pub const TRUE: Value = Value(nan_box::TRUE_VALUE);+ pub const EMPTY: Value = Value::from_bits(nan_box::EMPTY_VALUE);+ pub const UNDEFINED: Value = Value::from_bits(nan_box::UNDEFINED_VALUE);+ pub const NULL: Value = Value::from_bits(nan_box::NULL_VALUE);+ pub const FALSE: Value = Value::from_bits(nan_box::FALSE_VALUE);+ pub const TRUE: Value = Value::from_bits(nan_box::TRUE_VALUE);++ pub(crate) const fn from_bits(bits: u64) -> Value {+ Value(bits, PhantomData)+ }/// # Safety////// `bits` must be a NaN-boxed value, such as one C++ code hands over, and a cell it names must be live.pub const unsafe fn from_raw(bits: u64) -> Value {- Value(bits)+ Value::from_bits(bits)}/// The NaN-boxed bits, for handing the value to C++ code.diff --git a/Libraries/LibJS/Rust/src/runtime/native_function.rs b/Libraries/LibJS/Rust/src/runtime/native_function.rsindex e24d12e8d77..52e077ccf2a 100644--- a/Libraries/LibJS/Rust/src/runtime/native_function.rs+++ b/Libraries/LibJS/Rust/src/runtime/native_function.rs@@ -602,8 +602,8 @@ impl RawNativeFunctionResult {pub fn into_completion(self) -> ThrowCompletionOr<Value> {match self.variant {- 0 => Ok(Value(self.payload)),- 1 => Err(Throw::new(Value(self.payload))),+ 0 => Ok(Value::from_bits(self.payload)),+ 1 => Err(Throw::new(Value::from_bits(self.payload))),variant => unreachable!("{variant} is not a ThrowCompletionOr variant"),}}diff --git a/Libraries/LibJS/Rust/src/runtime/value.rs b/Libraries/LibJS/Rust/src/runtime/value.rsindex 8d2b6f65d1b..dd5bf5ff75f 100644--- a/Libraries/LibJS/Rust/src/runtime/value.rs+++ b/Libraries/LibJS/Rust/src/runtime/value.rs@@ -72,7 +72,7 @@ impl Value {}pub const fn from_i32(value: i32) -> Self {- Self(nan_box::SHIFTED_INT32_TAG | value as u32 as u64)+ Self::from_bits(nan_box::SHIFTED_INT32_TAG | value as u32 as u64)}/// Integral doubles that fit in an i32, other than negative zero, are stored as Int32, and every NaN becomes the@@ -83,9 +83,9 @@ impl Value {return Self::from_i32(value as i32);}if value.is_nan() {- return Self(nan_box::CANON_NAN_BITS);+ return Self::from_bits(nan_box::CANON_NAN_BITS);}- Self(value.to_bits())+ Self::from_bits(value.to_bits())}pub const fn tag(self) -> u64 {@@ -186,7 +186,7 @@ impl Value {pub(crate) fn with_cell_tag<T>(tag: u64, cell: Gc<T>) -> Self {let address = cell.as_ptr() as usize as u64;- Self((tag << nan_box::TAG_SHIFT) | (address & HEAP_REGION_OFFSET_MASK))+ Self::from_bits((tag << nan_box::TAG_SHIFT) | (address & HEAP_REGION_OFFSET_MASK))}/// # Safety