Index: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp |
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp |
index 6117ad46d8f0acfdf01748eeb04666b91d31ad83..38f390c25ec8598401bee703292dcacfe2c65ac4 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp |
@@ -441,6 +441,41 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledInternalScript(v8::Isolate* |
return result; |
} |
+v8::MaybeLocal<v8::Value> V8ScriptRunner::callAsConstructor(v8::Isolate* isolate, v8::Local<v8::Object> constructor, ExecutionContext* context, int argc, v8::Local<v8::Value> argv[]) |
+{ |
+ TRACE_EVENT0("v8", "v8.newInstance"); |
+ TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); |
+ |
+ int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); |
+ if (depth >= kMaxRecursionDepth) |
+ return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(isolate)); |
+ |
+ CHECK(!context->isIteratingOverObservers()); |
+ |
+ if (ScriptForbiddenScope::isScriptForbidden()) { |
+ throwScriptForbiddenException(isolate); |
+ return v8::MaybeLocal<v8::Value>(); |
+ } |
+ |
+ v8::Local<v8::Function> function; |
+ bool isFunction = constructor->IsFunction(); |
+ if (isFunction) |
+ function = constructor.As<v8::Function>(); |
+ |
+ bool shouldTraceFunctionCall = !depth && isFunction; |
+ |
+ if (shouldTraceFunctionCall) |
+ TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", InspectorFunctionCallEvent::data(context, function)); |
+ v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); |
+ ThreadDebugger::willExecuteScript(isolate, isFunction ? function->ScriptId() : v8::UnboundScript::kNoScriptId); |
+ v8::MaybeLocal<v8::Value> result = constructor->CallAsConstructor(isolate->GetCurrentContext(), argc, argv); |
+ crashIfIsolateIsDead(isolate); |
+ ThreadDebugger::didExecuteScript(isolate); |
+ if (shouldTraceFunctionCall) |
+ TRACE_EVENT_END0("devtools.timeline", "FunctionCall"); |
+ return result; |
+} |
+ |
v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction(v8::Local<v8::Function> function, ExecutionContext* context, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> args[], v8::Isolate* isolate) |
{ |
TRACE_EVENT0("v8", "v8.callFunction"); |