Skip to content

Pass a jsg::Lock to wrap and unwrap so we can get the isolate from it - #4244

Merged
erikcorry merged 9 commits into
mainfrom
erikcorry/wrap-unwrap-with-lock
Jun 10, 2025
Merged

erikcorry merged 9 commits into
mainfrom
erikcorry/wrap-unwrap-with-lock

Conversation

@erikcorry

@erikcorry erikcorry commented Jun 4, 2025 •

Copy link
Copy Markdown
Contributor

In #4208 we reduced the use of context->GetCurrent since is is only a wrapper around v8::Isolate::GetCurrent.

However, discussion there raised the issue that v8::Isolate::GetCurrent is potentially slow and messy since it gets the isolate from thread-local storage. It was agreed that it would be better to pass the jsg::Lock (which has the isolate) to those functions that need it. This change implements that suggestion.

@erikcorry
erikcorry requested review from a team as code owners June 4, 2025 09:13
@windsurf-bot

windsurf-bot Bot commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

The total size of the files in this PR is too large.

@erikcorry erikcorry changed the title Pass a jsg::Lock to wrap and unwrap so we can get the isolate from it  Pass a jsg::Lock to wrap and unwrap so we can get the isolate from it Jun 4, 2025
@github-actions

github-actions Bot commented Jun 4, 2025 •

Copy link
Copy Markdown

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

@erikcorry
erikcorry force-pushed the erikcorry/wrap-unwrap-with-lock branch from 9eb09d6 to 7ac507e Compare June 4, 2025 11:59
Comment thread src/workerd/io/promise-wrapper.h Resolved
@erikcorry
erikcorry force-pushed the erikcorry/wrap-unwrap-with-lock branch from eccc68a to ce30c20 Compare June 10, 2025 12:24

@jasnell jasnell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall LGTM (though I recognize there still might be some details remaining to get it to pass CI before it lands)

@erikcorry
erikcorry merged commit 08edebb into main Jun 10, 2025
@erikcorry
erikcorry deleted the erikcorry/wrap-unwrap-with-lock branch June 10, 2025 14:50
erikcorry added a commit that referenced this pull request Jun 10, 2025
…#4244)

* Pass a jsg::Lock to wrap and unwrap so we can get the isolate from it

In #4208 we reduced the use of context->GetCurrent since is is only a wrapper around v8::Isolate::GetCurrent.

However, discussion there raised the issue that v8::Isolate::GetCurrent is potentially slow and messy since it gets the isolate from thread-local storage. It was agreed that it would be better to pass the jsg::Lock (which has the isolate) to those functions that need it. This change implements that suggestion.
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