Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: test/cctest/interpreter/bytecode-expectations-printer.cc

Issue 1723223002: [Interpreter] Textual representation for runtime function IDs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CallJSRuntime != CallRuntime, DCHECK op type, Runtime::k prefix. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <iostream> 7 #include <iostream>
8 #include <vector> 8 #include <vector>
9 9
10 #include "include/libplatform/libplatform.h" 10 #include "include/libplatform/libplatform.h"
11 #include "include/v8.h" 11 #include "include/v8.h"
12 12
13 #include "src/base/logging.h" 13 #include "src/base/logging.h"
14 #include "src/base/smart-pointers.h" 14 #include "src/base/smart-pointers.h"
15 #include "src/compiler.h" 15 #include "src/compiler.h"
16 #include "src/runtime/runtime.h"
16 17
17 #include "src/interpreter/bytecode-array-iterator.h" 18 #include "src/interpreter/bytecode-array-iterator.h"
18 #include "src/interpreter/bytecode-generator.h" 19 #include "src/interpreter/bytecode-generator.h"
19 #include "src/interpreter/bytecodes.h" 20 #include "src/interpreter/bytecodes.h"
20 #include "src/interpreter/interpreter.h" 21 #include "src/interpreter/interpreter.h"
21 22
22 namespace v8 { 23 namespace v8 {
23 namespace internal { 24 namespace internal {
24 namespace interpreter { 25 namespace interpreter {
25 26
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 case '\\': 88 case '\\':
88 stream << "\\\\"; 89 stream << "\\\\";
89 break; 90 break;
90 default: 91 default:
91 stream << c; 92 stream << c;
92 break; 93 break;
93 } 94 }
94 } 95 }
95 } 96 }
96 97
98 namespace {
99 i::Runtime::FunctionId IndexToFunctionId(int index) {
100 return static_cast<i::Runtime::FunctionId>(index);
101 }
102 } // namespace
103
97 void BytecodeExpectationsPrinter::PrintBytecodeOperand( 104 void BytecodeExpectationsPrinter::PrintBytecodeOperand(
98 std::ostream& stream, const BytecodeArrayIterator& bytecode_iter, 105 std::ostream& stream, const BytecodeArrayIterator& bytecode_iter,
99 const Bytecode& bytecode, int op_index, int parameter_count) const { 106 const Bytecode& bytecode, int op_index, int parameter_count) const {
100 OperandType op_type = Bytecodes::GetOperandType(bytecode, op_index); 107 OperandType op_type = Bytecodes::GetOperandType(bytecode, op_index);
101 OperandSize op_size = Bytecodes::GetOperandSize(bytecode, op_index); 108 OperandSize op_size = Bytecodes::GetOperandSize(bytecode, op_index);
102 109
103 const char* size_tag; 110 const char* size_tag;
104 switch (op_size) { 111 switch (op_size) {
105 case OperandSize::kByte: 112 case OperandSize::kByte:
106 size_tag = "8"; 113 size_tag = "8";
(...skipping 22 matching lines...) Expand all
129 stream << "(this)"; 136 stream << "(this)";
130 } else { 137 } else {
131 stream << "(arg" << (parameter_index - 1) << ')'; 138 stream << "(arg" << (parameter_index - 1) << ')';
132 } 139 }
133 } else { 140 } else {
134 stream << '(' << register_value.index() << ')'; 141 stream << '(' << register_value.index() << ')';
135 } 142 }
136 } else { 143 } else {
137 stream << 'U' << size_tag << '('; 144 stream << 'U' << size_tag << '(';
138 145
139 if (Bytecodes::IsImmediateOperandType(op_type)) { 146 if (op_index == 0 && Bytecodes::IsCallRuntime(bytecode)) {
147 DCHECK_EQ(op_type, OperandType::kIdx16);
148 int operand = bytecode_iter.GetIndexOperand(op_index);
149 stream << "Runtime::k"
150 << i::Runtime::FunctionForId(IndexToFunctionId(operand))->name;
151 } else if (Bytecodes::IsImmediateOperandType(op_type)) {
140 // We need a cast, otherwise the result is printed as char. 152 // We need a cast, otherwise the result is printed as char.
141 stream << static_cast<int>(bytecode_iter.GetImmediateOperand(op_index)); 153 stream << static_cast<int>(bytecode_iter.GetImmediateOperand(op_index));
142 } else if (Bytecodes::IsRegisterCountOperandType(op_type)) { 154 } else if (Bytecodes::IsRegisterCountOperandType(op_type)) {
143 stream << bytecode_iter.GetRegisterCountOperand(op_index); 155 stream << bytecode_iter.GetRegisterCountOperand(op_index);
144 } else if (Bytecodes::IsIndexOperandType(op_type)) { 156 } else if (Bytecodes::IsIndexOperandType(op_type)) {
145 stream << bytecode_iter.GetIndexOperand(op_index); 157 stream << bytecode_iter.GetIndexOperand(op_index);
146 } else { 158 } else {
147 UNREACHABLE(); 159 UNREACHABLE();
148 } 160 }
149 161
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 304
293 stream << "---\n"; 305 stream << "---\n";
294 PrintCodeSnippet(stream, snippet); 306 PrintCodeSnippet(stream, snippet);
295 PrintBytecodeArray(stream, bytecode_array); 307 PrintBytecodeArray(stream, bytecode_array);
296 stream << '\n'; 308 stream << '\n';
297 } 309 }
298 310
299 } // namespace interpreter 311 } // namespace interpreter
300 } // namespace internal 312 } // namespace internal
301 } // namespace v8 313 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698