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 #include "src/frames.h" | 7 #include "src/frames.h" |
8 #include "src/interpreter/bytecode-traits.h" | 8 #include "src/interpreter/bytecode-traits.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 bytecode == Bytecode::kJumpIfTrueConstant || | 175 bytecode == Bytecode::kJumpIfTrueConstant || |
176 bytecode == Bytecode::kJumpIfFalseConstant || | 176 bytecode == Bytecode::kJumpIfFalseConstant || |
177 bytecode == Bytecode::kJumpIfToBooleanTrueConstant || | 177 bytecode == Bytecode::kJumpIfToBooleanTrueConstant || |
178 bytecode == Bytecode::kJumpIfToBooleanFalseConstant || | 178 bytecode == Bytecode::kJumpIfToBooleanFalseConstant || |
179 bytecode == Bytecode::kJumpIfNull || | 179 bytecode == Bytecode::kJumpIfNull || |
180 bytecode == Bytecode::kJumpIfUndefinedConstant; | 180 bytecode == Bytecode::kJumpIfUndefinedConstant; |
181 } | 181 } |
182 | 182 |
183 | 183 |
184 // static | 184 // static |
185 uint16_t Bytecodes::ShortOperandFromBytes(const uint8_t* bytes) { | |
186 return *reinterpret_cast<const uint16_t*>(bytes); | |
187 } | |
188 | |
189 | |
190 // static | |
191 void Bytecodes::ShortOperandToBytes(uint16_t operand, uint8_t* bytes_out) { | |
192 *reinterpret_cast<uint16_t*>(bytes_out) = operand; | |
193 } | |
194 | |
195 | |
196 // static | |
197 std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start, | 185 std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start, |
198 int parameter_count) { | 186 int parameter_count) { |
199 Vector<char> buf = Vector<char>::New(50); | 187 Vector<char> buf = Vector<char>::New(50); |
200 | 188 |
201 Bytecode bytecode = Bytecodes::FromByte(bytecode_start[0]); | 189 Bytecode bytecode = Bytecodes::FromByte(bytecode_start[0]); |
202 int bytecode_size = Bytecodes::Size(bytecode); | 190 int bytecode_size = Bytecodes::Size(bytecode); |
203 | 191 |
204 for (int i = 0; i < bytecode_size; i++) { | 192 for (int i = 0; i < bytecode_size; i++) { |
205 SNPrintF(buf, "%02x ", bytecode_start[i]); | 193 SNPrintF(buf, "%02x ", bytecode_start[i]); |
206 os << buf.start(); | 194 os << buf.start(); |
(...skipping 11 matching lines...) Expand all Loading... |
218 const uint8_t* operand_start = | 206 const uint8_t* operand_start = |
219 &bytecode_start[GetOperandOffset(bytecode, i)]; | 207 &bytecode_start[GetOperandOffset(bytecode, i)]; |
220 switch (op_type) { | 208 switch (op_type) { |
221 case interpreter::OperandType::kCount8: | 209 case interpreter::OperandType::kCount8: |
222 os << "#" << static_cast<unsigned int>(*operand_start); | 210 os << "#" << static_cast<unsigned int>(*operand_start); |
223 break; | 211 break; |
224 case interpreter::OperandType::kIdx8: | 212 case interpreter::OperandType::kIdx8: |
225 os << "[" << static_cast<unsigned int>(*operand_start) << "]"; | 213 os << "[" << static_cast<unsigned int>(*operand_start) << "]"; |
226 break; | 214 break; |
227 case interpreter::OperandType::kIdx16: { | 215 case interpreter::OperandType::kIdx16: { |
228 os << "[" << Bytecodes::ShortOperandFromBytes(operand_start) << "]"; | 216 os << "[" << ReadUnalignedUInt16(operand_start) << "]"; |
229 break; | 217 break; |
230 } | 218 } |
231 case interpreter::OperandType::kImm8: | 219 case interpreter::OperandType::kImm8: |
232 os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); | 220 os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); |
233 break; | 221 break; |
234 case interpreter::OperandType::kReg8: { | 222 case interpreter::OperandType::kReg8: { |
235 Register reg = Register::FromOperand(*operand_start); | 223 Register reg = Register::FromOperand(*operand_start); |
236 if (reg.is_function_context()) { | 224 if (reg.is_function_context()) { |
237 os << "<context>"; | 225 os << "<context>"; |
238 } else if (reg.is_function_closure()) { | 226 } else if (reg.is_function_closure()) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 339 } |
352 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { | 340 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { |
353 return false; | 341 return false; |
354 } | 342 } |
355 return true; | 343 return true; |
356 } | 344 } |
357 | 345 |
358 } // namespace interpreter | 346 } // namespace interpreter |
359 } // namespace internal | 347 } // namespace internal |
360 } // namespace v8 | 348 } // namespace v8 |
OLD | NEW |