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 the WeakRef builtin #2438

Closed
wants to merge 3 commits into from
Closed

Conversation

jedel1043
Copy link
Member

52/60 tests passing. The remaining tests are either features not implemented (FinalizationRegistry) or features still in development (symbols-as-weakmap-keys).

@jedel1043 jedel1043 added enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics labels Nov 14, 2022
@jedel1043 jedel1043 added this to the v0.17.0 milestone Nov 14, 2022
@github-actions
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 93,811 93,811 0
Passed 69,562 69,620 +58
Ignored 18,414 18,452 +38
Failed 5,835 5,739 -96
Panics 0 0 0
Conformance 74.15% 74.21% +0.06%
Fixed tests (58):
test/built-ins/WeakRef/name.js [strict mode] (previously Failed)
test/built-ins/WeakRef/name.js (previously Failed)
test/built-ins/WeakRef/returns-new-object-from-constructor-with-object-target.js [strict mode] (previously Failed)
test/built-ins/WeakRef/returns-new-object-from-constructor-with-object-target.js (previously Failed)
test/built-ins/WeakRef/prop-desc.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prop-desc.js (previously Failed)
test/built-ins/WeakRef/prototype-from-newtarget.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype-from-newtarget.js (previously Failed)
test/built-ins/WeakRef/prototype-from-newtarget-abrupt.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype-from-newtarget-abrupt.js (previously Failed)
test/built-ins/WeakRef/proto-from-ctor-realm.js [strict mode] (previously Failed)
test/built-ins/WeakRef/proto-from-ctor-realm.js (previously Failed)
test/built-ins/WeakRef/newtarget-prototype-is-not-object.js [strict mode] (previously Failed)
test/built-ins/WeakRef/newtarget-prototype-is-not-object.js (previously Failed)
test/built-ins/WeakRef/throws-when-target-cannot-be-held-weakly.js [strict mode] (previously Failed)
test/built-ins/WeakRef/throws-when-target-cannot-be-held-weakly.js (previously Failed)
test/built-ins/WeakRef/length.js [strict mode] (previously Failed)
test/built-ins/WeakRef/length.js (previously Failed)
test/built-ins/WeakRef/undefined-newtarget-throws.js [strict mode] (previously Failed)
test/built-ins/WeakRef/undefined-newtarget-throws.js (previously Failed)
test/built-ins/WeakRef/is-a-constructor.js [strict mode] (previously Failed)
test/built-ins/WeakRef/is-a-constructor.js (previously Failed)
test/built-ins/WeakRef/proto.js [strict mode] (previously Failed)
test/built-ins/WeakRef/proto.js (previously Failed)
test/built-ins/WeakRef/constructor.js [strict mode] (previously Failed)
test/built-ins/WeakRef/constructor.js (previously Failed)
test/built-ins/WeakRef/prototype-from-newtarget-custom.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype-from-newtarget-custom.js (previously Failed)
test/built-ins/WeakRef/instance-extensible.js [strict mode] (previously Failed)
test/built-ins/WeakRef/instance-extensible.js (previously Failed)
test/built-ins/WeakRef/prototype/prop-desc.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/prop-desc.js (previously Failed)
test/built-ins/WeakRef/prototype/Symbol.toStringTag.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/Symbol.toStringTag.js (previously Failed)
test/built-ins/WeakRef/prototype/proto.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/proto.js (previously Failed)
test/built-ins/WeakRef/prototype/constructor.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/constructor.js (previously Failed)
test/built-ins/WeakRef/prototype/deref/name.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/deref/name.js (previously Failed)
test/built-ins/WeakRef/prototype/deref/prop-desc.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/deref/prop-desc.js (previously Failed)
test/built-ins/WeakRef/prototype/deref/this-not-object-throws.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/deref/this-not-object-throws.js (previously Failed)
test/built-ins/WeakRef/prototype/deref/not-a-constructor.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/deref/not-a-constructor.js (previously Failed)
test/built-ins/WeakRef/prototype/deref/length.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/deref/length.js (previously Failed)
test/built-ins/WeakRef/prototype/deref/return-object-target.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/deref/return-object-target.js (previously Failed)
test/built-ins/WeakRef/prototype/deref/custom-this.js [strict mode] (previously Failed)
test/built-ins/WeakRef/prototype/deref/custom-this.js (previously Failed)
test/built-ins/Object/seal/seal-weakref.js [strict mode] (previously Failed)
test/built-ins/Object/seal/seal-weakref.js (previously Failed)
test/language/statements/class/subclass-builtins/subclass-WeakRef.js [strict mode] (previously Failed)
test/language/statements/class/subclass-builtins/subclass-WeakRef.js (previously Failed)
test/language/expressions/class/subclass-builtins/subclass-WeakRef.js [strict mode] (previously Failed)
test/language/expressions/class/subclass-builtins/subclass-WeakRef.js (previously Failed)

@codecov
Copy link

codecov bot commented Nov 14, 2022

Codecov Report

Merging #2438 (379d7e4) into main (98e6dd3) will increase coverage by 0.13%.
The diff coverage is 76.00%.

@@            Coverage Diff             @@
##             main    #2438      +/-   ##
==========================================
+ Coverage   52.41%   52.54%   +0.13%     
==========================================
  Files         329      329              
  Lines       34945    34942       -3     
==========================================
+ Hits        18315    18360      +45     
+ Misses      16630    16582      -48     
Impacted Files Coverage Δ
boa_engine/src/builtins/array/mod.rs 75.98% <0.00%> (+0.14%) ⬆️
boa_engine/src/builtins/object/mod.rs 60.22% <0.00%> (ø)
boa_engine/src/vm/code_block.rs 33.42% <0.00%> (ø)
boa_engine/src/object/mod.rs 45.98% <72.72%> (+0.32%) ⬆️
boa_engine/src/builtins/weak/weak_ref.rs 73.80% <73.80%> (ø)
boa_engine/src/builtins/mod.rs 98.57% <100.00%> (+0.02%) ⬆️
boa_engine/src/context/intrinsics.rs 98.76% <100.00%> (+0.02%) ⬆️
boa_engine/src/context/mod.rs 65.32% <100.00%> (+0.89%) ⬆️
boa_engine/src/object/jsobject.rs 66.08% <100.00%> (+0.44%) ⬆️
boa_engine/src/value/mod.rs 65.07% <100.00%> (ø)
... and 10 more

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

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

Looks good to me.

I think if we use a forced gc run, we could create a test to make sure that weakrefs are correctly gc'd after a microtask execution, right?

boa_engine/src/builtins/weak/weak_ref.rs Outdated Show resolved Hide resolved
boa_engine/src/builtins/weak/weak_ref.rs Outdated Show resolved Hide resolved
@jedel1043
Copy link
Member Author

jedel1043 commented Nov 14, 2022

Looks good to me.

I think if we use a forced gc run, we could create a test to make sure that weakrefs are correctly gc'd after a microtask execution, right?

Yep. I think the test262 only tests that objects aren't gc'd between derefs on the same script. To test the other half of the API, we'll need to:

  • Create a new Context.
  • Run a script that uses the API.
  • Call force_collect.
  • Check that the WeakRef stored in the previous run returns undefined on deref.

I'll add some tests for it.

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 great to me! :)

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.

Thank you! Just a small question about one piece of code :)

boa_engine/src/builtins/weak/weak_ref.rs Show resolved Hide resolved
@Razican
Copy link
Member

Razican commented Nov 15, 2022

Bors r+

bors bot pushed a commit that referenced this pull request Nov 15, 2022
52/60 tests passing. The remaining tests are either features not implemented ([FinalizationRegistry](https://tc39.es/ecma262/multipage/managing-memory.html#sec-finalization-registry-objects)) or features still in development ([symbols-as-weakmap-keys](https://github.com/tc39/proposal-symbols-as-weakmap-keys)).
@bors
Copy link

bors bot commented Nov 15, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Implement the WeakRef builtin [Merged by Bors] - Implement the WeakRef builtin Nov 15, 2022
@bors bors bot closed this Nov 15, 2022
@bors bors bot deleted the weak-ref branch November 15, 2022 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants