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

Side by Side Diff: src/wasm/wasm-opcodes.cc

Issue 1830663002: [wasm] Binary 11: AST changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Renumber opcodes and remove tests added elsewhere Created 4 years, 8 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
OLDNEW
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/wasm/wasm-opcodes.h" 5 #include "src/wasm/wasm-opcodes.h"
6 #include "src/signature.h" 6 #include "src/signature.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace wasm { 10 namespace wasm {
11 11
12 typedef Signature<LocalType> FunctionSig; 12 typedef Signature<LocalType> FunctionSig;
13 13
14 const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) { 14 const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) {
15 switch (opcode) { 15 switch (opcode) {
16 #define DECLARE_NAME_CASE(name, opcode, sig) \ 16 #define DECLARE_NAME_CASE(name, opcode, sig) \
17 case kExpr##name: \ 17 case kExpr##name: \
18 return "Expr" #name; 18 return "Expr" #name;
19 FOREACH_OPCODE(DECLARE_NAME_CASE) 19 FOREACH_OPCODE(DECLARE_NAME_CASE)
20 #undef DECLARE_NAME_CASE 20 #undef DECLARE_NAME_CASE
21 default: 21 default:
22 break; 22 break;
23 } 23 }
24 return "Unknown"; 24 return "Unknown";
25 } 25 }
26 26
27 const char* WasmOpcodes::ShortOpcodeName(WasmOpcode opcode) {
28 switch (opcode) {
29 #define DECLARE_NAME_CASE(name, opcode, sig) \
30 case kExpr##name: \
31 return #name;
32 FOREACH_OPCODE(DECLARE_NAME_CASE)
33 #undef DECLARE_NAME_CASE
34 default:
35 break;
36 }
37 return "Unknown";
38 }
27 39
28 std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) { 40 std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) {
29 if (sig.return_count() == 0) os << "v"; 41 if (sig.return_count() == 0) os << "v";
30 for (size_t i = 0; i < sig.return_count(); i++) { 42 for (size_t i = 0; i < sig.return_count(); i++) {
31 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i)); 43 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i));
32 } 44 }
33 os << "_"; 45 os << "_";
34 if (sig.parameter_count() == 0) os << "v"; 46 if (sig.parameter_count() == 0) os << "v";
35 for (size_t i = 0; i < sig.parameter_count(); i++) { 47 for (size_t i = 0; i < sig.parameter_count(); i++) {
36 os << WasmOpcodes::ShortNameOf(sig.GetParam(i)); 48 os << WasmOpcodes::ShortNameOf(sig.GetParam(i));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 default: 153 default:
142 return true; 154 return true;
143 } 155 }
144 #else 156 #else
145 return true; 157 return true;
146 #endif 158 #endif
147 } 159 }
148 } // namespace wasm 160 } // namespace wasm
149 } // namespace internal 161 } // namespace internal
150 } // namespace v8 162 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698