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) | 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) | 24 #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) | 25 #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) | 26 #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) | 27 #define CASE_I8x16_OP(name, str) CASE_OP(I8x16##name, "i8x16." 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) |
| 30 #define CASE_S8x16_OP(name, str) CASE_OP(S8x16##name, "s8x16." str) |
29 #define CASE_INT_OP(name, str) CASE_I32_OP(name, str) CASE_I64_OP(name, str) | 31 #define CASE_INT_OP(name, str) CASE_I32_OP(name, str) CASE_I64_OP(name, str) |
30 #define CASE_FLOAT_OP(name, str) CASE_F32_OP(name, str) CASE_F64_OP(name, str) | 32 #define CASE_FLOAT_OP(name, str) CASE_F32_OP(name, str) CASE_F64_OP(name, str) |
31 #define CASE_ALL_OP(name, str) CASE_FLOAT_OP(name, str) CASE_INT_OP(name, str) | 33 #define CASE_ALL_OP(name, str) CASE_FLOAT_OP(name, str) CASE_INT_OP(name, str) |
32 #define CASE_SIMD_OP(name, str) \ | 34 #define CASE_SIMD_OP(name, str) \ |
33 CASE_F32x4_OP(name, str) CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) \ | 35 CASE_F32x4_OP(name, str) CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) \ |
34 CASE_I8x16_OP(name, str) | 36 CASE_I8x16_OP(name, str) |
35 #define CASE_SIMDI_OP(name, str) \ | 37 #define CASE_SIMDI_OP(name, str) \ |
36 CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) CASE_I8x16_OP(name, str) | 38 CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) CASE_I8x16_OP(name, str) |
37 #define CASE_SIGN_OP(TYPE, name, str) \ | 39 #define CASE_SIGN_OP(TYPE, name, str) \ |
38 CASE_##TYPE##_OP(name##S, str "_s") CASE_##TYPE##_OP(name##U, str "_u") | 40 CASE_##TYPE##_OP(name##S, str "_s") CASE_##TYPE##_OP(name##U, str "_u") |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 CASE_F32x4_OP(SqrtApprox, "sqrt_approx") | 178 CASE_F32x4_OP(SqrtApprox, "sqrt_approx") |
177 CASE_F32x4_OP(Min, "min") | 179 CASE_F32x4_OP(Min, "min") |
178 CASE_F32x4_OP(Max, "max") | 180 CASE_F32x4_OP(Max, "max") |
179 CASE_F32x4_OP(MinNum, "min_num") | 181 CASE_F32x4_OP(MinNum, "min_num") |
180 CASE_F32x4_OP(MaxNum, "max_num") | 182 CASE_F32x4_OP(MaxNum, "max_num") |
181 CASE_F32x4_OP(Lt, "lt") | 183 CASE_F32x4_OP(Lt, "lt") |
182 CASE_F32x4_OP(Le, "le") | 184 CASE_F32x4_OP(Le, "le") |
183 CASE_F32x4_OP(Gt, "gt") | 185 CASE_F32x4_OP(Gt, "gt") |
184 CASE_F32x4_OP(Ge, "ge") | 186 CASE_F32x4_OP(Ge, "ge") |
185 CASE_CONVERT_OP(Convert, F32x4, I32x4, "i32", "convert") | 187 CASE_CONVERT_OP(Convert, F32x4, I32x4, "i32", "convert") |
| 188 CASE_CONVERT_OP(Convert, I32x4, F32x4, "f32", "convert") |
186 CASE_F32x4_OP(ExtractLane, "extract_lane") | 189 CASE_F32x4_OP(ExtractLane, "extract_lane") |
187 CASE_F32x4_OP(ReplaceLane, "replace_lane") | 190 CASE_F32x4_OP(ReplaceLane, "replace_lane") |
188 CASE_SIMDI_OP(ExtractLane, "extract_lane") | 191 CASE_SIMDI_OP(ExtractLane, "extract_lane") |
189 CASE_SIMDI_OP(ReplaceLane, "replace_lane") | 192 CASE_SIMDI_OP(ReplaceLane, "replace_lane") |
190 CASE_SIGN_OP(SIMDI, Min, "min") | 193 CASE_SIGN_OP(SIMDI, Min, "min") |
191 CASE_SIGN_OP(SIMDI, Max, "max") | 194 CASE_SIGN_OP(SIMDI, Max, "max") |
192 CASE_SIGN_OP(SIMDI, Lt, "lt") | 195 CASE_SIGN_OP(SIMDI, Lt, "lt") |
193 CASE_SIGN_OP(SIMDI, Le, "le") | 196 CASE_SIGN_OP(SIMDI, Le, "le") |
194 CASE_SIGN_OP(SIMDI, Gt, "gt") | 197 CASE_SIGN_OP(SIMDI, Gt, "gt") |
195 CASE_SIGN_OP(SIMDI, Ge, "ge") | 198 CASE_SIGN_OP(SIMDI, Ge, "ge") |
196 CASE_SIGN_OP(SIMDI, Shr, "shr") | 199 CASE_SIGN_OP(SIMDI, Shr, "shr") |
197 CASE_SIMDI_OP(Shl, "shl") | 200 CASE_SIMDI_OP(Shl, "shl") |
198 CASE_SIMDI_OP(Swizzle, "swizzle") | 201 CASE_SIGN_OP(I16x8, AddSaturate, "add_saturate") |
199 CASE_SIMDI_OP(Shuffle, "shuffle") | 202 CASE_SIGN_OP(I8x16, AddSaturate, "add_saturate") |
200 CASE_SIMDI_OP(Select, "select") | 203 CASE_SIGN_OP(I16x8, SubSaturate, "sub_saturate") |
201 CASE_S128_OP(Ior, "or") | 204 CASE_SIGN_OP(I8x16, SubSaturate, "sub_saturate") |
| 205 CASE_S128_OP(Or, "or") |
202 CASE_S128_OP(Xor, "xor") | 206 CASE_S128_OP(Xor, "xor") |
203 CASE_S128_OP(And, "and") | 207 CASE_S128_OP(And, "and") |
204 CASE_S128_OP(Not, "not") | 208 CASE_S128_OP(Not, "not") |
205 CASE_S32x4_OP(Select, "select") | 209 CASE_S32x4_OP(Select, "select") |
206 CASE_S32x4_OP(Swizzle, "swizzle") | 210 CASE_S32x4_OP(Swizzle, "swizzle") |
207 CASE_S32x4_OP(Shuffle, "shuffle") | 211 CASE_S32x4_OP(Shuffle, "shuffle") |
208 CASE_CONVERT_OP(Convert, I32x4, F32x4, "f32", "convert") | 212 CASE_S16x8_OP(Select, "select") |
209 CASE_SIGN_OP(I16x8, AddSaturate, "add_saturate") | 213 CASE_S16x8_OP(Swizzle, "swizzle") |
210 CASE_SIGN_OP(I8x16, AddSaturate, "add_saturate") | 214 CASE_S16x8_OP(Shuffle, "shuffle") |
211 CASE_SIGN_OP(I16x8, SubSaturate, "sub_saturate") | 215 CASE_S8x16_OP(Select, "select") |
212 CASE_SIGN_OP(I8x16, SubSaturate, "sub_saturate") | 216 CASE_S8x16_OP(Swizzle, "swizzle") |
| 217 CASE_S8x16_OP(Shuffle, "shuffle") |
213 | 218 |
214 // Atomic operations. | 219 // Atomic operations. |
215 CASE_L32_OP(AtomicAdd, "atomic_add") | 220 CASE_L32_OP(AtomicAdd, "atomic_add") |
216 CASE_L32_OP(AtomicAnd, "atomic_and") | 221 CASE_L32_OP(AtomicAnd, "atomic_and") |
217 CASE_L32_OP(AtomicCompareExchange, "atomic_cmpxchng") | 222 CASE_L32_OP(AtomicCompareExchange, "atomic_cmpxchng") |
218 CASE_L32_OP(AtomicExchange, "atomic_xchng") | 223 CASE_L32_OP(AtomicExchange, "atomic_xchng") |
219 CASE_L32_OP(AtomicOr, "atomic_or") | 224 CASE_L32_OP(AtomicOr, "atomic_or") |
220 CASE_L32_OP(AtomicSub, "atomic_sub") | 225 CASE_L32_OP(AtomicSub, "atomic_sub") |
221 CASE_L32_OP(AtomicXor, "atomic_xor") | 226 CASE_L32_OP(AtomicXor, "atomic_xor") |
222 | 227 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 return MessageTemplate::kNone; | 366 return MessageTemplate::kNone; |
362 } | 367 } |
363 } | 368 } |
364 | 369 |
365 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { | 370 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { |
366 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); | 371 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); |
367 } | 372 } |
368 } // namespace wasm | 373 } // namespace wasm |
369 } // namespace internal | 374 } // namespace internal |
370 } // namespace v8 | 375 } // namespace v8 |
OLD | NEW |