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

Side by Side Diff: src/wasm/wasm-macro-gen.h

Issue 2594993002: [wasm] Rename wasm::LocalType to wasm::ValueType and kAst* to kWasm* (Closed)
Patch Set: Fix inspector tests Created 3 years, 12 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-interpreter.cc ('k') | src/wasm/wasm-module.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_MACRO_GEN_H_ 5 #ifndef V8_WASM_MACRO_GEN_H_
6 #define V8_WASM_MACRO_GEN_H_ 6 #define V8_WASM_MACRO_GEN_H_
7 7
8 #include "src/wasm/wasm-opcodes.h" 8 #include "src/wasm/wasm-opcodes.h"
9 9
10 #include "src/zone/zone-containers.h" 10 #include "src/zone/zone-containers.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #define ARITY_1 1 64 #define ARITY_1 1
65 #define ARITY_2 2 65 #define ARITY_2 2
66 #define DEPTH_0 0 66 #define DEPTH_0 0
67 #define DEPTH_1 1 67 #define DEPTH_1 1
68 #define DEPTH_2 2 68 #define DEPTH_2 2
69 #define ARITY_2 2 69 #define ARITY_2 2
70 70
71 #define WASM_BLOCK(...) kExprBlock, kLocalVoid, __VA_ARGS__, kExprEnd 71 #define WASM_BLOCK(...) kExprBlock, kLocalVoid, __VA_ARGS__, kExprEnd
72 72
73 #define WASM_BLOCK_T(t, ...) \ 73 #define WASM_BLOCK_T(t, ...) \
74 kExprBlock, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t)), \ 74 kExprBlock, static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t)), \
75 __VA_ARGS__, kExprEnd 75 __VA_ARGS__, kExprEnd
76 76
77 #define WASM_BLOCK_TT(t1, t2, ...) \ 77 #define WASM_BLOCK_TT(t1, t2, ...) \
78 kExprBlock, kMultivalBlock, 0, \ 78 kExprBlock, kMultivalBlock, 0, \
79 static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t1)), \ 79 static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t1)), \
80 static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t2)), __VA_ARGS__, \ 80 static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t2)), __VA_ARGS__, \
81 kExprEnd 81 kExprEnd
82 82
83 #define WASM_BLOCK_I(...) kExprBlock, kLocalI32, __VA_ARGS__, kExprEnd 83 #define WASM_BLOCK_I(...) kExprBlock, kLocalI32, __VA_ARGS__, kExprEnd
84 #define WASM_BLOCK_L(...) kExprBlock, kLocalI64, __VA_ARGS__, kExprEnd 84 #define WASM_BLOCK_L(...) kExprBlock, kLocalI64, __VA_ARGS__, kExprEnd
85 #define WASM_BLOCK_F(...) kExprBlock, kLocalF32, __VA_ARGS__, kExprEnd 85 #define WASM_BLOCK_F(...) kExprBlock, kLocalF32, __VA_ARGS__, kExprEnd
86 #define WASM_BLOCK_D(...) kExprBlock, kLocalF64, __VA_ARGS__, kExprEnd 86 #define WASM_BLOCK_D(...) kExprBlock, kLocalF64, __VA_ARGS__, kExprEnd
87 87
88 #define WASM_INFINITE_LOOP kExprLoop, kLocalVoid, kExprBr, DEPTH_0, kExprEnd 88 #define WASM_INFINITE_LOOP kExprLoop, kLocalVoid, kExprBr, DEPTH_0, kExprEnd
89 89
90 #define WASM_LOOP(...) kExprLoop, kLocalVoid, __VA_ARGS__, kExprEnd 90 #define WASM_LOOP(...) kExprLoop, kLocalVoid, __VA_ARGS__, kExprEnd
91 #define WASM_LOOP_I(...) kExprLoop, kLocalI32, __VA_ARGS__, kExprEnd 91 #define WASM_LOOP_I(...) kExprLoop, kLocalI32, __VA_ARGS__, kExprEnd
92 #define WASM_LOOP_L(...) kExprLoop, kLocalI64, __VA_ARGS__, kExprEnd 92 #define WASM_LOOP_L(...) kExprLoop, kLocalI64, __VA_ARGS__, kExprEnd
93 #define WASM_LOOP_F(...) kExprLoop, kLocalF32, __VA_ARGS__, kExprEnd 93 #define WASM_LOOP_F(...) kExprLoop, kLocalF32, __VA_ARGS__, kExprEnd
94 #define WASM_LOOP_D(...) kExprLoop, kLocalF64, __VA_ARGS__, kExprEnd 94 #define WASM_LOOP_D(...) kExprLoop, kLocalF64, __VA_ARGS__, kExprEnd
95 95
96 #define WASM_IF(cond, tstmt) cond, kExprIf, kLocalVoid, tstmt, kExprEnd 96 #define WASM_IF(cond, tstmt) cond, kExprIf, kLocalVoid, tstmt, kExprEnd
97 97
98 #define WASM_IF_ELSE(cond, tstmt, fstmt) \ 98 #define WASM_IF_ELSE(cond, tstmt, fstmt) \
99 cond, kExprIf, kLocalVoid, tstmt, kExprElse, fstmt, kExprEnd 99 cond, kExprIf, kLocalVoid, tstmt, kExprElse, fstmt, kExprEnd
100 100
101 #define WASM_IF_ELSE_T(t, cond, tstmt, fstmt) \ 101 #define WASM_IF_ELSE_T(t, cond, tstmt, fstmt) \
102 cond, kExprIf, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t)), tstmt, \ 102 cond, kExprIf, static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t)), tstmt, \
103 kExprElse, fstmt, kExprEnd 103 kExprElse, fstmt, kExprEnd
104 104
105 #define WASM_IF_ELSE_TT(t1, t2, cond, tstmt, fstmt) \ 105 #define WASM_IF_ELSE_TT(t1, t2, cond, tstmt, fstmt) \
106 cond, kExprIf, kMultivalBlock, 0, \ 106 cond, kExprIf, kMultivalBlock, 0, \
107 static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t1)), \ 107 static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t1)), \
108 static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t2)), tstmt, kExprElse, \ 108 static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t2)), tstmt, kExprElse, \
109 fstmt, kExprEnd 109 fstmt, kExprEnd
110 110
111 #define WASM_IF_ELSE_I(cond, tstmt, fstmt) \ 111 #define WASM_IF_ELSE_I(cond, tstmt, fstmt) \
112 cond, kExprIf, kLocalI32, tstmt, kExprElse, fstmt, kExprEnd 112 cond, kExprIf, kLocalI32, tstmt, kExprElse, fstmt, kExprEnd
113 #define WASM_IF_ELSE_L(cond, tstmt, fstmt) \ 113 #define WASM_IF_ELSE_L(cond, tstmt, fstmt) \
114 cond, kExprIf, kLocalI64, tstmt, kExprElse, fstmt, kExprEnd 114 cond, kExprIf, kLocalI64, tstmt, kExprElse, fstmt, kExprEnd
115 #define WASM_IF_ELSE_F(cond, tstmt, fstmt) \ 115 #define WASM_IF_ELSE_F(cond, tstmt, fstmt) \
116 cond, kExprIf, kLocalF32, tstmt, kExprElse, fstmt, kExprEnd 116 cond, kExprIf, kLocalF32, tstmt, kExprElse, fstmt, kExprEnd
117 #define WASM_IF_ELSE_D(cond, tstmt, fstmt) \ 117 #define WASM_IF_ELSE_D(cond, tstmt, fstmt) \
118 cond, kExprIf, kLocalF64, tstmt, kExprElse, fstmt, kExprEnd 118 cond, kExprIf, kLocalF64, tstmt, kExprElse, fstmt, kExprEnd
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 pos += size; 188 pos += size;
189 *start = buffer; 189 *start = buffer;
190 *end = buffer + pos; 190 *end = buffer + pos;
191 } 191 }
192 192
193 size_t Emit(byte* buffer) const { 193 size_t Emit(byte* buffer) const {
194 size_t pos = 0; 194 size_t pos = 0;
195 pos = WriteUint32v(buffer, pos, static_cast<uint32_t>(local_decls.size())); 195 pos = WriteUint32v(buffer, pos, static_cast<uint32_t>(local_decls.size()));
196 for (size_t i = 0; i < local_decls.size(); ++i) { 196 for (size_t i = 0; i < local_decls.size(); ++i) {
197 pos = WriteUint32v(buffer, pos, local_decls[i].first); 197 pos = WriteUint32v(buffer, pos, local_decls[i].first);
198 buffer[pos++] = WasmOpcodes::LocalTypeCodeFor(local_decls[i].second); 198 buffer[pos++] = WasmOpcodes::ValueTypeCodeFor(local_decls[i].second);
199 } 199 }
200 DCHECK_EQ(Size(), pos); 200 DCHECK_EQ(Size(), pos);
201 return pos; 201 return pos;
202 } 202 }
203 203
204 // Add locals declarations to this helper. Return the index of the newly added 204 // Add locals declarations to this helper. Return the index of the newly added
205 // local(s), with an optional adjustment for the parameters. 205 // local(s), with an optional adjustment for the parameters.
206 uint32_t AddLocals(uint32_t count, LocalType type) { 206 uint32_t AddLocals(uint32_t count, ValueType type) {
207 uint32_t result = 207 uint32_t result =
208 static_cast<uint32_t>(total + (sig ? sig->parameter_count() : 0)); 208 static_cast<uint32_t>(total + (sig ? sig->parameter_count() : 0));
209 total += count; 209 total += count;
210 if (local_decls.size() > 0 && local_decls.back().second == type) { 210 if (local_decls.size() > 0 && local_decls.back().second == type) {
211 count += local_decls.back().first; 211 count += local_decls.back().first;
212 local_decls.pop_back(); 212 local_decls.pop_back();
213 } 213 }
214 local_decls.push_back(std::pair<uint32_t, LocalType>(count, type)); 214 local_decls.push_back(std::pair<uint32_t, ValueType>(count, type));
215 return result; 215 return result;
216 } 216 }
217 217
218 size_t Size() const { 218 size_t Size() const {
219 size_t size = SizeofUint32v(static_cast<uint32_t>(local_decls.size())); 219 size_t size = SizeofUint32v(static_cast<uint32_t>(local_decls.size()));
220 for (auto p : local_decls) size += 1 + SizeofUint32v(p.first); 220 for (auto p : local_decls) size += 1 + SizeofUint32v(p.first);
221 return size; 221 return size;
222 } 222 }
223 223
224 bool has_sig() const { return sig != nullptr; } 224 bool has_sig() const { return sig != nullptr; }
225 FunctionSig* get_sig() const { return sig; } 225 FunctionSig* get_sig() const { return sig; }
226 void set_sig(FunctionSig* s) { sig = s; } 226 void set_sig(FunctionSig* s) { sig = s; }
227 227
228 private: 228 private:
229 FunctionSig* sig; 229 FunctionSig* sig;
230 ZoneVector<std::pair<uint32_t, LocalType>> local_decls; 230 ZoneVector<std::pair<uint32_t, ValueType>> local_decls;
231 size_t total; 231 size_t total;
232 232
233 size_t SizeofUint32v(uint32_t val) const { 233 size_t SizeofUint32v(uint32_t val) const {
234 size_t size = 1; 234 size_t size = 1;
235 while (true) { 235 while (true) {
236 byte b = val & MASK_7; 236 byte b = val & MASK_7;
237 if (b == val) return size; 237 if (b == val) return size;
238 size++; 238 size++;
239 val = val >> 7; 239 val = val >> 7;
240 } 240 }
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 #define WASM_BRV(depth, val) val, kExprBr, static_cast<byte>(depth) 672 #define WASM_BRV(depth, val) val, kExprBr, static_cast<byte>(depth)
673 #define WASM_BRV_IF(depth, val, cond) \ 673 #define WASM_BRV_IF(depth, val, cond) \
674 val, cond, kExprBrIf, static_cast<byte>(depth) 674 val, cond, kExprBrIf, static_cast<byte>(depth)
675 #define WASM_BRV_IFD(depth, val, cond) \ 675 #define WASM_BRV_IFD(depth, val, cond) \
676 val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop 676 val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop
677 #define WASM_IFB(cond, ...) cond, kExprIf, kLocalVoid, __VA_ARGS__, kExprEnd 677 #define WASM_IFB(cond, ...) cond, kExprIf, kLocalVoid, __VA_ARGS__, kExprEnd
678 #define WASM_BR_TABLEV(val, key, count, ...) \ 678 #define WASM_BR_TABLEV(val, key, count, ...) \
679 val, key, kExprBrTable, U32V_1(count), __VA_ARGS__ 679 val, key, kExprBrTable, U32V_1(count), __VA_ARGS__
680 680
681 #endif // V8_WASM_MACRO_GEN_H_ 681 #endif // V8_WASM_MACRO_GEN_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-interpreter.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698