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
12 changes: 8 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ members = [

exclude = [
"tests/fuzz", # Does weird things on Windows tests
"tests/src", # Just a hack to have fuzz inside tests
"tests/wpt", # Should not run WPT by default.
"tests/src", # Just a hack to have fuzz inside tests
"tests/wpt", # Should not run WPT by default.
]

[workspace.package]
Expand Down Expand Up @@ -78,7 +78,9 @@ oneshot = "0.2.1"
phf = { version = "0.14.0", default-features = false }
regex = "1.13.2"
regress = { version = "0.12.0", features = ["utf16"] }
reqwest = { version = "0.13.5", default-features = false, features = ["rustls-no-provider"] }
reqwest = { version = "0.13.5", default-features = false, features = [
"rustls-no-provider",
] }
rustls = { version = "0.23.46", default-features = false, features = ["ring"] }
rustc-hash = { version = "2.1.3", default-features = false }
serde_json = "1.0.154"
Expand Down Expand Up @@ -130,7 +132,9 @@ cfg-if = "1.0.5"
either = "1.19.0"
sys-locale = "0.3.2"
timezone_provider = { version = "0.2.6" }
temporal_rs = { version = "0.2.6", default-features = false, features = ["float64_representable_durations"] }
temporal_rs = { version = "0.2.6", default-features = false, features = [
"float64_representable_durations",
] }
web-time = "1.1.0"
criterion = "0.8.2"
float-cmp = "0.10.0"
Expand Down
9 changes: 8 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ repository.workspace = true
rust-version.workspace = true

[dependencies]
boa_engine = { workspace = true, features = ["deser", "float16", "flowgraph", "temporal", "trace", "xsum"] }
boa_engine = { workspace = true, features = [
"deser",
"float16",
"flowgraph",
"temporal",
"trace",
"xsum",
] }
boa_parser.workspace = true
boa_gc.workspace = true
boa_runtime = { workspace = true, features = ["test262"] }
Expand Down
20 changes: 13 additions & 7 deletions core/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ trace = ["js"]
annex-b = ["boa_ast/annex-b", "boa_parser/annex-b"]

# Enable Boa's Temporal proposal implementation
temporal = ["dep:icu_calendar", "dep:temporal_rs", "dep:timezone_provider", "timezone_provider/experimental_tzif"]
temporal = [
"dep:icu_calendar",
"dep:temporal_rs",
"dep:timezone_provider",
"timezone_provider/experimental_tzif",
]

#Enable access to host system timezone
system-time-zone = ["dep:iana-time-zone"]
Expand Down Expand Up @@ -122,7 +127,9 @@ thiserror.workspace = true
dashmap.workspace = true
num_enum.workspace = true
thin-vec.workspace = true
itertools = { workspace = true, default-features = false, features = ["use_alloc"] }
itertools = { workspace = true, default-features = false, features = [
"use_alloc",
] }
icu_normalizer = { workspace = true, features = [
"compiled_data",
"utf16_iter",
Expand Down Expand Up @@ -153,7 +160,7 @@ icu_locale = { workspace = true, default-features = false, features = [
], optional = true }
icu_datetime = { workspace = true, default-features = false, features = [
"serde",
"unstable"
"unstable",
], optional = true }
icu_time = { workspace = true, default-features = false, features = [
"serde",
Expand All @@ -178,14 +185,13 @@ icu_segmenter = { workspace = true, default-features = false, features = [
"serde",
], optional = true }
icu_decimal = { workspace = true, default-features = false, features = [
"serde", "unstable"
"serde",
"unstable",
], optional = true }
writeable = { workspace = true, optional = true }
yoke = { workspace = true, optional = true }
zerofrom = { workspace = true, optional = true }
fixed_decimal = { workspace = true, features = [
"ryu",
], optional = true }
fixed_decimal = { workspace = true, features = ["ryu"], optional = true }
tinystr = { workspace = true, optional = true }

# temporal deps
Expand Down
7 changes: 7 additions & 0 deletions core/engine/src/builtins/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ impl JsData for Array {
fn internal_methods(&self) -> &'static InternalObjectMethods {
&ARRAY_EXOTIC_INTERNAL_METHODS
}

fn type_name() -> &'static str
where
Self: Sized,
{
"Array"
}
}

impl IntrinsicObject for Array {
Expand Down
82 changes: 15 additions & 67 deletions core/engine/src/builtins/array_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,19 +496,12 @@ impl ArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
let object = this.as_object();
let buf = object
.as_ref()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("get ArrayBuffer.prototype.byteLength called with invalid `this`")
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. If IsDetachedBuffer(O) is true, return +0𝔽.
// 5. Let length be O.[[ArrayBufferByteLength]].
// 6. Return 𝔽(length).
Ok(buf.len().into())
Ok(buf.borrow().data().len().into())
}

/// [`get ArrayBuffer.prototype.maxByteLength`][spec].
Expand All @@ -522,18 +515,12 @@ impl ArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
let object = this.as_object();
let buf = object
.as_ref()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ().with_message(
"get ArrayBuffer.prototype.maxByteLength called with invalid `this`",
)
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. If IsDetachedBuffer(O) is true, return +0𝔽.
let Some(data) = buf.bytes() else {
let buf_data = buf.borrow();
let buf_data = buf_data.data();
let Some(data) = buf_data.bytes() else {
return Ok(JsValue::from(0));
};

Expand All @@ -542,7 +529,7 @@ impl ArrayBuffer {
// 6. Else,
// a. Let length be O.[[ArrayBufferMaxByteLength]].
// 7. Return 𝔽(length).
Ok(buf.max_byte_len.unwrap_or(data.len() as u64).into())
Ok(buf_data.max_byte_len.unwrap_or(data.len() as u64).into())
}

/// [`get ArrayBuffer.prototype.resizable`][spec].
Expand All @@ -556,17 +543,10 @@ impl ArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
let object = this.as_object();
let buf = object
.as_ref()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("get ArrayBuffer.prototype.resizable called with invalid `this`")
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. If IsFixedLengthArrayBuffer(O) is false, return true; otherwise return false.
Ok(JsValue::from(!buf.is_fixed_len()))
Ok(JsValue::from(!buf.borrow().data().is_fixed_len()))
}

/// [`get ArrayBuffer.prototype.detached`][spec].
Expand All @@ -581,17 +561,10 @@ impl ArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
let object = this.as_object();
let buf = object
.as_ref()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("get ArrayBuffer.prototype.detached called with invalid `this`")
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. Return IsDetachedBuffer(O).
Ok(buf.is_detached().into())
Ok(buf.borrow().data().is_detached().into())
}

/// [`ArrayBuffer.prototype.resize ( newLength )`][spec].
Expand All @@ -605,13 +578,7 @@ impl ArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
let buf = this
.as_object()
.and_then(|o| o.clone().downcast::<Self>().ok())
.ok_or_else(|| {
JsNativeError::typ()
.with_message("ArrayBuffer.prototype.resize called with invalid `this`")
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. Let newByteLength be ? ToIndex(newLength).
let new_byte_length = args.get_or_undefined(0).to_index(context)?;
Expand Down Expand Up @@ -649,13 +616,7 @@ impl ArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
let buf = this
.as_object()
.and_then(|o| o.clone().downcast::<Self>().ok())
.ok_or_else(|| {
JsNativeError::typ()
.with_message("ArrayBuffer.slice called with invalid `this` value")
})?;
let buf = this.require_internal_slot::<Self>()?;

let len = {
let buf = buf.borrow();
Expand Down Expand Up @@ -695,11 +656,7 @@ impl ArrayBuffer {

// 17. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
// 18. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
let Ok(new) = new.downcast::<Self>() else {
return Err(JsNativeError::typ()
.with_message("ArrayBuffer constructor returned invalid object")
.into());
};
let new = new.require_internal_slot::<Self>()?;

// 20. If SameValue(new, O) is true, throw a TypeError exception.
if JsObject::equals(&buf, &new) {
Expand Down Expand Up @@ -766,16 +723,7 @@ impl ArrayBuffer {

// 1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]).
// 2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception.
let buf = this
.as_object()
.and_then(|o| o.clone().downcast::<Self>().ok())
.ok_or_else(|| {
JsNativeError::typ().with_message(if TO_FIXED_LENGTH {
"ArrayBuffer.prototype.transferToFixedLength called with invalid `this`"
} else {
"ArrayBuffer.prototype.transfer called with invalid `this`"
})
})?;
let buf = this.require_internal_slot::<Self>()?;

// 3. If newLength is undefined, then
let new_len = if new_length.is_undefined() {
Expand Down
50 changes: 8 additions & 42 deletions core/engine/src/builtins/array_buffer/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,10 @@ impl SharedArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
let object = this.as_object();
let buf = object
.as_ref()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("SharedArrayBuffer.byteLength called with invalid value")
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. Let length be ArrayBufferByteLength(O, seq-cst).
let len = buf.bytes(Ordering::SeqCst).len() as u64;
let len = buf.borrow().data().bytes(Ordering::SeqCst).len() as u64;

// 5. Return 𝔽(length).
Ok(len.into())
Expand All @@ -252,17 +245,10 @@ impl SharedArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
let object = this.as_object();
let buf = object
.as_ref()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("get SharedArrayBuffer.growable called with invalid `this`")
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. If IsFixedLengthArrayBuffer(O) is false, return true; otherwise return false.
Ok(JsValue::from(!buf.is_fixed_len()))
Ok(JsValue::from(!buf.borrow().data().is_fixed_len()))
}

/// [`get SharedArrayBuffer.prototype.maxByteLength`][spec].
Expand All @@ -276,21 +262,14 @@ impl SharedArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
let object = this.as_object();
let buf = object
.as_ref()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("get SharedArrayBuffer.maxByteLength called with invalid value")
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. If IsFixedLengthArrayBuffer(O) is true, then
// a. Let length be O.[[ArrayBufferByteLength]].
// 5. Else,
// a. Let length be O.[[ArrayBufferMaxByteLength]].
// 6. Return 𝔽(length).
Ok(buf.data.buffer.len().into())
Ok(buf.borrow().data().data.buffer.len().into())
}

/// [`SharedArrayBuffer.prototype.grow ( newLength )`][spec].
Expand All @@ -303,14 +282,7 @@ impl SharedArrayBuffer {
) -> JsResult<JsValue> {
// 1. Let O be the this value.
// 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
let Some(buf) = this
.as_object()
.and_then(|o| o.clone().downcast::<Self>().ok())
else {
return Err(JsNativeError::typ()
.with_message("SharedArrayBuffer.grow called with non-object value")
.into());
};
let buf = this.require_internal_slot::<Self>()?;

// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
if buf.borrow().data().is_fixed_len() {
Expand Down Expand Up @@ -398,13 +370,7 @@ impl SharedArrayBuffer {
// 1. Let O be the this value.
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
let buf = this
.as_object()
.and_then(|o| o.clone().downcast::<Self>().ok())
.ok_or_else(|| {
JsNativeError::typ()
.with_message("SharedArrayBuffer.slice called with invalid `this` value")
})?;
let buf = this.require_internal_slot::<Self>()?;

// 4. Let len be ArrayBufferByteLength(O, seq-cst).
let len = buf.borrow().data().len(Ordering::SeqCst);
Expand Down
Loading
Loading