Skip to content

Commit

Permalink
Implement Atomics builtin (#3394)
Browse files Browse the repository at this point in the history
* Implement `Atomics` builtin

* Apply review
  • Loading branch information
jedel1043 authored Oct 31, 2023
1 parent 2f1fef2 commit 04ed7be
Show file tree
Hide file tree
Showing 32 changed files with 3,030 additions and 449 deletions.
62 changes: 62 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ members = [
[workspace.package]
edition = "2021"
version = "0.17.0"
rust-version = "1.71.0"
rust-version = "1.73.0"
authors = ["boa-dev"]
repository = "https://github.com/boa-dev/boa"
license = "Unlicense OR MIT"
Expand Down
11 changes: 10 additions & 1 deletion boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fuzz = ["boa_ast/arbitrary", "boa_interner/arbitrary"]
flowgraph = []

# Enable Boa's VM instruction tracing.
trace = []
trace = ["js"]

# Enable Boa's additional ECMAScript features for web browsers.
annex-b = ["boa_parser/annex-b"]
Expand All @@ -52,6 +52,9 @@ temporal = ["boa_parser/temporal", "dep:icu_calendar"]
# Enable experimental features, like Stage 3 proposals.
experimental = ["temporal"]

# Enable binding to JS APIs for system related utilities.
js = ["dep:web-time"]

[dependencies]
boa_interner.workspace = true
boa_gc = { workspace = true, features = [ "thinvec" ] }
Expand Down Expand Up @@ -86,6 +89,9 @@ icu_normalizer = "~1.3.0"
paste = "1.0"
portable-atomic = "1.5.1"
bytemuck = { version = "1.14.0", features = ["derive"] }
arrayvec = "0.7.4"
intrusive-collections = "0.9.6"
cfg-if = "1.0.0"

# intl deps
boa_icu_provider = {workspace = true, features = ["std"], optional = true }
Expand All @@ -105,6 +111,9 @@ yoke = { workspace = true, optional = true }
zerofrom = { workspace = true, optional = true }
fixed_decimal = { workspace = true, features = ["ryu"], optional = true}

[target.'cfg(all(target_family = "wasm", not(any(target_os = "emscripten", target_os = "wasi"))))'.dependencies]
web-time = { version = "0.2.2", optional = true }

[dev-dependencies]
criterion = "0.5.1"
float-cmp = "0.9.0"
Expand Down
7 changes: 7 additions & 0 deletions boa_engine/src/builtins/array_buffer/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ pub struct SharedArrayBuffer {
}

impl SharedArrayBuffer {
/// Creates a `SharedArrayBuffer` with an empty buffer.
#[must_use]
pub fn empty() -> Self {
Self {
data: Arc::default(),
}
}
/// Gets the length of this `SharedArrayBuffer`.
pub(crate) fn len(&self) -> usize {
self.data.len()
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/builtins/array_buffer/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl SliceRef<'_> {
// 9. Return RawBytesToNumeric(type, rawValue, isLittleEndian).

// SAFETY: The invariants of this operation are ensured by the caller.
unsafe { T::read_from_buffer(buffer, order) }
unsafe { T::read(buffer).load(order) }
}

let buffer = *self;
Expand Down Expand Up @@ -259,7 +259,7 @@ impl SliceRefMut<'_> {

// SAFETY: The invariants of this operation are ensured by the caller.
unsafe {
T::write_to_buffer(buffer, value, order);
T::read_mut(buffer).store(value, order);
}
}

Expand Down
Loading

0 comments on commit 04ed7be

Please sign in to comment.