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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledInternalScript(v8::Isolate*
isolate, v8::Local<v8::Script> script) | 434 v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledInternalScript(v8::Isolate*
isolate, v8::Local<v8::Script> script) |
435 { | 435 { |
436 TRACE_EVENT0("v8", "v8.run"); | 436 TRACE_EVENT0("v8", "v8.run"); |
437 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); | 437 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); |
438 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); | 438 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); |
439 v8::MaybeLocal<v8::Value> result = script->Run(isolate->GetCurrentContext())
; | 439 v8::MaybeLocal<v8::Value> result = script->Run(isolate->GetCurrentContext())
; |
440 crashIfIsolateIsDead(isolate); | 440 crashIfIsolateIsDead(isolate); |
441 return result; | 441 return result; |
442 } | 442 } |
443 | 443 |
| 444 v8::MaybeLocal<v8::Value> V8ScriptRunner::callAsConstructor(v8::Isolate* isolate
, v8::Local<v8::Object> constructor, ExecutionContext* context, int argc, v8::Lo
cal<v8::Value> argv[]) |
| 445 { |
| 446 TRACE_EVENT0("v8", "v8.newInstance"); |
| 447 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); |
| 448 |
| 449 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); |
| 450 if (depth >= kMaxRecursionDepth) |
| 451 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso
late)); |
| 452 |
| 453 CHECK(!context->isIteratingOverObservers()); |
| 454 |
| 455 if (ScriptForbiddenScope::isScriptForbidden()) { |
| 456 throwScriptForbiddenException(isolate); |
| 457 return v8::MaybeLocal<v8::Value>(); |
| 458 } |
| 459 |
| 460 v8::Local<v8::Function> function; |
| 461 bool isFunction = constructor->IsFunction(); |
| 462 if (isFunction) |
| 463 function = constructor.As<v8::Function>(); |
| 464 |
| 465 bool shouldTraceFunctionCall = !depth && isFunction; |
| 466 |
| 467 if (shouldTraceFunctionCall) |
| 468 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", Inspecto
rFunctionCallEvent::data(context, function)); |
| 469 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); |
| 470 ThreadDebugger::willExecuteScript(isolate, isFunction ? function->ScriptId()
: v8::UnboundScript::kNoScriptId); |
| 471 v8::MaybeLocal<v8::Value> result = constructor->CallAsConstructor(isolate->G
etCurrentContext(), argc, argv); |
| 472 crashIfIsolateIsDead(isolate); |
| 473 ThreadDebugger::didExecuteScript(isolate); |
| 474 if (shouldTraceFunctionCall) |
| 475 TRACE_EVENT_END0("devtools.timeline", "FunctionCall"); |
| 476 return result; |
| 477 } |
| 478 |
444 v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction(v8::Local<v8::Function> f
unction, ExecutionContext* context, v8::Local<v8::Value> receiver, int argc, v8:
:Local<v8::Value> args[], v8::Isolate* isolate) | 479 v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction(v8::Local<v8::Function> f
unction, ExecutionContext* context, v8::Local<v8::Value> receiver, int argc, v8:
:Local<v8::Value> args[], v8::Isolate* isolate) |
445 { | 480 { |
446 TRACE_EVENT0("v8", "v8.callFunction"); | 481 TRACE_EVENT0("v8", "v8.callFunction"); |
447 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); | 482 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); |
448 | 483 |
449 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); | 484 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); |
450 if (depth >= kMaxRecursionDepth) | 485 if (depth >= kMaxRecursionDepth) |
451 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso
late)); | 486 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso
late)); |
452 | 487 |
453 RELEASE_ASSERT(!context->isIteratingOverObservers()); | 488 RELEASE_ASSERT(!context->isIteratingOverObservers()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // Store a timestamp to the cache as hint. | 567 // Store a timestamp to the cache as hint. |
533 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) | 568 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) |
534 { | 569 { |
535 double now = WTF::currentTime(); | 570 double now = WTF::currentTime(); |
536 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); | 571 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); |
537 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); | 572 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
538 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); | 573 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); |
539 } | 574 } |
540 | 575 |
541 } // namespace blink | 576 } // namespace blink |
OLD | NEW |