| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 | 94 |
| 95 // TODO(titzer): pull WASM_64 up to a common header. | 95 // TODO(titzer): pull WASM_64 up to a common header. |
| 96 #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64 | 96 #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64 |
| 97 #define WASM_64 1 | 97 #define WASM_64 1 |
| 98 #else | 98 #else |
| 99 #define WASM_64 0 | 99 #define WASM_64 0 |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 | |
| 103 bool WasmOpcodes::IsSupported(WasmOpcode opcode) { | |
| 104 #if !WASM_64 | |
| 105 switch (opcode) { | |
| 106 // Opcodes not supported on 32-bit platforms. | |
| 107 case kExprI64Add: | |
| 108 case kExprI64Sub: | |
| 109 case kExprI64Mul: | |
| 110 case kExprI64DivS: | |
| 111 case kExprI64DivU: | |
| 112 case kExprI64RemS: | |
| 113 case kExprI64RemU: | |
| 114 case kExprI64And: | |
| 115 case kExprI64Ior: | |
| 116 case kExprI64Xor: | |
| 117 case kExprI64Shl: | |
| 118 case kExprI64ShrU: | |
| 119 case kExprI64ShrS: | |
| 120 case kExprI64Ror: | |
| 121 case kExprI64Rol: | |
| 122 case kExprI64Eq: | |
| 123 case kExprI64Ne: | |
| 124 case kExprI64LtS: | |
| 125 case kExprI64LeS: | |
| 126 case kExprI64LtU: | |
| 127 case kExprI64LeU: | |
| 128 case kExprI64GtS: | |
| 129 case kExprI64GeS: | |
| 130 case kExprI64GtU: | |
| 131 case kExprI64GeU: | |
| 132 | |
| 133 case kExprI32ConvertI64: | |
| 134 case kExprI64SConvertI32: | |
| 135 case kExprI64UConvertI32: | |
| 136 | |
| 137 case kExprF64ReinterpretI64: | |
| 138 case kExprI64ReinterpretF64: | |
| 139 | |
| 140 case kExprI64Clz: | |
| 141 case kExprI64Ctz: | |
| 142 case kExprI64Popcnt: | |
| 143 | |
| 144 case kExprF32SConvertI64: | |
| 145 case kExprF32UConvertI64: | |
| 146 case kExprF64SConvertI64: | |
| 147 case kExprF64UConvertI64: | |
| 148 case kExprI64SConvertF32: | |
| 149 case kExprI64SConvertF64: | |
| 150 case kExprI64UConvertF32: | |
| 151 case kExprI64UConvertF64: | |
| 152 | |
| 153 return false; | |
| 154 default: | |
| 155 return true; | |
| 156 } | |
| 157 #else | |
| 158 return true; | |
| 159 #endif | |
| 160 } | |
| 161 | |
| 162 int WasmOpcodes::TrapReasonToMessageId(TrapReason reason) { | 102 int WasmOpcodes::TrapReasonToMessageId(TrapReason reason) { |
| 163 switch (reason) { | 103 switch (reason) { |
| 164 #define TRAPREASON_TO_MESSAGE(name) \ | 104 #define TRAPREASON_TO_MESSAGE(name) \ |
| 165 case k##name: \ | 105 case k##name: \ |
| 166 return MessageTemplate::kWasm##name; | 106 return MessageTemplate::kWasm##name; |
| 167 FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE) | 107 FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE) |
| 168 #undef TRAPREASON_TO_MESSAGE | 108 #undef TRAPREASON_TO_MESSAGE |
| 169 default: | 109 default: |
| 170 return MessageTemplate::kNone; | 110 return MessageTemplate::kNone; |
| 171 } | 111 } |
| 172 } | 112 } |
| 173 | 113 |
| 174 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { | 114 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { |
| 175 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); | 115 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); |
| 176 } | 116 } |
| 177 } // namespace wasm | 117 } // namespace wasm |
| 178 } // namespace internal | 118 } // namespace internal |
| 179 } // namespace v8 | 119 } // namespace v8 |
| OLD | NEW |