@@ -665,6 +665,16 @@ class ContextifyScript : public BaseObject {
665665 ContextifyScript* contextify_script =
666666 new ContextifyScript (env, args.This ());
667667
668+ if (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED (
669+ TRACING_CATEGORY_NODE2 (vm, script)) != 0 ) {
670+ Utf8Value fn (isolate, filename);
671+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN1 (
672+ TRACING_CATEGORY_NODE2 (vm, script),
673+ " ContextifyScript::New" ,
674+ contextify_script,
675+ " filename" , TRACE_STR_COPY (*fn));
676+ }
677+
668678 ScriptCompiler::CachedData* cached_data = nullptr ;
669679 if (!cached_data_buf.IsEmpty ()) {
670680 ArrayBuffer::Contents contents = cached_data_buf->Buffer ()->GetContents ();
@@ -694,6 +704,10 @@ class ContextifyScript : public BaseObject {
694704 DecorateErrorStack (env, try_catch);
695705 no_abort_scope.Close ();
696706 try_catch.ReThrow ();
707+ TRACE_EVENT_NESTABLE_ASYNC_END0 (
708+ TRACING_CATEGORY_NODE2 (vm, script),
709+ " ContextifyScript::New" ,
710+ contextify_script);
697711 return ;
698712 }
699713 contextify_script->script_ .Reset (isolate, v8_script.ToLocalChecked ());
@@ -717,6 +731,10 @@ class ContextifyScript : public BaseObject {
717731 env->cached_data_produced_string (),
718732 Boolean::New (isolate, cached_data_produced));
719733 }
734+ TRACE_EVENT_NESTABLE_ASYNC_END0 (
735+ TRACING_CATEGORY_NODE2 (vm, script),
736+ " ContextifyScript::New" ,
737+ contextify_script);
720738 }
721739
722740
@@ -729,6 +747,12 @@ class ContextifyScript : public BaseObject {
729747 static void RunInThisContext (const FunctionCallbackInfo<Value>& args) {
730748 Environment* env = Environment::GetCurrent (args);
731749
750+ ContextifyScript* wrapped_script;
751+ ASSIGN_OR_RETURN_UNWRAP (&wrapped_script, args.Holder ());
752+
753+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN0 (
754+ TRACING_CATEGORY_NODE2 (vm, script), " RunInThisContext" , wrapped_script);
755+
732756 CHECK_EQ (args.Length (), 3 );
733757
734758 CHECK (args[0 ]->IsNumber ());
@@ -742,11 +766,17 @@ class ContextifyScript : public BaseObject {
742766
743767 // Do the eval within this context
744768 EvalMachine (env, timeout, display_errors, break_on_sigint, args);
769+
770+ TRACE_EVENT_NESTABLE_ASYNC_END0 (
771+ TRACING_CATEGORY_NODE2 (vm, script), " RunInThisContext" , wrapped_script);
745772 }
746773
747774 static void RunInContext (const FunctionCallbackInfo<Value>& args) {
748775 Environment* env = Environment::GetCurrent (args);
749776
777+ ContextifyScript* wrapped_script;
778+ ASSIGN_OR_RETURN_UNWRAP (&wrapped_script, args.Holder ());
779+
750780 CHECK_EQ (args.Length (), 4 );
751781
752782 CHECK (args[0 ]->IsObject ());
@@ -759,6 +789,9 @@ class ContextifyScript : public BaseObject {
759789 if (contextify_context->context ().IsEmpty ())
760790 return ;
761791
792+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN0 (
793+ TRACING_CATEGORY_NODE2 (vm, script), " RunInContext" , wrapped_script);
794+
762795 CHECK (args[1 ]->IsNumber ());
763796 int64_t timeout = args[1 ]->IntegerValue (env->context ()).FromJust ();
764797
@@ -775,6 +808,9 @@ class ContextifyScript : public BaseObject {
775808 display_errors,
776809 break_on_sigint,
777810 args);
811+
812+ TRACE_EVENT_NESTABLE_ASYNC_END0 (
813+ TRACING_CATEGORY_NODE2 (vm, script), " RunInContext" , wrapped_script);
778814 }
779815
780816 static void DecorateErrorStack (Environment* env, const TryCatch& try_catch) {
0 commit comments