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/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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 // Eager parsing cannot benefit from cached data, and producing cached | 1065 // Eager parsing cannot benefit from cached data, and producing cached |
1066 // data while parsing eagerly is not implemented. | 1066 // data while parsing eagerly is not implemented. |
1067 parse_info->set_cached_data(nullptr); | 1067 parse_info->set_cached_data(nullptr); |
1068 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); | 1068 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); |
1069 } | 1069 } |
1070 if (!Parser::ParseStatic(parse_info)) { | 1070 if (!Parser::ParseStatic(parse_info)) { |
1071 return Handle<SharedFunctionInfo>::null(); | 1071 return Handle<SharedFunctionInfo>::null(); |
1072 } | 1072 } |
1073 } | 1073 } |
1074 | 1074 |
| 1075 DCHECK(!info->is_debug() || !parse_info->allow_lazy_parsing()); |
| 1076 |
1075 info->MarkAsFirstCompile(); | 1077 info->MarkAsFirstCompile(); |
1076 | 1078 |
1077 FunctionLiteral* lit = info->function(); | 1079 FunctionLiteral* lit = info->function(); |
1078 LiveEditFunctionTracker live_edit_tracker(isolate, lit); | 1080 LiveEditFunctionTracker live_edit_tracker(isolate, lit); |
1079 | 1081 |
1080 // Measure how long it takes to do the compilation; only take the | 1082 // Measure how long it takes to do the compilation; only take the |
1081 // rest of the function into account to avoid overlap with the | 1083 // rest of the function into account to avoid overlap with the |
1082 // parsing statistics. | 1084 // parsing statistics. |
1083 HistogramTimer* rate = info->is_eval() | 1085 HistogramTimer* rate = info->is_eval() |
1084 ? info->isolate()->counters()->compile_eval() | 1086 ? info->isolate()->counters()->compile_eval() |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 // TODO(titzer): increment the counters in caller. | 1328 // TODO(titzer): increment the counters in caller. |
1327 isolate->counters()->total_load_size()->Increment(source_length); | 1329 isolate->counters()->total_load_size()->Increment(source_length); |
1328 isolate->counters()->total_compile_size()->Increment(source_length); | 1330 isolate->counters()->total_compile_size()->Increment(source_length); |
1329 | 1331 |
1330 LanguageMode language_mode = | 1332 LanguageMode language_mode = |
1331 construct_language_mode(FLAG_use_strict, FLAG_use_strong); | 1333 construct_language_mode(FLAG_use_strict, FLAG_use_strong); |
1332 parse_info->set_language_mode( | 1334 parse_info->set_language_mode( |
1333 static_cast<LanguageMode>(parse_info->language_mode() | language_mode)); | 1335 static_cast<LanguageMode>(parse_info->language_mode() | language_mode)); |
1334 | 1336 |
1335 CompilationInfo compile_info(parse_info); | 1337 CompilationInfo compile_info(parse_info); |
1336 // TODO(marja): FLAG_serialize_toplevel is not honoured and won't be; when the | 1338 |
1337 // real code caching lands, streaming needs to be adapted to use it. | 1339 // If compiling for debugging, parse eagerly from scratch. |
| 1340 if (compile_info.is_debug()) parse_info->set_literal(NULL); |
| 1341 |
1338 return CompileToplevel(&compile_info); | 1342 return CompileToplevel(&compile_info); |
1339 } | 1343 } |
1340 | 1344 |
1341 | 1345 |
1342 Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo( | 1346 Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo( |
1343 FunctionLiteral* literal, Handle<Script> script, | 1347 FunctionLiteral* literal, Handle<Script> script, |
1344 CompilationInfo* outer_info) { | 1348 CompilationInfo* outer_info) { |
1345 // Precondition: code has been parsed and scopes have been analyzed. | 1349 // Precondition: code has been parsed and scopes have been analyzed. |
1346 Isolate* isolate = outer_info->isolate(); | 1350 Isolate* isolate = outer_info->isolate(); |
1347 MaybeHandle<SharedFunctionInfo> maybe_existing; | 1351 MaybeHandle<SharedFunctionInfo> maybe_existing; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 | 1625 |
1622 | 1626 |
1623 #if DEBUG | 1627 #if DEBUG |
1624 void CompilationInfo::PrintAstForTesting() { | 1628 void CompilationInfo::PrintAstForTesting() { |
1625 PrintF("--- Source from AST ---\n%s\n", | 1629 PrintF("--- Source from AST ---\n%s\n", |
1626 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1630 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
1627 } | 1631 } |
1628 #endif | 1632 #endif |
1629 } // namespace internal | 1633 } // namespace internal |
1630 } // namespace v8 | 1634 } // namespace v8 |
OLD | NEW |