From c16e90fac6181f0703c565ac7cfb375d609a99a0 Mon Sep 17 00:00:00 2001 From: Dan Lapid Date: Sat, 7 Dec 2024 00:36:07 +0000 Subject: [PATCH] fixup! Enable using context-specific type wrapper instances. --- src/workerd/jsg/setup.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/workerd/jsg/setup.h b/src/workerd/jsg/setup.h index 282f1fcc2086..35956d364e87 100644 --- a/src/workerd/jsg/setup.h +++ b/src/workerd/jsg/setup.h @@ -609,13 +609,13 @@ class Isolate: public IsolateBase { template JsContext newContextWithWrapper( - kj::Own& wrapper, NewContextOptions options, Args&&... args) { + TypeWrapper* wrapper, NewContextOptions options, Args&&... args) { // TODO(soon): Requiring move semantics for the global object is awkward. This should instead // allocate the object (forwarding arguments to the constructor) and return something like // a Ref. auto context = wrapper->newContext(*this, options, jsgIsolate.getObserver(), static_cast(nullptr), kj::fwd(args)...); - context.getHandle(v8Isolate)->SetAlignedPointerInEmbedderData(3, wrapper.get()); + context.getHandle(v8Isolate)->SetAlignedPointerInEmbedderData(3, wrapper); return context; } @@ -626,7 +626,8 @@ class Isolate: public IsolateBase { JsContext newContext(NewContextOptions options, Args&&... args) { KJ_DASSERT(!jsgIsolate.wrappers.empty()); KJ_DASSERT(jsgIsolate.wrappers[0].get() != nullptr); - return newContextWithWrapper(jsgIsolate.wrappers[0], options, kj::fwd(args)...); + return newContextWithWrapper( + jsgIsolate.wrappers[0].get(), options, kj::fwd(args)...); } // Creates a new JavaScript "context", i.e. the global object. This is the first step to @@ -643,7 +644,7 @@ class Isolate: public IsolateBase { jsgIsolate.hasExtraWrappers = true; auto& wrapper = jsgIsolate.wrappers.add( kj::heap(jsgIsolate.ptr, kj::fwd(configuration))); - return newContextWithWrapper(wrapper, options, kj::fwd(args)...); + return newContextWithWrapper(wrapper.get(), options, kj::fwd(args)...); } void reportError(const JsValue& value) override { @@ -706,10 +707,7 @@ class Isolate: public IsolateBase { return getWrapperByContext(js.v8Context()); } } - inline TypeWrapper* getWrapperByContext(v8::Local&& context) { - return getWrapperByContext(context); - } - inline TypeWrapper* getWrapperByContext(v8::Local& context) { + inline TypeWrapper* getWrapperByContext(v8::Local context) { if (KJ_LIKELY(!hasExtraWrappers)) { return wrappers[0].get(); } else {