Skip to content

Commit f92c252

Browse files
joyeecheungisheludko
authored andcommitted
src, test: migrate to cppgc-owned v8::MicrotaskQueue
Co-Authored-By: Igor Sheludko <isheludko@gmail.com> Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: #66537 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 18077b5 commit f92c252

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎src/node_contextify.cc‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ ContextifyContext* ContextifyContext::New(Environment* env,
155155

156156
MicrotaskQueue* queue =
157157
options->own_microtask_queue
158-
? options->own_microtask_queue.get()
158+
? options->own_microtask_queue
159159
: env->isolate()->GetCurrentContext()->GetMicrotaskQueue();
160160

161161
Local<Context> v8_context;
@@ -176,9 +176,7 @@ ContextifyContext::ContextifyContext(Environment* env,
176176
Local<Object> wrapper,
177177
Local<Context> v8_context,
178178
ContextOptions* options)
179-
: microtask_queue_(options->own_microtask_queue
180-
? options->own_microtask_queue.release()
181-
: nullptr) {
179+
: microtask_queue_(options->own_microtask_queue) {
182180
CppgcMixin::Wrap(this, env, wrapper);
183181

184182
context_.Reset(env->isolate(), v8_context);

‎src/node_contextify.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct ContextOptions {
1818
v8::Local<v8::String> origin;
1919
v8::Local<v8::Boolean> allow_code_gen_strings;
2020
v8::Local<v8::Boolean> allow_code_gen_wasm;
21-
std::unique_ptr<v8::MicrotaskQueue> own_microtask_queue;
21+
v8::MicrotaskQueue* own_microtask_queue = nullptr;
2222
v8::Local<v8::Symbol> host_defined_options_id;
2323
bool vanilla = false;
2424
};
@@ -122,7 +122,7 @@ class ContextifyContext final : CPPGC_MIXIN(ContextifyContext) {
122122
}
123123

124124
inline v8::MicrotaskQueue* microtask_queue() const {
125-
return microtask_queue_.get();
125+
return microtask_queue_;
126126
}
127127

128128
template <typename T>
@@ -186,7 +186,7 @@ class ContextifyContext final : CPPGC_MIXIN(ContextifyContext) {
186186
const v8::PropertyCallbackInfo<v8::Array>& args);
187187

188188
v8::TracedReference<v8::Context> context_;
189-
std::unique_ptr<v8::MicrotaskQueue> microtask_queue_;
189+
cppgc::Persistent<v8::MicrotaskQueue> microtask_queue_;
190190
};
191191

192192
class ContextifyScript final : CPPGC_MIXIN(ContextifyScript) {

‎test/cctest/test_environment.cc‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,15 +1062,16 @@ TEST_F(EnvironmentTest, NestedMicrotaskQueue) {
10621062
const v8::HandleScope handle_scope(isolate_);
10631063
const Argv argv;
10641064

1065-
std::unique_ptr<v8::MicrotaskQueue> queue = v8::MicrotaskQueue::New(
1066-
isolate_, v8::MicrotasksPolicy::kExplicit);
1065+
v8::MicrotaskQueue* queue =
1066+
v8::MicrotaskQueue::New(isolate_, v8::MicrotasksPolicy::kExplicit);
1067+
10671068
v8::Local<v8::Context> context =
10681069
v8::Context::New(isolate_,
10691070
nullptr,
10701071
{},
10711072
{},
10721073
v8::DeserializeInternalFieldsCallback(),
1073-
queue.get());
1074+
queue);
10741075
node::InitializeContext(context);
10751076
v8::Context::Scope context_scope(context);
10761077

0 commit comments

Comments
 (0)