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

Enable using context-specific typewrapper instances. #3194

Merged
merged 2 commits into from
Dec 7, 2024

Conversation

danlapid
Copy link
Collaborator

@danlapid danlapid commented Nov 29, 2024

This PR has two commits:

  1. Revert the previous commit to disable memoization as this is no longer required with the new approach
  2. A commit to enable using context-specific typewrapper instances

Sometimes we'd like to have multiple contexts with different
typewrapper that were instantiated with different configuration objects.
To do that this commit extends the Isolate class, wrapper is now a
vector of wrappers, the 0 indexed wrapper is the default wrapper but
additional wrappers can be created with instantiateWrapper which
receives a new Configuration object. To associate a context with its
wrapper we use context->SetAlignedPointerInEmbedderData(3, wrapper).

@danlapid danlapid changed the title Refactor limitEnforcer from api to Isolate. [DRAFT] new wrapper for context Nov 29, 2024
@danlapid danlapid force-pushed the dlapid/new_wrapper_for_context branch from 0ef2816 to 49f1368 Compare November 29, 2024 23:24
src/workerd/jsg/setup.h Outdated Show resolved Hide resolved
src/workerd/jsg/setup.h Outdated Show resolved Hide resolved
@danlapid danlapid force-pushed the dlapid/new_wrapper_for_context branch 6 times, most recently from b9369dc to 9490a98 Compare November 30, 2024 13:30
@danlapid danlapid changed the title [DRAFT] new wrapper for context Enable using context-specific type wrapper instances. Nov 30, 2024
@danlapid danlapid changed the title Enable using context-specific type wrapper instances. Enable using context-specific typewrapper instances. Nov 30, 2024
src/workerd/jsg/setup.h Outdated Show resolved Hide resolved
@danlapid danlapid force-pushed the dlapid/new_wrapper_for_context branch 2 times, most recently from bced90f to abb88ce Compare November 30, 2024 14:02
@danlapid danlapid requested review from jasnell and kentonv November 30, 2024 14:37
@danlapid danlapid marked this pull request as ready for review November 30, 2024 14:37
@danlapid danlapid requested review from a team as code owners November 30, 2024 14:37
@danlapid
Copy link
Collaborator Author

Hey @jasnell @kentonv
This is an alternate implementation following Kenton's remarks on the previous PR.
I think this should address Kenton's concerns.

I did my best to ensure the case where we never needed a second typewrapper doesn't see any performance regressions.

The types check GitHub check is failing just because I need to rebase, I'll do that after the review since there's no significant changes to the types in this PR.

src/workerd/jsg/setup.h Show resolved Hide resolved
src/workerd/jsg/setup.h Outdated Show resolved Hide resolved
src/workerd/jsg/setup.h Outdated Show resolved Hide resolved
src/workerd/jsg/setup.h Outdated Show resolved Hide resolved
@kentonv
Copy link
Member

kentonv commented Dec 2, 2024

Approach seems reasonable, just some nitpick comments.

@danlapid danlapid force-pushed the dlapid/new_wrapper_for_context branch 6 times, most recently from 3cf57d4 to a597983 Compare December 6, 2024 17:57
@danlapid danlapid force-pushed the dlapid/new_wrapper_for_context branch from a597983 to afa5410 Compare December 6, 2024 18:33
@danlapid
Copy link
Collaborator Author

danlapid commented Dec 6, 2024

Last push was just a rebase.
Fixups after the rebase are in the fixup commit: afa5410

src/workerd/jsg/setup.h Outdated Show resolved Hide resolved
src/workerd/jsg/setup.h Outdated Show resolved Hide resolved
Copy link
Member

@kentonv kentonv left a comment

Choose a reason for hiding this comment

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

Just some minor style nitpicks.

…le_memoize"

This reverts commit 0b6df82, reversing
changes made to a9cf631.
@danlapid danlapid force-pushed the dlapid/new_wrapper_for_context branch from c16e90f to 9c25460 Compare December 7, 2024 00:36
@danlapid
Copy link
Collaborator Author

danlapid commented Dec 7, 2024

Added a fixup with pr fixups in 9c25460 (#3194) then rebased

Sometimes we'd like to have multiple contexts with different
typewrapper that were instantiated with different configuration objects.
To do that this commit extends the Isolate class, wrapper is now a
vector of wrappers, the 0 indexed wrapper is the default wrapper but
additional wrappers can be created with `instantiateWrapper` which
receives a new Configuration object. To associate a context with its
wrapper we use `context->SetAlignedPointerInEmbedderData(3, wrapper)`.
@danlapid danlapid force-pushed the dlapid/new_wrapper_for_context branch from 9c25460 to 32191ee Compare December 7, 2024 00:43
@danlapid
Copy link
Collaborator Author

danlapid commented Dec 7, 2024

Last push merged fixups

@danlapid danlapid merged commit 52168e3 into main Dec 7, 2024
15 checks passed
@danlapid danlapid deleted the dlapid/new_wrapper_for_context branch December 7, 2024 11:44
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.

2 participants