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

Unify async iterators and iterators compilation #2976

Merged
merged 8 commits into from
Jun 6, 2023
Merged

Conversation

jedel1043
Copy link
Member

This Pull Request fixes a bunch of iterator tests that were failing because we handled async iterators and iterators differently with respect to closes and returns.

  • Unifies compilation logic for iterators and async iterators.
  • Refactors IteratorRecord to be able to use it as iterator state at vm execution.
  • Avoids using the values stack for iterator tracking, instead using an IteratorRecord stack.

@jedel1043 jedel1043 added bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution labels May 30, 2023
@jedel1043 jedel1043 added this to the v0.17.0 milestone May 30, 2023
@jedel1043 jedel1043 requested a review from a team May 30, 2023 00:59
@github-actions
Copy link

github-actions bot commented May 30, 2023

Test262 conformance changes

Test result main count PR count difference
Total 94,108 94,108 0
Passed 74,620 74,640 +20
Ignored 17,740 17,740 0
Failed 1,748 1,728 -20
Panics 0 0 0
Conformance 79.29% 79.31% +0.02%
Fixed tests (20):
test/language/statements/async-generator/return-undefined-implicit-and-explicit.js [strict mode] (previously Failed)
test/language/statements/async-generator/return-undefined-implicit-and-explicit.js (previously Failed)
test/language/statements/async-generator/yield-star-return-then-getter-ticks.js [strict mode] (previously Failed)
test/language/statements/async-generator/yield-star-return-then-getter-ticks.js (previously Failed)
test/language/statements/for-in/cptn-decl-abrupt-empty.js [strict mode] (previously Failed)
test/language/statements/for-in/cptn-decl-abrupt-empty.js (previously Failed)
test/language/statements/for-in/cptn-expr-abrupt-empty.js [strict mode] (previously Failed)
test/language/statements/for-in/cptn-expr-abrupt-empty.js (previously Failed)
test/language/statements/for-of/body-put-error.js [strict mode] (previously Failed)
test/language/statements/for-of/body-put-error.js (previously Failed)
test/language/statements/for-of/iterator-close-via-continue.js [strict mode] (previously Failed)
test/language/statements/for-of/iterator-close-via-continue.js (previously Failed)
test/language/statements/for-of/cptn-decl-abrupt-empty.js [strict mode] (previously Failed)
test/language/statements/for-of/cptn-decl-abrupt-empty.js (previously Failed)
test/language/statements/for-of/generator-close-via-continue.js [strict mode] (previously Failed)
test/language/statements/for-of/generator-close-via-continue.js (previously Failed)
test/language/statements/for-of/body-dstr-assign-error.js [strict mode] (previously Failed)
test/language/statements/for-of/body-dstr-assign-error.js (previously Failed)
test/language/statements/for-of/cptn-expr-abrupt-empty.js [strict mode] (previously Failed)
test/language/statements/for-of/cptn-expr-abrupt-empty.js (previously Failed)

@codecov
Copy link

codecov bot commented May 30, 2023

Codecov Report

Merging #2976 (ef3a4c6) into main (de241c2) will increase coverage by 0.45%.
The diff coverage is 43.10%.

@@            Coverage Diff             @@
##             main    #2976      +/-   ##
==========================================
+ Coverage   50.11%   50.56%   +0.45%     
==========================================
  Files         446      446              
  Lines       46028    45901     -127     
==========================================
+ Hits        23065    23210     +145     
+ Misses      22963    22691     -272     
Impacted Files Coverage Δ
boa_cli/src/main.rs 0.60% <0.00%> (ø)
boa_engine/src/builtins/intl/list_format/mod.rs 4.97% <0.00%> (ø)
.../src/builtins/iterable/async_from_sync_iterator.rs 7.97% <0.00%> (+0.94%) ⬆️
boa_engine/src/builtins/promise/mod.rs 32.27% <0.00%> (+2.35%) ⬆️
boa_engine/src/builtins/weak_set/mod.rs 13.75% <0.00%> (ø)
boa_engine/src/job.rs 54.54% <ø> (-3.09%) ⬇️
boa_engine/src/vm/call_frame/mod.rs 100.00% <ø> (ø)
boa_engine/src/vm/code_block.rs 60.45% <0.00%> (+4.15%) ⬆️
boa_engine/src/vm/completion_record.rs 100.00% <ø> (ø)
boa_engine/src/vm/flowgraph/graph.rs 0.00% <0.00%> (ø)
... and 26 more

... and 20 files with indirect coverage changes

Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changes. Just have to see if my comment in jump_control breaks anything.

boa_engine/src/vm/opcode/mod.rs Outdated Show resolved Hide resolved
boa_engine/src/bytecompiler/jump_control.rs Outdated Show resolved Hide resolved
@jedel1043
Copy link
Member Author

Hmm, the last commit didn't fix any tests. I'll try to come up with a test for this.

@jedel1043
Copy link
Member Author

jedel1043 commented Jun 5, 2023

Added some tests that cover the fixed bug :)
Will try to upstream the tests to 262, but this should be enough for this PR.

@jedel1043 jedel1043 requested review from a team and raskad June 5, 2023 21:48
Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Just a small nitpick :)

boa_engine/src/vm/call_frame/env_stack.rs Outdated Show resolved Hide resolved
@jedel1043 jedel1043 enabled auto-merge June 6, 2023 18:58
@jedel1043 jedel1043 added this pull request to the merge queue Jun 6, 2023
Merged via the queue into main with commit a989462 Jun 6, 2023
@raskad raskad deleted the async-gen-close branch June 6, 2023 19:37
Razican pushed a commit that referenced this pull request Jun 26, 2023
* Close active iterators when returning from async generator

* Fix remaining async generator tests

* Fix remaining async generator tests

* Replace some reserved opcodes

* Fix for await of loop flag

* Add tests for fix

* Remove whitespace

* Fix test display and improve test

* Change `usize` to `u32`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants