| Index: src/compiler.cc
|
| diff --git a/src/compiler.cc b/src/compiler.cc
|
| index 2a0eda0a551229eface54be75d02400b6c0be6ff..af4491c8c038a160c93e4057a81d34af919a0b03 100644
|
| --- a/src/compiler.cc
|
| +++ b/src/compiler.cc
|
| @@ -1483,7 +1483,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()) {
|
| @@ -1496,7 +1496,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.
|
| @@ -1532,14 +1533,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) {
|
| @@ -1557,7 +1563,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(
|
|
|