v8::Local<v8::Value> ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ScriptExecutionContext* context) { if (script.IsEmpty()) return v8::Local<v8::Value>(); V8GCController::checkMemoryUsage(); if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth) return handleMaxRecursionDepthExceeded(); if (handleOutOfMemory()) return v8::Local<v8::Value>(); // Run the script and keep track of the current recursion depth. v8::Local<v8::Value> result; { V8RecursionScope recursionScope(context); result = script->Run(); } if (handleOutOfMemory()) ASSERT(result.IsEmpty()); if (result.IsEmpty()) return v8::Local<v8::Value>(); crashIfV8IsDead(); return result; }
v8::Local<v8::Value> ScriptController::callFunctionWithInstrumentation(ScriptExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]) { V8GCController::checkMemoryUsage(); if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth) return handleMaxRecursionDepthExceeded(); InspectorInstrumentationCookie cookie; if (InspectorInstrumentation::timelineAgentEnabled(context)) { String resourceName; int lineNumber; resourceInfo(function, resourceName, lineNumber); cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber); } v8::Local<v8::Value> result; { TRACE_EVENT1("v8", "v8.callFunction", "callsite", resourceString(function).utf8()); V8RecursionScope recursionScope(context); result = function->Call(receiver, argc, args); } InspectorInstrumentation::didCallFunction(cookie); crashIfV8IsDead(); return result; }
v8::Local<v8::Value> V8ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ExecutionContext* context, v8::Isolate* isolate) { TRACE_EVENT0("v8", "v8.run"); TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution"); if (script.IsEmpty()) return v8::Local<v8::Value>(); if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth) return handleMaxRecursionDepthExceeded(isolate); RELEASE_ASSERT(!context->isIteratingOverObservers()); // Run the script and keep track of the current recursion depth. v8::Local<v8::Value> result; { V8RecursionScope recursionScope(isolate, context); result = script->Run(); } if (result.IsEmpty()) return v8::Local<v8::Value>(); crashIfV8IsDead(); return result; }
v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledScript(v8::Isolate* isolate, v8::Local<v8::Script> script, ExecutionContext* context) { ASSERT(!script.IsEmpty()); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); TRACE_EVENT1("v8", "v8.run", "fileName", TRACE_STR_COPY(*v8::String::Utf8Value(script->GetUnboundScript()->GetScriptName()))); if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth) return throwStackOverflowExceptionIfNeeded(isolate); RELEASE_ASSERT(!context->isIteratingOverObservers()); // Run the script and keep track of the current recursion depth. v8::MaybeLocal<v8::Value> result; { if (ScriptForbiddenScope::isScriptForbidden()) { throwScriptForbiddenException(isolate); return v8::MaybeLocal<v8::Value>(); } V8RecursionScope recursionScope(isolate); result = script->Run(isolate->GetCurrentContext()); } crashIfV8IsDead(); return result; }
v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledInternalScript(v8::Isolate* isolate, v8::Local<v8::Script> script) { TRACE_EVENT0("v8", "v8.run"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); V8RecursionScope::MicrotaskSuppression recursionScope(isolate); v8::MaybeLocal<v8::Value> result = script->Run(isolate->GetCurrentContext()); crashIfV8IsDead(); return result; }
v8::Local<v8::Value> V8ScriptRunner::callInternalFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate) { TRACE_EVENT0("v8", "v8.callFunction"); TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution"); V8RecursionScope::MicrotaskSuppression recursionScope(isolate); v8::Local<v8::Value> result = function->Call(receiver, argc, args); crashIfV8IsDead(); return result; }
v8::Local<v8::Object> V8ScriptRunner::instantiateObjectInDocument(v8::Isolate* isolate, v8::Handle<v8::Function> function, ExecutionContext* context, int argc, v8::Handle<v8::Value> argv[]) { TRACE_EVENT0("v8", "v8.newInstance"); TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution"); V8RecursionScope scope(isolate, context); v8::Local<v8::Object> result = function->NewInstance(argc, argv); crashIfV8IsDead(); return result; }
v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[]) { if (function.IsEmpty()) return v8::Local<v8::Object>(); ConstructorMode constructorMode; V8RecursionScope::MicrotaskSuppression scope; v8::Local<v8::Object> result = function->NewInstance(argc, argv); crashIfV8IsDead(); return result; }
v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::ObjectTemplate> objectTemplate) { if (objectTemplate.IsEmpty()) return v8::Local<v8::Object>(); ConstructorMode constructorMode; V8RecursionScope::MicrotaskSuppression scope; v8::Local<v8::Object> result = objectTemplate->NewInstance(); crashIfV8IsDead(); return result; }
v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObject(v8::Isolate* isolate, v8::Local<v8::Function> function, int argc, v8::Local<v8::Value> argv[]) { TRACE_EVENT0("v8", "v8.newInstance"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); V8RecursionScope::MicrotaskSuppression scope(isolate); v8::MaybeLocal<v8::Object> result = function->NewInstance(isolate->GetCurrentContext(), argc, argv); crashIfV8IsDead(); return result; }
v8::Local<v8::Object> V8ScriptRunner::instantiateObject(v8::Isolate* isolate, v8::Handle<v8::ObjectTemplate> objectTemplate) { TRACE_EVENT0("v8", "v8.newInstance"); TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution"); V8RecursionScope::MicrotaskSuppression scope(isolate); v8::Local<v8::Object> result = objectTemplate->NewInstance(); crashIfV8IsDead(); return result; }
v8::Local<v8::Object> V8ObjectConstructor::newInstanceInDocument(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[], Document* document) { #if PLATFORM(CHROMIUM) TRACE_EVENT0("v8", "v8.newInstance"); #endif // No artificial limitations on the depth of recursion. V8RecursionScope recursionScope(document); v8::Local<v8::Object> result = function->NewInstance(argc, argv); crashIfV8IsDead(); return result; }
v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObjectInDocument(v8::Isolate* isolate, v8::Local<v8::Function> function, ExecutionContext* context, int argc, v8::Local<v8::Value> argv[]) { TRACE_EVENT0("v8", "v8.newInstance"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); if (ScriptForbiddenScope::isScriptForbidden()) { throwScriptForbiddenException(isolate); return v8::MaybeLocal<v8::Object>(); } V8RecursionScope scope(isolate); v8::MaybeLocal<v8::Object> result = function->NewInstance(isolate->GetCurrentContext(), argc, argv); crashIfV8IsDead(); return result; }
v8::MaybeLocal<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Local<v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosition& scriptStartPosition) { v8::Local<v8::Script> script; if (!V8ScriptRunner::compileScript(source, fileName, String(), scriptStartPosition, isolate, nullptr, nullptr, nullptr, SharableCrossOrigin, V8CacheOptionsDefault, true).ToLocal(&script)) return v8::MaybeLocal<v8::Value>(); TRACE_EVENT0("v8", "v8.run"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); V8RecursionScope::MicrotaskSuppression recursionScope(isolate); v8::MaybeLocal<v8::Value> result = script->Run(isolate->GetCurrentContext()); crashIfV8IsDead(); return result; }
v8::Local<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Handle<v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosition& scriptStartPosition) { TRACE_EVENT0("v8", "v8.run"); TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution"); v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, fileName, scriptStartPosition, 0, isolate); if (script.IsEmpty()) return v8::Local<v8::Value>(); V8RecursionScope::MicrotaskSuppression recursionScope(isolate); v8::Local<v8::Value> result = script->Run(); crashIfV8IsDead(); return result; }
v8::Local<v8::Value> V8ScriptRunner::callFunction(v8::Handle<v8::Function> function, ExecutionContext* context, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate) { TRACE_EVENT0("v8", "v8.callFunction"); TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution"); if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth) return handleMaxRecursionDepthExceeded(isolate); RELEASE_ASSERT(!context->isIteratingOverObservers()); V8RecursionScope recursionScope(isolate, context); v8::Local<v8::Value> result = function->Call(receiver, argc, args); crashIfV8IsDead(); 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"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth) return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(isolate)); RELEASE_ASSERT(!context->isIteratingOverObservers()); if (ScriptForbiddenScope::isScriptForbidden()) { throwScriptForbiddenException(isolate); return v8::MaybeLocal<v8::Value>(); } V8RecursionScope recursionScope(isolate); v8::MaybeLocal<v8::Value> result = function->Call(isolate->GetCurrentContext(), receiver, argc, args); crashIfV8IsDead(); return result; }