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

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

Issue 1775123003: [wasm] Encode immediates to Load and Store as varint. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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-macro-gen.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('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
(...skipping 28 matching lines...) Expand all
39 // A typedef improves readability without adding a whole new type system. 39 // A typedef improves readability without adding a whole new type system.
40 typedef MachineRepresentation LocalType; 40 typedef MachineRepresentation LocalType;
41 const LocalType kAstStmt = MachineRepresentation::kNone; 41 const LocalType kAstStmt = MachineRepresentation::kNone;
42 const LocalType kAstI32 = MachineRepresentation::kWord32; 42 const LocalType kAstI32 = MachineRepresentation::kWord32;
43 const LocalType kAstI64 = MachineRepresentation::kWord64; 43 const LocalType kAstI64 = MachineRepresentation::kWord64;
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 // Functionality related to encoding memory accesses.
50 struct MemoryAccess {
51 // Atomicity annotations for access to the memory and globals.
52 enum Atomicity {
53 kNone = 0, // non-atomic
54 kSequential = 1, // sequential consistency
55 kAcquire = 2, // acquire semantics
56 kRelease = 3 // release semantics
57 };
58
59 // Alignment annotations for memory accesses.
60 enum Alignment { kAligned = 0, kUnaligned = 1 };
61
62 // Bitfields for the various annotations for memory accesses.
63 typedef BitField<Alignment, 7, 1> AlignmentField;
64 typedef BitField<Atomicity, 5, 2> AtomicityField;
65 typedef BitField<bool, 4, 1> OffsetField;
66 };
67
68 typedef Signature<LocalType> FunctionSig; 49 typedef Signature<LocalType> FunctionSig;
69 std::ostream& operator<<(std::ostream& os, const FunctionSig& function); 50 std::ostream& operator<<(std::ostream& os, const FunctionSig& function);
70 51
71 // TODO(titzer): Renumber all the opcodes to fill in holes. 52 // TODO(titzer): Renumber all the opcodes to fill in holes.
72 53
73 // Control expressions and blocks. 54 // Control expressions and blocks.
74 #define FOREACH_CONTROL_OPCODE(V) \ 55 #define FOREACH_CONTROL_OPCODE(V) \
75 V(Nop, 0x00, _) \ 56 V(Nop, 0x00, _) \
76 V(Block, 0x01, _) \ 57 V(Block, 0x01, _) \
77 V(Loop, 0x02, _) \ 58 V(Loop, 0x02, _) \
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } else if (type == MachineType::Float32()) { 422 } else if (type == MachineType::Float32()) {
442 return store ? kExprF32StoreMem : kExprF32LoadMem; 423 return store ? kExprF32StoreMem : kExprF32LoadMem;
443 } else if (type == MachineType::Float64()) { 424 } else if (type == MachineType::Float64()) {
444 return store ? kExprF64StoreMem : kExprF64LoadMem; 425 return store ? kExprF64StoreMem : kExprF64LoadMem;
445 } else { 426 } else {
446 UNREACHABLE(); 427 UNREACHABLE();
447 return kExprNop; 428 return kExprNop;
448 } 429 }
449 } 430 }
450 431
451 static byte LoadStoreAccessOf(bool with_offset) {
452 return MemoryAccess::OffsetField::encode(with_offset);
453 }
454
455 static char ShortNameOf(LocalType type) { 432 static char ShortNameOf(LocalType type) {
456 switch (type) { 433 switch (type) {
457 case kAstI32: 434 case kAstI32:
458 return 'i'; 435 return 'i';
459 case kAstI64: 436 case kAstI64:
460 return 'l'; 437 return 'l';
461 case kAstF32: 438 case kAstF32:
462 return 'f'; 439 return 'f';
463 case kAstF64: 440 case kAstF64:
464 return 'd'; 441 return 'd';
(...skipping 24 matching lines...) Expand all
489 default: 466 default:
490 return "<unknown>"; 467 return "<unknown>";
491 } 468 }
492 } 469 }
493 }; 470 };
494 } // namespace wasm 471 } // namespace wasm
495 } // namespace internal 472 } // namespace internal
496 } // namespace v8 473 } // namespace v8
497 474
498 #endif // V8_WASM_OPCODES_H_ 475 #endif // V8_WASM_OPCODES_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-macro-gen.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698