Skip to content
Closed
21 changes: 4 additions & 17 deletions cli/src/debug/limits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use boa_engine::{
Context, JsArgs, JsNativeError, JsObject, JsResult, JsValue, NativeFunction, js_string,
Context, JsArgs, JsObject, JsResult, JsValue, NativeFunction, js_string,
object::{FunctionObjectBuilder, ObjectInitializer},
property::Attribute,
};
Expand All @@ -11,7 +11,9 @@ fn get_loop(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<JsVal

fn set_loop(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
let value = args.get_or_undefined(0).to_length(context)?;
context.runtime_limits_mut().set_loop_iteration_limit(value);
context
.runtime_limits_mut()
.set_loop_iteration_limit(value as u64);
Ok(JsValue::undefined())
}

Expand All @@ -22,11 +24,6 @@ fn get_stack(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<JsVa

fn set_stack(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
let value = args.get_or_undefined(0).to_length(context)?;
let Ok(value) = value.try_into() else {
return Err(JsNativeError::range()
.with_message(format!("Argument {value} greater than usize::MAX"))
.into());
};
context.runtime_limits_mut().set_stack_size_limit(value);
Ok(JsValue::undefined())
}
Expand All @@ -38,11 +35,6 @@ fn get_recursion(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<

fn set_recursion(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
let value = args.get_or_undefined(0).to_length(context)?;
let Ok(value) = value.try_into() else {
return Err(JsNativeError::range()
.with_message(format!("Argument {value} greater than usize::MAX"))
.into());
};
context.runtime_limits_mut().set_recursion_limit(value);
Ok(JsValue::undefined())
}
Expand All @@ -54,11 +46,6 @@ fn get_backtrace(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<

fn set_backtrace(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
let value = args.get_or_undefined(0).to_length(context)?;
let Ok(value) = value.try_into() else {
return Err(JsNativeError::range()
.with_message(format!("Argument {value} greater than usize::MAX"))
.into());
};
context.runtime_limits_mut().set_backtrace_limit(value);
Ok(JsValue::undefined())
}
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/builtins/array/array_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use boa_gc::{Finalize, Trace};
#[derive(Debug, Clone, Finalize, Trace, JsData)]
pub(crate) struct ArrayIterator {
array: JsObject,
next_index: u64,
next_index: usize,
#[unsafe_ignore_trace]
kind: PropertyNameKind,
done: bool,
Expand Down
22 changes: 11 additions & 11 deletions core/engine/src/builtins/array/from_async.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use boa_gc::{Finalize, Trace};

use super::Array;
use crate::builtins::AsyncFromSyncIterator;
use crate::builtins::iterable::IteratorRecord;
use crate::builtins::promise::ResolvingFunctions;
use crate::builtins::{AsyncFromSyncIterator, Number};
use crate::native_function::{CoroutineState, NativeCoroutine};
use crate::object::{JsFunction, JsPromise};
use crate::{
Expand Down Expand Up @@ -206,17 +206,17 @@ struct GlobalState {
enum AsyncIteratorStateMachine {
LoopStart {
a: JsObject,
k: u64,
k: usize,
iterator_record: IteratorRecord,
},
LoopContinue {
a: JsObject,
k: u64,
k: usize,
iterator_record: IteratorRecord,
},
LoopEnd {
a: JsObject,
k: u64,
k: usize,
iterator_record: IteratorRecord,
mapped_value: Option<JsResult<JsValue>>,
},
Expand Down Expand Up @@ -249,7 +249,7 @@ fn from_async_iterator(
iterator_record,
} => {
// Inverted conditional makes for a simpler code.
if k < 2u64.pow(53) - 1 {
if (k as u64) < Number::MAX_SAFE_INTEGER as u64 {
// 2. Let Pk be ! ToString(𝔽(k)).
// 3. Let nextResult be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]).
let next_result = iterator_record.next_method().call(
Expand Down Expand Up @@ -468,20 +468,20 @@ enum ArrayLikeStateMachine {
LoopStart {
array_like: JsObject,
a: JsObject,
len: u64,
k: u64,
len: usize,
k: usize,
},
LoopContinue {
array_like: JsObject,
a: JsObject,
len: u64,
k: u64,
len: usize,
k: usize,
},
LoopEnd {
array_like: JsObject,
a: JsObject,
len: u64,
k: u64,
len: usize,
k: usize,
mapped_value: Option<JsValue>,
},
}
Expand Down
Loading
Loading