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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp

Issue 2035623002: Implement the script parts of custom element upgrade steps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ce-upgrade-in-document-dom-merge2
Patch Set: Do not assign in conditional to unbreak windows builder. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
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..ef59faf41f163b994d286fec0405daa06dea4c45 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
@@ -441,6 +441,42 @@ 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.callAsConstructor");
+ 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>();
+ }
+
+ // TODO(dominicc): When inspector supports tracing object
+ // invocation, change this to use v8::Object instead of
+ // v8::Function. All callers use functions because
+ // CustomElementsRegistry#define's IDL signature is Function.
+ CHECK(constructor->IsFunction());
+ v8::Local<v8::Function> function = constructor.As<v8::Function>();
+
+ bool shouldTraceFunctionCall = !depth;
+ if (shouldTraceFunctionCall)
+ TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", InspectorFunctionCallEvent::data(context, function));
+ v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMicrotasks);
+ ThreadDebugger::willExecuteScript(isolate, function->ScriptId());
+ v8::MaybeLocal<v8::Value> result = constructor->CallAsConstructor(isolate->GetCurrentContext(), argc, argv);
+ crashIfIsolateIsDead(isolate);
+ ThreadDebugger::didExecuteScript(isolate);
+ if (shouldTraceFunctionCall)
+ TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
alph 2016/06/09 00:22:47 microtasksScope destructor must be called before r
+ 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");

Powered by Google App Engine
This is Rietveld 408576698