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

Unified Diff: src/api.cc

Issue 910683002: Introduce a compile method that takes context extensions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 10 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
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index e7e41987a73c304d7f1489fede06c2c42f5b48cc..d335cb159e114a9a6b0af375fe7dcda6f4590523 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1652,6 +1652,33 @@ Local<Script> ScriptCompiler::CompileModule(Isolate* v8_isolate, Source* source,
}
+Local<Function> ScriptCompiler::CompileFunctionInContext(
+ Isolate* v8_isolate, Source* source, Local<Context> v8_context,
+ size_t context_extension_count, Local<Object> context_extensions[]) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
+ ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileFunctionInContext()",
+ return Local<Function>());
+ LOG_API(isolate, "ScriptCompiler::CompileFunctionInContext()");
+ ENTER_V8(isolate);
+ i::Handle<i::Context> context = Utils::OpenHandle(*v8_context);
+ i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(),
+ isolate);
+ for (size_t i = 0; i < context_extension_count; ++i) {
+ i::Handle<i::JSObject> extension =
+ Utils::OpenHandle(*context_extensions[i]);
+ i::Handle<i::JSFunction> closure(context->closure(), isolate);
+ context = isolate->factory()->NewWithContext(closure, context, extension);
+ }
+ EXCEPTION_PREAMBLE(isolate);
+ i::MaybeHandle<i::JSFunction> result = i::Compiler::GetFunctionFromEval(
+ Utils::OpenHandle(*source->source_string), outer_info, context, i::SLOPPY,
+ i::NO_PARSE_RESTRICTION, 0 /* scope_position */);
+ has_pending_exception = result.is_null();
+ EXCEPTION_BAILOUT_CHECK(isolate, Local<Function>());
+ return Utils::ToLocal(result.ToHandleChecked());
+}
+
+
ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreamingScript(
Isolate* v8_isolate, StreamedSource* source, CompileOptions options) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698