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 double property access on assignment ops #2551

Closed
wants to merge 1 commit into from

Conversation

raskad
Copy link
Member

@raskad raskad commented Jan 20, 2023

Currently the compilation of assignment operators leads to a double object property access, both on the get and set access.

While this refactor adds special access handling instead of using the existing access_set and access_get functions, it fixes the double access and should also make the resulting code more efficient.

@raskad raskad added bug Something isn't working vm Issues and PRs related to the Boa Virtual Machine. labels Jan 20, 2023
@raskad raskad added this to the v0.17.0 milestone Jan 20, 2023
@github-actions
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 94,205 94,205 0
Passed 70,624 70,652 +28
Ignored 18,622 18,622 0
Failed 4,959 4,931 -28
Panics 0 0 0
Conformance 74.97% 75.00% +0.03%
Fixed tests (28):
test/language/expressions/logical-assignment/lgcl-or-assignment-operator-lhs-before-rhs.js [strict mode] (previously Failed)
test/language/expressions/logical-assignment/lgcl-or-assignment-operator-lhs-before-rhs.js (previously Failed)
test/language/expressions/logical-assignment/lgcl-and-assignment-operator-lhs-before-rhs.js [strict mode] (previously Failed)
test/language/expressions/logical-assignment/lgcl-and-assignment-operator-lhs-before-rhs.js (previously Failed)
test/language/expressions/logical-assignment/lgcl-nullish-assignment-operator-lhs-before-rhs.js [strict mode] (previously Failed)
test/language/expressions/logical-assignment/lgcl-nullish-assignment-operator-lhs-before-rhs.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.6_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.6_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.7_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.7_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.8_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.8_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.4_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.4_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.2_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.2_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.11_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.11_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.5_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.5_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.3_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.3_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.9_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.9_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.1_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.1_T4.js (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.10_T4.js [strict mode] (previously Failed)
test/language/expressions/compound-assignment/S11.13.2_A7.10_T4.js (previously Failed)

@codecov
Copy link

codecov bot commented Jan 20, 2023

Codecov Report

Merging #2551 (f178492) into main (f19467a) will decrease coverage by 0.06%.
The diff coverage is 36.44%.

@@            Coverage Diff             @@
##             main    #2551      +/-   ##
==========================================
- Coverage   49.99%   49.93%   -0.06%     
==========================================
  Files         379      379              
  Lines       37642    37721      +79     
==========================================
+ Hits        18819    18836      +17     
- Misses      18823    18885      +62     
Impacted Files Coverage Δ
boa_engine/src/bytecompiler/expression/assign.rs 39.09% <36.44%> (-25.72%) ⬇️
boa_engine/src/vm/mod.rs 48.75% <0.00%> (-1.00%) ⬇️
boa_gc/src/cell.rs 58.75% <0.00%> (-0.57%) ⬇️
...arser/expression/primary/object_initializer/mod.rs 65.58% <0.00%> (+0.23%) ⬆️
boa_engine/src/environments/runtime.rs 49.46% <0.00%> (+0.70%) ⬆️

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

@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.

A bit unfortunate that we can't share logic between simple accesses and assignments, but makes sense since they're special in the first place.

On another note, maybe we should split this function into compile_simple_assign and compile_assign_op, since they don't share any logic at all.

@raskad
Copy link
Member Author

raskad commented Jan 23, 2023

On another note, maybe we should split this function into compile_simple_assign and compile_assign_op, since they don't share any logic at all.

I thought this too. In the same change I would also refactor the AST to make it a bit typesafer. I'd like to push that in a follow up PR to keep the diff reasonable.

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.

Sounds good!

Copy link
Member

@nekevss nekevss 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 😄

@jedel1043
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jan 25, 2023
Currently the compilation of assignment operators leads to a double object property access, both on the get and set access.

While this refactor adds special access handling instead of using the existing `access_set` and `access_get` functions, it fixes the double access and should also make the resulting code more efficient.
@bors
Copy link

bors bot commented Jan 25, 2023

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Fix double property access on assignment ops [Merged by Bors] - Fix double property access on assignment ops Jan 25, 2023
@bors bors bot closed this Jan 25, 2023
@bors bors bot deleted the fix-assignment-ops branch January 25, 2023 15:23
bors bot pushed a commit that referenced this pull request Mar 25, 2023
Currently update expressions get values multiple times. This can lead to multiple executions of object property getters.

This is very similar to #2551. Unfortunateley it seems like we have to sacrifice some code duplication for correctness in these cases. But that is probably for the best, as we can generate more optimized bytecode for each of these `get/set` cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vm Issues and PRs related to the Boa Virtual Machine.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants