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/runtime/runtime.h" | 7 #include "src/runtime/runtime.h" |
8 #include "src/signature.h" | 8 #include "src/signature.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace wasm { | 12 namespace wasm { |
13 | 13 |
14 typedef Signature<ValueType> FunctionSig; | 14 typedef Signature<ValueType> FunctionSig; |
15 | 15 |
16 #define CASE_OP(name, str) \ | 16 #define CASE_OP(name, str) \ |
17 case kExpr##name: \ | 17 case kExpr##name: \ |
18 return str; | 18 return str; |
19 #define CASE_I32_OP(name, str) CASE_OP(I32##name, "i32." str) | 19 #define CASE_I32_OP(name, str) CASE_OP(I32##name, "i32." str) |
20 #define CASE_I64_OP(name, str) CASE_OP(I64##name, "i64." str) | 20 #define CASE_I64_OP(name, str) CASE_OP(I64##name, "i64." str) |
21 #define CASE_F32_OP(name, str) CASE_OP(F32##name, "f32." str) | 21 #define CASE_F32_OP(name, str) CASE_OP(F32##name, "f32." str) |
22 #define CASE_F64_OP(name, str) CASE_OP(F64##name, "f64." str) | 22 #define CASE_F64_OP(name, str) CASE_OP(F64##name, "f64." str) |
23 #define CASE_S128_OP(name, str) CASE_OP(S128##name, "s128." str) | |
24 #define CASE_F32x4_OP(name, str) CASE_OP(F32x4##name, "f32x4." str) | 23 #define CASE_F32x4_OP(name, str) CASE_OP(F32x4##name, "f32x4." str) |
25 #define CASE_I32x4_OP(name, str) CASE_OP(I32x4##name, "i32x4." str) | 24 #define CASE_I32x4_OP(name, str) CASE_OP(I32x4##name, "i32x4." str) |
26 #define CASE_I16x8_OP(name, str) CASE_OP(I16x8##name, "i16x8." str) | 25 #define CASE_I16x8_OP(name, str) CASE_OP(I16x8##name, "i16x8." str) |
27 #define CASE_I8x16_OP(name, str) CASE_OP(I8x16##name, "i8x16." str) | 26 #define CASE_I8x16_OP(name, str) CASE_OP(I8x16##name, "i8x16." str) |
| 27 #define CASE_S128_OP(name, str) CASE_OP(S128##name, "s128." str) |
28 #define CASE_S32x4_OP(name, str) CASE_OP(S32x4##name, "s32x4." str) | 28 #define CASE_S32x4_OP(name, str) CASE_OP(S32x4##name, "s32x4." str) |
29 #define CASE_S16x8_OP(name, str) CASE_OP(S16x8##name, "s16x8." str) | 29 #define CASE_S16x8_OP(name, str) CASE_OP(S16x8##name, "s16x8." str) |
30 #define CASE_S8x16_OP(name, str) CASE_OP(S8x16##name, "s8x16." str) | 30 #define CASE_S8x16_OP(name, str) CASE_OP(S8x16##name, "s8x16." str) |
| 31 #define CASE_S1x4_OP(name, str) CASE_OP(S1x4##name, "s1x4." str) |
| 32 #define CASE_S1x8_OP(name, str) CASE_OP(S1x8##name, "s1x8." str) |
| 33 #define CASE_S1x16_OP(name, str) CASE_OP(S1x16##name, "s1x16." str) |
31 #define CASE_INT_OP(name, str) CASE_I32_OP(name, str) CASE_I64_OP(name, str) | 34 #define CASE_INT_OP(name, str) CASE_I32_OP(name, str) CASE_I64_OP(name, str) |
32 #define CASE_FLOAT_OP(name, str) CASE_F32_OP(name, str) CASE_F64_OP(name, str) | 35 #define CASE_FLOAT_OP(name, str) CASE_F32_OP(name, str) CASE_F64_OP(name, str) |
33 #define CASE_ALL_OP(name, str) CASE_FLOAT_OP(name, str) CASE_INT_OP(name, str) | 36 #define CASE_ALL_OP(name, str) CASE_FLOAT_OP(name, str) CASE_INT_OP(name, str) |
34 #define CASE_SIMD_OP(name, str) \ | 37 #define CASE_SIMD_OP(name, str) \ |
35 CASE_F32x4_OP(name, str) CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) \ | 38 CASE_F32x4_OP(name, str) CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) \ |
36 CASE_I8x16_OP(name, str) | 39 CASE_I8x16_OP(name, str) |
37 #define CASE_SIMDI_OP(name, str) \ | 40 #define CASE_SIMDI_OP(name, str) \ |
38 CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) CASE_I8x16_OP(name, str) | 41 CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) CASE_I8x16_OP(name, str) |
39 #define CASE_SIGN_OP(TYPE, name, str) \ | 42 #define CASE_SIGN_OP(TYPE, name, str) \ |
40 CASE_##TYPE##_OP(name##S, str "_s") CASE_##TYPE##_OP(name##U, str "_u") | 43 CASE_##TYPE##_OP(name##S, str "_s") CASE_##TYPE##_OP(name##U, str "_u") |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 CASE_SIGN_OP(SIMDI, Lt, "lt") | 198 CASE_SIGN_OP(SIMDI, Lt, "lt") |
196 CASE_SIGN_OP(SIMDI, Le, "le") | 199 CASE_SIGN_OP(SIMDI, Le, "le") |
197 CASE_SIGN_OP(SIMDI, Gt, "gt") | 200 CASE_SIGN_OP(SIMDI, Gt, "gt") |
198 CASE_SIGN_OP(SIMDI, Ge, "ge") | 201 CASE_SIGN_OP(SIMDI, Ge, "ge") |
199 CASE_SIGN_OP(SIMDI, Shr, "shr") | 202 CASE_SIGN_OP(SIMDI, Shr, "shr") |
200 CASE_SIMDI_OP(Shl, "shl") | 203 CASE_SIMDI_OP(Shl, "shl") |
201 CASE_SIGN_OP(I16x8, AddSaturate, "add_saturate") | 204 CASE_SIGN_OP(I16x8, AddSaturate, "add_saturate") |
202 CASE_SIGN_OP(I8x16, AddSaturate, "add_saturate") | 205 CASE_SIGN_OP(I8x16, AddSaturate, "add_saturate") |
203 CASE_SIGN_OP(I16x8, SubSaturate, "sub_saturate") | 206 CASE_SIGN_OP(I16x8, SubSaturate, "sub_saturate") |
204 CASE_SIGN_OP(I8x16, SubSaturate, "sub_saturate") | 207 CASE_SIGN_OP(I8x16, SubSaturate, "sub_saturate") |
| 208 CASE_S128_OP(And, "and") |
205 CASE_S128_OP(Or, "or") | 209 CASE_S128_OP(Or, "or") |
206 CASE_S128_OP(Xor, "xor") | 210 CASE_S128_OP(Xor, "xor") |
207 CASE_S128_OP(And, "and") | |
208 CASE_S128_OP(Not, "not") | 211 CASE_S128_OP(Not, "not") |
209 CASE_S32x4_OP(Select, "select") | 212 CASE_S32x4_OP(Select, "select") |
210 CASE_S32x4_OP(Swizzle, "swizzle") | 213 CASE_S32x4_OP(Swizzle, "swizzle") |
211 CASE_S32x4_OP(Shuffle, "shuffle") | 214 CASE_S32x4_OP(Shuffle, "shuffle") |
212 CASE_S16x8_OP(Select, "select") | 215 CASE_S16x8_OP(Select, "select") |
213 CASE_S16x8_OP(Swizzle, "swizzle") | 216 CASE_S16x8_OP(Swizzle, "swizzle") |
214 CASE_S16x8_OP(Shuffle, "shuffle") | 217 CASE_S16x8_OP(Shuffle, "shuffle") |
215 CASE_S8x16_OP(Select, "select") | 218 CASE_S8x16_OP(Select, "select") |
216 CASE_S8x16_OP(Swizzle, "swizzle") | 219 CASE_S8x16_OP(Swizzle, "swizzle") |
217 CASE_S8x16_OP(Shuffle, "shuffle") | 220 CASE_S8x16_OP(Shuffle, "shuffle") |
| 221 CASE_S1x4_OP(And, "and") |
| 222 CASE_S1x4_OP(Or, "or") |
| 223 CASE_S1x4_OP(Xor, "xor") |
| 224 CASE_S1x4_OP(Not, "not") |
| 225 CASE_S1x4_OP(AnyTrue, "any_true") |
| 226 CASE_S1x4_OP(AllTrue, "all_true") |
| 227 CASE_S1x8_OP(And, "and") |
| 228 CASE_S1x8_OP(Or, "or") |
| 229 CASE_S1x8_OP(Xor, "xor") |
| 230 CASE_S1x8_OP(Not, "not") |
| 231 CASE_S1x8_OP(AnyTrue, "any_true") |
| 232 CASE_S1x8_OP(AllTrue, "all_true") |
| 233 CASE_S1x16_OP(And, "and") |
| 234 CASE_S1x16_OP(Or, "or") |
| 235 CASE_S1x16_OP(Xor, "xor") |
| 236 CASE_S1x16_OP(Not, "not") |
| 237 CASE_S1x16_OP(AnyTrue, "any_true") |
| 238 CASE_S1x16_OP(AllTrue, "all_true") |
218 | 239 |
219 // Atomic operations. | 240 // Atomic operations. |
220 CASE_L32_OP(AtomicAdd, "atomic_add") | 241 CASE_L32_OP(AtomicAdd, "atomic_add") |
221 CASE_L32_OP(AtomicAnd, "atomic_and") | 242 CASE_L32_OP(AtomicAnd, "atomic_and") |
222 CASE_L32_OP(AtomicCompareExchange, "atomic_cmpxchng") | 243 CASE_L32_OP(AtomicCompareExchange, "atomic_cmpxchng") |
223 CASE_L32_OP(AtomicExchange, "atomic_xchng") | 244 CASE_L32_OP(AtomicExchange, "atomic_xchng") |
224 CASE_L32_OP(AtomicOr, "atomic_or") | 245 CASE_L32_OP(AtomicOr, "atomic_or") |
225 CASE_L32_OP(AtomicSub, "atomic_sub") | 246 CASE_L32_OP(AtomicSub, "atomic_sub") |
226 CASE_L32_OP(AtomicXor, "atomic_xor") | 247 CASE_L32_OP(AtomicXor, "atomic_xor") |
227 | 248 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 return MessageTemplate::kNone; | 387 return MessageTemplate::kNone; |
367 } | 388 } |
368 } | 389 } |
369 | 390 |
370 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { | 391 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { |
371 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); | 392 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); |
372 } | 393 } |
373 } // namespace wasm | 394 } // namespace wasm |
374 } // namespace internal | 395 } // namespace internal |
375 } // namespace v8 | 396 } // namespace v8 |
OLD | NEW |