Skip to content

Commit

Permalink
vm: migrate measureMemory to new v8 api
Browse files Browse the repository at this point in the history
  • Loading branch information
gengjiawen committed Mar 4, 2020
1 parent 535dc9b commit d1a1e20
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 d1a1e20

Please sign in to comment.