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

Side by Side Diff: src/compiler.cc

Issue 1008363002: Promote code from code cache to compilation cache. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: improve test case slightly Created 5 years, 9 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 | « no previous file | test/cctest/test-serialize.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/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 bool use_strong = FLAG_use_strong && !isolate->bootstrapper()->IsActive(); 1239 bool use_strong = FLAG_use_strong && !isolate->bootstrapper()->IsActive();
1240 LanguageMode language_mode = 1240 LanguageMode language_mode =
1241 construct_language_mode(FLAG_use_strict, use_strong); 1241 construct_language_mode(FLAG_use_strict, use_strong);
1242 1242
1243 CompilationCache* compilation_cache = isolate->compilation_cache(); 1243 CompilationCache* compilation_cache = isolate->compilation_cache();
1244 1244
1245 // Do a lookup in the compilation cache but not for extensions. 1245 // Do a lookup in the compilation cache but not for extensions.
1246 MaybeHandle<SharedFunctionInfo> maybe_result; 1246 MaybeHandle<SharedFunctionInfo> maybe_result;
1247 Handle<SharedFunctionInfo> result; 1247 Handle<SharedFunctionInfo> result;
1248 if (extension == NULL) { 1248 if (extension == NULL) {
1249 // First check per-isolate compilation cache.
1249 maybe_result = compilation_cache->LookupScript( 1250 maybe_result = compilation_cache->LookupScript(
1250 source, script_name, line_offset, column_offset, 1251 source, script_name, line_offset, column_offset,
1251 is_embedder_debug_script, is_shared_cross_origin, context, 1252 is_embedder_debug_script, is_shared_cross_origin, context,
1252 language_mode); 1253 language_mode);
1253 if (maybe_result.is_null() && FLAG_serialize_toplevel && 1254 if (maybe_result.is_null() && FLAG_serialize_toplevel &&
1254 compile_options == ScriptCompiler::kConsumeCodeCache && 1255 compile_options == ScriptCompiler::kConsumeCodeCache &&
1255 !isolate->debug()->is_loaded()) { 1256 !isolate->debug()->is_loaded()) {
1257 // Then check cached code provided by embedder.
1256 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); 1258 HistogramTimerScope timer(isolate->counters()->compile_deserialize());
1257 Handle<SharedFunctionInfo> result; 1259 Handle<SharedFunctionInfo> result;
1258 if (CodeSerializer::Deserialize(isolate, *cached_data, source) 1260 if (CodeSerializer::Deserialize(isolate, *cached_data, source)
1259 .ToHandle(&result)) { 1261 .ToHandle(&result)) {
1262 // Promote to per-isolate compilation cache.
1263 DCHECK(!result->dont_cache());
1264 compilation_cache->PutScript(source, context, language_mode, result);
1260 return result; 1265 return result;
1261 } 1266 }
1262 // Deserializer failed. Fall through to compile. 1267 // Deserializer failed. Fall through to compile.
1263 } 1268 }
1264 } 1269 }
1265 1270
1266 base::ElapsedTimer timer; 1271 base::ElapsedTimer timer;
1267 if (FLAG_profile_deserialization && FLAG_serialize_toplevel && 1272 if (FLAG_profile_deserialization && FLAG_serialize_toplevel &&
1268 compile_options == ScriptCompiler::kProduceCodeCache) { 1273 compile_options == ScriptCompiler::kProduceCodeCache) {
1269 timer.Start(); 1274 timer.Start();
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 parse_info_ = nullptr; 1594 parse_info_ = nullptr;
1590 } 1595 }
1591 1596
1592 #if DEBUG 1597 #if DEBUG
1593 void CompilationInfo::PrintAstForTesting() { 1598 void CompilationInfo::PrintAstForTesting() {
1594 PrintF("--- Source from AST ---\n%s\n", 1599 PrintF("--- Source from AST ---\n%s\n",
1595 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1600 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1596 } 1601 }
1597 #endif 1602 #endif
1598 } } // namespace v8::internal 1603 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698