| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return parse_info_ && parse_info_->literal() != nullptr; | 112 return parse_info_ && parse_info_->literal() != nullptr; |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 bool CompilationInfo::has_scope() const { | 116 bool CompilationInfo::has_scope() const { |
| 117 return parse_info_ && parse_info_->scope() != nullptr; | 117 return parse_info_ && parse_info_->scope() != nullptr; |
| 118 } | 118 } |
| 119 | 119 |
| 120 | 120 |
| 121 CompilationInfo::CompilationInfo(ParseInfo* parse_info) | 121 CompilationInfo::CompilationInfo(ParseInfo* parse_info) |
| 122 : CompilationInfo(parse_info, nullptr, BASE, parse_info->isolate(), | 122 : CompilationInfo(parse_info, nullptr, interpreter::Bytecode::kLast, BASE, |
| 123 parse_info->zone()) { | 123 parse_info->isolate(), parse_info->zone()) { |
| 124 // Compiling for the snapshot typically results in different code than | 124 // Compiling for the snapshot typically results in different code than |
| 125 // compiling later on. This means that code recompiled with deoptimization | 125 // compiling later on. This means that code recompiled with deoptimization |
| 126 // support won't be "equivalent" (as defined by SharedFunctionInfo:: | 126 // support won't be "equivalent" (as defined by SharedFunctionInfo:: |
| 127 // EnableDeoptimizationSupport), so it will replace the old code and all | 127 // EnableDeoptimizationSupport), so it will replace the old code and all |
| 128 // 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 |
| 129 // with deoptimization support. | 129 // with deoptimization support. |
| 130 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); | 130 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); |
| 131 | 131 |
| 132 if (FLAG_context_specialization) MarkAsContextSpecializing(); | 132 if (FLAG_context_specialization) MarkAsContextSpecializing(); |
| 133 if (FLAG_turbo_inlining) MarkAsInliningEnabled(); | 133 if (FLAG_turbo_inlining) MarkAsInliningEnabled(); |
| 134 if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled(); | 134 if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled(); |
| 135 if (FLAG_turbo_splitting) MarkAsSplittingEnabled(); | 135 if (FLAG_turbo_splitting) MarkAsSplittingEnabled(); |
| 136 if (FLAG_turbo_types) MarkAsTypingEnabled(); | 136 if (FLAG_turbo_types) MarkAsTypingEnabled(); |
| 137 | 137 |
| 138 if (has_shared_info()) { | 138 if (has_shared_info()) { |
| 139 if (shared_info()->is_compiled()) { | 139 if (shared_info()->is_compiled()) { |
| 140 // We should initialize the CompilationInfo feedback vector from the | 140 // We should initialize the CompilationInfo feedback vector from the |
| 141 // passed in shared info, rather than creating a new one. | 141 // passed in shared info, rather than creating a new one. |
| 142 feedback_vector_ = Handle<TypeFeedbackVector>( | 142 feedback_vector_ = Handle<TypeFeedbackVector>( |
| 143 shared_info()->feedback_vector(), parse_info->isolate()); | 143 shared_info()->feedback_vector(), parse_info->isolate()); |
| 144 } | 144 } |
| 145 if (shared_info()->never_compiled()) MarkAsFirstCompile(); | 145 if (shared_info()->never_compiled()) MarkAsFirstCompile(); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 | 149 |
| 150 CompilationInfo::CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone) | 150 CompilationInfo::CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone) |
| 151 : CompilationInfo(nullptr, stub, STUB, isolate, zone) {} | 151 : CompilationInfo(nullptr, stub, interpreter::Bytecode::kLast, STUB, |
| 152 isolate, zone) {} |
| 152 | 153 |
| 154 CompilationInfo::CompilationInfo(interpreter::Bytecode bytecode, |
| 155 Isolate* isolate, Zone* zone) |
| 156 : CompilationInfo(nullptr, nullptr, bytecode, BYTECODE_HANDLER, isolate, |
| 157 zone) {} |
| 153 | 158 |
| 154 CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub, | 159 CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub, |
| 155 Mode mode, Isolate* isolate, Zone* zone) | 160 interpreter::Bytecode bytecode, Mode mode, |
| 161 Isolate* isolate, Zone* zone) |
| 156 : parse_info_(parse_info), | 162 : parse_info_(parse_info), |
| 157 isolate_(isolate), | 163 isolate_(isolate), |
| 158 flags_(0), | 164 flags_(0), |
| 159 code_stub_(code_stub), | 165 code_stub_(code_stub), |
| 166 bytecode_(bytecode), |
| 160 mode_(mode), | 167 mode_(mode), |
| 161 osr_ast_id_(BailoutId::None()), | 168 osr_ast_id_(BailoutId::None()), |
| 162 zone_(zone), | 169 zone_(zone), |
| 163 deferred_handles_(nullptr), | 170 deferred_handles_(nullptr), |
| 164 dependencies_(isolate, zone), | 171 dependencies_(isolate, zone), |
| 165 bailout_reason_(kNoReason), | 172 bailout_reason_(kNoReason), |
| 166 prologue_offset_(Code::kPrologueOffsetNotSet), | 173 prologue_offset_(Code::kPrologueOffsetNotSet), |
| 167 no_frame_ranges_(isolate->cpu_profiler()->is_profiling() | 174 no_frame_ranges_(isolate->cpu_profiler()->is_profiling() |
| 168 ? new List<OffsetRange>(2) | 175 ? new List<OffsetRange>(2) |
| 169 : nullptr), | 176 : nullptr), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 216 |
| 210 bool CompilationInfo::is_this_defined() const { return !IsStub(); } | 217 bool CompilationInfo::is_this_defined() const { return !IsStub(); } |
| 211 | 218 |
| 212 | 219 |
| 213 int CompilationInfo::num_heap_slots() const { | 220 int CompilationInfo::num_heap_slots() const { |
| 214 return has_scope() ? scope()->num_heap_slots() : 0; | 221 return has_scope() ? scope()->num_heap_slots() : 0; |
| 215 } | 222 } |
| 216 | 223 |
| 217 | 224 |
| 218 Code::Flags CompilationInfo::flags() const { | 225 Code::Flags CompilationInfo::flags() const { |
| 219 return code_stub() != nullptr | 226 if (IsBytecodeHandler()) { |
| 220 ? Code::ComputeFlags( | 227 return Code::ComputeFlags(Code::STUB); |
| 221 code_stub()->GetCodeKind(), code_stub()->GetICState(), | 228 } else if (code_stub() != nullptr) { |
| 222 code_stub()->GetExtraICState(), code_stub()->GetStubType()) | 229 return Code::ComputeFlags( |
| 223 : Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); | 230 code_stub()->GetCodeKind(), code_stub()->GetICState(), |
| 231 code_stub()->GetExtraICState(), code_stub()->GetStubType()); |
| 232 } else { |
| 233 return Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); |
| 234 } |
| 224 } | 235 } |
| 225 | 236 |
| 226 | 237 |
| 227 // Primitive functions are unlikely to be picked up by the stack-walking | 238 // Primitive functions are unlikely to be picked up by the stack-walking |
| 228 // profiler, so they trigger their own optimization when they're called | 239 // profiler, so they trigger their own optimization when they're called |
| 229 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. | 240 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. |
| 230 bool CompilationInfo::ShouldSelfOptimize() { | 241 bool CompilationInfo::ShouldSelfOptimize() { |
| 231 return FLAG_crankshaft && | 242 return FLAG_crankshaft && |
| 232 !(literal()->flags() & AstProperties::kDontSelfOptimize) && | 243 !(literal()->flags() & AstProperties::kDontSelfOptimize) && |
| 233 !literal()->dont_optimize() && | 244 !literal()->dont_optimize() && |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 | 1738 |
| 1728 | 1739 |
| 1729 #if DEBUG | 1740 #if DEBUG |
| 1730 void CompilationInfo::PrintAstForTesting() { | 1741 void CompilationInfo::PrintAstForTesting() { |
| 1731 PrintF("--- Source from AST ---\n%s\n", | 1742 PrintF("--- Source from AST ---\n%s\n", |
| 1732 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); | 1743 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); |
| 1733 } | 1744 } |
| 1734 #endif | 1745 #endif |
| 1735 } // namespace internal | 1746 } // namespace internal |
| 1736 } // namespace v8 | 1747 } // namespace v8 |
| OLD | NEW |