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/bytecodes.h" | 5 #include "src/interpreter/bytecodes.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace interpreter { | 9 namespace interpreter { |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // static | 46 // static |
47 Bytecode Bytecodes::FromByte(uint8_t value) { | 47 Bytecode Bytecodes::FromByte(uint8_t value) { |
48 Bytecode bytecode = static_cast<Bytecode>(value); | 48 Bytecode bytecode = static_cast<Bytecode>(value); |
49 DCHECK(bytecode <= Bytecode::kLast); | 49 DCHECK(bytecode <= Bytecode::kLast); |
50 return bytecode; | 50 return bytecode; |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 // static | 54 // static |
55 const int Bytecodes::NumberOfOperands(Bytecode bytecode) { | 55 int Bytecodes::NumberOfOperands(Bytecode bytecode) { |
56 DCHECK(bytecode <= Bytecode::kLast); | 56 DCHECK(bytecode <= Bytecode::kLast); |
57 int count; | 57 int count; |
58 uint8_t row = ToByte(bytecode); | 58 uint8_t row = ToByte(bytecode); |
59 for (count = 0; count < kMaxOperands; count++) { | 59 for (count = 0; count < kMaxOperands; count++) { |
60 if (kBytecodeTable[row][count] == OperandType::kNone) { | 60 if (kBytecodeTable[row][count] == OperandType::kNone) { |
61 break; | 61 break; |
62 } | 62 } |
63 } | 63 } |
64 return count; | 64 return count; |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 // static | 68 // static |
69 const OperandType Bytecodes::GetOperandType(Bytecode bytecode, int i) { | 69 OperandType Bytecodes::GetOperandType(Bytecode bytecode, int i) { |
70 DCHECK(bytecode <= Bytecode::kLast && i < NumberOfOperands(bytecode)); | 70 DCHECK(bytecode <= Bytecode::kLast && i < NumberOfOperands(bytecode)); |
71 return kBytecodeTable[ToByte(bytecode)][i]; | 71 return kBytecodeTable[ToByte(bytecode)][i]; |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 // static | 75 // static |
76 const int Bytecodes::Size(Bytecode bytecode) { | 76 int Bytecodes::Size(Bytecode bytecode) { |
77 return 1 + NumberOfOperands(bytecode); | 77 return 1 + NumberOfOperands(bytecode); |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 // static | 81 // static |
82 const int Bytecodes::MaximumNumberOfOperands() { return kMaxOperands; } | 82 int Bytecodes::MaximumNumberOfOperands() { return kMaxOperands; } |
83 | 83 |
84 | 84 |
85 // static | 85 // static |
86 const int Bytecodes::MaximumSize() { return 1 + kMaxOperands; } | 86 int Bytecodes::MaximumSize() { return 1 + kMaxOperands; } |
87 | 87 |
88 | 88 |
89 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { | 89 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { |
90 return os << Bytecodes::ToString(bytecode); | 90 return os << Bytecodes::ToString(bytecode); |
91 } | 91 } |
92 | 92 |
93 } // namespace interpreter | 93 } // namespace interpreter |
94 } // namespace internal | 94 } // namespace internal |
95 } // namespace v8 | 95 } // namespace v8 |
OLD | NEW |