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