| OLD | NEW |
| 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/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 bool use_strong = FLAG_use_strong && !isolate->bootstrapper()->IsActive(); | 1281 bool use_strong = FLAG_use_strong && !isolate->bootstrapper()->IsActive(); |
| 1282 LanguageMode language_mode = | 1282 LanguageMode language_mode = |
| 1283 construct_language_mode(FLAG_use_strict, use_strong); | 1283 construct_language_mode(FLAG_use_strict, use_strong); |
| 1284 | 1284 |
| 1285 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1285 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 1286 | 1286 |
| 1287 // Do a lookup in the compilation cache but not for extensions. | 1287 // Do a lookup in the compilation cache but not for extensions. |
| 1288 MaybeHandle<SharedFunctionInfo> maybe_result; | 1288 MaybeHandle<SharedFunctionInfo> maybe_result; |
| 1289 Handle<SharedFunctionInfo> result; | 1289 Handle<SharedFunctionInfo> result; |
| 1290 if (extension == NULL) { | 1290 if (extension == NULL) { |
| 1291 // First check per-isolate compilation cache. |
| 1291 maybe_result = compilation_cache->LookupScript( | 1292 maybe_result = compilation_cache->LookupScript( |
| 1292 source, script_name, line_offset, column_offset, | 1293 source, script_name, line_offset, column_offset, |
| 1293 is_embedder_debug_script, is_shared_cross_origin, context, | 1294 is_embedder_debug_script, is_shared_cross_origin, context, |
| 1294 language_mode); | 1295 language_mode); |
| 1295 if (maybe_result.is_null() && FLAG_serialize_toplevel && | 1296 if (maybe_result.is_null() && FLAG_serialize_toplevel && |
| 1296 compile_options == ScriptCompiler::kConsumeCodeCache && | 1297 compile_options == ScriptCompiler::kConsumeCodeCache && |
| 1297 !isolate->debug()->is_loaded()) { | 1298 !isolate->debug()->is_loaded()) { |
| 1299 // Then check cached code provided by embedder. |
| 1298 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); | 1300 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); |
| 1299 Handle<SharedFunctionInfo> result; | 1301 Handle<SharedFunctionInfo> result; |
| 1300 if (CodeSerializer::Deserialize(isolate, *cached_data, source) | 1302 if (CodeSerializer::Deserialize(isolate, *cached_data, source) |
| 1301 .ToHandle(&result)) { | 1303 .ToHandle(&result)) { |
| 1304 // Promote to per-isolate compilation cache. |
| 1305 DCHECK(!result->dont_cache()); |
| 1306 compilation_cache->PutScript(source, context, language_mode, result); |
| 1302 return result; | 1307 return result; |
| 1303 } | 1308 } |
| 1304 // Deserializer failed. Fall through to compile. | 1309 // Deserializer failed. Fall through to compile. |
| 1305 } | 1310 } |
| 1306 } | 1311 } |
| 1307 | 1312 |
| 1308 base::ElapsedTimer timer; | 1313 base::ElapsedTimer timer; |
| 1309 if (FLAG_profile_deserialization && FLAG_serialize_toplevel && | 1314 if (FLAG_profile_deserialization && FLAG_serialize_toplevel && |
| 1310 compile_options == ScriptCompiler::kProduceCodeCache) { | 1315 compile_options == ScriptCompiler::kProduceCodeCache) { |
| 1311 timer.Start(); | 1316 timer.Start(); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 } | 1605 } |
| 1601 | 1606 |
| 1602 | 1607 |
| 1603 #if DEBUG | 1608 #if DEBUG |
| 1604 void CompilationInfo::PrintAstForTesting() { | 1609 void CompilationInfo::PrintAstForTesting() { |
| 1605 PrintF("--- Source from AST ---\n%s\n", | 1610 PrintF("--- Source from AST ---\n%s\n", |
| 1606 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1611 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
| 1607 } | 1612 } |
| 1608 #endif | 1613 #endif |
| 1609 } } // namespace v8::internal | 1614 } } // namespace v8::internal |
| OLD | NEW |