From d19a2c33b35b3256a738966231848a6679d7bb7d Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Wed, 4 Mar 2020 19:43:37 +0800 Subject: [PATCH] src: migrate measureMemory to new v8 api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/32116 Reviewed-By: Michaƫl Zasso Reviewed-By: Jiawen Geng Reviewed-By: Ruben Bridgewater --- src/node_contextify.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/node_contextify.cc b/src/node_contextify.cc index e6e2d123c04278..7926965302161c 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1224,15 +1224,18 @@ static void MeasureMemory(const FunctionCallbackInfo& args) { args[1].As()); CHECK_NOT_NULL(sandbox); context = sandbox->context(); - if (context.IsEmpty()) { // Not yet fully initilaized + if (context.IsEmpty()) { // Not yet fully initialized return; } } - v8::Local promise; - if (!isolate->MeasureMemory(context, static_cast(mode)) - .ToLocal(&promise)) { - return; - } + Local resolver; + if (!Promise::Resolver::New(context).ToLocal(&resolver)) return; + std::unique_ptr i = + v8::MeasureMemoryDelegate::Default( + isolate, context, resolver, static_cast(mode)); + CHECK_NOT_NULL(i); + v8::Local promise = resolver->GetPromise(); + args.GetReturnValue().Set(promise); }