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

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

Issue 1307363006: DevTools: move instrumentation of v8 calls into V8ScriptRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed comments Created 5 years, 3 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 28
29 #include "bindings/core/v8/ScriptSourceCode.h" 29 #include "bindings/core/v8/ScriptSourceCode.h"
30 #include "bindings/core/v8/ScriptStreamer.h" 30 #include "bindings/core/v8/ScriptStreamer.h"
31 #include "bindings/core/v8/V8Binding.h" 31 #include "bindings/core/v8/V8Binding.h"
32 #include "bindings/core/v8/V8GCController.h" 32 #include "bindings/core/v8/V8GCController.h"
33 #include "bindings/core/v8/V8RecursionScope.h" 33 #include "bindings/core/v8/V8RecursionScope.h"
34 #include "bindings/core/v8/V8ThrowException.h" 34 #include "bindings/core/v8/V8ThrowException.h"
35 #include "core/dom/ExecutionContext.h" 35 #include "core/dom/ExecutionContext.h"
36 #include "core/fetch/CachedMetadata.h" 36 #include "core/fetch/CachedMetadata.h"
37 #include "core/fetch/ScriptResource.h" 37 #include "core/fetch/ScriptResource.h"
38 #include "core/inspector/InspectorInstrumentation.h"
38 #include "core/inspector/InspectorTraceEvents.h" 39 #include "core/inspector/InspectorTraceEvents.h"
39 #include "platform/ScriptForbiddenScope.h" 40 #include "platform/ScriptForbiddenScope.h"
40 #include "platform/TraceEvent.h" 41 #include "platform/TraceEvent.h"
41 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
42 #include "wtf/CurrentTime.h" 43 #include "wtf/CurrentTime.h"
43 44
44 #if defined(WTF_OS_WIN) 45 #if defined(WTF_OS_WIN)
45 #include <malloc.h> 46 #include <malloc.h>
46 #else 47 #else
47 #include <alloca.h> 48 #include <alloca.h>
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 RELEASE_ASSERT(!context->isIteratingOverObservers()); 382 RELEASE_ASSERT(!context->isIteratingOverObservers());
382 383
383 // Run the script and keep track of the current recursion depth. 384 // Run the script and keep track of the current recursion depth.
384 v8::MaybeLocal<v8::Value> result; 385 v8::MaybeLocal<v8::Value> result;
385 { 386 {
386 if (ScriptForbiddenScope::isScriptForbidden()) { 387 if (ScriptForbiddenScope::isScriptForbidden()) {
387 throwScriptForbiddenException(isolate); 388 throwScriptForbiddenException(isolate);
388 return v8::MaybeLocal<v8::Value>(); 389 return v8::MaybeLocal<v8::Value>();
389 } 390 }
390 V8RecursionScope recursionScope(isolate); 391 V8RecursionScope recursionScope(isolate);
392 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEx ecuteScript(context, script->GetUnboundScript()->GetId());
391 result = script->Run(isolate->GetCurrentContext()); 393 result = script->Run(isolate->GetCurrentContext());
394 InspectorInstrumentation::didExecuteScript(cookie);
392 } 395 }
393 396
394 crashIfV8IsDead(); 397 crashIfV8IsDead();
395 return result; 398 return result;
396 } 399 }
397 400
398 v8::MaybeLocal<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Local< v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosi tion& scriptStartPosition) 401 v8::MaybeLocal<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Local< v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosi tion& scriptStartPosition)
399 { 402 {
400 v8::Local<v8::Script> script; 403 v8::Local<v8::Script> script;
401 if (!V8ScriptRunner::compileScript(source, fileName, String(), scriptStartPo sition, isolate, nullptr, nullptr, nullptr, SharableCrossOrigin, V8CacheOptionsD efault, true).ToLocal(&script)) 404 if (!V8ScriptRunner::compileScript(source, fileName, String(), scriptStartPo sition, isolate, nullptr, nullptr, nullptr, SharableCrossOrigin, V8CacheOptionsD efault, true).ToLocal(&script))
(...skipping 25 matching lines...) Expand all
427 if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth) 430 if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth)
428 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso late)); 431 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso late));
429 432
430 RELEASE_ASSERT(!context->isIteratingOverObservers()); 433 RELEASE_ASSERT(!context->isIteratingOverObservers());
431 434
432 if (ScriptForbiddenScope::isScriptForbidden()) { 435 if (ScriptForbiddenScope::isScriptForbidden()) {
433 throwScriptForbiddenException(isolate); 436 throwScriptForbiddenException(isolate);
434 return v8::MaybeLocal<v8::Value>(); 437 return v8::MaybeLocal<v8::Value>();
435 } 438 }
436 V8RecursionScope recursionScope(isolate); 439 V8RecursionScope recursionScope(isolate);
440 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willExecut eScript(context, function->ScriptId());
437 v8::MaybeLocal<v8::Value> result = function->Call(isolate->GetCurrentContext (), receiver, argc, args); 441 v8::MaybeLocal<v8::Value> result = function->Call(isolate->GetCurrentContext (), receiver, argc, args);
438 crashIfV8IsDead(); 442 crashIfV8IsDead();
443 InspectorInstrumentation::didExecuteScript(cookie);
439 return result; 444 return result;
440 } 445 }
441 446
442 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) 447 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)
443 { 448 {
444 TRACE_EVENT0("v8", "v8.callFunction"); 449 TRACE_EVENT0("v8", "v8.callFunction");
445 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); 450 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution");
446 V8RecursionScope::MicrotaskSuppression recursionScope(isolate); 451 V8RecursionScope::MicrotaskSuppression recursionScope(isolate);
447 v8::MaybeLocal<v8::Value> result = function->Call(isolate->GetCurrentContext (), receiver, argc, args); 452 v8::MaybeLocal<v8::Value> result = function->Call(isolate->GetCurrentContext (), receiver, argc, args);
448 crashIfV8IsDead(); 453 crashIfV8IsDead();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 { 494 {
490 return cacheTag(CacheTagParser, cacheHandler); 495 return cacheTag(CacheTagParser, cacheHandler);
491 } 496 }
492 497
493 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) 498 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler)
494 { 499 {
495 return cacheTag(CacheTagCode, cacheHandler); 500 return cacheTag(CacheTagCode, cacheHandler);
496 } 501 }
497 502
498 } // namespace blink 503 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptController.cpp ('k') | Source/bindings/core/v8/V8WorkerGlobalScopeEventListener.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698