| 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/wasm/wasm-opcodes.h" | 5 #include "src/wasm/wasm-opcodes.h" |
| 6 #include "src/messages.h" | 6 #include "src/messages.h" |
| 7 #include "src/signature.h" | 7 #include "src/signature.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| 11 namespace wasm { | 11 namespace wasm { |
| 12 | 12 |
| 13 typedef Signature<LocalType> FunctionSig; | 13 typedef Signature<LocalType> FunctionSig; |
| 14 | 14 |
| 15 const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) { | 15 const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) { |
| 16 switch (opcode) { | 16 switch (opcode) { |
| 17 #define DECLARE_NAME_CASE(name, opcode, sig) \ | 17 #define DECLARE_NAME_CASE(name, opcode, sig) \ |
| 18 case kExpr##name: \ | 18 case kExpr##name: \ |
| 19 return "Expr" #name; | 19 return "Expr" #name; |
| 20 FOREACH_OPCODE(DECLARE_NAME_CASE) | 20 FOREACH_OPCODE(DECLARE_NAME_CASE) |
| 21 #undef DECLARE_NAME_CASE | 21 #undef DECLARE_NAME_CASE |
| 22 default: | 22 default: |
| 23 break; | 23 break; |
| 24 } | 24 } |
| 25 return "Unknown"; | 25 return "Unknown"; |
| 26 } | 26 } |
| 27 | 27 |
| 28 const char* WasmOpcodes::ShortOpcodeName(WasmOpcode opcode) { |
| 29 switch (opcode) { |
| 30 #define DECLARE_NAME_CASE(name, opcode, sig) \ |
| 31 case kExpr##name: \ |
| 32 return #name; |
| 33 FOREACH_OPCODE(DECLARE_NAME_CASE) |
| 34 #undef DECLARE_NAME_CASE |
| 35 default: |
| 36 break; |
| 37 } |
| 38 return "Unknown"; |
| 39 } |
| 28 | 40 |
| 29 std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) { | 41 std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) { |
| 30 if (sig.return_count() == 0) os << "v"; | 42 if (sig.return_count() == 0) os << "v"; |
| 31 for (size_t i = 0; i < sig.return_count(); i++) { | 43 for (size_t i = 0; i < sig.return_count(); i++) { |
| 32 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i)); | 44 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i)); |
| 33 } | 45 } |
| 34 os << "_"; | 46 os << "_"; |
| 35 if (sig.parameter_count() == 0) os << "v"; | 47 if (sig.parameter_count() == 0) os << "v"; |
| 36 for (size_t i = 0; i < sig.parameter_count(); i++) { | 48 for (size_t i = 0; i < sig.parameter_count(); i++) { |
| 37 os << WasmOpcodes::ShortNameOf(sig.GetParam(i)); | 49 os << WasmOpcodes::ShortNameOf(sig.GetParam(i)); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return MessageTemplate::kNone; | 170 return MessageTemplate::kNone; |
| 159 } | 171 } |
| 160 } | 172 } |
| 161 | 173 |
| 162 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { | 174 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { |
| 163 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); | 175 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); |
| 164 } | 176 } |
| 165 } // namespace wasm | 177 } // namespace wasm |
| 166 } // namespace internal | 178 } // namespace internal |
| 167 } // namespace v8 | 179 } // namespace v8 |
| OLD | NEW |