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

Side by Side Diff: src/compiler.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 unified diff | Download patch
« no previous file with comments | « src/compiler.h ('k') | src/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/ast-this-access-visitor.h" 10 #include "src/ast-this-access-visitor.h"
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 PostponeInterruptsScope postpone(isolate); 1128 PostponeInterruptsScope postpone(isolate);
1129 DCHECK(!isolate->native_context().is_null()); 1129 DCHECK(!isolate->native_context().is_null());
1130 Handle<Script> script = info->script(); 1130 Handle<Script> script = info->script();
1131 1131
1132 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? 1132 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile?
1133 FixedArray* array = isolate->native_context()->embedder_data(); 1133 FixedArray* array = isolate->native_context()->embedder_data();
1134 script->set_context_data(array->get(0)); 1134 script->set_context_data(array->get(0));
1135 1135
1136 isolate->debug()->OnBeforeCompile(script); 1136 isolate->debug()->OnBeforeCompile(script);
1137 1137
1138 DCHECK(info->is_eval() || info->is_global()); 1138 DCHECK(info->is_eval() || info->is_global() || info->is_module());
1139 1139
1140 info->MarkAsToplevel(); 1140 info->MarkAsToplevel();
1141 1141
1142 Handle<SharedFunctionInfo> result; 1142 Handle<SharedFunctionInfo> result;
1143 1143
1144 { VMState<COMPILER> state(info->isolate()); 1144 { VMState<COMPILER> state(info->isolate());
1145 if (info->function() == NULL) { 1145 if (info->function() == NULL) {
1146 // Parse the script if needed (if it's already parsed, function() is 1146 // Parse the script if needed (if it's already parsed, function() is
1147 // non-NULL). 1147 // non-NULL).
1148 bool parse_allow_lazy = 1148 bool parse_allow_lazy =
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 return isolate->factory()->NewFunctionFromSharedFunctionInfo( 1273 return isolate->factory()->NewFunctionFromSharedFunctionInfo(
1274 shared_info, context, NOT_TENURED); 1274 shared_info, context, NOT_TENURED);
1275 } 1275 }
1276 1276
1277 1277
1278 Handle<SharedFunctionInfo> Compiler::CompileScript( 1278 Handle<SharedFunctionInfo> Compiler::CompileScript(
1279 Handle<String> source, Handle<Object> script_name, int line_offset, 1279 Handle<String> source, Handle<Object> script_name, int line_offset,
1280 int column_offset, bool is_embedder_debug_script, 1280 int column_offset, bool is_embedder_debug_script,
1281 bool is_shared_cross_origin, Handle<Context> context, 1281 bool is_shared_cross_origin, Handle<Context> context,
1282 v8::Extension* extension, ScriptData** cached_data, 1282 v8::Extension* extension, ScriptData** cached_data,
1283 ScriptCompiler::CompileOptions compile_options, NativesFlag natives) { 1283 ScriptCompiler::CompileOptions compile_options, NativesFlag natives,
1284 bool is_module) {
1284 Isolate* isolate = source->GetIsolate(); 1285 Isolate* isolate = source->GetIsolate();
1285 if (compile_options == ScriptCompiler::kNoCompileOptions) { 1286 if (compile_options == ScriptCompiler::kNoCompileOptions) {
1286 cached_data = NULL; 1287 cached_data = NULL;
1287 } else if (compile_options == ScriptCompiler::kProduceParserCache || 1288 } else if (compile_options == ScriptCompiler::kProduceParserCache ||
1288 compile_options == ScriptCompiler::kProduceCodeCache) { 1289 compile_options == ScriptCompiler::kProduceCodeCache) {
1289 DCHECK(cached_data && !*cached_data); 1290 DCHECK(cached_data && !*cached_data);
1290 DCHECK(extension == NULL); 1291 DCHECK(extension == NULL);
1291 DCHECK(!isolate->debug()->is_loaded()); 1292 DCHECK(!isolate->debug()->is_loaded());
1292 } else { 1293 } else {
1293 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || 1294 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache ||
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 if (!script_name.is_null()) { 1339 if (!script_name.is_null()) {
1339 script->set_name(*script_name); 1340 script->set_name(*script_name);
1340 script->set_line_offset(Smi::FromInt(line_offset)); 1341 script->set_line_offset(Smi::FromInt(line_offset));
1341 script->set_column_offset(Smi::FromInt(column_offset)); 1342 script->set_column_offset(Smi::FromInt(column_offset));
1342 } 1343 }
1343 script->set_is_shared_cross_origin(is_shared_cross_origin); 1344 script->set_is_shared_cross_origin(is_shared_cross_origin);
1344 script->set_is_embedder_debug_script(is_embedder_debug_script); 1345 script->set_is_embedder_debug_script(is_embedder_debug_script);
1345 1346
1346 // Compile the function and add it to the cache. 1347 // Compile the function and add it to the cache.
1347 CompilationInfoWithZone info(script); 1348 CompilationInfoWithZone info(script);
1348 info.MarkAsGlobal(); 1349 if (FLAG_harmony_modules && is_module) {
1350 info.MarkAsModule();
1351 } else {
1352 info.MarkAsGlobal();
1353 }
1349 info.SetCachedData(cached_data, compile_options); 1354 info.SetCachedData(cached_data, compile_options);
1350 info.SetExtension(extension); 1355 info.SetExtension(extension);
1351 info.SetContext(context); 1356 info.SetContext(context);
1352 if (FLAG_serialize_toplevel && 1357 if (FLAG_serialize_toplevel &&
1353 compile_options == ScriptCompiler::kProduceCodeCache) { 1358 compile_options == ScriptCompiler::kProduceCodeCache) {
1354 info.PrepareForSerializing(); 1359 info.PrepareForSerializing();
1355 } 1360 }
1356 if (FLAG_use_strict) { 1361 if (FLAG_use_strict) {
1357 info.SetLanguageMode( 1362 info.SetLanguageMode(
1358 static_cast<LanguageMode>(info.language_mode() | STRICT_BIT)); 1363 static_cast<LanguageMode>(info.language_mode() | STRICT_BIT));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 } 1614 }
1610 1615
1611 1616
1612 #if DEBUG 1617 #if DEBUG
1613 void CompilationInfo::PrintAstForTesting() { 1618 void CompilationInfo::PrintAstForTesting() {
1614 PrintF("--- Source from AST ---\n%s\n", 1619 PrintF("--- Source from AST ---\n%s\n",
1615 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1620 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1616 } 1621 }
1617 #endif 1622 #endif
1618 } } // namespace v8::internal 1623 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698