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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 DCHECK(dependencies()->IsEmpty()); | 168 DCHECK(dependencies()->IsEmpty()); |
169 #endif // DEBUG | 169 #endif // DEBUG |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 int CompilationInfo::num_parameters() const { | 173 int CompilationInfo::num_parameters() const { |
174 return has_scope() ? scope()->num_parameters() : parameter_count_; | 174 return has_scope() ? scope()->num_parameters() : parameter_count_; |
175 } | 175 } |
176 | 176 |
177 | 177 |
| 178 int CompilationInfo::num_parameters_including_this() const { |
| 179 return num_parameters() + (is_this_defined() ? 1 : 0); |
| 180 } |
| 181 |
| 182 |
| 183 bool CompilationInfo::is_this_defined() const { return !IsStub(); } |
| 184 |
| 185 |
178 int CompilationInfo::num_heap_slots() const { | 186 int CompilationInfo::num_heap_slots() const { |
179 return has_scope() ? scope()->num_heap_slots() : 0; | 187 return has_scope() ? scope()->num_heap_slots() : 0; |
180 } | 188 } |
181 | 189 |
182 | 190 |
183 Code::Flags CompilationInfo::flags() const { | 191 Code::Flags CompilationInfo::flags() const { |
184 return code_stub() != nullptr | 192 return code_stub() != nullptr |
185 ? Code::ComputeFlags( | 193 ? Code::ComputeFlags( |
186 code_stub()->GetCodeKind(), code_stub()->GetICState(), | 194 code_stub()->GetCodeKind(), code_stub()->GetICState(), |
187 code_stub()->GetExtraICState(), code_stub()->GetStubType()) | 195 code_stub()->GetExtraICState(), code_stub()->GetStubType()) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 274 } |
267 | 275 |
268 | 276 |
269 void CompilationInfo::LogDeoptCallPosition(int pc_offset, int inlining_id) { | 277 void CompilationInfo::LogDeoptCallPosition(int pc_offset, int inlining_id) { |
270 if (!track_positions_ || IsStub()) return; | 278 if (!track_positions_ || IsStub()) return; |
271 DCHECK_LT(static_cast<size_t>(inlining_id), inlined_function_infos_.size()); | 279 DCHECK_LT(static_cast<size_t>(inlining_id), inlined_function_infos_.size()); |
272 inlined_function_infos_.at(inlining_id).deopt_pc_offsets.push_back(pc_offset); | 280 inlined_function_infos_.at(inlining_id).deopt_pc_offsets.push_back(pc_offset); |
273 } | 281 } |
274 | 282 |
275 | 283 |
| 284 Handle<Code> CompilationInfo::GenerateCodeStub() { |
| 285 // Run a "mini pipeline", extracted from compiler.cc. |
| 286 CHECK(Parser::ParseStatic(parse_info())); |
| 287 CHECK(Compiler::Analyze(parse_info())); |
| 288 return compiler::Pipeline(this).GenerateCode(); |
| 289 } |
| 290 |
| 291 |
276 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 292 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
277 public: | 293 public: |
278 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 294 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
279 : HOptimizedGraphBuilder(info) { | 295 : HOptimizedGraphBuilder(info) { |
280 } | 296 } |
281 | 297 |
282 #define DEF_VISIT(type) \ | 298 #define DEF_VISIT(type) \ |
283 void Visit##type(type* node) override { \ | 299 void Visit##type(type* node) override { \ |
284 SourcePosition old_position = SourcePosition::Unknown(); \ | 300 SourcePosition old_position = SourcePosition::Unknown(); \ |
285 if (node->position() != RelocInfo::kNoPosition) { \ | 301 if (node->position() != RelocInfo::kNoPosition) { \ |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 } | 1566 } |
1551 | 1567 |
1552 | 1568 |
1553 #if DEBUG | 1569 #if DEBUG |
1554 void CompilationInfo::PrintAstForTesting() { | 1570 void CompilationInfo::PrintAstForTesting() { |
1555 PrintF("--- Source from AST ---\n%s\n", | 1571 PrintF("--- Source from AST ---\n%s\n", |
1556 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1572 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
1557 } | 1573 } |
1558 #endif | 1574 #endif |
1559 } } // namespace v8::internal | 1575 } } // namespace v8::internal |
OLD | NEW |