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

Unified Diff: src/compiler.cc

Issue 2065453002: [module] Track script "module code" status Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use idiomatic variable names 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
« no previous file with comments | « src/compilation-cache.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 72cdc038ebfdb39e96573e6f49433dd84a292bc7..113c1b398f65fcaba3a4690f05cbebd6c3538838 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1488,7 +1488,7 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
// First check per-isolate compilation cache.
maybe_result = compilation_cache->LookupScript(
source, script_name, line_offset, column_offset, resource_options,
- context, language_mode);
+ context, language_mode, is_module);
if (maybe_result.is_null() && FLAG_serialize_toplevel &&
compile_options == ScriptCompiler::kConsumeCodeCache &&
!isolate->debug()->is_loaded()) {
@@ -1501,7 +1501,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
if (CodeSerializer::Deserialize(isolate, *cached_data, source)
.ToHandle(&result)) {
// Promote to per-isolate compilation cache.
- compilation_cache->PutScript(source, context, language_mode, result);
+ compilation_cache->PutScript(source, context, language_mode, is_module,
+ result);
return result;
}
// Deserializer failed. Fall through to compile.
@@ -1537,14 +1538,19 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
if (!source_map_url.is_null()) {
script->set_source_mapping_url(*source_map_url);
}
+ script->set_is_module(is_module);
// Compile the function and add it to the cache.
Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
if (is_module) {
- parse_info.set_module();
+ // The ParseInfo constructor unconditionally sets the `is_module` bit
+ // when its script is module code.
+ DCHECK(parse_info.is_module());
} else {
+ // In the current context of script compilation, the input cannot be eval
+ // code, so the input must be global code.
parse_info.set_global();
}
if (compile_options != ScriptCompiler::kNoCompileOptions) {
@@ -1562,7 +1568,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
static_cast<LanguageMode>(parse_info.language_mode() | language_mode));
result = CompileToplevel(&info);
if (extension == NULL && !result.is_null()) {
- compilation_cache->PutScript(source, context, language_mode, result);
+ compilation_cache->PutScript(source, context, language_mode, is_module,
+ result);
if (FLAG_serialize_toplevel &&
compile_options == ScriptCompiler::kProduceCodeCache) {
HistogramTimerScope histogram_timer(
« no previous file with comments | « src/compilation-cache.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698