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 { |
(...skipping 20 matching lines...) Expand all Loading... |
31 case kExpr##name: \ | 31 case kExpr##name: \ |
32 return #name; | 32 return #name; |
33 FOREACH_OPCODE(DECLARE_NAME_CASE) | 33 FOREACH_OPCODE(DECLARE_NAME_CASE) |
34 #undef DECLARE_NAME_CASE | 34 #undef DECLARE_NAME_CASE |
35 default: | 35 default: |
36 break; | 36 break; |
37 } | 37 } |
38 return "Unknown"; | 38 return "Unknown"; |
39 } | 39 } |
40 | 40 |
| 41 bool WasmOpcodes::IsPrefixOpcode(WasmOpcode opcode) { |
| 42 switch (opcode) { |
| 43 #define CHECK_PREFIX(name, opcode) \ |
| 44 case k##name##Prefix: \ |
| 45 return true; |
| 46 FOREACH_PREFIX(CHECK_PREFIX) |
| 47 #undef CHECK_PREFIX |
| 48 default: |
| 49 return false; |
| 50 } |
| 51 } |
| 52 |
41 std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) { | 53 std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) { |
42 if (sig.return_count() == 0) os << "v"; | 54 if (sig.return_count() == 0) os << "v"; |
43 for (size_t i = 0; i < sig.return_count(); ++i) { | 55 for (size_t i = 0; i < sig.return_count(); ++i) { |
44 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i)); | 56 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i)); |
45 } | 57 } |
46 os << "_"; | 58 os << "_"; |
47 if (sig.parameter_count() == 0) os << "v"; | 59 if (sig.parameter_count() == 0) os << "v"; |
48 for (size_t i = 0; i < sig.parameter_count(); ++i) { | 60 for (size_t i = 0; i < sig.parameter_count(); ++i) { |
49 os << WasmOpcodes::ShortNameOf(sig.GetParam(i)); | 61 os << WasmOpcodes::ShortNameOf(sig.GetParam(i)); |
50 } | 62 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return MessageTemplate::kNone; | 148 return MessageTemplate::kNone; |
137 } | 149 } |
138 } | 150 } |
139 | 151 |
140 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { | 152 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { |
141 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); | 153 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); |
142 } | 154 } |
143 } // namespace wasm | 155 } // namespace wasm |
144 } // namespace internal | 156 } // namespace internal |
145 } // namespace v8 | 157 } // namespace v8 |
OLD | NEW |