| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #define PARSE_INFO_GETTER_WITH_DEFAULT(type, name, def) \ | 57 #define PARSE_INFO_GETTER_WITH_DEFAULT(type, name, def) \ |
| 58 type CompilationInfo::name() const { \ | 58 type CompilationInfo::name() const { \ |
| 59 return parse_info() ? parse_info()->name() : def; \ | 59 return parse_info() ? parse_info()->name() : def; \ |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 PARSE_INFO_GETTER(Handle<Script>, script) | 63 PARSE_INFO_GETTER(Handle<Script>, script) |
| 64 PARSE_INFO_GETTER(bool, is_eval) | 64 PARSE_INFO_GETTER(bool, is_eval) |
| 65 PARSE_INFO_GETTER(bool, is_native) | 65 PARSE_INFO_GETTER(bool, is_native) |
| 66 PARSE_INFO_GETTER(bool, is_module) | 66 PARSE_INFO_GETTER(bool, is_module) |
| 67 PARSE_INFO_GETTER(FunctionLiteral*, literal) |
| 67 PARSE_INFO_GETTER_WITH_DEFAULT(LanguageMode, language_mode, STRICT) | 68 PARSE_INFO_GETTER_WITH_DEFAULT(LanguageMode, language_mode, STRICT) |
| 68 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<JSFunction>, closure, | 69 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<JSFunction>, closure, |
| 69 Handle<JSFunction>::null()) | 70 Handle<JSFunction>::null()) |
| 70 PARSE_INFO_GETTER(FunctionLiteral*, function) | |
| 71 PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr) | 71 PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr) |
| 72 PARSE_INFO_GETTER(Handle<Context>, context) | 72 PARSE_INFO_GETTER(Handle<Context>, context) |
| 73 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) | 73 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) |
| 74 | 74 |
| 75 #undef PARSE_INFO_GETTER | 75 #undef PARSE_INFO_GETTER |
| 76 #undef PARSE_INFO_GETTER_WITH_DEFAULT | 76 #undef PARSE_INFO_GETTER_WITH_DEFAULT |
| 77 | 77 |
| 78 | 78 |
| 79 // Exactly like a CompilationInfo, except being allocated via {new} and it also | 79 // Exactly like a CompilationInfo, except being allocated via {new} and it also |
| 80 // creates and enters a Zone on construction and deallocates it on destruction. | 80 // creates and enters a Zone on construction and deallocates it on destruction. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 101 bool CompilationInfo::has_shared_info() const { | 101 bool CompilationInfo::has_shared_info() const { |
| 102 return parse_info_ && !parse_info_->shared_info().is_null(); | 102 return parse_info_ && !parse_info_->shared_info().is_null(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| 106 bool CompilationInfo::has_context() const { | 106 bool CompilationInfo::has_context() const { |
| 107 return parse_info_ && !parse_info_->context().is_null(); | 107 return parse_info_ && !parse_info_->context().is_null(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 bool CompilationInfo::has_literal() const { |
| 112 return parse_info_ && parse_info_->literal() != nullptr; |
| 113 } |
| 114 |
| 115 |
| 116 bool CompilationInfo::has_scope() const { |
| 117 return parse_info_ && parse_info_->scope() != nullptr; |
| 118 } |
| 119 |
| 120 |
| 111 CompilationInfo::CompilationInfo(ParseInfo* parse_info) | 121 CompilationInfo::CompilationInfo(ParseInfo* parse_info) |
| 112 : CompilationInfo(parse_info, nullptr, BASE, parse_info->isolate(), | 122 : CompilationInfo(parse_info, nullptr, BASE, parse_info->isolate(), |
| 113 parse_info->zone()) { | 123 parse_info->zone()) { |
| 114 // Compiling for the snapshot typically results in different code than | 124 // Compiling for the snapshot typically results in different code than |
| 115 // compiling later on. This means that code recompiled with deoptimization | 125 // compiling later on. This means that code recompiled with deoptimization |
| 116 // support won't be "equivalent" (as defined by SharedFunctionInfo:: | 126 // support won't be "equivalent" (as defined by SharedFunctionInfo:: |
| 117 // EnableDeoptimizationSupport), so it will replace the old code and all | 127 // EnableDeoptimizationSupport), so it will replace the old code and all |
| 118 // its type feedback. To avoid this, always compile functions in the snapshot | 128 // its type feedback. To avoid this, always compile functions in the snapshot |
| 119 // with deoptimization support. | 129 // with deoptimization support. |
| 120 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); | 130 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 code_stub()->GetExtraICState(), code_stub()->GetStubType()) | 213 code_stub()->GetExtraICState(), code_stub()->GetStubType()) |
| 204 : Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); | 214 : Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); |
| 205 } | 215 } |
| 206 | 216 |
| 207 | 217 |
| 208 // Primitive functions are unlikely to be picked up by the stack-walking | 218 // Primitive functions are unlikely to be picked up by the stack-walking |
| 209 // profiler, so they trigger their own optimization when they're called | 219 // profiler, so they trigger their own optimization when they're called |
| 210 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. | 220 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. |
| 211 bool CompilationInfo::ShouldSelfOptimize() { | 221 bool CompilationInfo::ShouldSelfOptimize() { |
| 212 return FLAG_crankshaft && | 222 return FLAG_crankshaft && |
| 213 !(function()->flags() & AstProperties::kDontSelfOptimize) && | 223 !(literal()->flags() & AstProperties::kDontSelfOptimize) && |
| 214 !function()->dont_optimize() && | 224 !literal()->dont_optimize() && |
| 215 function()->scope()->AllowsLazyCompilation() && | 225 literal()->scope()->AllowsLazyCompilation() && |
| 216 (!has_shared_info() || !shared_info()->optimization_disabled()); | 226 (!has_shared_info() || !shared_info()->optimization_disabled()); |
| 217 } | 227 } |
| 218 | 228 |
| 219 | 229 |
| 220 void CompilationInfo::EnsureFeedbackVector() { | 230 void CompilationInfo::EnsureFeedbackVector() { |
| 221 if (feedback_vector_.is_null()) { | 231 if (feedback_vector_.is_null()) { |
| 222 feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector( | 232 feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector( |
| 223 function()->feedback_vector_spec()); | 233 literal()->feedback_vector_spec()); |
| 224 } | 234 } |
| 225 | 235 |
| 226 // It's very important that recompiles do not alter the structure of the | 236 // It's very important that recompiles do not alter the structure of the |
| 227 // type feedback vector. | 237 // type feedback vector. |
| 228 CHECK(!feedback_vector_->SpecDiffersFrom(function()->feedback_vector_spec())); | 238 CHECK(!feedback_vector_->SpecDiffersFrom(literal()->feedback_vector_spec())); |
| 229 } | 239 } |
| 230 | 240 |
| 231 | 241 |
| 232 bool CompilationInfo::has_simple_parameters() { | 242 bool CompilationInfo::has_simple_parameters() { |
| 233 return scope()->has_simple_parameters(); | 243 return scope()->has_simple_parameters(); |
| 234 } | 244 } |
| 235 | 245 |
| 236 | 246 |
| 237 bool CompilationInfo::MayUseThis() const { | 247 bool CompilationInfo::MayUseThis() const { |
| 238 return scope()->has_this_declaration() && scope()->receiver()->is_used(); | 248 return scope()->has_this_declaration() && scope()->receiver()->is_used(); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 690 |
| 681 | 691 |
| 682 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( | 692 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( |
| 683 CompilationInfo* info) { | 693 CompilationInfo* info) { |
| 684 VMState<COMPILER> state(info->isolate()); | 694 VMState<COMPILER> state(info->isolate()); |
| 685 PostponeInterruptsScope postpone(info->isolate()); | 695 PostponeInterruptsScope postpone(info->isolate()); |
| 686 | 696 |
| 687 // Parse and update CompilationInfo with the results. | 697 // Parse and update CompilationInfo with the results. |
| 688 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); | 698 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); |
| 689 Handle<SharedFunctionInfo> shared = info->shared_info(); | 699 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 690 FunctionLiteral* lit = info->function(); | 700 FunctionLiteral* lit = info->literal(); |
| 691 shared->set_language_mode(lit->language_mode()); | 701 shared->set_language_mode(lit->language_mode()); |
| 692 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 702 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
| 693 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); | 703 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); |
| 694 | 704 |
| 695 if (FLAG_ignition && info->closure()->PassesFilter(FLAG_ignition_filter)) { | 705 if (FLAG_ignition && info->closure()->PassesFilter(FLAG_ignition_filter)) { |
| 696 // Compile bytecode for the interpreter. | 706 // Compile bytecode for the interpreter. |
| 697 if (!GenerateBytecode(info)) return MaybeHandle<Code>(); | 707 if (!GenerateBytecode(info)) return MaybeHandle<Code>(); |
| 698 } else { | 708 } else { |
| 699 // Compile unoptimized code. | 709 // Compile unoptimized code. |
| 700 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); | 710 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 DCHECK(!info->is_context_specializing()); | 774 DCHECK(!info->is_context_specializing()); |
| 765 DCHECK(info->osr_ast_id().IsNone()); | 775 DCHECK(info->osr_ast_id().IsNone()); |
| 766 Handle<SharedFunctionInfo> shared(function->shared()); | 776 Handle<SharedFunctionInfo> shared(function->shared()); |
| 767 SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(shared, code); | 777 SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(shared, code); |
| 768 } | 778 } |
| 769 } | 779 } |
| 770 | 780 |
| 771 | 781 |
| 772 static bool Renumber(ParseInfo* parse_info) { | 782 static bool Renumber(ParseInfo* parse_info) { |
| 773 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), | 783 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), |
| 774 parse_info->function())) { | 784 parse_info->literal())) { |
| 775 return false; | 785 return false; |
| 776 } | 786 } |
| 777 Handle<SharedFunctionInfo> shared_info = parse_info->shared_info(); | 787 Handle<SharedFunctionInfo> shared_info = parse_info->shared_info(); |
| 778 if (!shared_info.is_null()) { | 788 if (!shared_info.is_null()) { |
| 779 FunctionLiteral* lit = parse_info->function(); | 789 FunctionLiteral* lit = parse_info->literal(); |
| 780 shared_info->set_ast_node_count(lit->ast_node_count()); | 790 shared_info->set_ast_node_count(lit->ast_node_count()); |
| 781 MaybeDisableOptimization(shared_info, lit->dont_optimize_reason()); | 791 MaybeDisableOptimization(shared_info, lit->dont_optimize_reason()); |
| 782 shared_info->set_dont_crankshaft(lit->flags() & | 792 shared_info->set_dont_crankshaft(lit->flags() & |
| 783 AstProperties::kDontCrankshaft); | 793 AstProperties::kDontCrankshaft); |
| 784 } | 794 } |
| 785 return true; | 795 return true; |
| 786 } | 796 } |
| 787 | 797 |
| 788 | 798 |
| 789 bool Compiler::Analyze(ParseInfo* info) { | 799 bool Compiler::Analyze(ParseInfo* info) { |
| 790 DCHECK(info->function() != NULL); | 800 DCHECK_NOT_NULL(info->literal()); |
| 791 if (!Rewriter::Rewrite(info)) return false; | 801 if (!Rewriter::Rewrite(info)) return false; |
| 792 if (!Scope::Analyze(info)) return false; | 802 if (!Scope::Analyze(info)) return false; |
| 793 if (!Renumber(info)) return false; | 803 if (!Renumber(info)) return false; |
| 794 DCHECK(info->scope() != NULL); | 804 DCHECK_NOT_NULL(info->scope()); |
| 795 return true; | 805 return true; |
| 796 } | 806 } |
| 797 | 807 |
| 798 | 808 |
| 799 bool Compiler::ParseAndAnalyze(ParseInfo* info) { | 809 bool Compiler::ParseAndAnalyze(ParseInfo* info) { |
| 800 if (!Parser::ParseStatic(info)) return false; | 810 if (!Parser::ParseStatic(info)) return false; |
| 801 return Compiler::Analyze(info); | 811 return Compiler::Analyze(info); |
| 802 } | 812 } |
| 803 | 813 |
| 804 | 814 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 } | 953 } |
| 944 function->ReplaceCode(*code); | 954 function->ReplaceCode(*code); |
| 945 DCHECK(function->is_compiled()); | 955 DCHECK(function->is_compiled()); |
| 946 return true; | 956 return true; |
| 947 } | 957 } |
| 948 | 958 |
| 949 | 959 |
| 950 // TODO(turbofan): In the future, unoptimized code with deopt support could | 960 // TODO(turbofan): In the future, unoptimized code with deopt support could |
| 951 // be generated lazily once deopt is triggered. | 961 // be generated lazily once deopt is triggered. |
| 952 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { | 962 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { |
| 953 DCHECK(info->function() != NULL); | 963 DCHECK_NOT_NULL(info->literal()); |
| 954 DCHECK(info->scope() != NULL); | 964 DCHECK(info->has_scope()); |
| 955 Handle<SharedFunctionInfo> shared = info->shared_info(); | 965 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 956 if (!shared->has_deoptimization_support()) { | 966 if (!shared->has_deoptimization_support()) { |
| 957 // TODO(titzer): just reuse the ParseInfo for the unoptimized compile. | 967 // TODO(titzer): just reuse the ParseInfo for the unoptimized compile. |
| 958 CompilationInfoWithZone unoptimized(info->closure()); | 968 CompilationInfoWithZone unoptimized(info->closure()); |
| 959 // Note that we use the same AST that we will use for generating the | 969 // Note that we use the same AST that we will use for generating the |
| 960 // optimized code. | 970 // optimized code. |
| 961 ParseInfo* parse_info = unoptimized.parse_info(); | 971 ParseInfo* parse_info = unoptimized.parse_info(); |
| 962 parse_info->set_literal(info->function()); | 972 parse_info->set_literal(info->literal()); |
| 963 parse_info->set_scope(info->scope()); | 973 parse_info->set_scope(info->scope()); |
| 964 parse_info->set_context(info->context()); | 974 parse_info->set_context(info->context()); |
| 965 unoptimized.EnableDeoptimizationSupport(); | 975 unoptimized.EnableDeoptimizationSupport(); |
| 966 // If the current code has reloc info for serialization, also include | 976 // If the current code has reloc info for serialization, also include |
| 967 // reloc info for serialization for the new code, so that deopt support | 977 // reloc info for serialization for the new code, so that deopt support |
| 968 // can be added without losing IC state. | 978 // can be added without losing IC state. |
| 969 if (shared->code()->kind() == Code::FUNCTION && | 979 if (shared->code()->kind() == Code::FUNCTION && |
| 970 shared->code()->has_reloc_info_for_serialization()) { | 980 shared->code()->has_reloc_info_for_serialization()) { |
| 971 unoptimized.PrepareForSerializing(); | 981 unoptimized.PrepareForSerializing(); |
| 972 } | 982 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 parse_info.set_parse_restriction(NO_PARSE_RESTRICTION); | 1021 parse_info.set_parse_restriction(NO_PARSE_RESTRICTION); |
| 1012 info.MarkAsDebug(); | 1022 info.MarkAsDebug(); |
| 1013 | 1023 |
| 1014 VMState<COMPILER> state(info.isolate()); | 1024 VMState<COMPILER> state(info.isolate()); |
| 1015 | 1025 |
| 1016 if (!Parser::ParseStatic(&parse_info)) { | 1026 if (!Parser::ParseStatic(&parse_info)) { |
| 1017 isolate->clear_pending_exception(); | 1027 isolate->clear_pending_exception(); |
| 1018 return false; | 1028 return false; |
| 1019 } | 1029 } |
| 1020 | 1030 |
| 1021 FunctionLiteral* lit = info.function(); | 1031 FunctionLiteral* lit = parse_info.literal(); |
| 1022 LiveEditFunctionTracker live_edit_tracker(isolate, lit); | 1032 LiveEditFunctionTracker live_edit_tracker(isolate, lit); |
| 1023 | 1033 |
| 1024 if (!CompileUnoptimizedCode(&info)) { | 1034 if (!CompileUnoptimizedCode(&info)) { |
| 1025 isolate->clear_pending_exception(); | 1035 isolate->clear_pending_exception(); |
| 1026 return false; | 1036 return false; |
| 1027 } | 1037 } |
| 1028 shared->ReplaceCode(*info.code()); | 1038 shared->ReplaceCode(*info.code()); |
| 1029 return true; | 1039 return true; |
| 1030 } | 1040 } |
| 1031 | 1041 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 ParseInfo parse_info(&zone, script); | 1084 ParseInfo parse_info(&zone, script); |
| 1075 CompilationInfo info(&parse_info); | 1085 CompilationInfo info(&parse_info); |
| 1076 PostponeInterruptsScope postpone(info.isolate()); | 1086 PostponeInterruptsScope postpone(info.isolate()); |
| 1077 VMState<COMPILER> state(info.isolate()); | 1087 VMState<COMPILER> state(info.isolate()); |
| 1078 | 1088 |
| 1079 // Get rid of old list of shared function infos. | 1089 // Get rid of old list of shared function infos. |
| 1080 info.MarkAsFirstCompile(); | 1090 info.MarkAsFirstCompile(); |
| 1081 info.parse_info()->set_global(); | 1091 info.parse_info()->set_global(); |
| 1082 if (!Parser::ParseStatic(info.parse_info())) return; | 1092 if (!Parser::ParseStatic(info.parse_info())) return; |
| 1083 | 1093 |
| 1084 LiveEditFunctionTracker tracker(info.isolate(), info.function()); | 1094 LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal()); |
| 1085 if (!CompileUnoptimizedCode(&info)) return; | 1095 if (!CompileUnoptimizedCode(&info)) return; |
| 1086 if (info.has_shared_info()) { | 1096 if (info.has_shared_info()) { |
| 1087 Handle<ScopeInfo> scope_info = | 1097 Handle<ScopeInfo> scope_info = |
| 1088 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); | 1098 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); |
| 1089 info.shared_info()->set_scope_info(*scope_info); | 1099 info.shared_info()->set_scope_info(*scope_info); |
| 1090 } | 1100 } |
| 1091 tracker.RecordRootFunctionInfo(info.code()); | 1101 tracker.RecordRootFunctionInfo(info.code()); |
| 1092 } | 1102 } |
| 1093 | 1103 |
| 1094 | 1104 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1107 | 1117 |
| 1108 DCHECK(parse_info->is_eval() || parse_info->is_global() || | 1118 DCHECK(parse_info->is_eval() || parse_info->is_global() || |
| 1109 parse_info->is_module()); | 1119 parse_info->is_module()); |
| 1110 | 1120 |
| 1111 parse_info->set_toplevel(); | 1121 parse_info->set_toplevel(); |
| 1112 | 1122 |
| 1113 Handle<SharedFunctionInfo> result; | 1123 Handle<SharedFunctionInfo> result; |
| 1114 | 1124 |
| 1115 { VMState<COMPILER> state(info->isolate()); | 1125 { VMState<COMPILER> state(info->isolate()); |
| 1116 if (parse_info->literal() == NULL) { | 1126 if (parse_info->literal() == NULL) { |
| 1117 // Parse the script if needed (if it's already parsed, function() is | 1127 // Parse the script if needed (if it's already parsed, literal() is |
| 1118 // non-NULL). If compiling for debugging, we may eagerly compile inner | 1128 // non-NULL). If compiling for debugging, we may eagerly compile inner |
| 1119 // functions, so do not parse lazily in that case. | 1129 // functions, so do not parse lazily in that case. |
| 1120 ScriptCompiler::CompileOptions options = parse_info->compile_options(); | 1130 ScriptCompiler::CompileOptions options = parse_info->compile_options(); |
| 1121 bool parse_allow_lazy = (options == ScriptCompiler::kConsumeParserCache || | 1131 bool parse_allow_lazy = (options == ScriptCompiler::kConsumeParserCache || |
| 1122 String::cast(script->source())->length() > | 1132 String::cast(script->source())->length() > |
| 1123 FLAG_min_preparse_length) && | 1133 FLAG_min_preparse_length) && |
| 1124 !info->is_debug(); | 1134 !info->is_debug(); |
| 1125 | 1135 |
| 1126 parse_info->set_allow_lazy_parsing(parse_allow_lazy); | 1136 parse_info->set_allow_lazy_parsing(parse_allow_lazy); |
| 1127 if (!parse_allow_lazy && | 1137 if (!parse_allow_lazy && |
| 1128 (options == ScriptCompiler::kProduceParserCache || | 1138 (options == ScriptCompiler::kProduceParserCache || |
| 1129 options == ScriptCompiler::kConsumeParserCache)) { | 1139 options == ScriptCompiler::kConsumeParserCache)) { |
| 1130 // We are going to parse eagerly, but we either 1) have cached data | 1140 // We are going to parse eagerly, but we either 1) have cached data |
| 1131 // produced by lazy parsing or 2) are asked to generate cached data. | 1141 // produced by lazy parsing or 2) are asked to generate cached data. |
| 1132 // Eager parsing cannot benefit from cached data, and producing cached | 1142 // Eager parsing cannot benefit from cached data, and producing cached |
| 1133 // data while parsing eagerly is not implemented. | 1143 // data while parsing eagerly is not implemented. |
| 1134 parse_info->set_cached_data(nullptr); | 1144 parse_info->set_cached_data(nullptr); |
| 1135 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); | 1145 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); |
| 1136 } | 1146 } |
| 1137 if (!Parser::ParseStatic(parse_info)) { | 1147 if (!Parser::ParseStatic(parse_info)) { |
| 1138 return Handle<SharedFunctionInfo>::null(); | 1148 return Handle<SharedFunctionInfo>::null(); |
| 1139 } | 1149 } |
| 1140 } | 1150 } |
| 1141 | 1151 |
| 1142 DCHECK(!info->is_debug() || !parse_info->allow_lazy_parsing()); | 1152 DCHECK(!info->is_debug() || !parse_info->allow_lazy_parsing()); |
| 1143 | 1153 |
| 1144 info->MarkAsFirstCompile(); | 1154 info->MarkAsFirstCompile(); |
| 1145 | 1155 |
| 1146 FunctionLiteral* lit = info->function(); | 1156 FunctionLiteral* lit = parse_info->literal(); |
| 1147 LiveEditFunctionTracker live_edit_tracker(isolate, lit); | 1157 LiveEditFunctionTracker live_edit_tracker(isolate, lit); |
| 1148 | 1158 |
| 1149 // Measure how long it takes to do the compilation; only take the | 1159 // Measure how long it takes to do the compilation; only take the |
| 1150 // rest of the function into account to avoid overlap with the | 1160 // rest of the function into account to avoid overlap with the |
| 1151 // parsing statistics. | 1161 // parsing statistics. |
| 1152 HistogramTimer* rate = info->is_eval() | 1162 HistogramTimer* rate = info->is_eval() |
| 1153 ? info->isolate()->counters()->compile_eval() | 1163 ? info->isolate()->counters()->compile_eval() |
| 1154 : info->isolate()->counters()->compile(); | 1164 : info->isolate()->counters()->compile(); |
| 1155 HistogramTimerScope timer(rate); | 1165 HistogramTimerScope timer(rate); |
| 1156 | 1166 |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 : (FLAG_trace_hydrogen && | 1712 : (FLAG_trace_hydrogen && |
| 1703 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1713 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1704 return (tracing_on && | 1714 return (tracing_on && |
| 1705 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1715 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1706 } | 1716 } |
| 1707 | 1717 |
| 1708 | 1718 |
| 1709 #if DEBUG | 1719 #if DEBUG |
| 1710 void CompilationInfo::PrintAstForTesting() { | 1720 void CompilationInfo::PrintAstForTesting() { |
| 1711 PrintF("--- Source from AST ---\n%s\n", | 1721 PrintF("--- Source from AST ---\n%s\n", |
| 1712 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1722 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); |
| 1713 } | 1723 } |
| 1714 #endif | 1724 #endif |
| 1715 } // namespace internal | 1725 } // namespace internal |
| 1716 } // namespace v8 | 1726 } // namespace v8 |
| OLD | NEW |