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 #ifndef V8_WASM_OPCODES_H_ | 5 #ifndef V8_WASM_OPCODES_H_ |
6 #define V8_WASM_OPCODES_H_ | 6 #define V8_WASM_OPCODES_H_ |
7 | 7 |
8 #include "src/globals.h" | 8 #include "src/globals.h" |
9 #include "src/machine-type.h" | 9 #include "src/machine-type.h" |
10 #include "src/signature.h" | 10 #include "src/signature.h" |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 V(S128Ior, 0xe577, s_ss) \ | 393 V(S128Ior, 0xe577, s_ss) \ |
394 V(S128Xor, 0xe578, s_ss) \ | 394 V(S128Xor, 0xe578, s_ss) \ |
395 V(S128Not, 0xe579, s_s) | 395 V(S128Not, 0xe579, s_s) |
396 | 396 |
397 #define FOREACH_SIMD_1_OPERAND_OPCODE(V) \ | 397 #define FOREACH_SIMD_1_OPERAND_OPCODE(V) \ |
398 V(F32x4ExtractLane, 0xe501, _) \ | 398 V(F32x4ExtractLane, 0xe501, _) \ |
399 V(I32x4ExtractLane, 0xe51c, _) \ | 399 V(I32x4ExtractLane, 0xe51c, _) \ |
400 V(I16x8ExtractLane, 0xe539, _) \ | 400 V(I16x8ExtractLane, 0xe539, _) \ |
401 V(I8x16ExtractLane, 0xe558, _) | 401 V(I8x16ExtractLane, 0xe558, _) |
402 | 402 |
| 403 #define FOREACH_ATOMIC_OPCODE(V) \ |
| 404 V(I32AtomicAdd8S, 0xe601, i_ii) \ |
| 405 V(I32AtomicAdd8U, 0xe602, i_ii) \ |
| 406 V(I32AtomicAdd16S, 0xe603, i_ii) \ |
| 407 V(I32AtomicAdd16U, 0xe604, i_ii) \ |
| 408 V(I32AtomicAdd32, 0xe605, i_ii) \ |
| 409 V(I32AtomicAnd8S, 0xe606, i_ii) \ |
| 410 V(I32AtomicAnd8U, 0xe607, i_ii) \ |
| 411 V(I32AtomicAnd16S, 0xe608, i_ii) \ |
| 412 V(I32AtomicAnd16U, 0xe609, i_ii) \ |
| 413 V(I32AtomicAnd32, 0xe60a, i_ii) \ |
| 414 V(I32AtomicCompareExchange8S, 0xe60b, i_ii) \ |
| 415 V(I32AtomicCompareExchange8U, 0xe60c, i_ii) \ |
| 416 V(I32AtomicCompareExchange16S, 0xe60d, i_ii) \ |
| 417 V(I32AtomicCompareExchange16U, 0xe60e, i_ii) \ |
| 418 V(I32AtomicCompareExchange32, 0xe60f, i_ii) \ |
| 419 V(I32AtomicExchange8S, 0xe610, i_ii) \ |
| 420 V(I32AtomicExchange8U, 0xe611, i_ii) \ |
| 421 V(I32AtomicExchange16S, 0xe612, i_ii) \ |
| 422 V(I32AtomicExchange16U, 0xe613, i_ii) \ |
| 423 V(I32AtomicExchange32, 0xe614, i_ii) \ |
| 424 V(I32AtomicOr8S, 0xe615, i_ii) \ |
| 425 V(I32AtomicOr8U, 0xe616, i_ii) \ |
| 426 V(I32AtomicOr16S, 0xe617, i_ii) \ |
| 427 V(I32AtomicOr16U, 0xe618, i_ii) \ |
| 428 V(I32AtomicOr32, 0xe619, i_ii) \ |
| 429 V(I32AtomicSub8S, 0xe61a, i_ii) \ |
| 430 V(I32AtomicSub8U, 0xe61b, i_ii) \ |
| 431 V(I32AtomicSub16S, 0xe61c, i_ii) \ |
| 432 V(I32AtomicSub16U, 0xe61d, i_ii) \ |
| 433 V(I32AtomicSub32, 0xe61e, i_ii) \ |
| 434 V(I32AtomicXor8S, 0xe61f, i_ii) \ |
| 435 V(I32AtomicXor8U, 0xe620, i_ii) \ |
| 436 V(I32AtomicXor16S, 0xe621, i_ii) \ |
| 437 V(I32AtomicXor16U, 0xe622, i_ii) \ |
| 438 V(I32AtomicXor32, 0xe623, i_ii) |
| 439 |
403 // All opcodes. | 440 // All opcodes. |
404 #define FOREACH_OPCODE(V) \ | 441 #define FOREACH_OPCODE(V) \ |
405 FOREACH_CONTROL_OPCODE(V) \ | 442 FOREACH_CONTROL_OPCODE(V) \ |
406 FOREACH_MISC_OPCODE(V) \ | 443 FOREACH_MISC_OPCODE(V) \ |
407 FOREACH_SIMPLE_OPCODE(V) \ | 444 FOREACH_SIMPLE_OPCODE(V) \ |
408 FOREACH_STORE_MEM_OPCODE(V) \ | 445 FOREACH_STORE_MEM_OPCODE(V) \ |
409 FOREACH_LOAD_MEM_OPCODE(V) \ | 446 FOREACH_LOAD_MEM_OPCODE(V) \ |
410 FOREACH_MISC_MEM_OPCODE(V) \ | 447 FOREACH_MISC_MEM_OPCODE(V) \ |
411 FOREACH_ASMJS_COMPAT_OPCODE(V) \ | 448 FOREACH_ASMJS_COMPAT_OPCODE(V) \ |
412 FOREACH_SIMD_0_OPERAND_OPCODE(V) \ | 449 FOREACH_SIMD_0_OPERAND_OPCODE(V) \ |
413 FOREACH_SIMD_1_OPERAND_OPCODE(V) | 450 FOREACH_SIMD_1_OPERAND_OPCODE(V) \ |
| 451 FOREACH_ATOMIC_OPCODE(V) |
414 | 452 |
415 // All signatures. | 453 // All signatures. |
416 #define FOREACH_SIGNATURE(V) \ | 454 #define FOREACH_SIGNATURE(V) \ |
417 FOREACH_SIMD_SIGNATURE(V) \ | 455 FOREACH_SIMD_SIGNATURE(V) \ |
418 V(i_ii, kAstI32, kAstI32, kAstI32) \ | 456 V(i_ii, kAstI32, kAstI32, kAstI32) \ |
419 V(i_i, kAstI32, kAstI32) \ | 457 V(i_i, kAstI32, kAstI32) \ |
420 V(i_v, kAstI32) \ | 458 V(i_v, kAstI32) \ |
421 V(i_ff, kAstI32, kAstF32, kAstF32) \ | 459 V(i_ff, kAstI32, kAstF32, kAstF32) \ |
422 V(i_f, kAstI32, kAstF32) \ | 460 V(i_f, kAstI32, kAstF32) \ |
423 V(i_dd, kAstI32, kAstF64, kAstF64) \ | 461 V(i_dd, kAstI32, kAstF64, kAstF64) \ |
(...skipping 22 matching lines...) Expand all Loading... |
446 #define FOREACH_SIMD_SIGNATURE(V) \ | 484 #define FOREACH_SIMD_SIGNATURE(V) \ |
447 V(s_s, kAstS128, kAstS128) \ | 485 V(s_s, kAstS128, kAstS128) \ |
448 V(s_f, kAstS128, kAstF32) \ | 486 V(s_f, kAstS128, kAstF32) \ |
449 V(s_sif, kAstS128, kAstS128, kAstI32, kAstF32) \ | 487 V(s_sif, kAstS128, kAstS128, kAstI32, kAstF32) \ |
450 V(s_ss, kAstS128, kAstS128, kAstS128) \ | 488 V(s_ss, kAstS128, kAstS128, kAstS128) \ |
451 V(s_sss, kAstS128, kAstS128, kAstS128, kAstS128) \ | 489 V(s_sss, kAstS128, kAstS128, kAstS128, kAstS128) \ |
452 V(s_i, kAstS128, kAstI32) \ | 490 V(s_i, kAstS128, kAstI32) \ |
453 V(s_sii, kAstS128, kAstS128, kAstI32, kAstI32) \ | 491 V(s_sii, kAstS128, kAstS128, kAstI32, kAstI32) \ |
454 V(s_si, kAstS128, kAstS128, kAstI32) | 492 V(s_si, kAstS128, kAstS128, kAstI32) |
455 | 493 |
456 #define FOREACH_PREFIX(V) V(Simd, 0xe5) | 494 #define FOREACH_PREFIX(V) \ |
| 495 V(Simd, 0xe5) \ |
| 496 V(Atomic, 0xe6) |
457 | 497 |
458 enum WasmOpcode { | 498 enum WasmOpcode { |
459 // Declare expression opcodes. | 499 // Declare expression opcodes. |
460 #define DECLARE_NAMED_ENUM(name, opcode, sig) kExpr##name = opcode, | 500 #define DECLARE_NAMED_ENUM(name, opcode, sig) kExpr##name = opcode, |
461 FOREACH_OPCODE(DECLARE_NAMED_ENUM) | 501 FOREACH_OPCODE(DECLARE_NAMED_ENUM) |
462 #undef DECLARE_NAMED_ENUM | 502 #undef DECLARE_NAMED_ENUM |
463 #define DECLARE_PREFIX(name, opcode) k##name##Prefix = opcode, | 503 #define DECLARE_PREFIX(name, opcode) k##name##Prefix = opcode, |
464 FOREACH_PREFIX(DECLARE_PREFIX) | 504 FOREACH_PREFIX(DECLARE_PREFIX) |
465 #undef DECLARE_PREFIX | 505 #undef DECLARE_PREFIX |
466 }; | 506 }; |
(...skipping 17 matching lines...) Expand all Loading... |
484 #undef DECLARE_ENUM | 524 #undef DECLARE_ENUM |
485 }; | 525 }; |
486 | 526 |
487 // A collection of opcode-related static methods. | 527 // A collection of opcode-related static methods. |
488 class V8_EXPORT_PRIVATE WasmOpcodes { | 528 class V8_EXPORT_PRIVATE WasmOpcodes { |
489 public: | 529 public: |
490 static const char* OpcodeName(WasmOpcode opcode); | 530 static const char* OpcodeName(WasmOpcode opcode); |
491 static const char* ShortOpcodeName(WasmOpcode opcode); | 531 static const char* ShortOpcodeName(WasmOpcode opcode); |
492 static FunctionSig* Signature(WasmOpcode opcode); | 532 static FunctionSig* Signature(WasmOpcode opcode); |
493 static FunctionSig* AsmjsSignature(WasmOpcode opcode); | 533 static FunctionSig* AsmjsSignature(WasmOpcode opcode); |
| 534 static FunctionSig* AtomicSignature(WasmOpcode opcode); |
494 static bool IsPrefixOpcode(WasmOpcode opcode); | 535 static bool IsPrefixOpcode(WasmOpcode opcode); |
495 | 536 |
496 static int TrapReasonToMessageId(TrapReason reason); | 537 static int TrapReasonToMessageId(TrapReason reason); |
497 static const char* TrapReasonMessage(TrapReason reason); | 538 static const char* TrapReasonMessage(TrapReason reason); |
498 | 539 |
499 static byte MemSize(MachineType type) { | 540 static byte MemSize(MachineType type) { |
500 return 1 << ElementSizeLog2Of(type.representation()); | 541 return 1 << ElementSizeLog2Of(type.representation()); |
501 } | 542 } |
502 | 543 |
503 static byte MemSize(LocalType type) { return 1 << ElementSizeLog2Of(type); } | 544 static byte MemSize(LocalType type) { return 1 << ElementSizeLog2Of(type); } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 default: | 680 default: |
640 return "<unknown>"; | 681 return "<unknown>"; |
641 } | 682 } |
642 } | 683 } |
643 }; | 684 }; |
644 } // namespace wasm | 685 } // namespace wasm |
645 } // namespace internal | 686 } // namespace internal |
646 } // namespace v8 | 687 } // namespace v8 |
647 | 688 |
648 #endif // V8_WASM_OPCODES_H_ | 689 #endif // V8_WASM_OPCODES_H_ |
OLD | NEW |