diff --git a/src/node_perf.cc b/src/node_perf.cc index 1e1fe13d938566..5f1b70a5c4db6c 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -317,49 +317,30 @@ void TimerFunctionCall(const FunctionCallbackInfo& args) { size_t idx; SlicedArguments call_args(args); Utf8Value name(isolate, GetName(fn)); + bool is_construct_call = args.IsConstructCall(); - uint64_t start; - uint64_t end; - v8::TryCatch try_catch(isolate); - if (args.IsConstructCall()) { - start = PERFORMANCE_NOW(); - TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0( - TRACING_CATEGORY_NODE2(perf, timerify), - *name, *name, start / 1000); - v8::MaybeLocal ret = fn->NewInstance(context, - call_args.size(), - call_args.data()); - end = PERFORMANCE_NOW(); - TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0( - TRACING_CATEGORY_NODE2(perf, timerify), - *name, *name, end / 1000); - - if (ret.IsEmpty()) { - try_catch.ReThrow(); - return; - } - args.GetReturnValue().Set(ret.ToLocalChecked()); + uint64_t start = PERFORMANCE_NOW(); + TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0( + TRACING_CATEGORY_NODE2(perf, timerify), + *name, *name, start / 1000); + v8::MaybeLocal ret; + + if (is_construct_call) { + ret = fn->NewInstance(context, call_args.size(), call_args.data()) + .FromMaybe(Local()); } else { - start = PERFORMANCE_NOW(); - TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0( - TRACING_CATEGORY_NODE2(perf, timerify), - *name, *name, start / 1000); - v8::MaybeLocal ret = fn->Call(context, - args.This(), - call_args.size(), - call_args.data()); - end = PERFORMANCE_NOW(); - TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0( - TRACING_CATEGORY_NODE2(perf, timerify), - *name, *name, end / 1000); - - if (ret.IsEmpty()) { - try_catch.ReThrow(); - return; - } - args.GetReturnValue().Set(ret.ToLocalChecked()); + ret = fn->Call(context, args.This(), call_args.size(), call_args.data()); } + uint64_t end = PERFORMANCE_NOW(); + TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0( + TRACING_CATEGORY_NODE2(perf, timerify), + *name, *name, end / 1000); + + if (ret.IsEmpty()) + return; + args.GetReturnValue().Set(ret.ToLocalChecked()); + AliasedBuffer& observers = env->performance_state()->observers; if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION])