From d1a1e203cc78d929e6c22f5ae63c2ee5ec68ca8b Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Wed, 4 Mar 2020 19:43:37 +0800 Subject: [PATCH] vm: migrate measureMemory to new v8 api --- 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 e6e2d123c04..79269653021 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); }