Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: src/wasm/wasm-opcodes.h

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | src/wasm/wasm-result.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace wasm { 13 namespace wasm {
14 14
15 // Binary encoding of local types. 15 // Binary encoding of local types.
16 enum LocalTypeCode { 16 enum LocalTypeCode {
17 kLocalVoid = 0, 17 kLocalVoid = 0,
18 kLocalI32 = 1, 18 kLocalI32 = 1,
19 kLocalI64 = 2, 19 kLocalI64 = 2,
20 kLocalF32 = 3, 20 kLocalF32 = 3,
21 kLocalF64 = 4, 21 kLocalF64 = 4,
22 kLocalS128 = 5 22 kLocalS128 = 5
23 }; 23 };
24 24
25 // Type code for multi-value block types.
26 static const uint8_t kMultivalBlock = 0x41;
27
25 // We reuse the internal machine type to represent WebAssembly AST types. 28 // We reuse the internal machine type to represent WebAssembly AST types.
26 // A typedef improves readability without adding a whole new type system. 29 // A typedef improves readability without adding a whole new type system.
27 typedef MachineRepresentation LocalType; 30 typedef MachineRepresentation LocalType;
28 const LocalType kAstStmt = MachineRepresentation::kNone; 31 const LocalType kAstStmt = MachineRepresentation::kNone;
29 const LocalType kAstI32 = MachineRepresentation::kWord32; 32 const LocalType kAstI32 = MachineRepresentation::kWord32;
30 const LocalType kAstI64 = MachineRepresentation::kWord64; 33 const LocalType kAstI64 = MachineRepresentation::kWord64;
31 const LocalType kAstF32 = MachineRepresentation::kFloat32; 34 const LocalType kAstF32 = MachineRepresentation::kFloat32;
32 const LocalType kAstF64 = MachineRepresentation::kFloat64; 35 const LocalType kAstF64 = MachineRepresentation::kFloat64;
33 const LocalType kAstS128 = MachineRepresentation::kSimd128; 36 const LocalType kAstS128 = MachineRepresentation::kSimd128;
34 // We use kTagged here because kNone is already used by kAstStmt. 37 // We use kTagged here because kNone is already used by kAstStmt.
35 const LocalType kAstEnd = MachineRepresentation::kTagged; 38 const LocalType kAstEnd = MachineRepresentation::kTagged;
36 39
37 typedef Signature<LocalType> FunctionSig; 40 typedef Signature<LocalType> FunctionSig;
38 std::ostream& operator<<(std::ostream& os, const FunctionSig& function); 41 std::ostream& operator<<(std::ostream& os, const FunctionSig& function);
39 42
40 typedef Vector<const char> WasmName; 43 typedef Vector<const char> WasmName;
41 44
42 typedef int WasmCodePosition; 45 typedef int WasmCodePosition;
43 const WasmCodePosition kNoCodePosition = -1; 46 const WasmCodePosition kNoCodePosition = -1;
44 47
45 // Control expressions and blocks. 48 // Control expressions and blocks.
46 #define FOREACH_CONTROL_OPCODE(V) \ 49 #define FOREACH_CONTROL_OPCODE(V) \
47 V(Nop, 0x00, _) \ 50 V(Unreachable, 0x00, _) \
48 V(Block, 0x01, _) \ 51 V(Block, 0x01, _) \
49 V(Loop, 0x02, _) \ 52 V(Loop, 0x02, _) \
50 V(If, 0x03, _) \ 53 V(If, 0x03, _) \
51 V(Else, 0x04, _) \ 54 V(Else, 0x04, _) \
52 V(Select, 0x05, _) \ 55 V(Select, 0x05, _) \
53 V(Br, 0x06, _) \ 56 V(Br, 0x06, _) \
54 V(BrIf, 0x07, _) \ 57 V(BrIf, 0x07, _) \
55 V(BrTable, 0x08, _) \ 58 V(BrTable, 0x08, _) \
56 V(Return, 0x09, _) \ 59 V(Return, 0x09, _) \
57 V(Unreachable, 0x0a, _) \ 60 V(Nop, 0x0a, _) \
58 V(Throw, 0xfa, _) \ 61 V(Throw, 0xfa, _) \
59 V(Try, 0xfb, _) \ 62 V(Try, 0xfb, _) \
60 V(Catch, 0xfe, _) \ 63 V(Catch, 0xfe, _) \
61 V(End, 0x0F, _) 64 V(End, 0x0F, _)
62 65
63 // Constants, locals, globals, and calls. 66 // Constants, locals, globals, and calls.
64 #define FOREACH_MISC_OPCODE(V) \ 67 #define FOREACH_MISC_OPCODE(V) \
65 V(I32Const, 0x10, _) \ 68 V(I32Const, 0x10, _) \
66 V(I64Const, 0x11, _) \ 69 V(I64Const, 0x11, _) \
67 V(F64Const, 0x12, _) \ 70 V(F64Const, 0x12, _) \
68 V(F32Const, 0x13, _) \ 71 V(F32Const, 0x13, _) \
69 V(GetLocal, 0x14, _) \ 72 V(GetLocal, 0x14, _) \
70 V(SetLocal, 0x15, _) \ 73 V(SetLocal, 0x15, _) \
74 V(TeeLocal, 0x19, _) \
75 V(Drop, 0x0b, _) \
71 V(CallFunction, 0x16, _) \ 76 V(CallFunction, 0x16, _) \
72 V(CallIndirect, 0x17, _) \ 77 V(CallIndirect, 0x17, _) \
73 V(CallImport, 0x18, _) \
74 V(I8Const, 0xcb, _) \ 78 V(I8Const, 0xcb, _) \
75 V(GetGlobal, 0xbb, _) \ 79 V(GetGlobal, 0xbb, _) \
76 V(SetGlobal, 0xbc, _) 80 V(SetGlobal, 0xbc, _)
77 81
78 // Load memory expressions. 82 // Load memory expressions.
79 #define FOREACH_LOAD_MEM_OPCODE(V) \ 83 #define FOREACH_LOAD_MEM_OPCODE(V) \
80 V(I32LoadMem8S, 0x20, i_i) \ 84 V(I32LoadMem8S, 0x20, i_i) \
81 V(I32LoadMem8U, 0x21, i_i) \ 85 V(I32LoadMem8U, 0x21, i_i) \
82 V(I32LoadMem16S, 0x22, i_i) \ 86 V(I32LoadMem16S, 0x22, i_i) \
83 V(I32LoadMem16U, 0x23, i_i) \ 87 V(I32LoadMem16U, 0x23, i_i) \
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 static FunctionSig* AsmjsSignature(WasmOpcode opcode); 494 static FunctionSig* AsmjsSignature(WasmOpcode opcode);
491 static bool IsPrefixOpcode(WasmOpcode opcode); 495 static bool IsPrefixOpcode(WasmOpcode opcode);
492 496
493 static int TrapReasonToMessageId(TrapReason reason); 497 static int TrapReasonToMessageId(TrapReason reason);
494 static const char* TrapReasonMessage(TrapReason reason); 498 static const char* TrapReasonMessage(TrapReason reason);
495 499
496 static byte MemSize(MachineType type) { 500 static byte MemSize(MachineType type) {
497 return 1 << ElementSizeLog2Of(type.representation()); 501 return 1 << ElementSizeLog2Of(type.representation());
498 } 502 }
499 503
504 static byte MemSize(LocalType type) { return 1 << ElementSizeLog2Of(type); }
505
500 static LocalTypeCode LocalTypeCodeFor(LocalType type) { 506 static LocalTypeCode LocalTypeCodeFor(LocalType type) {
501 switch (type) { 507 switch (type) {
502 case kAstI32: 508 case kAstI32:
503 return kLocalI32; 509 return kLocalI32;
504 case kAstI64: 510 case kAstI64:
505 return kLocalI64; 511 return kLocalI64;
506 case kAstF32: 512 case kAstF32:
507 return kLocalF32; 513 return kLocalF32;
508 case kAstF64: 514 case kAstF64:
509 return kLocalF64; 515 return kLocalF64;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 default: 640 default:
635 return "<unknown>"; 641 return "<unknown>";
636 } 642 }
637 } 643 }
638 }; 644 };
639 } // namespace wasm 645 } // namespace wasm
640 } // namespace internal 646 } // namespace internal
641 } // namespace v8 647 } // namespace v8
642 648
643 #endif // V8_WASM_OPCODES_H_ 649 #endif // V8_WASM_OPCODES_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | src/wasm/wasm-result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698