| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "test/cctest/interpreter/bytecode-expectations-printer.h" | 5 #include "test/cctest/interpreter/bytecode-expectations-printer.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 #include <iostream> | 8 #include <iostream> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "include/libplatform/libplatform.h" | 11 #include "include/libplatform/libplatform.h" |
| 12 #include "include/v8.h" | 12 #include "include/v8.h" |
| 13 | 13 |
| 14 #include "src/base/logging.h" | 14 #include "src/base/logging.h" |
| 15 #include "src/base/smart-pointers.h" | 15 #include "src/base/smart-pointers.h" |
| 16 #include "src/compiler.h" | 16 #include "src/compiler.h" |
| 17 #include "src/runtime/runtime.h" | 17 #include "src/runtime/runtime.h" |
| 18 | 18 |
| 19 #include "src/interpreter/bytecode-array-iterator.h" | 19 #include "src/interpreter/bytecode-array-iterator.h" |
| 20 #include "src/interpreter/bytecode-generator.h" | 20 #include "src/interpreter/bytecode-generator.h" |
| 21 #include "src/interpreter/bytecodes.h" | 21 #include "src/interpreter/bytecodes.h" |
| 22 #include "src/interpreter/interpreter-intrinsics.h" | |
| 23 #include "src/interpreter/interpreter.h" | 22 #include "src/interpreter/interpreter.h" |
| 24 #include "src/interpreter/source-position-table.h" | 23 #include "src/interpreter/source-position-table.h" |
| 25 | 24 |
| 26 namespace v8 { | 25 namespace v8 { |
| 27 namespace internal { | 26 namespace internal { |
| 28 namespace interpreter { | 27 namespace interpreter { |
| 29 | 28 |
| 30 // static | 29 // static |
| 31 const char* const BytecodeExpectationsPrinter::kDefaultTopFunctionName = | 30 const char* const BytecodeExpectationsPrinter::kDefaultTopFunctionName = |
| 32 "__genbckexp_wrapper__"; | 31 "__genbckexp_wrapper__"; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 case '\\': | 91 case '\\': |
| 93 stream << "\\\\"; | 92 stream << "\\\\"; |
| 94 break; | 93 break; |
| 95 default: | 94 default: |
| 96 stream << c; | 95 stream << c; |
| 97 break; | 96 break; |
| 98 } | 97 } |
| 99 } | 98 } |
| 100 } | 99 } |
| 101 | 100 |
| 101 namespace { |
| 102 i::Runtime::FunctionId IndexToFunctionId(uint32_t index) { |
| 103 return static_cast<i::Runtime::FunctionId>(index); |
| 104 } |
| 105 } // namespace |
| 106 |
| 102 void BytecodeExpectationsPrinter::PrintBytecodeOperand( | 107 void BytecodeExpectationsPrinter::PrintBytecodeOperand( |
| 103 std::ostream& stream, const BytecodeArrayIterator& bytecode_iterator, | 108 std::ostream& stream, const BytecodeArrayIterator& bytecode_iterator, |
| 104 const Bytecode& bytecode, int op_index, int parameter_count) const { | 109 const Bytecode& bytecode, int op_index, int parameter_count) const { |
| 105 OperandType op_type = Bytecodes::GetOperandType(bytecode, op_index); | 110 OperandType op_type = Bytecodes::GetOperandType(bytecode, op_index); |
| 106 OperandSize op_size = Bytecodes::GetOperandSize( | 111 OperandSize op_size = Bytecodes::GetOperandSize( |
| 107 bytecode, op_index, bytecode_iterator.current_operand_scale()); | 112 bytecode, op_index, bytecode_iterator.current_operand_scale()); |
| 108 | 113 |
| 109 const char* size_tag; | 114 const char* size_tag; |
| 110 switch (op_size) { | 115 switch (op_size) { |
| 111 case OperandSize::kByte: | 116 case OperandSize::kByte: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 case OperandType::kIdx: | 157 case OperandType::kIdx: |
| 153 stream << bytecode_iterator.GetIndexOperand(op_index); | 158 stream << bytecode_iterator.GetIndexOperand(op_index); |
| 154 break; | 159 break; |
| 155 case OperandType::kImm: | 160 case OperandType::kImm: |
| 156 stream << bytecode_iterator.GetImmediateOperand(op_index); | 161 stream << bytecode_iterator.GetImmediateOperand(op_index); |
| 157 break; | 162 break; |
| 158 case OperandType::kRegCount: | 163 case OperandType::kRegCount: |
| 159 stream << bytecode_iterator.GetRegisterCountOperand(op_index); | 164 stream << bytecode_iterator.GetRegisterCountOperand(op_index); |
| 160 break; | 165 break; |
| 161 case OperandType::kRuntimeId: { | 166 case OperandType::kRuntimeId: { |
| 162 Runtime::FunctionId id = | 167 uint32_t operand = bytecode_iterator.GetRuntimeIdOperand(op_index); |
| 163 bytecode_iterator.GetRuntimeIdOperand(op_index); | 168 stream << "Runtime::k" |
| 164 stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; | 169 << i::Runtime::FunctionForId(IndexToFunctionId(operand))->name; |
| 165 break; | |
| 166 } | |
| 167 case OperandType::kIntrinsicId: { | |
| 168 Runtime::FunctionId id = | |
| 169 bytecode_iterator.GetIntrinsicIdOperand(op_index); | |
| 170 stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; | |
| 171 break; | 170 break; |
| 172 } | 171 } |
| 173 default: | 172 default: |
| 174 UNREACHABLE(); | 173 UNREACHABLE(); |
| 175 } | 174 } |
| 176 | 175 |
| 177 stream << ')'; | 176 stream << ')'; |
| 178 } | 177 } |
| 179 } | 178 } |
| 180 | 179 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 345 |
| 347 stream << "---\n"; | 346 stream << "---\n"; |
| 348 PrintCodeSnippet(stream, snippet); | 347 PrintCodeSnippet(stream, snippet); |
| 349 PrintBytecodeArray(stream, bytecode_array); | 348 PrintBytecodeArray(stream, bytecode_array); |
| 350 stream << '\n'; | 349 stream << '\n'; |
| 351 } | 350 } |
| 352 | 351 |
| 353 } // namespace interpreter | 352 } // namespace interpreter |
| 354 } // namespace internal | 353 } // namespace internal |
| 355 } // namespace v8 | 354 } // namespace v8 |
| OLD | NEW |