-
-
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
Implement Async Generator Parsing #1669
Conversation
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.
Great work! Sorry for the late review. I have some small changes.
It would also be great if you could rebase this. Right now It is difficult to see which new passing/failing tests are because of your changes and which are because of the diff to main and the submodule update.
I was able to make a change that fixed the tests for test/language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js. It passed when I ran the tests on my computer. I'm not entirely sure how the rest of the tests are breaking off adding in the async method parsing and async gen parsing. I can definitely look into it further, but I might need some direction on where to look. |
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.
Hi there, sorry it took me some time to review this, and I wasn't able to review all of it. For now, I can tell a couple of things:
- Thank you for your contribution! This looks very, very promising, and I think we are very close to have it ready :)
- I see there are changes to GitHub workflows and so on, that are unrelated to this PR. I guess this is due to a strange re-base. No worries, you should merge the
main
branch into this one, and do agit submodule update
to make sure you have the latest Test262 submodule. We will squash the commits when merging, so the list of commits is not very important, the important part is the diff, and it should be as clean as possible to make the review easier. - I saw that you were not fully following some parsers, probably because some of the checks for
await
, then noLineTerminator
, thenfunction
were done beforehand. This is not a good practice, and I would prefer if you changed this so that each parser follows its spec correctly. This makes it much easier to develop each parser on its own (you only need to check for the spec of that parser), and it's easier to maintain. If someone in the future would like to change theAsyncGeneratorDeclaration
parser, for example, it shouldn't need to be aware of where is it being called from and what tokens that are part of it are already consumed. It should just follow the parser specification for that particular non-terminal.
Let me know if any of my comments are not clear, or if you would like to have some guidance on this, and thank you again! :)
boa/src/syntax/parser/expression/primary/async_generator_expression/mod.rs
Outdated
Show resolved
Hide resolved
boa/src/syntax/parser/expression/primary/async_generator_expression/mod.rs
Outdated
Show resolved
Hide resolved
boa/src/syntax/parser/expression/primary/async_generator_expression/mod.rs
Show resolved
Hide resolved
boa/src/syntax/parser/expression/primary/async_generator_expression/mod.rs
Outdated
Show resolved
Hide resolved
boa/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs
Outdated
Show resolved
Hide resolved
boa/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/mod.rs
Outdated
Show resolved
Hide resolved
boa/src/syntax/parser/expression/primary/async_function_expression/mod.rs
Outdated
Show resolved
Hide resolved
I went through and made a bunch of the changes. Thought I would push what I have so far even though I still have a question regarding @Razican I merged the main branch into this one and ran |
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 very good now! There are only a couple of things (and a small formatting recommendation):
Try running the following:
cd test262 && git pull origin 12e9d67bb529474ad1ffddca92361512ab30c4c0
This should update the test262 suite to the one in the main
branch, hopefully. It seems this one is using a different commit of the tests.
Then, it seems that these changes were not taken into account for our (in progress) virtual machine. To check this, you can compile the code with the "vm" feature:
cargo check --features "vm"
This way you will get the error in that piece of code. It should be pretty easy, it's just a match
that doesn't take into account the new AST nodes.
fn error_context(&self) -> &'static str { | ||
"async generator declaration" | ||
} | ||
fn is_default(&self) -> bool { | ||
self.is_default.0 | ||
} | ||
fn name_allow_yield(&self) -> bool { | ||
self.allow_yield.0 | ||
} | ||
fn name_allow_await(&self) -> bool { | ||
self.allow_await.0 | ||
} | ||
fn parameters_allow_yield(&self) -> bool { | ||
true | ||
} | ||
fn parameters_allow_await(&self) -> bool { | ||
true | ||
} | ||
fn body_allow_yield(&self) -> bool { | ||
true | ||
} | ||
fn body_allow_await(&self) -> bool { | ||
true | ||
} |
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.
Could we add the #[inline]
attribute to all of these, and separate each function with an empty line?
fn error_context(&self) -> &'static str { | |
"async generator declaration" | |
} | |
fn is_default(&self) -> bool { | |
self.is_default.0 | |
} | |
fn name_allow_yield(&self) -> bool { | |
self.allow_yield.0 | |
} | |
fn name_allow_await(&self) -> bool { | |
self.allow_await.0 | |
} | |
fn parameters_allow_yield(&self) -> bool { | |
true | |
} | |
fn parameters_allow_await(&self) -> bool { | |
true | |
} | |
fn body_allow_yield(&self) -> bool { | |
true | |
} | |
fn body_allow_await(&self) -> bool { | |
true | |
} | |
#[inline] | |
fn error_context(&self) -> &'static str { | |
"async generator declaration" | |
} | |
#[inline] | |
fn is_default(&self) -> bool { | |
self.is_default.0 | |
} | |
#[inline] | |
fn name_allow_yield(&self) -> bool { | |
self.allow_yield.0 | |
} | |
#[inline] | |
fn name_allow_await(&self) -> bool { | |
self.allow_await.0 | |
} | |
#[inline] | |
fn parameters_allow_yield(&self) -> bool { | |
true | |
} | |
#[inline] | |
fn parameters_allow_await(&self) -> bool { | |
true | |
} | |
#[inline] | |
fn body_allow_yield(&self) -> bool { | |
true | |
} | |
#[inline] | |
fn body_allow_await(&self) -> bool { | |
true | |
} |
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.
Sounds good. Should this also be applied to all other hoistable declarations as well?
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 think we do not have to add #[inline]
to theses functions. The compiler should always inline oneliners like this without the hint as far as I know.
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'll leave it off for now since it can always be added in across all the hoistable declarations if need be.
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.
Oh, sorry, I didn't read these and I added it anyway. Feel free to remove them. It should inline them in --release
mode without any issue, but with the #[inline]
keyword it should also inline them in debug mode.
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.
@nekevss Sorry, this discussion gets a bit off topic ;)
@Razican My impression is that the #[inline]
hints are mainly for the LLVM codegen. And in debug mode rustc is called with -C opt-level=0
so no LLVM optimizations would run at all.
I just tried it on godbolt
:
-C opt-level=0
=> not inlined-C opt-level=0
+#[inline]
=> not inlined-C opt-level=1
=> not inlined-C opt-level=1
+#[inline]
=> inlined-C opt-level=2
=> inlined
We have no [profile.dev]
, but we have a [profile.test]
where opt level is set to 1. So it would only matter for running cargo test
.
I honestly don't know if it's worth it, because imo all the #[inline]
s really clutter the codebase. I think we should decide how we want to deal with it and maybe document it, so the question does not come up again. What do you think?
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.
Makes sense, let's open a discussion about it and see what gets decided :)
boa/src/syntax/ast/node/declaration/async_generator_expr/mod.rs
Outdated
Show resolved
Hide resolved
/// - [ECMAScript reference][spec] | ||
/// | ||
/// [spec]: https://tc39.es/ecma262/#prod-AsyncGeneratorMethod | ||
|
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.
boa/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/mod.rs
Outdated
Show resolved
Hide resolved
…nerator_decl/mod.rs
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.
This looks now ready to merge from my side! :)
This Pull Request addresses #1558.
There were a lot of files and different small changes here and there with some larger chunks as well. Let me know what you think. While I was in implementing the AsyncGeneratorMethod on the object initializer. I also added the AsyncMethod as well...hopefully that's not stepping on anyone's toes, so to speak. There were a lot of different changes across quite a few files, so please let me know if I missed anything.
It changes the following: