OLD | NEW |
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 Loading... |
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 RELEASE_ASSERT(!context->isIteratingOverObservers()); | 405 RELEASE_ASSERT(!context->isIteratingOverObservers()); |
405 | 406 |
406 // Run the script and keep track of the current recursion depth. | 407 // Run the script and keep track of the current recursion depth. |
407 v8::MaybeLocal<v8::Value> result; | 408 v8::MaybeLocal<v8::Value> result; |
408 { | 409 { |
409 if (ScriptForbiddenScope::isScriptForbidden()) { | 410 if (ScriptForbiddenScope::isScriptForbidden()) { |
410 throwScriptForbiddenException(isolate); | 411 throwScriptForbiddenException(isolate); |
411 return v8::MaybeLocal<v8::Value>(); | 412 return v8::MaybeLocal<v8::Value>(); |
412 } | 413 } |
413 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMi
crotasks); | 414 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMi
crotasks); |
| 415 InspectorInstrumentation::willExecuteScript(context); |
414 ThreadDebugger::willExecuteScript(isolate, script->GetUnboundScript()->G
etId()); | 416 ThreadDebugger::willExecuteScript(isolate, script->GetUnboundScript()->G
etId()); |
415 result = script->Run(isolate->GetCurrentContext()); | 417 result = script->Run(isolate->GetCurrentContext()); |
416 ThreadDebugger::didExecuteScript(isolate); | 418 ThreadDebugger::didExecuteScript(isolate); |
| 419 InspectorInstrumentation::didExecuteScript(context); |
417 } | 420 } |
418 | 421 |
419 crashIfIsolateIsDead(isolate); | 422 crashIfIsolateIsDead(isolate); |
420 return result; | 423 return result; |
421 } | 424 } |
422 | 425 |
423 v8::MaybeLocal<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Local<
v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosi
tion& scriptStartPosition) | 426 v8::MaybeLocal<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Local<
v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosi
tion& scriptStartPosition) |
424 { | 427 { |
425 v8::Local<v8::Script> script; | 428 v8::Local<v8::Script> script; |
426 if (!V8ScriptRunner::compileScript(source, fileName, String(), scriptStartPo
sition, isolate, nullptr, nullptr, nullptr, SharableCrossOrigin, V8CacheOptionsD
efault).ToLocal(&script)) | 429 if (!V8ScriptRunner::compileScript(source, fileName, String(), scriptStartPo
sition, isolate, nullptr, nullptr, nullptr, SharableCrossOrigin, V8CacheOptionsD
efault).ToLocal(&script)) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso
late)); | 498 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso
late)); |
496 | 499 |
497 RELEASE_ASSERT(!context->isIteratingOverObservers()); | 500 RELEASE_ASSERT(!context->isIteratingOverObservers()); |
498 | 501 |
499 if (ScriptForbiddenScope::isScriptForbidden()) { | 502 if (ScriptForbiddenScope::isScriptForbidden()) { |
500 throwScriptForbiddenException(isolate); | 503 throwScriptForbiddenException(isolate); |
501 return v8::MaybeLocal<v8::Value>(); | 504 return v8::MaybeLocal<v8::Value>(); |
502 } | 505 } |
503 if (!depth) | 506 if (!depth) |
504 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", Inspecto
rFunctionCallEvent::data(context, function)); | 507 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", Inspecto
rFunctionCallEvent::data(context, function)); |
| 508 |
505 v8::MaybeLocal<v8::Value> result; | 509 v8::MaybeLocal<v8::Value> result; |
506 { | 510 { |
507 // Create an extra block so FunctionCall trace event end phase is record
ed after | 511 // Create an extra block so FunctionCall trace event end phase is record
ed after |
508 // v8::MicrotasksScope destructor, as the latter is running microtasks. | 512 // v8::MicrotasksScope destructor, as the latter is running microtasks. |
509 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMi
crotasks); | 513 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMi
crotasks); |
| 514 InspectorInstrumentation::willExecuteScript(context); |
510 ThreadDebugger::willExecuteScript(isolate, function->ScriptId()); | 515 ThreadDebugger::willExecuteScript(isolate, function->ScriptId()); |
511 result = function->Call(isolate->GetCurrentContext(), receiver, argc, ar
gs); | 516 result = function->Call(isolate->GetCurrentContext(), receiver, argc, ar
gs); |
512 crashIfIsolateIsDead(isolate); | 517 crashIfIsolateIsDead(isolate); |
513 ThreadDebugger::didExecuteScript(isolate); | 518 ThreadDebugger::didExecuteScript(isolate); |
| 519 InspectorInstrumentation::didExecuteScript(context); |
514 } | 520 } |
515 if (!depth) | 521 if (!depth) |
516 TRACE_EVENT_END0("devtools.timeline", "FunctionCall"); | 522 TRACE_EVENT_END0("devtools.timeline", "FunctionCall"); |
517 return result; | 523 return result; |
518 } | 524 } |
519 | 525 |
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) | 526 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 { | 527 { |
522 TRACE_EVENT0("v8", "v8.callFunction"); | 528 TRACE_EVENT0("v8", "v8.callFunction"); |
523 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); | 529 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 // Store a timestamp to the cache as hint. | 582 // Store a timestamp to the cache as hint. |
577 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) | 583 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) |
578 { | 584 { |
579 double now = WTF::currentTime(); | 585 double now = WTF::currentTime(); |
580 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); | 586 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); |
581 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); | 587 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
582 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); | 588 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); |
583 } | 589 } |
584 | 590 |
585 } // namespace blink | 591 } // namespace blink |
OLD | NEW |