@@ -23,6 +23,7 @@ using v8::Isolate;
23
23
using v8::KeyCollectionMode;
24
24
using v8::Local;
25
25
using v8::LocalVector;
26
+ using v8::Name;
26
27
using v8::Object;
27
28
using v8::ObjectTemplate;
28
29
using v8::ONLY_CONFIGURABLE;
@@ -262,28 +263,32 @@ static void GetCallSite(const FunctionCallbackInfo<Value>& args) {
262
263
263
264
// Frame 0 is node:util. It should be skipped.
264
265
for (int i = 1 ; i < frame_count; ++i) {
265
- Local<Object> obj = Object::New (isolate);
266
266
Local<StackFrame> stack_frame = stack->GetFrame (isolate, i);
267
267
268
- Utf8Value function_name (isolate, stack_frame->GetFunctionName ());
269
- Utf8Value script_name (isolate, stack_frame->GetScriptName ());
270
-
271
- obj->Set (env->context (),
272
- env->function_name_string (),
273
- String::NewFromUtf8 (isolate, *function_name).ToLocalChecked ())
274
- .Check ();
275
- obj->Set (env->context (),
276
- env->script_name_string (),
277
- String::NewFromUtf8 (isolate, *script_name).ToLocalChecked ())
278
- .Check ();
279
- obj->Set (env->context (),
280
- env->line_number_string (),
281
- Integer::NewFromUnsigned (isolate, stack_frame->GetLineNumber ()))
282
- .Check ();
283
- obj->Set (env->context (),
284
- env->column_string (),
285
- Integer::NewFromUnsigned (isolate, stack_frame->GetColumn ()))
286
- .Check ();
268
+ Local<Value> function_name = stack_frame->GetFunctionName ();
269
+ if (function_name.IsEmpty ()) {
270
+ function_name = v8::String::Empty (isolate);
271
+ }
272
+
273
+ Local<Value> script_name = stack_frame->GetScriptName ();
274
+ if (script_name.IsEmpty ()) {
275
+ script_name = v8::String::Empty (isolate);
276
+ }
277
+
278
+ Local<Name> names[] = {
279
+ env->function_name_string (),
280
+ env->script_name_string (),
281
+ env->line_number_string (),
282
+ env->column_string (),
283
+ };
284
+ Local<Value> values[] = {
285
+ function_name,
286
+ script_name,
287
+ Integer::NewFromUnsigned (isolate, stack_frame->GetLineNumber ()),
288
+ Integer::NewFromUnsigned (isolate, stack_frame->GetColumn ()),
289
+ };
290
+ Local<Object> obj = Object::New (
291
+ isolate, v8::Null (isolate), names, values, arraysize (names));
287
292
288
293
callsite_objects.push_back (obj);
289
294
}
0 commit comments