Don’t enter node::MakeCallback if we have a calling context

this means we already have JavaScript frames on the execution stack
This commit is contained in:
Yavor Georgiev 2017-07-11 16:10:22 +02:00
parent fe756bdc86
commit 1e58351ace
No known key found for this signature in database
GPG Key ID: 83FC145DA0CCA9C3
1 changed files with 8 additions and 0 deletions

View File

@ -38,6 +38,14 @@ inline v8::Local<v8::Value> node::Function::call(v8::Isolate* isolate, const v8:
template<>
inline v8::Local<v8::Value> node::Function::callback(v8::Isolate* isolate, const v8::Local<v8::Function> &function, const v8::Local<v8::Object> &this_object, size_t argc, const v8::Local<v8::Value> arguments[]) {
if (!isolate->GetCallingContext().IsEmpty()) {
// if there are any JavaScript frames on the stack below this one we don't need to
// go through the trouble of calling MakeCallback. MakeCallback is only for when a
// thread with no JavaScript frames on its stack needs to call into JavaScript, like in
// an uv_async callback.
return call(isolate, function, this_object, argc, arguments);
}
v8::TryCatch trycatch(isolate);
auto recv = this_object.IsEmpty() ? isolate->GetCurrentContext()->Global() : this_object;