Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nova_vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ unicode-normalization = { workspace = true }
wtf8 = { workspace = true }

[features]
default = ["math", "json", "date", "array-buffer", "shared-array-buffer", "weak-refs"]
default = ["math", "json", "date", "array-buffer", "shared-array-buffer", "weak-refs", "atomics"]
math = []
json = ["sonic-rs"]
date = []
array-buffer = []
shared-array-buffer = []
weak-refs = []
atomics = ["array-buffer", "shared-array-buffer"]
typescript = []

[build-dependencies]
Expand Down
1 change: 1 addition & 0 deletions nova_vm/src/ecmascript/builtins/structured_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#[cfg(feature = "array-buffer")]
pub(crate) mod array_buffer_objects;
#[cfg(feature = "atomics")]
pub(crate) mod atomics_object;
#[cfg(feature = "array-buffer")]
pub(crate) mod data_view_objects;
Expand Down
24 changes: 13 additions & 11 deletions nova_vm/src/ecmascript/execution/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,17 +982,19 @@ pub(crate) fn set_default_global_bindings(
// 19.4 Other Properties of the Global Object
{
// 19.4.1 Atomics
let name = PropertyKey::from(BUILTIN_STRING_MEMORY.Atomics);
let value = agent.get_realm(realm_id).intrinsics().atomics();
let desc = PropertyDescriptor {
value: Some(value.into_value()),
writable: Some(true),
enumerable: Some(false),
configurable: Some(true),
..Default::default()
};
define_property_or_throw(agent, global, name, desc)?;

#[cfg(feature = "atomics")]
{
let name = PropertyKey::from(BUILTIN_STRING_MEMORY.Atomics);
let value = agent.get_realm(realm_id).intrinsics().atomics();
let desc = PropertyDescriptor {
value: Some(value.into_value()),
writable: Some(true),
enumerable: Some(false),
configurable: Some(true),
..Default::default()
};
define_property_or_throw(agent, global, name, desc)?;
}
// 19.4.2 JSON
#[cfg(feature = "json")]
{
Expand Down
7 changes: 5 additions & 2 deletions nova_vm/src/ecmascript/execution/realm/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use crate::ecmascript::builtins::numbers_and_dates::date_objects::{
};
#[cfg(feature = "math")]
use crate::ecmascript::builtins::numbers_and_dates::math_object::MathObject;
#[cfg(feature = "atomics")]
use crate::ecmascript::builtins::structured_data::atomics_object::AtomicsObject;
#[cfg(feature = "json")]
use crate::ecmascript::builtins::structured_data::json_object::JSONObject;
#[cfg(feature = "shared-array-buffer")]
Expand Down Expand Up @@ -96,7 +98,6 @@ use crate::{
},
primitive_objects::PrimitiveObject,
reflection::{proxy_constructor::ProxyConstructor, reflect_object::ReflectObject},
structured_data::atomics_object::AtomicsObject,
text_processing::{
regexp_objects::{
regexp_constructor::RegExpConstructor, regexp_prototype::RegExpPrototype,
Expand Down Expand Up @@ -149,7 +150,6 @@ use crate::{
IntrinsicObjectIndexes, IntrinsicPrimitiveObjectIndexes, WorkQueues,
},
};

#[derive(Debug, Clone)]
pub(crate) struct Intrinsics {
pub(crate) object_index_base: ObjectIndex,
Expand Down Expand Up @@ -329,6 +329,7 @@ impl Intrinsics {
DataViewPrototype::create_intrinsic(agent, realm);
#[cfg(feature = "array-buffer")]
DataViewConstructor::create_intrinsic(agent, realm);
#[cfg(feature = "atomics")]
AtomicsObject::create_intrinsic(agent, realm);
#[cfg(feature = "json")]
JSONObject::create_intrinsic(agent, realm);
Expand Down Expand Up @@ -612,6 +613,7 @@ impl Intrinsics {
}

/// %Atomics%
#[cfg(feature = "atomics")]
pub(crate) fn atomics(&self) -> OrdinaryObject {
IntrinsicObjectIndexes::AtomicsObject
.get_object_index(self.object_index_base)
Expand Down Expand Up @@ -1618,6 +1620,7 @@ impl HeapMarkAndSweep for Intrinsics {
self.async_generator_function().mark_values(queues);
self.async_generator_prototype().mark_values(queues);
self.async_iterator_prototype().mark_values(queues);
#[cfg(feature = "atomics")]
self.atomics().mark_values(queues);
self.big_int_prototype().mark_values(queues);
self.big_int().mark_values(queues);
Expand Down
1 change: 1 addition & 0 deletions nova_vm/src/heap/heap_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub(crate) enum IntrinsicObjectIndexes {
SharedArrayBufferPrototype,
#[cfg(feature = "array-buffer")]
DataViewPrototype,
#[cfg(feature = "atomics")]
AtomicsObject,
JSONObject,

Expand Down