Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix internal vm tests #1718

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e46e95d
Fix some more things
raskad Nov 9, 2021
0aa8907
Move function parameter initialization to bytecode
raskad Nov 11, 2021
5245eec
Fix constructor return value
raskad Nov 11, 2021
cec184e
Fix rest argument length
raskad Nov 12, 2021
06278bd
Fix logical and / or
raskad Nov 12, 2021
73003bc
Fix some more vm ops
raskad Nov 14, 2021
a42c788
Fix invalid parsing of update expression
raskad Nov 14, 2021
0b67407
Fix $262.evalScript function for vm
raskad Nov 14, 2021
77cb58b
Fix panic on function argument
raskad Nov 15, 2021
ecb8d5a
Refactor try catch to work with continue
raskad Nov 15, 2021
d09e405
Make try block finally work in for in/of loops
raskad Nov 16, 2021
8d6bd1f
FIx function argument execution order
raskad Nov 16, 2021
d4af48c
Typeof operator catches non-existing variables
raskad Nov 16, 2021
7af7c83
Fix tagged template raws
raskad Nov 16, 2021
b7b4fec
Fix some strict mode bugs
raskad Nov 17, 2021
a58e7c8
Fix undefined new_target on function call
raskad Nov 18, 2021
7035aae
Fix object literal creation
raskad Nov 18, 2021
39bfd34
Fix nested try blocks
raskad Nov 19, 2021
c471a66
Implement toString for vm functions
raskad Nov 19, 2021
30ea839
Make try block work with return
raskad Nov 20, 2021
7f137b2
Fix argument object bug
raskad Nov 20, 2021
0fdce3a
Fix vm import
raskad Nov 21, 2021
19b8f9e
Fix tests
raskad Dec 6, 2021
9828673
Fix some lints
raskad Dec 6, 2021
3dfd0a7
Fix some suggestions
raskad Dec 7, 2021
21a0076
Improve opcode docs and rename related code
raskad Dec 7, 2021
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
13 changes: 12 additions & 1 deletion boa/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl fmt::Debug for Function {

impl Function {
// Adds the final rest parameters to the Environment as an array
#[cfg(not(feature = "vm"))]
pub(crate) fn add_rest_param(
param: &FormalParameter,
index: usize,
Expand Down Expand Up @@ -240,6 +241,7 @@ impl Function {
}

// Adds an argument to the environment
#[cfg(not(feature = "vm"))]
pub(crate) fn add_arguments_to_environment(
param: &FormalParameter,
value: JsValue,
Expand Down Expand Up @@ -580,7 +582,16 @@ impl BuiltInFunctionObject {
.into())
}
}

#[cfg(feature = "vm")]
(Function::VmOrdinary { .. }, Some(name)) if name.is_empty() => {
Ok("[Function (anonymous)]".into())
}
#[cfg(feature = "vm")]
(Function::VmOrdinary { .. }, Some(name)) => {
Ok(format!("[Function: {}]", &name).into())
}
#[cfg(feature = "vm")]
(Function::VmOrdinary { .. }, None) => Ok("[Function (anonymous)]".into()),
raskad marked this conversation as resolved.
Show resolved Hide resolved
_ => Ok("TODO".into()),
}
}
Expand Down
45 changes: 29 additions & 16 deletions boa/src/builtins/iterable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,30 +230,43 @@ impl IteratorRecord {
completion: JsResult<JsValue>,
context: &mut Context,
) -> JsResult<JsValue> {
let mut inner_result = self.iterator_object.get_field("return", context);
// 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
// 2. Let iterator be iteratorRecord.[[Iterator]].
// 3. Let innerResult be GetMethod(iterator, "return").
let inner_result = self.iterator_object.get_method("return", context);
//let mut inner_result = self.iterator_object.get_field("return", context);

// 5
// 4. If innerResult.[[Type]] is normal, then
if let Ok(inner_value) = inner_result {
// b
if inner_value.is_undefined() {
return completion;
// a. Let return be innerResult.[[Value]].
match inner_value {
// b. If return is undefined, return Completion(completion).
None => return completion,
// c. Set innerResult to Call(return, iterator).
Some(value) => {
let inner_result = value.call(&self.iterator_object, &[], context);

// 5. If completion.[[Type]] is throw, return Completion(completion).
let completion = completion?;

// 6. If innerResult.[[Type]] is throw, return Completion(innerResult).
inner_result?;

// 7. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
// 8. Return Completion(completion).
return Ok(completion);
}
}
// c
inner_result = context.call(&inner_value, &self.iterator_object, &[]);
}

// 6
// 5. If completion.[[Type]] is throw, return Completion(completion).
let completion = completion?;

// 7
let inner_result = inner_result?;

// 8
if !inner_result.is_object() {
return context.throw_type_error("`return` method of iterator didn't return an Object");
}
// 6. If innerResult.[[Type]] is throw, return Completion(innerResult).
inner_result?;

// 9
// 7. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
// 8. Return Completion(completion).
Ok(completion)
}
}
Expand Down
2 changes: 2 additions & 0 deletions boa/src/builtins/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ impl Json {
// 9. Let unfiltered be completion.[[Value]].
// 10. Assert: unfiltered is either a String, Number, Boolean, Null, or an Object that is defined by either an ArrayLiteral or an ObjectLiteral.
let unfiltered = context.eval(script_string.as_bytes())?;
#[cfg(feature = "vm")]
context.vm.pop_frame();

// 11. If IsCallable(reviver) is true, then
if let Some(obj) = args.get_or_undefined(1).as_callable() {
Expand Down
4 changes: 0 additions & 4 deletions boa/src/builtins/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ pub struct RegExp {
/// Regex matcher.
matcher: Regex,

/// Update last_index, set if global or sticky flags are set.
use_last_index: bool,

/// Flag 's' - dot matches newline characters.
dot_all: bool,

Expand Down Expand Up @@ -340,7 +337,6 @@ impl RegExp {

let regexp = RegExp {
matcher,
use_last_index: global || sticky,
dot_all,
global,
ignore_case,
Expand Down
Loading