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