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 cross-realm construction bugs #2786

Closed
wants to merge 8 commits into from

Conversation

jedel1043
Copy link
Member

@jedel1043 jedel1043 commented Apr 5, 2023

This Pull Request fixes test assert-throws-same-realm.js.

It changes the following:

  • Handles global variables through the global object, instead of the context.
  • Adds an active_function field to the vm, which is used as the NewTarget when certain builtins aren't called with new.
  • Adds a realm_intrinsics field to Function.

@jedel1043
Copy link
Member Author

Drafting because I want to see the impact this change makes in the test suite first.

@github-actions
Copy link

github-actions bot commented Apr 5, 2023

Test262 conformance changes

Test result main count PR count difference
Total 94,343 94,343 0
Passed 71,170 71,163 -7
Ignored 17,386 17,386 0
Failed 5,787 5,794 +7
Panics 0 0 0
Conformance 75.44% 75.43% -0.01%
Fixed tests (13):
test/harness/assert-throws-same-realm.js [strict mode] (previously Failed)
test/harness/assert-throws-same-realm.js (previously Failed)
test/harness/asyncHelpers-throwsAsync-same-realm.js [strict mode] (previously Failed)
test/harness/asyncHelpers-throwsAsync-same-realm.js (previously Failed)
test/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js [strict mode] (previously Failed)
test/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js (previously Failed)
test/built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js [strict mode] (previously Failed)
test/built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js (previously Failed)
test/built-ins/Symbol/keyFor/cross-realm.js [strict mode] (previously Failed)
test/built-ins/Symbol/keyFor/cross-realm.js (previously Failed)
test/built-ins/Symbol/for/cross-realm.js [strict mode] (previously Failed)
test/built-ins/Symbol/for/cross-realm.js (previously Failed)
test/built-ins/String/prototype/split/checking-by-using-eval.js [strict mode] (previously Failed)
Broken tests (20):
test/built-ins/Function/proto-from-ctor-realm-prototype.js [strict mode] (previously Passed)
test/built-ins/Function/proto-from-ctor-realm-prototype.js (previously Passed)
test/built-ins/Function/prototype/apply/this-not-callable-realm.js [strict mode] (previously Passed)
test/built-ins/Function/prototype/apply/this-not-callable-realm.js (previously Passed)
test/built-ins/Function/prototype/apply/argarray-not-object-realm.js [strict mode] (previously Passed)
test/built-ins/Function/prototype/apply/argarray-not-object-realm.js (previously Passed)
test/built-ins/Function/internals/Call/class-ctor-realm.js [strict mode] (previously Passed)
test/built-ins/Function/internals/Call/class-ctor-realm.js (previously Passed)
test/built-ins/AsyncGeneratorFunction/proto-from-ctor-realm-prototype.js [strict mode] (previously Passed)
test/built-ins/AsyncGeneratorFunction/proto-from-ctor-realm-prototype.js (previously Passed)
test/built-ins/GeneratorFunction/proto-from-ctor-realm-prototype.js [strict mode] (previously Passed)
test/built-ins/GeneratorFunction/proto-from-ctor-realm-prototype.js (previously Passed)
test/built-ins/RegExp/prototype/Symbol.split/splitter-proto-from-ctor-realm.js [strict mode] (previously Passed)
test/built-ins/RegExp/prototype/Symbol.split/splitter-proto-from-ctor-realm.js (previously Passed)
test/built-ins/String/prototype/valueOf/non-generic-realm.js [strict mode] (previously Passed)
test/built-ins/String/prototype/valueOf/non-generic-realm.js (previously Passed)
test/built-ins/String/prototype/toString/non-generic-realm.js [strict mode] (previously Passed)
test/built-ins/String/prototype/toString/non-generic-realm.js (previously Passed)
test/language/types/reference/get-value-prop-base-primitive-realm.js [strict mode] (previously Passed)
test/language/types/reference/get-value-prop-base-primitive-realm.js (previously Passed)

@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #2786 (8e302f6) into main (928d67b) will decrease coverage by 0.09%.
The diff coverage is 39.45%.

@@            Coverage Diff             @@
##             main    #2786      +/-   ##
==========================================
- Coverage   50.66%   50.57%   -0.09%     
==========================================
  Files         415      415              
  Lines       41063    41207     +144     
==========================================
+ Hits        20803    20841      +38     
- Misses      20260    20366     +106     
Impacted Files Coverage Δ
boa_cli/src/debug/function.rs 0.00% <0.00%> (ø)
boa_cli/src/debug/mod.rs 0.00% <0.00%> (ø)
boa_cli/src/debug/realm.rs 0.00% <0.00%> (ø)
boa_engine/src/builtins/async_function/mod.rs 36.36% <0.00%> (-25.18%) ⬇️
...ngine/src/builtins/async_generator_function/mod.rs 44.00% <0.00%> (-24.75%) ⬇️
boa_engine/src/builtins/error/aggregate.rs 20.83% <0.00%> (-7.74%) ⬇️
boa_engine/src/builtins/generator/mod.rs 8.67% <0.00%> (-0.65%) ⬇️
boa_engine/src/builtins/generator_function/mod.rs 44.00% <0.00%> (-24.75%) ⬇️
boa_engine/src/builtins/intl/collator/mod.rs 5.39% <0.00%> (ø)
boa_engine/src/builtins/intl/date_time_format.rs 2.83% <0.00%> (-0.40%) ⬇️
... and 52 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jedel1043
Copy link
Member Author

Ok, this PR fixes half of the problem. The other half is that functions should also store the global_object and the global_this from the current realm, or the full realm in short. Otherwise, the function calls try to access properties from the context realm instead of their stored realm, which causes the regressions. To fix this we need to make realm shareable between functions.

There is a problem with this though: the realm is storing the full environment stack instead of only the global bindings. This means the vm needs to access the realm to access any binding at execution, which would be a disaster perf-wise if we wrapped the DeclarativeEnvironmentStack on a GcRefCell to make it shareable between functions.

Considering this, it'll be better to merge this as it is to reduce the size of the next PR, which will solve the second part of the problem.

@jedel1043 jedel1043 marked this pull request as ready for review April 6, 2023 06:45
@jedel1043 jedel1043 added the Internal Category for changelog label Apr 6, 2023
@jedel1043 jedel1043 added this to the v0.17.0 milestone Apr 6, 2023
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! Just some small suggestions :)

Also If the added TODOs are not going to be addressed in this PR, maybe we should create issues about them?

boa_cli/src/debug/realm.rs Outdated Show resolved Hide resolved
boa_cli/src/debug/mod.rs Show resolved Hide resolved
@jedel1043
Copy link
Member Author

Also If the added TODOs are not going to be addressed in this PR, maybe we should create issues about them?

Ah, I'll probably solve those on the follow-up PR. I just added those to be easily searchable when I start working on it.

@jedel1043 jedel1043 requested a review from HalidOdat April 7, 2023 17:06
@Razican
Copy link
Member

Razican commented Apr 8, 2023

I'll try to use the new realm module in $boa you implement new realm creation in boa_tester when I return from vacation

I went through most filled and it looked good. If I have the time I'll finish the review today :)

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

Great work! LGTM

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! :)

@jedel1043
Copy link
Member Author

bors r+

bors bot pushed a commit that referenced this pull request Apr 10, 2023
This Pull Request fixes test [`assert-throws-same-realm.js`](https://github.com/tc39/test262/blob/eb44f67274bf3896fbec8814f81dd2ae02236686/test/harness/assert-throws-same-realm.js).

It changes the following:

- Handles global variables through the global object, instead of the `context`.
- Adds an `active_function` field to the vm, which is used as the `NewTarget` when certain builtins aren't called with `new`.
- Adds a `realm_intrinsics` field to `Function`.
@bors
Copy link

bors bot commented Apr 10, 2023

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Fix cross-realm construction bugs [Merged by Bors] - Fix cross-realm construction bugs Apr 10, 2023
@bors bors bot closed this Apr 10, 2023
@bors bors bot deleted the cross-realm-error branch April 10, 2023 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Category for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants