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

[[HostDefined]] Improvements #3460

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

johnyob
Copy link
Contributor

@johnyob johnyob commented Nov 8, 2023

Context

Related PRs: #3370

Currently HostDefined doesn't permit you to mutably borrow two objects from the [[HostDefined]] field since the FxHashMap is wrapped under a GcRefCell.

Description

This PR implements a get_mut_many (from hashbrown's HashMap) method to permit accessing several NativeObjects using a NativeTuple.

Additionally, this commit takes the opportunity to provide automatic downcasting on the insert and remove methods for [[HostDefined]].

@johnyob johnyob mentioned this pull request Nov 8, 2023
@johnyob johnyob force-pushed the ajob410@host-defined-refactor-2 branch from d5f18f8 to fe26dbd Compare November 8, 2023 11:26
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 really great! Just have a comment about the lint and some suggestions.

boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_engine/src/host_defined.rs Outdated Show resolved Hide resolved
boa_engine/src/host_defined.rs Outdated Show resolved Hide resolved
boa_engine/src/host_defined.rs Outdated Show resolved Hide resolved
@johnyob johnyob force-pushed the ajob410@host-defined-refactor-2 branch from fe26dbd to ab6a9f1 Compare November 9, 2023 14:41
Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Attention: 72 lines in your changes are missing coverage. Please review.

Comparison is base (baa4f98) 44.65% compared to head (022ee6a) 44.62%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3460      +/-   ##
==========================================
- Coverage   44.65%   44.62%   -0.04%     
==========================================
  Files         487      487              
  Lines       50503    50541      +38     
==========================================
  Hits        22554    22554              
- Misses      27949    27987      +38     
Files Coverage Δ
boa_gc/src/trace.rs 91.66% <ø> (ø)
boa_engine/src/realm.rs 50.00% <0.00%> (-1.67%) ⬇️
boa_examples/src/bin/host_defined.rs 0.00% <0.00%> (ø)
boa_engine/src/host_defined.rs 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@johnyob johnyob force-pushed the ajob410@host-defined-refactor-2 branch from ab6a9f1 to 79279ad Compare November 9, 2023 14:44
@johnyob johnyob requested a review from jedel1043 November 9, 2023 14:45
Currently `[[HostDefined]]` doesn't permit you to mutably borrow two objects from the `[[HostDefined]]` field since the `FxHashMap` is wrapped under a `GcRefCell`.

This commit implements a `get_mut_many` (from `hashbrown`'s `HashMap`) method to permit accessing several `NativeObject`s using a `NativeTuple`.

Additionally, this commit takes the opportunity to provide automatic downcasting on the `insert` and `remove` methods for `[[HostDefined]]`.
@johnyob johnyob force-pushed the ajob410@host-defined-refactor-2 branch from 79279ad to 022ee6a Compare November 10, 2023 10:05
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.

Excellent work!

@jedel1043 jedel1043 requested a review from a team November 10, 2023 10:12
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 addition! Looks good to me! :)

@HalidOdat HalidOdat added this pull request to the merge queue Nov 10, 2023
Merged via the queue into boa-dev:main with commit 89fd3be Nov 10, 2023
14 checks passed
ahaoboy pushed a commit to ahaoboy/boa that referenced this pull request Nov 15, 2023
* Refactor the `[[HostDefined]]` implementation.

Currently `[[HostDefined]]` doesn't permit you to mutably borrow two objects from the `[[HostDefined]]` field since the `FxHashMap` is wrapped under a `GcRefCell`.

This commit implements a `get_mut_many` (from `hashbrown`'s `HashMap`) method to permit accessing several `NativeObject`s using a `NativeTuple`.

Additionally, this commit takes the opportunity to provide automatic downcasting on the `insert` and `remove` methods for `[[HostDefined]]`.

* Update `[[HostDefined]]` example.
ahaoboy pushed a commit to ahaoboy/boa that referenced this pull request Nov 15, 2023
* Refactor the `[[HostDefined]]` implementation.

Currently `[[HostDefined]]` doesn't permit you to mutably borrow two objects from the `[[HostDefined]]` field since the `FxHashMap` is wrapped under a `GcRefCell`.

This commit implements a `get_mut_many` (from `hashbrown`'s `HashMap`) method to permit accessing several `NativeObject`s using a `NativeTuple`.

Additionally, this commit takes the opportunity to provide automatic downcasting on the `insert` and `remove` methods for `[[HostDefined]]`.

* Update `[[HostDefined]]` example.
sam-finch-tezos pushed a commit to trilitech/boa that referenced this pull request Nov 29, 2023
* Refactor the `[[HostDefined]]` implementation.

Currently `[[HostDefined]]` doesn't permit you to mutably borrow two objects from the `[[HostDefined]]` field since the `FxHashMap` is wrapped under a `GcRefCell`.

This commit implements a `get_mut_many` (from `hashbrown`'s `HashMap`) method to permit accessing several `NativeObject`s using a `NativeTuple`.

Additionally, this commit takes the opportunity to provide automatic downcasting on the `insert` and `remove` methods for `[[HostDefined]]`.

* Update `[[HostDefined]]` example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants