src: add env->cppgc_allocation_handle() convenience method · nodejs/node@ca0f5a0

4 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -1193,7 +1193,7 @@ MyWrap* MyWrap::New(Environment* env, v8::Local<v8::Object> object) {

11931193

// pointer with this, as this is not managed by the native memory

11941194

// allocator but by V8.

11951195

return cppgc::MakeGarbageCollected<MyWrap>(

1196-

env->isolate()->GetCppHeap()->GetAllocationHandle(), env, object);

1196+

env->cppgc_allocation_handle(), env, object);

11971197

}

11981198
11991199

// Binding method to be invoked by JavaScript.

Original file line numberDiff line numberDiff line change

@@ -205,6 +205,10 @@ inline v8::Isolate* Environment::isolate() const {

205205

return isolate_;

206206

}

207207
208+

inline cppgc::AllocationHandle& Environment::cppgc_allocation_handle() const {

209+

return isolate_->GetCppHeap()->GetAllocationHandle();

210+

}

211+
208212

inline v8::ExternalMemoryAccounter* Environment::external_memory_accounter()

209213

const {

210214

return external_memory_accounter_;

Original file line numberDiff line numberDiff line change

@@ -692,6 +692,7 @@ class Environment final : public MemoryRetainer {

692692

void StartProfilerIdleNotifier();

693693
694694

inline v8::Isolate* isolate() const;

695+

inline cppgc::AllocationHandle& cppgc_allocation_handle() const;

695696

inline v8::ExternalMemoryAccounter* external_memory_accounter() const;

696697

inline uv_loop_t* event_loop() const;

697698

void TryLoadAddon(const char* filename,

Original file line numberDiff line numberDiff line change

@@ -330,11 +330,7 @@ ContextifyContext* ContextifyContext::New(Local<Context> v8_context,

330330

}

331331

DCHECK_NOT_NULL(env->isolate()->GetCppHeap());

332332

result = cppgc::MakeGarbageCollected<ContextifyContext>(

333-

env->isolate()->GetCppHeap()->GetAllocationHandle(),

334-

env,

335-

wrapper,

336-

v8_context,

337-

options);

333+

env->cppgc_allocation_handle(), env, wrapper, v8_context, options);

338334

}

339335
340336

Local<Object> wrapper_holder =

@@ -975,7 +971,7 @@ ContextifyScript* ContextifyScript::New(Environment* env,

975971

Local<Object> object) {

976972

DCHECK_NOT_NULL(env->isolate()->GetCppHeap());

977973

return cppgc::MakeGarbageCollected<ContextifyScript>(

978-

env->isolate()->GetCppHeap()->GetAllocationHandle(), env, object);

974+

env->cppgc_allocation_handle(), env, object);

979975

}

980976
981977

void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {