-
-
Notifications
You must be signed in to change notification settings - Fork 407
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] - Implement CompletionRecords
for the Vm
#2618
Conversation
Test262 conformance changes
|
Codecov Report
@@ Coverage Diff @@
## main #2618 +/- ##
==========================================
- Coverage 49.63% 49.57% -0.06%
==========================================
Files 386 388 +2
Lines 39176 39280 +104
==========================================
+ Hits 19445 19475 +30
- Misses 19731 19805 +74
... and 13 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
I think it does in a way. It's a bit hard to say as I think those issues may predate the move to the VM. It does have Essentially, this should allow us to use |
pub(crate) fn convert(self, context: &mut Context<'_>) -> JsResult<JsValue> { | ||
match self.completion_type { | ||
CompletionType::Throw => { | ||
let err = JsError::from_opaque(self.value); | ||
if let Ok(native) = err.try_native(context) { | ||
Err(JsError::from_native(native)) | ||
} else { | ||
Err(err) | ||
} | ||
} | ||
_ => Ok(self.value), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to instead make CompletionRecord
something like:
enum CompletionRecord {
Normal(JsValue),
Return(JsValue),
Throw(JsError)
}
?
That way we don't need to convert JsError
s to opaque errors back and forth.
@@ -0,0 +1,24 @@ | |||
use crate::{JsError, JsResult, JsValue}; | |||
|
|||
#[derive(Debug, Clone)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Debug, Clone)] | |
// spec: <https://tc39.es/ecma262/#sec-completion-record-specification-type> | |
#[derive(Debug, Clone)] |
Would be nice to have a link to spec :)
} | ||
|
||
/// This function will consume the current `CompletionRecord` and return a `JsResult<JsValue>` | ||
#[allow(clippy::missing_const_for_fn)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this lint allowed? If there is a valid reason could we have a comment explaining it :)
} else { | ||
Err(JsNativeError::typ() | ||
return Err(JsNativeError::typ() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why explicitly use return
keyword here?
Looks good! Great work @nekevss , Will try to do a more thorough review tomorrow! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! :)
3aaa136
to
34eccb4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new logic.
If @jedel1043 agrees and you want to merge this as is lets do it @nekevss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! The changes look almost perfect :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
bors r+ |
<!--- Thank you for contributing to Boa! Please fill out the template below, and remove or add any information as you feel necessary. ---> This goal of this draft is to begin to implement `CompletionRecords`. This draft switches the `Vm`'s `Opcode` from `JsResult<ShouldExit>` to `CompletionType` where the value is the top of the stack and returns a `CompletionRecord`. Primarily submitting as a draft for now for feedback. It changes the following: - Adds `CompletionRecord` and `CompletionType` to `Vm`. - Changes the evaluation loop from `while` to `loop` that returns a `CompletionType`. - Adapts `Context::run` to handle `CompletionType` and `CompletionRecord`. - Removes `FinallyAddresses` in favor of just checking the `env_stack`.
Pull request successfully merged into main. Build succeeded: |
CompletionRecords
for the VmCompletionRecords
for the Vm
This goal of this draft is to begin to implement
CompletionRecords
. This draft switches theVm
'sOpcode
fromJsResult<ShouldExit>
toCompletionType
where the value is the top of the stack and returns aCompletionRecord
. Primarily submitting as a draft for now for feedback.It changes the following:
CompletionRecord
andCompletionType
toVm
.while
toloop
that returns aCompletionType
.Context::run
to handleCompletionType
andCompletionRecord
.FinallyAddresses
in favor of just checking theenv_stack
.