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

Side by Side Diff: src/compiler.cc

Issue 1196223002: Do not look for existing shared function info when compiling a new script. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « src/compiler.h ('k') | src/objects.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/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
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 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 // Eager parsing cannot benefit from cached data, and producing cached 1068 // Eager parsing cannot benefit from cached data, and producing cached
1069 // data while parsing eagerly is not implemented. 1069 // data while parsing eagerly is not implemented.
1070 parse_info->set_cached_data(nullptr); 1070 parse_info->set_cached_data(nullptr);
1071 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); 1071 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions);
1072 } 1072 }
1073 if (!Parser::ParseStatic(parse_info)) { 1073 if (!Parser::ParseStatic(parse_info)) {
1074 return Handle<SharedFunctionInfo>::null(); 1074 return Handle<SharedFunctionInfo>::null();
1075 } 1075 }
1076 } 1076 }
1077 1077
1078 info->MarkAsNewScript();
1079
1078 FunctionLiteral* lit = info->function(); 1080 FunctionLiteral* lit = info->function();
1079 LiveEditFunctionTracker live_edit_tracker(isolate, lit); 1081 LiveEditFunctionTracker live_edit_tracker(isolate, lit);
1080 1082
1081 // Measure how long it takes to do the compilation; only take the 1083 // Measure how long it takes to do the compilation; only take the
1082 // rest of the function into account to avoid overlap with the 1084 // rest of the function into account to avoid overlap with the
1083 // parsing statistics. 1085 // parsing statistics.
1084 HistogramTimer* rate = info->is_eval() 1086 HistogramTimer* rate = info->is_eval()
1085 ? info->isolate()->counters()->compile_eval() 1087 ? info->isolate()->counters()->compile_eval()
1086 : info->isolate()->counters()->compile(); 1088 : info->isolate()->counters()->compile();
1087 HistogramTimerScope timer(rate); 1089 HistogramTimerScope timer(rate);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 // TODO(marja): FLAG_serialize_toplevel is not honoured and won't be; when the 1330 // TODO(marja): FLAG_serialize_toplevel is not honoured and won't be; when the
1329 // real code caching lands, streaming needs to be adapted to use it. 1331 // real code caching lands, streaming needs to be adapted to use it.
1330 return CompileToplevel(&compile_info); 1332 return CompileToplevel(&compile_info);
1331 } 1333 }
1332 1334
1333 1335
1334 Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo( 1336 Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
1335 FunctionLiteral* literal, Handle<Script> script, 1337 FunctionLiteral* literal, Handle<Script> script,
1336 CompilationInfo* outer_info) { 1338 CompilationInfo* outer_info) {
1337 // Precondition: code has been parsed and scopes have been analyzed. 1339 // Precondition: code has been parsed and scopes have been analyzed.
1338 MaybeHandle<SharedFunctionInfo> maybe_existing = 1340 MaybeHandle<SharedFunctionInfo> maybe_existing;
1339 script->FindSharedFunctionInfo(literal); 1341 if (outer_info->is_new_script()) {
1342 // There is no existing shared function info when compiling a new script.
1343 DCHECK(script->FindSharedFunctionInfo(literal).is_null());
1344 } else {
1345 maybe_existing = script->FindSharedFunctionInfo(literal);
1346 }
1340 // We found an existing shared function info. If it's already compiled, 1347 // We found an existing shared function info. If it's already compiled,
1341 // don't worry about compiling it, and simply return it. If it's not yet 1348 // don't worry about compiling it, and simply return it. If it's not yet
1342 // compiled, continue to decide whether to eagerly compile. 1349 // compiled, continue to decide whether to eagerly compile.
1343 Handle<SharedFunctionInfo> existing; 1350 Handle<SharedFunctionInfo> existing;
1344 if (maybe_existing.ToHandle(&existing) && existing->is_compiled()) { 1351 if (maybe_existing.ToHandle(&existing) && existing->is_compiled()) {
1345 return existing; 1352 return existing;
1346 } 1353 }
1347 1354
1348 Zone zone; 1355 Zone zone;
1349 ParseInfo parse_info(&zone, script); 1356 ParseInfo parse_info(&zone, script);
1350 CompilationInfo info(&parse_info); 1357 CompilationInfo info(&parse_info);
1351 parse_info.set_literal(literal); 1358 parse_info.set_literal(literal);
1352 parse_info.set_scope(literal->scope()); 1359 parse_info.set_scope(literal->scope());
1353 parse_info.set_language_mode(literal->scope()->language_mode()); 1360 parse_info.set_language_mode(literal->scope()->language_mode());
1354 if (outer_info->will_serialize()) info.PrepareForSerializing(); 1361 if (outer_info->will_serialize()) info.PrepareForSerializing();
1362 if (outer_info->is_new_script()) info.MarkAsNewScript();
1355 1363
1356 Isolate* isolate = info.isolate(); 1364 Isolate* isolate = info.isolate();
1357 Factory* factory = isolate->factory(); 1365 Factory* factory = isolate->factory();
1358 LiveEditFunctionTracker live_edit_tracker(isolate, literal); 1366 LiveEditFunctionTracker live_edit_tracker(isolate, literal);
1359 // Determine if the function can be lazily compiled. This is necessary to 1367 // Determine if the function can be lazily compiled. This is necessary to
1360 // allow some of our builtin JS files to be lazily compiled. These 1368 // allow some of our builtin JS files to be lazily compiled. These
1361 // builtins cannot be handled lazily by the parser, since we have to know 1369 // builtins cannot be handled lazily by the parser, since we have to know
1362 // if a function uses the special natives syntax, which is something the 1370 // if a function uses the special natives syntax, which is something the
1363 // parser records. 1371 // parser records.
1364 // If the debugger requests compilation for break points, we cannot be 1372 // If the debugger requests compilation for break points, we cannot be
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 1594
1587 1595
1588 #if DEBUG 1596 #if DEBUG
1589 void CompilationInfo::PrintAstForTesting() { 1597 void CompilationInfo::PrintAstForTesting() {
1590 PrintF("--- Source from AST ---\n%s\n", 1598 PrintF("--- Source from AST ---\n%s\n",
1591 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1599 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1592 } 1600 }
1593 #endif 1601 #endif
1594 } // namespace internal 1602 } // namespace internal
1595 } // namespace v8 1603 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698