Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp

Issue 2737863002: DevTools: move counter-related devtools.timeline trace events into probe:: probes. (Closed)
Patch Set: same Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 return v8::MaybeLocal<v8::Value>(); 602 return v8::MaybeLocal<v8::Value>();
603 } 603 }
604 604
605 // TODO(dominicc): When inspector supports tracing object 605 // TODO(dominicc): When inspector supports tracing object
606 // invocation, change this to use v8::Object instead of 606 // invocation, change this to use v8::Object instead of
607 // v8::Function. All callers use functions because 607 // v8::Function. All callers use functions because
608 // CustomElementRegistry#define's IDL signature is Function. 608 // CustomElementRegistry#define's IDL signature is Function.
609 CHECK(constructor->IsFunction()); 609 CHECK(constructor->IsFunction());
610 v8::Local<v8::Function> function = constructor.As<v8::Function>(); 610 v8::Local<v8::Function> function = constructor.As<v8::Function>();
611 611
612 if (!depth)
613 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data",
614 InspectorFunctionCallEvent::data(context, function));
615 v8::MicrotasksScope microtasksScope(isolate, 612 v8::MicrotasksScope microtasksScope(isolate,
616 v8::MicrotasksScope::kRunMicrotasks); 613 v8::MicrotasksScope::kRunMicrotasks);
614 probe::CallFunction probe(context, function, depth);
617 ThreadDebugger::willExecuteScript(isolate, function->ScriptId()); 615 ThreadDebugger::willExecuteScript(isolate, function->ScriptId());
618 v8::MaybeLocal<v8::Value> result = 616 v8::MaybeLocal<v8::Value> result =
619 constructor->CallAsConstructor(isolate->GetCurrentContext(), argc, argv); 617 constructor->CallAsConstructor(isolate->GetCurrentContext(), argc, argv);
620 CHECK(!isolate->IsDead()); 618 CHECK(!isolate->IsDead());
621 ThreadDebugger::didExecuteScript(isolate); 619 ThreadDebugger::didExecuteScript(isolate);
622 if (!depth)
623 TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
624 return result; 620 return result;
625 } 621 }
626 622
627 v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction( 623 v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction(
628 v8::Local<v8::Function> function, 624 v8::Local<v8::Function> function,
629 ExecutionContext* context, 625 ExecutionContext* context,
630 v8::Local<v8::Value> receiver, 626 v8::Local<v8::Value> receiver,
631 int argc, 627 int argc,
632 v8::Local<v8::Value> args[], 628 v8::Local<v8::Value> args[],
633 v8::Isolate* isolate) { 629 v8::Isolate* isolate) {
634 LocalFrame* frame = 630 LocalFrame* frame =
635 context->isDocument() ? toDocument(context)->frame() : nullptr; 631 context->isDocument() ? toDocument(context)->frame() : nullptr;
636 ScopedFrameBlamer frameBlamer(frame); 632 ScopedFrameBlamer frameBlamer(frame);
637 TRACE_EVENT0("v8", "v8.callFunction"); 633 TRACE_EVENT0("v8", "v8.callFunction");
638 634
639 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); 635 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate);
640 if (depth >= kMaxRecursionDepth) 636 if (depth >= kMaxRecursionDepth)
641 return v8::MaybeLocal<v8::Value>( 637 return v8::MaybeLocal<v8::Value>(
642 throwStackOverflowExceptionIfNeeded(isolate)); 638 throwStackOverflowExceptionIfNeeded(isolate));
643 639
644 RELEASE_ASSERT(!context->isIteratingOverObservers()); 640 RELEASE_ASSERT(!context->isIteratingOverObservers());
645 641
646 if (ScriptForbiddenScope::isScriptForbidden()) { 642 if (ScriptForbiddenScope::isScriptForbidden()) {
647 throwScriptForbiddenException(isolate); 643 throwScriptForbiddenException(isolate);
648 return v8::MaybeLocal<v8::Value>(); 644 return v8::MaybeLocal<v8::Value>();
649 } 645 }
650 if (!depth)
651 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data",
652 InspectorFunctionCallEvent::data(context, function));
653 646
654 DCHECK(!frame || 647 DCHECK(!frame ||
655 BindingSecurity::shouldAllowAccessToFrame( 648 BindingSecurity::shouldAllowAccessToFrame(
656 toDOMWindow(function->CreationContext())->toLocalDOMWindow(), 649 toDOMWindow(function->CreationContext())->toLocalDOMWindow(),
657 frame, BindingSecurity::ErrorReportOption::DoNotReport)); 650 frame, BindingSecurity::ErrorReportOption::DoNotReport));
658 CHECK(!ThreadState::current()->isWrapperTracingForbidden()); 651 CHECK(!ThreadState::current()->isWrapperTracingForbidden());
659 v8::MicrotasksScope microtasksScope(isolate, 652 v8::MicrotasksScope microtasksScope(isolate,
660 v8::MicrotasksScope::kRunMicrotasks); 653 v8::MicrotasksScope::kRunMicrotasks);
661 probe::CallFunction probe(context, function); 654 probe::CallFunction probe(context, function, depth);
662 ThreadDebugger::willExecuteScript(isolate, function->ScriptId()); 655 ThreadDebugger::willExecuteScript(isolate, function->ScriptId());
663 v8::MaybeLocal<v8::Value> result = 656 v8::MaybeLocal<v8::Value> result =
664 function->Call(isolate->GetCurrentContext(), receiver, argc, args); 657 function->Call(isolate->GetCurrentContext(), receiver, argc, args);
665 CHECK(!isolate->IsDead()); 658 CHECK(!isolate->IsDead());
666 ThreadDebugger::didExecuteScript(isolate); 659 ThreadDebugger::didExecuteScript(isolate);
667 if (!depth) 660
668 TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
669 return result; 661 return result;
670 } 662 }
671 663
672 v8::MaybeLocal<v8::Value> V8ScriptRunner::callInternalFunction( 664 v8::MaybeLocal<v8::Value> V8ScriptRunner::callInternalFunction(
673 v8::Local<v8::Function> function, 665 v8::Local<v8::Function> function,
674 v8::Local<v8::Value> receiver, 666 v8::Local<v8::Value> receiver,
675 int argc, 667 int argc,
676 v8::Local<v8::Value> args[], 668 v8::Local<v8::Value> args[],
677 v8::Isolate* isolate) { 669 v8::Isolate* isolate) {
678 TRACE_EVENT0("v8", "v8.callFunction"); 670 TRACE_EVENT0("v8", "v8.callFunction");
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 v8AtomicString(isolate, "((e) => { throw e; })"), origin) 725 v8AtomicString(isolate, "((e) => { throw e; })"), origin)
734 .ToLocalChecked(); 726 .ToLocalChecked();
735 v8::Local<v8::Function> thrower = runCompiledInternalScript(isolate, script) 727 v8::Local<v8::Function> thrower = runCompiledInternalScript(isolate, script)
736 .ToLocalChecked() 728 .ToLocalChecked()
737 .As<v8::Function>(); 729 .As<v8::Function>();
738 v8::Local<v8::Value> args[] = {exception}; 730 v8::Local<v8::Value> args[] = {exception};
739 callInternalFunction(thrower, thrower, WTF_ARRAY_LENGTH(args), args, isolate); 731 callInternalFunction(thrower, thrower, WTF_ARRAY_LENGTH(args), args, isolate);
740 } 732 }
741 733
742 } // namespace blink 734 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698