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

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

Issue 2248553002: Add Inspector Agent for WebPerf, add probes in V8ScriptRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 17 matching lines...) Expand all
28 #include "bindings/core/v8/ScriptSourceCode.h" 28 #include "bindings/core/v8/ScriptSourceCode.h"
29 #include "bindings/core/v8/ScriptStreamer.h" 29 #include "bindings/core/v8/ScriptStreamer.h"
30 #include "bindings/core/v8/V8Binding.h" 30 #include "bindings/core/v8/V8Binding.h"
31 #include "bindings/core/v8/V8GCController.h" 31 #include "bindings/core/v8/V8GCController.h"
32 #include "bindings/core/v8/V8ThrowException.h" 32 #include "bindings/core/v8/V8ThrowException.h"
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/ExecutionContext.h" 34 #include "core/dom/ExecutionContext.h"
35 #include "core/fetch/CachedMetadata.h" 35 #include "core/fetch/CachedMetadata.h"
36 #include "core/fetch/ScriptResource.h" 36 #include "core/fetch/ScriptResource.h"
37 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
38 #include "core/inspector/InspectorInstrumentation.h"
38 #include "core/inspector/InspectorTraceEvents.h" 39 #include "core/inspector/InspectorTraceEvents.h"
39 #include "core/inspector/ThreadDebugger.h" 40 #include "core/inspector/ThreadDebugger.h"
40 #include "platform/Histogram.h" 41 #include "platform/Histogram.h"
41 #include "platform/ScriptForbiddenScope.h" 42 #include "platform/ScriptForbiddenScope.h"
42 #include "platform/TraceEvent.h" 43 #include "platform/TraceEvent.h"
43 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
44 #include "wtf/CurrentTime.h" 45 #include "wtf/CurrentTime.h"
45 46
46 #if OS(WIN) 47 #if OS(WIN)
47 #include <malloc.h> 48 #include <malloc.h>
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 ASSERT(!script.IsEmpty()); 397 ASSERT(!script.IsEmpty());
397 ScopedFrameBlamer frameBlamer(context->isDocument() ? toDocument(context)->f rame() : nullptr); 398 ScopedFrameBlamer frameBlamer(context->isDocument() ? toDocument(context)->f rame() : nullptr);
398 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); 399 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution");
399 TRACE_EVENT1("v8", "v8.run", "fileName", TRACE_STR_COPY(*v8::String::Utf8Val ue(script->GetUnboundScript()->GetScriptName()))); 400 TRACE_EVENT1("v8", "v8.run", "fileName", TRACE_STR_COPY(*v8::String::Utf8Val ue(script->GetUnboundScript()->GetScriptName())));
400 401
401 if (v8::MicrotasksScope::GetCurrentDepth(isolate) >= kMaxRecursionDepth) 402 if (v8::MicrotasksScope::GetCurrentDepth(isolate) >= kMaxRecursionDepth)
402 return throwStackOverflowExceptionIfNeeded(isolate); 403 return throwStackOverflowExceptionIfNeeded(isolate);
403 404
404 RELEASE_ASSERT(!context->isIteratingOverObservers()); 405 RELEASE_ASSERT(!context->isIteratingOverObservers());
405 406
407 InspectorInstrumentation::willExecuteScript(
pfeldman 2016/08/15 17:59:55 Here and below: you can pass |context| here, it'll
panicker 2016/08/15 20:48:55 Done.
408 context->isDocument() ? toDocument(context)->frame() : nullptr);
409
406 // Run the script and keep track of the current recursion depth. 410 // Run the script and keep track of the current recursion depth.
407 v8::MaybeLocal<v8::Value> result; 411 v8::MaybeLocal<v8::Value> result;
408 { 412 {
409 if (ScriptForbiddenScope::isScriptForbidden()) { 413 if (ScriptForbiddenScope::isScriptForbidden()) {
410 throwScriptForbiddenException(isolate); 414 throwScriptForbiddenException(isolate);
411 return v8::MaybeLocal<v8::Value>(); 415 return v8::MaybeLocal<v8::Value>();
pfeldman 2016/08/15 17:59:55 This will break your will* and did* apart, lets pl
panicker 2016/08/15 20:48:55 Done.
412 } 416 }
413 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMi crotasks); 417 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMi crotasks);
414 ThreadDebugger::willExecuteScript(isolate, script->GetUnboundScript()->G etId()); 418 ThreadDebugger::willExecuteScript(isolate, script->GetUnboundScript()->G etId());
415 result = script->Run(isolate->GetCurrentContext()); 419 result = script->Run(isolate->GetCurrentContext());
416 ThreadDebugger::didExecuteScript(isolate); 420 ThreadDebugger::didExecuteScript(isolate);
417 } 421 }
418 422
423 InspectorInstrumentation::didExecuteScript(
424 context->isDocument() ? toDocument(context)->frame() : nullptr);
419 crashIfIsolateIsDead(isolate); 425 crashIfIsolateIsDead(isolate);
420 return result; 426 return result;
421 } 427 }
422 428
423 v8::MaybeLocal<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Local< v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosi tion& scriptStartPosition) 429 v8::MaybeLocal<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Local< v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosi tion& scriptStartPosition)
424 { 430 {
425 v8::Local<v8::Script> script; 431 v8::Local<v8::Script> script;
426 if (!V8ScriptRunner::compileScript(source, fileName, String(), scriptStartPo sition, isolate, nullptr, nullptr, nullptr, SharableCrossOrigin, V8CacheOptionsD efault).ToLocal(&script)) 432 if (!V8ScriptRunner::compileScript(source, fileName, String(), scriptStartPo sition, isolate, nullptr, nullptr, nullptr, SharableCrossOrigin, V8CacheOptionsD efault).ToLocal(&script))
427 return v8::MaybeLocal<v8::Value>(); 433 return v8::MaybeLocal<v8::Value>();
428 434
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso late)); 501 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso late));
496 502
497 RELEASE_ASSERT(!context->isIteratingOverObservers()); 503 RELEASE_ASSERT(!context->isIteratingOverObservers());
498 504
499 if (ScriptForbiddenScope::isScriptForbidden()) { 505 if (ScriptForbiddenScope::isScriptForbidden()) {
500 throwScriptForbiddenException(isolate); 506 throwScriptForbiddenException(isolate);
501 return v8::MaybeLocal<v8::Value>(); 507 return v8::MaybeLocal<v8::Value>();
502 } 508 }
503 if (!depth) 509 if (!depth)
504 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", Inspecto rFunctionCallEvent::data(context, function)); 510 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", Inspecto rFunctionCallEvent::data(context, function));
511 InspectorInstrumentation::willExecuteScript(
512 context->isDocument() ? toDocument(context)->frame() : nullptr);
513
505 v8::MaybeLocal<v8::Value> result; 514 v8::MaybeLocal<v8::Value> result;
506 { 515 {
507 // Create an extra block so FunctionCall trace event end phase is record ed after 516 // Create an extra block so FunctionCall trace event end phase is record ed after
508 // v8::MicrotasksScope destructor, as the latter is running microtasks. 517 // v8::MicrotasksScope destructor, as the latter is running microtasks.
509 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMi crotasks); 518 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMi crotasks);
510 ThreadDebugger::willExecuteScript(isolate, function->ScriptId()); 519 ThreadDebugger::willExecuteScript(isolate, function->ScriptId());
511 result = function->Call(isolate->GetCurrentContext(), receiver, argc, ar gs); 520 result = function->Call(isolate->GetCurrentContext(), receiver, argc, ar gs);
512 crashIfIsolateIsDead(isolate); 521 crashIfIsolateIsDead(isolate);
513 ThreadDebugger::didExecuteScript(isolate); 522 ThreadDebugger::didExecuteScript(isolate);
514 } 523 }
524 InspectorInstrumentation::didExecuteScript(
525 context->isDocument() ? toDocument(context)->frame() : nullptr);
515 if (!depth) 526 if (!depth)
516 TRACE_EVENT_END0("devtools.timeline", "FunctionCall"); 527 TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
517 return result; 528 return result;
518 } 529 }
519 530
520 v8::MaybeLocal<v8::Value> V8ScriptRunner::callInternalFunction(v8::Local<v8::Fun ction> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> a rgs[], v8::Isolate* isolate) 531 v8::MaybeLocal<v8::Value> V8ScriptRunner::callInternalFunction(v8::Local<v8::Fun ction> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> a rgs[], v8::Isolate* isolate)
521 { 532 {
522 TRACE_EVENT0("v8", "v8.callFunction"); 533 TRACE_EVENT0("v8", "v8.callFunction");
523 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); 534 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution");
524 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks); 535 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // Store a timestamp to the cache as hint. 587 // Store a timestamp to the cache as hint.
577 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) 588 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler)
578 { 589 {
579 double now = WTF::currentTime(); 590 double now = WTF::currentTime();
580 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); 591 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler);
581 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); 592 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally);
582 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n ow), CachedMetadataHandler::SendToPlatform); 593 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n ow), CachedMetadataHandler::SendToPlatform);
583 } 594 }
584 595
585 } // namespace blink 596 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698