OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/instruction.h" | 5 #include "src/compiler/instruction.h" |
6 | 6 |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 InstructionSequence::StateId state_id) { | 409 InstructionSequence::StateId state_id) { |
410 return deoptimization_entries_[state_id.ToInt()]; | 410 return deoptimization_entries_[state_id.ToInt()]; |
411 } | 411 } |
412 | 412 |
413 | 413 |
414 int InstructionSequence::GetFrameStateDescriptorCount() { | 414 int InstructionSequence::GetFrameStateDescriptorCount() { |
415 return static_cast<int>(deoptimization_entries_.size()); | 415 return static_cast<int>(deoptimization_entries_.size()); |
416 } | 416 } |
417 | 417 |
418 | 418 |
| 419 FrameStateDescriptor::FrameStateDescriptor( |
| 420 Zone* zone, const FrameStateCallInfo& state_info, size_t parameters_count, |
| 421 size_t locals_count, size_t stack_count, FrameStateDescriptor* outer_state) |
| 422 : type_(state_info.type()), |
| 423 bailout_id_(state_info.bailout_id()), |
| 424 frame_state_combine_(state_info.state_combine()), |
| 425 parameters_count_(parameters_count), |
| 426 locals_count_(locals_count), |
| 427 stack_count_(stack_count), |
| 428 types_(zone), |
| 429 outer_state_(outer_state), |
| 430 jsfunction_(state_info.jsfunction()) {} |
| 431 |
| 432 size_t FrameStateDescriptor::GetSize(OutputFrameStateCombine combine) const { |
| 433 size_t size = parameters_count() + locals_count() + stack_count() + |
| 434 (HasContext() ? 1 : 0); |
| 435 switch (combine.kind()) { |
| 436 case OutputFrameStateCombine::kPushOutput: |
| 437 size += combine.GetPushCount(); |
| 438 break; |
| 439 case OutputFrameStateCombine::kPokeAt: |
| 440 break; |
| 441 } |
| 442 return size; |
| 443 } |
| 444 |
| 445 |
| 446 size_t FrameStateDescriptor::GetTotalSize() const { |
| 447 size_t total_size = 0; |
| 448 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 449 iter = iter->outer_state_) { |
| 450 total_size += iter->GetSize(); |
| 451 } |
| 452 return total_size; |
| 453 } |
| 454 |
| 455 |
| 456 size_t FrameStateDescriptor::GetFrameCount() const { |
| 457 size_t count = 0; |
| 458 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 459 iter = iter->outer_state_) { |
| 460 ++count; |
| 461 } |
| 462 return count; |
| 463 } |
| 464 |
| 465 |
| 466 size_t FrameStateDescriptor::GetJSFrameCount() const { |
| 467 size_t count = 0; |
| 468 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 469 iter = iter->outer_state_) { |
| 470 if (iter->type_ == JS_FRAME) { |
| 471 ++count; |
| 472 } |
| 473 } |
| 474 return count; |
| 475 } |
| 476 |
| 477 |
| 478 MachineType FrameStateDescriptor::GetType(size_t index) const { |
| 479 return types_[index]; |
| 480 } |
| 481 |
| 482 |
| 483 void FrameStateDescriptor::SetTypes(ZoneVector<MachineType>* types) { |
| 484 DCHECK(types_.empty()); |
| 485 types->swap(types_); |
| 486 } |
| 487 |
| 488 |
419 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code) { | 489 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code) { |
420 for (size_t i = 0; i < code.immediates_.size(); ++i) { | 490 for (size_t i = 0; i < code.immediates_.size(); ++i) { |
421 Constant constant = code.immediates_[i]; | 491 Constant constant = code.immediates_[i]; |
422 os << "IMM#" << i << ": " << constant << "\n"; | 492 os << "IMM#" << i << ": " << constant << "\n"; |
423 } | 493 } |
424 int i = 0; | 494 int i = 0; |
425 for (ConstantMap::const_iterator it = code.constants_.begin(); | 495 for (ConstantMap::const_iterator it = code.constants_.begin(); |
426 it != code.constants_.end(); ++i, ++it) { | 496 it != code.constants_.end(); ++i, ++it) { |
427 os << "CST#" << i << ": v" << it->first << " = " << it->second << "\n"; | 497 os << "CST#" << i << ": v" << it->first << " = " << it->second << "\n"; |
428 } | 498 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 os << " B" << (*iter)->id(); | 546 os << " B" << (*iter)->id(); |
477 } | 547 } |
478 os << "\n"; | 548 os << "\n"; |
479 } | 549 } |
480 return os; | 550 return os; |
481 } | 551 } |
482 | 552 |
483 } // namespace compiler | 553 } // namespace compiler |
484 } // namespace internal | 554 } // namespace internal |
485 } // namespace v8 | 555 } // namespace v8 |
OLD | NEW |