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] - Implement with and object environments #2692

Closed
wants to merge 2 commits into from
Closed

Conversation

raskad
Copy link
Member

@raskad raskad commented Mar 19, 2023

This Pull Request changes the following:

  • Implement with statement parsing, ast node, compilation and excution.
  • Implement object environments that are used in the with statement excution.

The implementation of object environments can probably be optimized further by using more compile-time information about when object environments can exist. Maybe there could also be a separate environment stack for object environments to reduce the filtering and iteration that is needed with the current implementation.
This does not fix all tests in the test/language/statements/with suite yet. But for most failing tests that I have looked at we are missing other features / have bugs elsewhere.

As a note for the review:
The functions in the impl Context block in boa_engine/src/environments/runtime.rs are mostly copied / moved from the existing functions. The only change there should be the addition of the object environment logic. They had to be moved to Context because of borrow semantics.

@raskad raskad added parser Issues surrounding the parser execution Issues or PRs related to code execution ast Issue surrounding the abstract syntax tree labels Mar 19, 2023
@raskad raskad added this to the v0.17.0 milestone Mar 19, 2023
@github-actions
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 94,277 94,277 0
Passed 70,720 70,917 +197
Ignored 17,324 17,324 0
Failed 6,233 6,036 -197
Panics 14 14 0
Conformance 75.01% 75.22% +0.21%
Fixed tests (197):
test/language/statements/try/S12.14_A14.js (previously Failed)
test/language/statements/with/S12.10_A1.2_T3.js (previously Failed)
test/language/statements/with/S12.10_A4_T4.js (previously Failed)
test/language/statements/with/S12.10_A1.8_T4.js (previously Failed)
test/language/statements/with/S12.10_A1.7_T1.js (previously Failed)
test/language/statements/with/S12.10_A3.10_T1.js (previously Failed)
test/language/statements/with/scope-var-open.js (previously Failed)
test/language/statements/with/S12.10_A5_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.8_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.5_T4.js (previously Failed)
test/language/statements/with/S12.10_A3.3_T2.js (previously Failed)
test/language/statements/with/12.10-7-1.js (previously Failed)
test/language/statements/with/S12.10_A5_T4.js (previously Failed)
test/language/statements/with/S12.10_A1.6_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.10_T3.js (previously Failed)
test/language/statements/with/S12.10_A1.4_T3.js (previously Failed)
test/language/statements/with/S12.10_A1.5_T2.js (previously Failed)
test/language/statements/with/unscopables-get-err.js (previously Failed)
test/language/statements/with/S12.10_A3.4_T2.js (previously Failed)
test/language/statements/with/S12.10_A1.6_T3.js (previously Failed)
test/language/statements/with/S12.10_A1.4_T4.js (previously Failed)
test/language/statements/with/S12.10_A1.10_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.5_T1.js (previously Failed)
test/language/statements/with/has-property-err.js (previously Failed)
test/language/statements/with/12.10-2-3.js (previously Failed)
test/language/statements/with/S12.10_A1.9_T1.js (previously Failed)
test/language/statements/with/S12.10_A3.2_T2.js (previously Failed)
test/language/statements/with/12.10-0-7.js (previously Failed)
test/language/statements/with/S12.10_A3.2_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.6_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.10_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.4_T1.js (previously Failed)
test/language/statements/with/12.10-2-2.js (previously Failed)
test/language/statements/with/S12.10_A1.10_T4.js (previously Failed)
test/language/statements/with/S12.10_A1.4_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.12_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.5_T5.js (previously Failed)
test/language/statements/with/S12.10_A3.7_T2.js (previously Failed)
test/language/statements/with/12.10-0-9.js (previously Failed)
test/language/statements/with/S12.10_A3.8_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.4_T5.js (previously Failed)
test/language/statements/with/S12.10_A1.8_T2.js (previously Failed)
test/language/statements/with/S12.10_A1.3_T5.js (previously Failed)
test/language/statements/with/S12.10_A1.2_T5.js (previously Failed)
test/language/statements/with/S12.10_A3.11_T4.js (previously Failed)
test/language/statements/with/S12.10_A3.5_T2.js (previously Failed)
test/language/statements/with/S12.10_A5_T1.js (previously Failed)
test/language/statements/with/S12.10_A3.3_T1.js (previously Failed)
test/language/statements/with/S12.10_A3.8_T4.js (previously Failed)
test/language/statements/with/S12.10_A3.11_T5.js (previously Failed)
test/language/statements/with/S12.10_A4_T2.js (previously Failed)
test/language/statements/with/let-identifier-with-newline.js (previously Failed)
test/language/statements/with/S12.10_A1.10_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.1_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.9_T3.js (previously Failed)
test/language/statements/with/S12.10_A1.10_T5.js (previously Failed)
test/language/statements/with/S12.10_A3.8_T1.js (previously Failed)
test/language/statements/with/S12.10_A3.3_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.7_T5.js (previously Failed)
test/language/statements/with/S12.10_A3.1_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.9_T1.js (previously Failed)
test/language/statements/with/S12.10_A5_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.11_T3.js (previously Failed)
test/language/statements/with/S12.10_A1.9_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.10_T5.js (previously Failed)
test/language/statements/with/S12.10_A3.8_T5.js (previously Failed)
test/language/statements/with/S12.10_A1.6_T2.js (previously Failed)
test/language/statements/with/S12.10_A4_T5.js (previously Failed)
test/language/statements/with/S12.10_A4_T3.js (previously Failed)
test/language/statements/with/12.10-0-11.js (previously Failed)
test/language/statements/with/S12.10_A3.11_T1.js (previously Failed)
test/language/statements/with/S12.10_A5_T5.js (previously Failed)
test/language/statements/with/S12.10_A3.12_T4.js (previously Failed)
test/language/statements/with/S12.10_A3.7_T4.js (previously Failed)
test/language/statements/with/S12.10_A3.7_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.2_T5.js (previously Failed)
test/language/statements/with/12.10-0-1.js (previously Failed)
test/language/statements/with/binding-not-blocked-by-unscopables-falsey-prop.js (previously Failed)
test/language/statements/with/let-block-with-newline.js (previously Failed)
test/language/statements/with/12.10-0-8.js (previously Failed)
test/language/statements/with/S12.10_A1.5_T5.js (previously Failed)
test/language/statements/with/S12.10_A1.11_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.1_T2.js (previously Failed)
test/language/statements/with/S12.10_A1.7_T2.js (previously Failed)
test/language/statements/with/binding-blocked-by-unscopables.js (previously Failed)
test/language/statements/with/12.10-0-10.js (previously Failed)
test/language/statements/with/S12.10_A1.12_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.7_T4.js (previously Failed)
test/language/statements/with/12.10.1-13-s.js (previously Failed)
test/language/statements/with/S12.10_A3.10_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.1_T1.js (previously Failed)
test/language/statements/with/scope-var-close.js (previously Failed)
test/language/statements/with/S12.10_A3.11_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.7_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.11_T4.js (previously Failed)
test/language/statements/with/unscopables-not-referenced-for-undef.js (previously Failed)
test/language/statements/with/unscopables-prop-get-err.js (previously Failed)
test/language/statements/with/binding-not-blocked-by-unscopables-non-obj.js (previously Failed)
test/language/statements/with/S12.10_A3.6_T1.js (previously Failed)
test/language/statements/with/12.10-0-12.js (previously Failed)
test/language/statements/with/S12.10_A3.12_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.2_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.11_T1.js (previously Failed)
test/language/statements/with/12.10-0-3.js (previously Failed)
test/language/statements/with/S12.10_A1.3_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.9_T3.js (previously Failed)
test/language/statements/with/S12.10_A1.5_T4.js (previously Failed)
test/language/statements/with/S12.10_A1.5_T3.js (previously Failed)
test/language/statements/with/S12.10_A4_T6.js (previously Failed)
test/language/statements/with/S12.10_A1.5_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.8_T1.js (previously Failed)
test/language/statements/with/12.10-2-5.js (previously Failed)
test/language/statements/with/S12.10_A3.4_T3.js (previously Failed)
test/language/statements/with/S12.10_A1.12_T4.js (previously Failed)
test/language/statements/with/S12.10_A3.6_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.2_T4.js (previously Failed)
test/language/statements/with/S12.10_A3.4_T4.js (previously Failed)
test/language/statements/with/S12.10_A1.4_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.1_T2.js (previously Failed)
test/language/statements/with/S12.10_A3.5_T3.js (previously Failed)
test/language/statements/with/S12.10_A3.10_T4.js (previously Failed)
test/language/statements/with/12.10-2-4.js (previously Failed)
test/language/statements/with/S12.10_A3.9_T2.js (previously Failed)
test/language/statements/with/S12.10_A4_T1.js (previously Failed)
test/language/statements/with/S12.10_A3.12_T5.js (previously Failed)
test/language/statements/with/S12.10_A3.12_T1.js (previously Failed)
test/language/statements/with/S12.10_A1.12_T2.js (previously Failed)
test/language/statements/with/S12.10_A5_T6.js (previously Failed)
test/language/statements/with/S12.10_A1.4_T5.js (previously Failed)
test/language/statements/with/S12.10_A1.1_T3.js (previously Failed)
test/language/statements/with/12.10-2-1.js (previously Failed)
test/language/statements/function/S13.2.2_A19_T2.js (previously Failed)
test/language/statements/function/S13.2.2_A17_T2.js (previously Failed)
test/language/statements/function/S13.2.2_A18_T2.js (previously Failed)
test/language/statements/function/S13.2.2_A19_T4.js (previously Failed)
test/language/statements/function/S13.2.2_A19_T8.js (previously Failed)
test/language/statements/function/S13.2.2_A18_T1.js (previously Failed)
test/language/statements/function/S13.2.2_A19_T7.js (previously Failed)
test/language/statements/function/unscopables-with-in-nested-fn.js (previously Failed)
test/language/statements/function/S13.2.2_A19_T3.js (previously Failed)
test/language/statements/function/S13.2.2_A19_T1.js (previously Failed)
test/language/statements/function/S13.2.2_A19_T5.js (previously Failed)
test/language/statements/function/S13.2.2_A19_T6.js (previously Failed)
test/language/statements/generators/unscopables-with-in-nested-fn.js (previously Failed)
test/language/statements/async-function/unscopables-with-in-nested-fn.js (previously Failed)
test/language/statements/async-generator/unscopables-with-in-nested-fn.js (previously Failed)
test/language/identifier-resolution/S10.2.2_A1_T8.js (previously Failed)
test/language/identifier-resolution/S10.2.2_A1_T9.js (previously Failed)
test/language/identifier-resolution/S10.2.2_A1_T7.js (previously Failed)
test/language/identifier-resolution/S10.2.2_A1_T6.js (previously Failed)
test/language/identifier-resolution/S10.2.2_A1_T5.js (previously Failed)
test/language/comments/hashbang/use-strict.js (previously Failed)
test/language/eval-code/indirect/always-non-strict.js [strict mode] (previously Failed)
test/language/eval-code/indirect/global-env-rec-with.js (previously Failed)
test/language/eval-code/direct/global-env-rec-with.js (previously Failed)
test/language/expressions/postfix-decrement/operator-x-postfix-decrement-calls-putvalue-lhs-newvalue-.js (previously Failed)
test/language/expressions/postfix-increment/operator-x-postfix-increment-calls-putvalue-lhs-newvalue-.js (previously Failed)
test/language/expressions/call/eval-strictness-inherit-non-strict.js (previously Failed)
test/language/expressions/prefix-decrement/operator-prefix-decrement-x-calls-putvalue-lhs-newvalue-.js (previously Failed)
test/language/expressions/async-arrow-function/unscopables-with-in-nested-fn.js (previously Failed)
test/language/expressions/delete/11.4.1-4.a-6.js (previously Failed)
test/language/expressions/delete/11.4.1-4.a-5.js (previously Failed)
test/language/expressions/assignment/assignment-operator-calls-putvalue-lref--rval-.js (previously Failed)
test/language/expressions/prefix-increment/operator-prefix-increment-x-calls-putvalue-lhs-newvalue-.js (previously Failed)
test/language/expressions/function/unscopables-with-in-nested-fn.js (previously Failed)
test/language/expressions/arrow-function/unscopables-with-in-nested-fn.js (previously Failed)
test/language/expressions/arrow-function/arrow/capturing-closure-variables-2.js (previously Failed)
test/language/expressions/yield/from-with.js (previously Failed)
test/language/expressions/object/prop-def-id-eval-error-2.js (previously Failed)
test/language/expressions/object/prop-def-id-eval-error.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--2.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v-.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--18.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--10.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--12.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--16.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--4.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--6.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--8.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--20.js (previously Failed)
test/language/expressions/compound-assignment/compound-assignment-operator-calls-putvalue-lref--v--14.js (previously Failed)
test/language/expressions/generators/unscopables-with-in-nested-fn.js (previously Failed)
test/language/expressions/async-function/nameless-unscopables-with-in-nested-fn.js (previously Failed)
test/language/expressions/async-function/named-unscopables-with-in-nested-fn.js (previously Failed)
test/language/expressions/async-generator/named-unscopables-with-in-nested-fn.js (previously Failed)
test/language/expressions/async-generator/unscopables-with-in-nested-fn.js (previously Failed)
test/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js (previously Failed)
test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/infinity-with-detached-buffer.js (previously Failed)
test/built-ins/Proxy/has/trap-is-not-callable-using-with.js (previously Failed)
test/built-ins/Proxy/has/null-handler-using-with.js (previously Failed)
test/built-ins/Proxy/has/return-true-target-prop-exists-using-with.js (previously Failed)
test/built-ins/Proxy/has/return-is-abrupt-with.js (previously Failed)
test/built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js (previously Failed)
test/built-ins/Proxy/has/call-with.js (previously Failed)
test/built-ins/Proxy/has/return-false-target-prop-exists-using-with.js (previously Failed)
test/built-ins/Proxy/has/trap-is-undefined-using-with.js (previously Failed)
test/built-ins/Proxy/has/return-false-target-not-extensible-using-with.js (previously Failed)

@codecov
Copy link

codecov bot commented Mar 19, 2023

Codecov Report

Merging #2692 (25301e2) into main (7e6d3c9) will increase coverage by 1.00%.
The diff coverage is 44.95%.

@@            Coverage Diff             @@
##             main    #2692      +/-   ##
==========================================
+ Coverage   49.36%   50.36%   +1.00%     
==========================================
  Files         397      392       -5     
  Lines       39568    38897     -671     
==========================================
+ Hits        19533    19591      +58     
+ Misses      20035    19306     -729     
Impacted Files Coverage Δ
boa_ast/src/statement/mod.rs 57.14% <0.00%> (-2.32%) ⬇️
boa_ast/src/statement/with.rs 0.00% <0.00%> (ø)
boa_ast/src/visitor.rs 11.34% <ø> (-0.52%) ⬇️
boa_engine/src/builtins/eval/mod.rs 6.48% <ø> (ø)
boa_engine/src/bytecompiler/statement/with.rs 0.00% <0.00%> (ø)
boa_engine/src/vm/code_block.rs 29.56% <ø> (ø)
boa_engine/src/vm/flowgraph/mod.rs 0.00% <0.00%> (ø)
boa_engine/src/vm/opcode/mod.rs 45.45% <ø> (ø)
boa_engine/src/vm/opcode/push/environment.rs 40.74% <0.00%> (-11.65%) ⬇️
boa_engine/src/environments/runtime.rs 47.86% <46.53%> (-5.14%) ⬇️
... and 8 more

... and 14 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.

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.

Looks good! Great work @raskad

Just some small improvement suggestions

boa_engine/src/environments/runtime.rs Outdated Show resolved Hide resolved
boa_engine/src/environments/runtime.rs Outdated Show resolved Hide resolved
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.

Looks good to me! :)

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Looks perfect!

@jedel1043
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Mar 20, 2023
This Pull Request changes the following:

- Implement `with` statement parsing, ast node, compilation and excution.
- Implement object environments that are used in the `with` statement excution.

The implementation of object environments can probably be optimized further by using more compile-time information about when object environments can exist. Maybe there could also be a separate environment stack for object environments to reduce the filtering and iteration that is needed with the current implementation.
This does not fix all tests in the `test/language/statements/with` suite yet. But for most failing tests that I have looked at we are missing other features / have bugs elsewhere.

As a note for the review:
The functions in the `impl Context` block in `boa_engine/src/environments/runtime.rs` are mostly copied / moved from the existing functions. The only change there should be the addition of the object environment logic. They had to be moved to `Context` because of borrow semantics.
@bors
Copy link

bors bot commented Mar 20, 2023

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Implement with and object environments [Merged by Bors] - Implement with and object environments Mar 20, 2023
@bors bors bot closed this Mar 20, 2023
@bors bors bot deleted the with branch March 20, 2023 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Issue surrounding the abstract syntax tree execution Issues or PRs related to code execution parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants