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

Unified Diff: src/api.cc

Issue 902093002: Add basic compilation support for modules (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add TODO 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') | src/bootstrapper.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 0393693e570dd7c7c128a6f827fd9e3f846453fe..b36211e21da2e47203eecfe192fc724defd0eac5 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1563,10 +1563,9 @@ Local<UnboundScript> Script::GetUnboundScript() {
}
-Local<UnboundScript> ScriptCompiler::CompileUnbound(
- Isolate* v8_isolate,
- Source* source,
- CompileOptions options) {
+Local<UnboundScript> ScriptCompiler::CompileUnboundInternal(
+ Isolate* v8_isolate, Source* source, CompileOptions options,
+ bool is_module) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()",
return Local<UnboundScript>());
@@ -1627,7 +1626,7 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript(
str, name_obj, line_offset, column_offset, is_embedder_debug_script,
is_shared_cross_origin, isolate->native_context(), NULL, &script_data,
- options, i::NOT_NATIVES_CODE);
+ options, i::NOT_NATIVES_CODE, is_module);
has_pending_exception = result.is_null();
if (has_pending_exception && script_data != NULL) {
// This case won't happen during normal operation; we have compiled
@@ -1656,13 +1655,20 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
}
+Local<UnboundScript> ScriptCompiler::CompileUnbound(Isolate* v8_isolate,
+ Source* source,
+ CompileOptions options) {
+ return CompileUnboundInternal(v8_isolate, source, options, false);
+}
+
+
Local<Script> ScriptCompiler::Compile(
Isolate* v8_isolate,
Source* source,
CompileOptions options) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ON_BAILOUT(isolate, "v8::ScriptCompiler::Compile()", return Local<Script>());
- LOG_API(isolate, "ScriptCompiler::CompiletBound()");
+ LOG_API(isolate, "ScriptCompiler::CompileBound()");
ENTER_V8(isolate);
Local<UnboundScript> generic = CompileUnbound(v8_isolate, source, options);
if (generic.IsEmpty()) return Local<Script>();
@@ -1670,6 +1676,21 @@ Local<Script> ScriptCompiler::Compile(
}
+Local<Script> ScriptCompiler::CompileModule(Isolate* v8_isolate, Source* source,
+ CompileOptions options) {
+ CHECK(i::FLAG_harmony_modules);
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
+ ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileModule()",
+ return Local<Script>());
+ LOG_API(isolate, "ScriptCompiler::CompileModule()");
+ ENTER_V8(isolate);
+ Local<UnboundScript> generic =
+ CompileUnboundInternal(v8_isolate, source, options, true);
+ if (generic.IsEmpty()) return Local<Script>();
+ return generic->BindToCurrentContext();
+}
+
+
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') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698