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

refactor: stateShape causes accessor sharing #7444

Merged
merged 2 commits into from
Apr 18, 2023
Merged

Conversation

erights
Copy link
Member

@erights erights commented Apr 18, 2023

Revive #7286

Staged on #7443

When a kind is provided with a stateShape, we know exactly what the names are for all of the state fields across all instances. For that case, it is wasteful to create accessor properties per instance. So instead, when there is a stateShape, this PR will instead install similar accessors on a shared statePrototype object. Each state object is then a frozen empty object that inherits from that statePrototype. As with a shared prototype for methods, to make this work, we also introduce a separate state to baseRef weakmap, so the accessor can get the correct baseRef from its this, which is the empty state instance itself.

See also
#7289
#6693
#7138

To get the benefit of this PR, more exoClasses will need stateShape metaData. See #7445

Please review while hiding whitespace differences.

@erights erights self-assigned this Apr 18, 2023
@erights erights force-pushed the markm-state-proto-2 branch from 676b201 to ea21995 Compare April 18, 2023 04:42
@erights erights force-pushed the markm-vom-readability-only branch from c583f3f to c3a84c5 Compare April 18, 2023 04:46
@erights erights force-pushed the markm-state-proto-2 branch from ea21995 to 2c1ae07 Compare April 18, 2023 04:48
@erights erights changed the base branch from markm-vom-readability-only to master April 18, 2023 04:49
@erights erights changed the base branch from master to markm-vom-readability-only April 18, 2023 04:49
@erights erights force-pushed the markm-state-proto-2 branch from 2c1ae07 to bc3075d Compare April 18, 2023 04:55
@erights erights requested review from warner and FUDCo April 18, 2023 05:20
@Agoric Agoric deleted a comment from mergify bot Apr 18, 2023
@erights erights changed the title WIP refactor: stateShape causes accessor sharing refactor: stateShape causes accessor sharing Apr 18, 2023
@erights erights marked this pull request as ready for review April 18, 2023 05:20
@erights erights requested a review from dckc April 18, 2023 06:24
Base automatically changed from markm-vom-readability-only to master April 18, 2023 08:17
@erights erights force-pushed the markm-state-proto-2 branch from 4a086ce to 693d00b Compare April 18, 2023 16:37
@erights erights changed the base branch from master to markm-more-stateShapes April 18, 2023 16:38
Base automatically changed from markm-more-stateShapes to master April 18, 2023 17:17
@erights erights force-pushed the markm-state-proto-2 branch 2 times, most recently from 7ee043d to b514d4b Compare April 18, 2023 19:19
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

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

It's like deja vu all over again.

@erights erights added the automerge:rebase Automatically rebase updates, then merge label Apr 18, 2023
@erights erights force-pushed the markm-state-proto-2 branch from b514d4b to f264d43 Compare April 18, 2023 20:38
@mergify mergify bot merged commit 52d161b into master Apr 18, 2023
@mergify mergify bot deleted the markm-state-proto-2 branch April 18, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants