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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 InstructionSequence::StateId state_id) { | 438 InstructionSequence::StateId state_id) { |
439 return deoptimization_entries_[state_id.ToInt()]; | 439 return deoptimization_entries_[state_id.ToInt()]; |
440 } | 440 } |
441 | 441 |
442 | 442 |
443 int InstructionSequence::GetFrameStateDescriptorCount() { | 443 int InstructionSequence::GetFrameStateDescriptorCount() { |
444 return static_cast<int>(deoptimization_entries_.size()); | 444 return static_cast<int>(deoptimization_entries_.size()); |
445 } | 445 } |
446 | 446 |
447 | 447 |
| 448 FrameStateDescriptor::FrameStateDescriptor( |
| 449 Zone* zone, const FrameStateCallInfo& state_info, size_t parameters_count, |
| 450 size_t locals_count, size_t stack_count, FrameStateDescriptor* outer_state) |
| 451 : type_(state_info.type()), |
| 452 bailout_id_(state_info.bailout_id()), |
| 453 frame_state_combine_(state_info.state_combine()), |
| 454 parameters_count_(parameters_count), |
| 455 locals_count_(locals_count), |
| 456 stack_count_(stack_count), |
| 457 types_(zone), |
| 458 outer_state_(outer_state), |
| 459 jsfunction_(state_info.jsfunction()) { |
| 460 types_.resize(GetSize(), kMachNone); |
| 461 } |
| 462 |
| 463 size_t FrameStateDescriptor::GetSize(OutputFrameStateCombine combine) const { |
| 464 size_t size = parameters_count() + locals_count() + stack_count() + |
| 465 (HasContext() ? 1 : 0); |
| 466 switch (combine.kind()) { |
| 467 case OutputFrameStateCombine::kPushOutput: |
| 468 size += combine.GetPushCount(); |
| 469 break; |
| 470 case OutputFrameStateCombine::kPokeAt: |
| 471 break; |
| 472 } |
| 473 return size; |
| 474 } |
| 475 |
| 476 |
| 477 size_t FrameStateDescriptor::GetTotalSize() const { |
| 478 size_t total_size = 0; |
| 479 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 480 iter = iter->outer_state_) { |
| 481 total_size += iter->GetSize(); |
| 482 } |
| 483 return total_size; |
| 484 } |
| 485 |
| 486 |
| 487 size_t FrameStateDescriptor::GetFrameCount() const { |
| 488 size_t count = 0; |
| 489 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 490 iter = iter->outer_state_) { |
| 491 ++count; |
| 492 } |
| 493 return count; |
| 494 } |
| 495 |
| 496 |
| 497 size_t FrameStateDescriptor::GetJSFrameCount() const { |
| 498 size_t count = 0; |
| 499 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 500 iter = iter->outer_state_) { |
| 501 if (iter->type_ == JS_FRAME) { |
| 502 ++count; |
| 503 } |
| 504 } |
| 505 return count; |
| 506 } |
| 507 |
| 508 |
| 509 MachineType FrameStateDescriptor::GetType(size_t index) const { |
| 510 return types_[index]; |
| 511 } |
| 512 |
| 513 |
| 514 void FrameStateDescriptor::SetType(size_t index, MachineType type) { |
| 515 DCHECK(index < GetSize()); |
| 516 types_[index] = type; |
| 517 } |
| 518 |
| 519 |
448 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code) { | 520 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code) { |
449 for (size_t i = 0; i < code.immediates_.size(); ++i) { | 521 for (size_t i = 0; i < code.immediates_.size(); ++i) { |
450 Constant constant = code.immediates_[i]; | 522 Constant constant = code.immediates_[i]; |
451 os << "IMM#" << i << ": " << constant << "\n"; | 523 os << "IMM#" << i << ": " << constant << "\n"; |
452 } | 524 } |
453 int i = 0; | 525 int i = 0; |
454 for (ConstantMap::const_iterator it = code.constants_.begin(); | 526 for (ConstantMap::const_iterator it = code.constants_.begin(); |
455 it != code.constants_.end(); ++i, ++it) { | 527 it != code.constants_.end(); ++i, ++it) { |
456 os << "CST#" << i << ": v" << it->first << " = " << it->second << "\n"; | 528 os << "CST#" << i << ": v" << it->first << " = " << it->second << "\n"; |
457 } | 529 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 os << " B" << (*iter)->id(); | 577 os << " B" << (*iter)->id(); |
506 } | 578 } |
507 os << "\n"; | 579 os << "\n"; |
508 } | 580 } |
509 return os; | 581 return os; |
510 } | 582 } |
511 | 583 |
512 } // namespace compiler | 584 } // namespace compiler |
513 } // namespace internal | 585 } // namespace internal |
514 } // namespace v8 | 586 } // namespace v8 |
OLD | NEW |