| 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/machine-type.h" | 8 #include "src/machine-type.h" |
| 9 #include "src/signature.h" | 9 #include "src/signature.h" |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const LocalType kAstF32 = MachineRepresentation::kFloat32; | 44 const LocalType kAstF32 = MachineRepresentation::kFloat32; |
| 45 const LocalType kAstF64 = MachineRepresentation::kFloat64; | 45 const LocalType kAstF64 = MachineRepresentation::kFloat64; |
| 46 // We use kTagged here because kNone is already used by kAstStmt. | 46 // We use kTagged here because kNone is already used by kAstStmt. |
| 47 const LocalType kAstEnd = MachineRepresentation::kTagged; | 47 const LocalType kAstEnd = MachineRepresentation::kTagged; |
| 48 | 48 |
| 49 typedef Signature<LocalType> FunctionSig; | 49 typedef Signature<LocalType> FunctionSig; |
| 50 std::ostream& operator<<(std::ostream& os, const FunctionSig& function); | 50 std::ostream& operator<<(std::ostream& os, const FunctionSig& function); |
| 51 | 51 |
| 52 typedef Vector<const char> WasmName; | 52 typedef Vector<const char> WasmName; |
| 53 | 53 |
| 54 // TODO(titzer): Renumber all the opcodes to fill in holes. | |
| 55 | |
| 56 // Control expressions and blocks. | 54 // Control expressions and blocks. |
| 57 #define FOREACH_CONTROL_OPCODE(V) \ | 55 #define FOREACH_CONTROL_OPCODE(V) \ |
| 58 V(Nop, 0x00, _) \ | 56 V(Nop, 0x00, _) \ |
| 59 V(Block, 0x01, _) \ | 57 V(Block, 0x01, _) \ |
| 60 V(Loop, 0x02, _) \ | 58 V(Loop, 0x02, _) \ |
| 61 V(If, 0x03, _) \ | 59 V(If, 0x03, _) \ |
| 62 V(IfElse, 0x04, _) \ | 60 V(Else, 0x04, _) \ |
| 63 V(Select, 0x05, _) \ | 61 V(Select, 0x05, _) \ |
| 64 V(Br, 0x06, _) \ | 62 V(Br, 0x06, _) \ |
| 65 V(BrIf, 0x07, _) \ | 63 V(BrIf, 0x07, _) \ |
| 66 V(BrTable, 0x08, _) \ | 64 V(BrTable, 0x08, _) \ |
| 67 V(Return, 0x14, _) \ | 65 V(Return, 0x09, _) \ |
| 68 V(Unreachable, 0x15, _) | 66 V(Unreachable, 0x0a, _) \ |
| 67 V(End, 0x0F, _) |
| 69 | 68 |
| 70 // Constants, locals, globals, and calls. | 69 // Constants, locals, globals, and calls. |
| 71 #define FOREACH_MISC_OPCODE(V) \ | 70 #define FOREACH_MISC_OPCODE(V) \ |
| 72 V(I8Const, 0x09, _) \ | 71 V(I32Const, 0x10, _) \ |
| 73 V(I32Const, 0x0a, _) \ | 72 V(I64Const, 0x11, _) \ |
| 74 V(I64Const, 0x0b, _) \ | 73 V(F64Const, 0x12, _) \ |
| 75 V(F64Const, 0x0c, _) \ | 74 V(F32Const, 0x13, _) \ |
| 76 V(F32Const, 0x0d, _) \ | 75 V(GetLocal, 0x14, _) \ |
| 77 V(GetLocal, 0x0e, _) \ | 76 V(SetLocal, 0x15, _) \ |
| 78 V(SetLocal, 0x0f, _) \ | 77 V(CallFunction, 0x16, _) \ |
| 79 V(LoadGlobal, 0x10, _) \ | 78 V(CallIndirect, 0x17, _) \ |
| 80 V(StoreGlobal, 0x11, _) \ | 79 V(CallImport, 0x18, _) \ |
| 81 V(CallFunction, 0x12, _) \ | 80 V(I8Const, 0xcb, _) \ |
| 82 V(CallIndirect, 0x13, _) \ | 81 V(LoadGlobal, 0xcc, _) \ |
| 83 V(CallImport, 0x1F, _) \ | 82 V(StoreGlobal, 0xcd, _) |
| 84 V(DeclLocals, 0x1E, _) | |
| 85 | 83 |
| 86 // Load memory expressions. | 84 // Load memory expressions. |
| 87 #define FOREACH_LOAD_MEM_OPCODE(V) \ | 85 #define FOREACH_LOAD_MEM_OPCODE(V) \ |
| 88 V(I32LoadMem8S, 0x20, i_i) \ | 86 V(I32LoadMem8S, 0x20, i_i) \ |
| 89 V(I32LoadMem8U, 0x21, i_i) \ | 87 V(I32LoadMem8U, 0x21, i_i) \ |
| 90 V(I32LoadMem16S, 0x22, i_i) \ | 88 V(I32LoadMem16S, 0x22, i_i) \ |
| 91 V(I32LoadMem16U, 0x23, i_i) \ | 89 V(I32LoadMem16U, 0x23, i_i) \ |
| 92 V(I64LoadMem8S, 0x24, l_i) \ | 90 V(I64LoadMem8S, 0x24, l_i) \ |
| 93 V(I64LoadMem8U, 0x25, l_i) \ | 91 V(I64LoadMem8U, 0x25, l_i) \ |
| 94 V(I64LoadMem16S, 0x26, l_i) \ | 92 V(I64LoadMem16S, 0x26, l_i) \ |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 FOREACH_WASM_TRAPREASON(DECLARE_ENUM) | 340 FOREACH_WASM_TRAPREASON(DECLARE_ENUM) |
| 343 kTrapCount | 341 kTrapCount |
| 344 #undef DECLARE_ENUM | 342 #undef DECLARE_ENUM |
| 345 }; | 343 }; |
| 346 | 344 |
| 347 // A collection of opcode-related static methods. | 345 // A collection of opcode-related static methods. |
| 348 class WasmOpcodes { | 346 class WasmOpcodes { |
| 349 public: | 347 public: |
| 350 static bool IsSupported(WasmOpcode opcode); | 348 static bool IsSupported(WasmOpcode opcode); |
| 351 static const char* OpcodeName(WasmOpcode opcode); | 349 static const char* OpcodeName(WasmOpcode opcode); |
| 350 static const char* ShortOpcodeName(WasmOpcode opcode); |
| 352 static FunctionSig* Signature(WasmOpcode opcode); | 351 static FunctionSig* Signature(WasmOpcode opcode); |
| 353 | 352 |
| 354 static int TrapReasonToMessageId(TrapReason reason); | 353 static int TrapReasonToMessageId(TrapReason reason); |
| 355 static const char* TrapReasonMessage(TrapReason reason); | 354 static const char* TrapReasonMessage(TrapReason reason); |
| 356 | 355 |
| 357 static byte MemSize(MachineType type) { | 356 static byte MemSize(MachineType type) { |
| 358 return 1 << ElementSizeLog2Of(type.representation()); | 357 return 1 << ElementSizeLog2Of(type.representation()); |
| 359 } | 358 } |
| 360 | 359 |
| 361 static LocalTypeCode LocalTypeCodeFor(LocalType type) { | 360 static LocalTypeCode LocalTypeCodeFor(LocalType type) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 default: | 511 default: |
| 513 return "<unknown>"; | 512 return "<unknown>"; |
| 514 } | 513 } |
| 515 } | 514 } |
| 516 }; | 515 }; |
| 517 } // namespace wasm | 516 } // namespace wasm |
| 518 } // namespace internal | 517 } // namespace internal |
| 519 } // namespace v8 | 518 } // namespace v8 |
| 520 | 519 |
| 521 #endif // V8_WASM_OPCODES_H_ | 520 #endif // V8_WASM_OPCODES_H_ |
| OLD | NEW |