| 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.callAsConstructor"); | |
| 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 // TODO(dominicc): When inspector supports tracing object | |
| 461 // invocation, change this to use v8::Object instead of | |
| 462 // v8::Function. All callers use functions because | |
| 463 // CustomElementsRegistry#define's IDL signature is Function. | |
| 464 CHECK(constructor->IsFunction()); | |
| 465 v8::Local<v8::Function> function = constructor.As<v8::Function>(); | |
| 466 | |
| 467 bool shouldTraceFunctionCall = !depth; | |
| 468 if (shouldTraceFunctionCall) | |
| 469 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", Inspecto
rFunctionCallEvent::data(context, function)); | |
| 470 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMicrot
asks); | |
| 471 ThreadDebugger::willExecuteScript(isolate, function->ScriptId()); | |
| 472 v8::MaybeLocal<v8::Value> result = constructor->CallAsConstructor(isolate->G
etCurrentContext(), argc, argv); | |
| 473 crashIfIsolateIsDead(isolate); | |
| 474 ThreadDebugger::didExecuteScript(isolate); | |
| 475 if (shouldTraceFunctionCall) | |
| 476 TRACE_EVENT_END0("devtools.timeline", "FunctionCall"); | |
| 477 return result; | |
| 478 } | |
| 479 | |
| 480 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) | 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) |
| 481 { | 445 { |
| 482 TRACE_EVENT0("v8", "v8.callFunction"); | 446 TRACE_EVENT0("v8", "v8.callFunction"); |
| 483 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); | 447 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); |
| 484 | 448 |
| 485 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); | 449 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); |
| 486 if (depth >= kMaxRecursionDepth) | 450 if (depth >= kMaxRecursionDepth) |
| 487 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso
late)); | 451 return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(iso
late)); |
| 488 | 452 |
| 489 RELEASE_ASSERT(!context->isIteratingOverObservers()); | 453 RELEASE_ASSERT(!context->isIteratingOverObservers()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 // Store a timestamp to the cache as hint. | 532 // Store a timestamp to the cache as hint. |
| 569 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) | 533 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) |
| 570 { | 534 { |
| 571 double now = WTF::currentTime(); | 535 double now = WTF::currentTime(); |
| 572 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); | 536 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); |
| 573 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); | 537 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
| 574 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); | 538 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); |
| 575 } | 539 } |
| 576 | 540 |
| 577 } // namespace blink | 541 } // namespace blink |
| OLD | NEW |