8000 src: add env->cppgc_allocation_handle() convenience method · nodejs/node@ca0f5a0 · GitHub
[go: up one dir, main page]

Skip to content
.kglDHV{width:20px;height:20px;}/*!sc*/ .fTXDSd{width:60px;}/*!sc*/ .bpjOzT{width:62px;}/*!sc*/ .eXXeJz{width:60px;height:22px;}/*!sc*/ data-styled.g1[id="Box-sc-62in7e-0"]{content:"kglDHV,fTXDSd,bpjOzT,eXXeJz,"}/*!sc*/ .iIGVMW{font-weight:600;color:var(--fgColor-default,var(--color-fg-default,#1F2328));}/*!sc*/ .iIGVMW:hover{color:var(--fgColor-default,var(--color-fg-default,#1F2328));}/*!sc*/ data-styled.g27[id="Link__StyledLink-sc-1syctfj-0"]{content:"iIGVMW,"}/*!sc*/ .hlLCru{position:relative;overflow:hidden;-webkit-mask-image:radial-gradient(white,black);mask-image:radial-gradient(white,black);background-color:var(--bgColor-neutral-muted,var(--color-neutral-subtle,rgba(234,238,242,0.5)));border-radius:3px;display:block;height:1.2em;width:60px;}/*!sc*/ .hlLCru::after{-webkit-animation:crVFvv 1.5s infinite linear;animation:crVFvv 1.5s infinite linear;background:linear-gradient(90deg,transparent,var(--bgColor-neutral-muted,var(--color-neutral-subtle,rgba(234,238,242,0.5))),transparent);content:'';position:absolute;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);bottom:0;left:0;right:0;top:0;}/*!sc*/ .hvOysI{position:relative;overflow:hidden;-webkit-mask-image:radial-gradient(white,black);mask-image:radial-gradient(white,black);background-color:var(--bgColor-neutral-muted,var(--color-neutral-subtle,rgba(234,238,242,0.5)));border-radius:3px;display:block;height:1.2em;width:62px;}/*!sc*/ .hvOysI::after{-webkit-animation:crVFvv 1.5s infinite linear;animation:crVFvv 1.5s infinite linear;background:linear-gradient(90deg,transparent,var(--bgColor-neutral-muted,var(--color-neutral-subtle,rgba(234,238,242,0.5))),transparent);content:'';position:absolute;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);bottom:0;left:0;right:0;top:0;}/*!sc*/ .biZyBe{position:relative;overflow:hidden;-webkit-mask-image:radial-gradient(white,black);mask-image:radial-gradient(white,black);background-color:var(--bgColor-neutral-muted,var(--color-neutral-subtle,rgba(234,238,242,0.5)));border-radius:3px;display:block;height:1.2em;width:60px;height:22px;}/*!sc*/ .biZyBe::after{-webkit-animation:crVFvv 1.5s infinite linear;animation:crVFvv 1.5s infinite linear;background:linear-gradient(90deg,transparent,var(--bgColor-neutral-muted,var(--color-neutral-subtle,rgba(234,238,242,0.5))),transparent);content:'';position:absolute;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);bottom:0;left:0;right:0;top:0;}/*!sc*/ data-styled.g46[id="LoadingSkeleton-sc-f120ff6b-0"]{content:"hlLCru,hvOysI,biZyBe,"}/*!sc*/ @-webkit-keyframes crVFvv{0%{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);}50%{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%);}100%{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%);}}/*!sc*/ @keyframes crVFvv{0%{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);}50%{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%);}100%{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%);}}/*!sc*/ data-styled.g63[id="sc-keyframes-crVFvv"]{content:"crVFvv,"}/*!sc*/

Commit ca0f5a0

Browse files
jasnelltargos
authored andcommitted
src: add env->cppgc_allocation_handle() convenience method
Reduce some of the boilerplate code needed to access the cppgc::AllocationHandle from the Node.js Environment. PR-URL: #58483 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 80cc17f commit ca0f5a0

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/README.md

Lines changed: 1 addition & 1 deletion
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.

src/env-inl.h

Lines changed: 4 additions & 0 deletions
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_;

src/env.h

Lines changed: 1 addition & 0 deletions
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,

src/node_contextify.cc

Lines changed: 2 additions & 6 deletions
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) {

0 commit comments

Comments
 (0)
0