Skip to content

Commit

Permalink
src: migrate measureMemory to new v8 api
Browse files Browse the repository at this point in the history
  • Loading branch information
gengjiawen authored and nodejs-ci committed Mar 8, 2020
1 parent d9c4fad commit 591b4d2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1224,15 +1224,18 @@ static void MeasureMemory(const FunctionCallbackInfo<Value>& args) {
args[1].As<Object>());
CHECK_NOT_NULL(sandbox);
context = sandbox->context();
if (context.IsEmpty()) { // Not yet fully initilaized
if (context.IsEmpty()) { // Not yet fully initialized
return;
}
}
v8::Local<v8::Promise> promise;
if (!isolate->MeasureMemory(context, static_cast<v8::MeasureMemoryMode>(mode))
.ToLocal(&promise)) {
return;
}
Local<Promise::Resolver> resolver;
if (!Promise::Resolver::New(context).ToLocal(&resolver)) return;
std::unique_ptr<v8::MeasureMemoryDelegate> i =
v8::MeasureMemoryDelegate::Default(
isolate, context, resolver, static_cast<v8::MeasureMemoryMode>(mode));
CHECK_NOT_NULL(i);
v8::Local<v8::Promise> promise = resolver->GetPromise();

args.GetReturnValue().Set(promise);
}

Expand Down

0 comments on commit 591b4d2

Please sign in to comment.