| OLD | NEW | 
|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-pipeline.h" | 5 #include "src/interpreter/bytecode-pipeline.h" | 
| 6 | 6 | 
| 7 #include <iomanip> | 7 #include <iomanip> | 
| 8 #include "src/source-position-table.h" | 8 #include "src/source-position-table.h" | 
| 9 | 9 | 
| 10 namespace v8 { | 10 namespace v8 { | 
| 11 namespace internal { | 11 namespace internal { | 
| 12 namespace interpreter { | 12 namespace interpreter { | 
| 13 | 13 | 
| 14 BytecodeNode::BytecodeNode(Bytecode bytecode) { |  | 
| 15   DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0); |  | 
| 16   bytecode_ = bytecode; |  | 
| 17 } |  | 
| 18 |  | 
| 19 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0) { |  | 
| 20   DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1); |  | 
| 21   bytecode_ = bytecode; |  | 
| 22   operands_[0] = operand0; |  | 
| 23 } |  | 
| 24 |  | 
| 25 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0, |  | 
| 26                            uint32_t operand1) { |  | 
| 27   DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 2); |  | 
| 28   bytecode_ = bytecode; |  | 
| 29   operands_[0] = operand0; |  | 
| 30   operands_[1] = operand1; |  | 
| 31 } |  | 
| 32 |  | 
| 33 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0, |  | 
| 34                            uint32_t operand1, uint32_t operand2) { |  | 
| 35   DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3); |  | 
| 36   bytecode_ = bytecode; |  | 
| 37   operands_[0] = operand0; |  | 
| 38   operands_[1] = operand1; |  | 
| 39   operands_[2] = operand2; |  | 
| 40 } |  | 
| 41 |  | 
| 42 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0, |  | 
| 43                            uint32_t operand1, uint32_t operand2, |  | 
| 44                            uint32_t operand3) { |  | 
| 45   DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 4); |  | 
| 46   bytecode_ = bytecode; |  | 
| 47   operands_[0] = operand0; |  | 
| 48   operands_[1] = operand1; |  | 
| 49   operands_[2] = operand2; |  | 
| 50   operands_[3] = operand3; |  | 
| 51 } |  | 
| 52 |  | 
| 53 BytecodeNode::BytecodeNode(const BytecodeNode& other) { | 14 BytecodeNode::BytecodeNode(const BytecodeNode& other) { | 
| 54   memcpy(this, &other, sizeof(other)); | 15   memcpy(this, &other, sizeof(other)); | 
| 55 } | 16 } | 
| 56 | 17 | 
| 57 BytecodeNode& BytecodeNode::operator=(const BytecodeNode& other) { | 18 BytecodeNode& BytecodeNode::operator=(const BytecodeNode& other) { | 
| 58   memcpy(this, &other, sizeof(other)); | 19   memcpy(this, &other, sizeof(other)); | 
| 59   return *this; | 20   return *this; | 
| 60 } | 21 } | 
| 61 | 22 | 
| 62 void BytecodeNode::Clone(const BytecodeNode* const other) { | 23 void BytecodeNode::Clone(const BytecodeNode* const other) { | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 76 | 37 | 
| 77   if (source_info_.is_valid()) { | 38   if (source_info_.is_valid()) { | 
| 78     os << ' ' << source_info_; | 39     os << ' ' << source_info_; | 
| 79   } | 40   } | 
| 80   os << '\n'; | 41   os << '\n'; | 
| 81 #else | 42 #else | 
| 82   os << static_cast<const void*>(this); | 43   os << static_cast<const void*>(this); | 
| 83 #endif  // DEBUG | 44 #endif  // DEBUG | 
| 84 } | 45 } | 
| 85 | 46 | 
| 86 void BytecodeNode::Transform(Bytecode new_bytecode, uint32_t extra_operand) { |  | 
| 87   DCHECK_EQ(Bytecodes::NumberOfOperands(new_bytecode), |  | 
| 88             Bytecodes::NumberOfOperands(bytecode()) + 1); |  | 
| 89   DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 1 || |  | 
| 90          Bytecodes::GetOperandType(new_bytecode, 0) == |  | 
| 91              Bytecodes::GetOperandType(bytecode(), 0)); |  | 
| 92   DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 2 || |  | 
| 93          Bytecodes::GetOperandType(new_bytecode, 1) == |  | 
| 94              Bytecodes::GetOperandType(bytecode(), 1)); |  | 
| 95   DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 3 || |  | 
| 96          Bytecodes::GetOperandType(new_bytecode, 2) == |  | 
| 97              Bytecodes::GetOperandType(bytecode(), 2)); |  | 
| 98   DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 4); |  | 
| 99   operands_[operand_count()] = extra_operand; |  | 
| 100   bytecode_ = new_bytecode; |  | 
| 101 } |  | 
| 102 |  | 
| 103 bool BytecodeNode::operator==(const BytecodeNode& other) const { | 47 bool BytecodeNode::operator==(const BytecodeNode& other) const { | 
| 104   if (this == &other) { | 48   if (this == &other) { | 
| 105     return true; | 49     return true; | 
| 106   } else if (this->bytecode() != other.bytecode() || | 50   } else if (this->bytecode() != other.bytecode() || | 
| 107              this->source_info() != other.source_info()) { | 51              this->source_info() != other.source_info()) { | 
| 108     return false; | 52     return false; | 
| 109   } else { | 53   } else { | 
| 110     for (int i = 0; i < this->operand_count(); ++i) { | 54     for (int i = 0; i < this->operand_count(); ++i) { | 
| 111       if (this->operand(i) != other.operand(i)) { | 55       if (this->operand(i) != other.operand(i)) { | 
| 112         return false; | 56         return false; | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 125 } | 69 } | 
| 126 | 70 | 
| 127 std::ostream& operator<<(std::ostream& os, const BytecodeNode& node) { | 71 std::ostream& operator<<(std::ostream& os, const BytecodeNode& node) { | 
| 128   node.Print(os); | 72   node.Print(os); | 
| 129   return os; | 73   return os; | 
| 130 } | 74 } | 
| 131 | 75 | 
| 132 }  // namespace interpreter | 76 }  // namespace interpreter | 
| 133 }  // namespace internal | 77 }  // namespace internal | 
| 134 }  // namespace v8 | 78 }  // namespace v8 | 
| OLD | NEW | 
|---|