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

Side by Side Diff: src/compiler.cc

Issue 923573002: Properly thread language mode to compilation cache (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/compilation-cache.cc ('k') | src/d8.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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 } else { 1256 } else {
1257 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || 1257 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache ||
1258 compile_options == ScriptCompiler::kConsumeCodeCache); 1258 compile_options == ScriptCompiler::kConsumeCodeCache);
1259 DCHECK(cached_data && *cached_data); 1259 DCHECK(cached_data && *cached_data);
1260 DCHECK(extension == NULL); 1260 DCHECK(extension == NULL);
1261 } 1261 }
1262 int source_length = source->length(); 1262 int source_length = source->length();
1263 isolate->counters()->total_load_size()->Increment(source_length); 1263 isolate->counters()->total_load_size()->Increment(source_length);
1264 isolate->counters()->total_compile_size()->Increment(source_length); 1264 isolate->counters()->total_compile_size()->Increment(source_length);
1265 1265
1266 // TODO(rossberg): The natives do not yet obey strong mode rules
1267 // (for example, some macros use '==').
1268 bool use_strong = FLAG_use_strong && !isolate->bootstrapper()->IsActive();
1269 LanguageMode language_mode =
1270 construct_language_mode(FLAG_use_strict, use_strong);
1271
1266 CompilationCache* compilation_cache = isolate->compilation_cache(); 1272 CompilationCache* compilation_cache = isolate->compilation_cache();
1267 1273
1268 // Do a lookup in the compilation cache but not for extensions. 1274 // Do a lookup in the compilation cache but not for extensions.
1269 MaybeHandle<SharedFunctionInfo> maybe_result; 1275 MaybeHandle<SharedFunctionInfo> maybe_result;
1270 Handle<SharedFunctionInfo> result; 1276 Handle<SharedFunctionInfo> result;
1271 if (extension == NULL) { 1277 if (extension == NULL) {
1272 maybe_result = compilation_cache->LookupScript( 1278 maybe_result = compilation_cache->LookupScript(
1273 source, script_name, line_offset, column_offset, 1279 source, script_name, line_offset, column_offset,
1274 is_embedder_debug_script, is_shared_cross_origin, context); 1280 is_embedder_debug_script, is_shared_cross_origin, context,
1281 language_mode);
1275 if (maybe_result.is_null() && FLAG_serialize_toplevel && 1282 if (maybe_result.is_null() && FLAG_serialize_toplevel &&
1276 compile_options == ScriptCompiler::kConsumeCodeCache && 1283 compile_options == ScriptCompiler::kConsumeCodeCache &&
1277 !isolate->debug()->is_loaded()) { 1284 !isolate->debug()->is_loaded()) {
1278 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); 1285 HistogramTimerScope timer(isolate->counters()->compile_deserialize());
1279 Handle<SharedFunctionInfo> result; 1286 Handle<SharedFunctionInfo> result;
1280 if (CodeSerializer::Deserialize(isolate, *cached_data, source) 1287 if (CodeSerializer::Deserialize(isolate, *cached_data, source)
1281 .ToHandle(&result)) { 1288 .ToHandle(&result)) {
1282 return result; 1289 return result;
1283 } 1290 }
1284 // Deserializer failed. Fall through to compile. 1291 // Deserializer failed. Fall through to compile.
(...skipping 30 matching lines...) Expand all
1315 info.MarkAsGlobal(); 1322 info.MarkAsGlobal();
1316 } 1323 }
1317 info.SetCachedData(cached_data, compile_options); 1324 info.SetCachedData(cached_data, compile_options);
1318 info.SetExtension(extension); 1325 info.SetExtension(extension);
1319 info.SetContext(context); 1326 info.SetContext(context);
1320 if (FLAG_serialize_toplevel && 1327 if (FLAG_serialize_toplevel &&
1321 compile_options == ScriptCompiler::kProduceCodeCache) { 1328 compile_options == ScriptCompiler::kProduceCodeCache) {
1322 info.PrepareForSerializing(); 1329 info.PrepareForSerializing();
1323 } 1330 }
1324 1331
1325 LanguageMode language_mode =
1326 construct_language_mode(FLAG_use_strict, FLAG_use_strong);
1327 info.SetLanguageMode( 1332 info.SetLanguageMode(
1328 static_cast<LanguageMode>(info.language_mode() | language_mode)); 1333 static_cast<LanguageMode>(info.language_mode() | language_mode));
1329
1330 result = CompileToplevel(&info); 1334 result = CompileToplevel(&info);
1331 if (extension == NULL && !result.is_null() && !result->dont_cache()) { 1335 if (extension == NULL && !result.is_null() && !result->dont_cache()) {
1332 compilation_cache->PutScript(source, context, result); 1336 compilation_cache->PutScript(source, context, language_mode, result);
1333 if (FLAG_serialize_toplevel && 1337 if (FLAG_serialize_toplevel &&
1334 compile_options == ScriptCompiler::kProduceCodeCache) { 1338 compile_options == ScriptCompiler::kProduceCodeCache) {
1335 HistogramTimerScope histogram_timer( 1339 HistogramTimerScope histogram_timer(
1336 isolate->counters()->compile_serialize()); 1340 isolate->counters()->compile_serialize());
1337 *cached_data = CodeSerializer::Serialize(isolate, result, source); 1341 *cached_data = CodeSerializer::Serialize(isolate, result, source);
1338 if (FLAG_profile_deserialization) { 1342 if (FLAG_profile_deserialization) {
1339 PrintF("[Compiling and serializing took %0.3f ms]\n", 1343 PrintF("[Compiling and serializing took %0.3f ms]\n",
1340 timer.Elapsed().InMillisecondsF()); 1344 timer.Elapsed().InMillisecondsF());
1341 } 1345 }
1342 } 1346 }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 } 1587 }
1584 1588
1585 1589
1586 #if DEBUG 1590 #if DEBUG
1587 void CompilationInfo::PrintAstForTesting() { 1591 void CompilationInfo::PrintAstForTesting() {
1588 PrintF("--- Source from AST ---\n%s\n", 1592 PrintF("--- Source from AST ---\n%s\n",
1589 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1593 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1590 } 1594 }
1591 #endif 1595 #endif
1592 } } // namespace v8::internal 1596 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compilation-cache.cc ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698