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

Side by Side Diff: src/wasm/ast-decoder.h

Issue 1830663002: [wasm] Binary 11: AST changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/asm-wasm-builder.cc ('k') | src/wasm/ast-decoder.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_AST_DECODER_H_ 5 #ifndef V8_WASM_AST_DECODER_H_
6 #define V8_WASM_AST_DECODER_H_ 6 #define V8_WASM_AST_DECODER_H_
7 7
8 #include "src/signature.h" 8 #include "src/signature.h"
9 #include "src/wasm/decoder.h" 9 #include "src/wasm/decoder.h"
10 #include "src/wasm/wasm-opcodes.h" 10 #include "src/wasm/wasm-opcodes.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 MachineType machine_type; 82 MachineType machine_type;
83 int length; 83 int length;
84 84
85 inline GlobalIndexOperand(Decoder* decoder, const byte* pc) { 85 inline GlobalIndexOperand(Decoder* decoder, const byte* pc) {
86 index = decoder->checked_read_u32v(pc, 1, &length, "global index"); 86 index = decoder->checked_read_u32v(pc, 1, &length, "global index");
87 type = kAstStmt; 87 type = kAstStmt;
88 machine_type = MachineType::None(); 88 machine_type = MachineType::None();
89 } 89 }
90 }; 90 };
91 91
92 struct Block; 92 struct Control;
93 struct BreakDepthOperand { 93 struct BreakDepthOperand {
94 uint32_t arity;
94 uint32_t depth; 95 uint32_t depth;
95 Block* target; 96 Control* target;
96 int length; 97 int length;
97 inline BreakDepthOperand(Decoder* decoder, const byte* pc) { 98 inline BreakDepthOperand(Decoder* decoder, const byte* pc) {
98 depth = decoder->checked_read_u32v(pc, 1, &length, "break depth"); 99 int len1 = 0;
100 int len2 = 0;
101 arity = decoder->checked_read_u32v(pc, 1, &len1, "argument count");
102 depth = decoder->checked_read_u32v(pc, 1 + len1, &len2, "break depth");
103 length = len1 + len2;
99 target = nullptr; 104 target = nullptr;
100 } 105 }
101 }; 106 };
102 107
103 struct BlockCountOperand { 108 struct CallIndirectOperand {
104 uint32_t count; 109 uint32_t arity;
105 int length;
106 inline BlockCountOperand(Decoder* decoder, const byte* pc) {
107 count = decoder->checked_read_u32v(pc, 1, &length, "block count");
108 }
109 };
110
111 struct SignatureIndexOperand {
112 uint32_t index; 110 uint32_t index;
113 FunctionSig* sig; 111 FunctionSig* sig;
114 int length; 112 int length;
115 inline SignatureIndexOperand(Decoder* decoder, const byte* pc) { 113 inline CallIndirectOperand(Decoder* decoder, const byte* pc) {
116 index = decoder->checked_read_u32v(pc, 1, &length, "signature index"); 114 int len1 = 0;
115 int len2 = 0;
116 arity = decoder->checked_read_u32v(pc, 1, &len1, "argument count");
117 index = decoder->checked_read_u32v(pc, 1 + len1, &len2, "signature index");
118 length = len1 + len2;
117 sig = nullptr; 119 sig = nullptr;
118 } 120 }
119 }; 121 };
120 122
121 struct FunctionIndexOperand { 123 struct CallFunctionOperand {
124 uint32_t arity;
122 uint32_t index; 125 uint32_t index;
123 FunctionSig* sig; 126 FunctionSig* sig;
124 int length; 127 int length;
125 inline FunctionIndexOperand(Decoder* decoder, const byte* pc) { 128 inline CallFunctionOperand(Decoder* decoder, const byte* pc) {
126 index = decoder->checked_read_u32v(pc, 1, &length, "function index"); 129 int len1 = 0;
130 int len2 = 0;
131 arity = decoder->checked_read_u32v(pc, 1, &len1, "argument count");
132 index = decoder->checked_read_u32v(pc, 1 + len1, &len2, "function index");
133 length = len1 + len2;
127 sig = nullptr; 134 sig = nullptr;
128 } 135 }
129 }; 136 };
130 137
131 struct ImportIndexOperand { 138 struct CallImportOperand {
139 uint32_t arity;
132 uint32_t index; 140 uint32_t index;
133 FunctionSig* sig; 141 FunctionSig* sig;
134 int length; 142 int length;
135 inline ImportIndexOperand(Decoder* decoder, const byte* pc) { 143 inline CallImportOperand(Decoder* decoder, const byte* pc) {
136 index = decoder->checked_read_u32v(pc, 1, &length, "import index"); 144 int len1 = 0;
145 int len2 = 0;
146 arity = decoder->checked_read_u32v(pc, 1, &len1, "argument count");
147 index = decoder->checked_read_u32v(pc, 1 + len1, &len2, "import index");
148 length = len1 + len2;
137 sig = nullptr; 149 sig = nullptr;
138 } 150 }
139 }; 151 };
140 152
141 struct BranchTableOperand { 153 struct BranchTableOperand {
154 uint32_t arity;
142 uint32_t table_count; 155 uint32_t table_count;
143 const byte* table; 156 const byte* table;
144 int length; 157 int length;
145 inline BranchTableOperand(Decoder* decoder, const byte* pc) { 158 inline BranchTableOperand(Decoder* decoder, const byte* pc) {
146 int varint_length; 159 int len1 = 0;
160 int len2 = 0;
161 arity = decoder->checked_read_u32v(pc, 1, &len1, "argument count");
147 table_count = 162 table_count =
148 decoder->checked_read_u32v(pc, 1, &varint_length, "expected #entries"); 163 decoder->checked_read_u32v(pc, 1 + len1, &len2, "table count");
149 length = varint_length + (table_count + 1) * sizeof(uint32_t); 164 length = len1 + len2 + (table_count + 1) * sizeof(uint32_t);
150 165
151 uint32_t table_start = 1 + varint_length; 166 uint32_t table_start = 1 + len1 + len2;
152 if (decoder->check(pc, table_start, (table_count + 1) * sizeof(uint32_t), 167 if (decoder->check(pc, table_start, (table_count + 1) * sizeof(uint32_t),
153 "expected <table entries>")) { 168 "expected <table entries>")) {
154 table = pc + table_start; 169 table = pc + table_start;
155 } else { 170 } else {
156 table = nullptr; 171 table = nullptr;
157 } 172 }
158 } 173 }
159 inline uint32_t read_entry(Decoder* decoder, int i) { 174 inline uint32_t read_entry(Decoder* decoder, int i) {
160 DCHECK(i >= 0 && static_cast<uint32_t>(i) <= table_count); 175 DCHECK(i >= 0 && static_cast<uint32_t>(i) <= table_count);
161 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; 176 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0;
162 } 177 }
163 }; 178 };
164 179
165 struct MemoryAccessOperand { 180 struct MemoryAccessOperand {
166 uint32_t alignment; 181 uint32_t alignment;
167 uint32_t offset; 182 uint32_t offset;
168 int length; 183 int length;
169 inline MemoryAccessOperand(Decoder* decoder, const byte* pc) { 184 inline MemoryAccessOperand(Decoder* decoder, const byte* pc) {
170 int alignment_length; 185 int alignment_length;
171 alignment = 186 alignment =
172 decoder->checked_read_u32v(pc, 1, &alignment_length, "alignment"); 187 decoder->checked_read_u32v(pc, 1, &alignment_length, "alignment");
173 int offset_length; 188 int offset_length;
174 offset = decoder->checked_read_u32v(pc, 1 + alignment_length, 189 offset = decoder->checked_read_u32v(pc, 1 + alignment_length,
175 &offset_length, "offset"); 190 &offset_length, "offset");
176 length = alignment_length + offset_length; 191 length = alignment_length + offset_length;
177 } 192 }
178 }; 193 };
179 194
195 struct ReturnArityOperand {
196 uint32_t arity;
197 int length;
198
199 inline ReturnArityOperand(Decoder* decoder, const byte* pc) {
200 arity = decoder->checked_read_u32v(pc, 1, &length, "return count");
201 }
202 };
203
180 typedef compiler::WasmGraphBuilder TFBuilder; 204 typedef compiler::WasmGraphBuilder TFBuilder;
181 struct ModuleEnv; // forward declaration of module interface. 205 struct ModuleEnv; // forward declaration of module interface.
182 206
183 // All of the various data structures necessary to decode a function body. 207 // All of the various data structures necessary to decode a function body.
184 struct FunctionBody { 208 struct FunctionBody {
185 ModuleEnv* module; // module environment 209 ModuleEnv* module; // module environment
186 FunctionSig* sig; // function signature 210 FunctionSig* sig; // function signature
187 const byte* base; // base of the module bytes, for error reporting 211 const byte* base; // base of the module bytes, for error reporting
188 const byte* start; // start of the function body 212 const byte* start; // start of the function body
189 const byte* end; // end of the function body 213 const byte* end; // end of the function body
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 int OpcodeLength(const byte* pc, const byte* end); 262 int OpcodeLength(const byte* pc, const byte* end);
239 263
240 // Computes the arity (number of sub-nodes) of the opcode at the given address. 264 // Computes the arity (number of sub-nodes) of the opcode at the given address.
241 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc, 265 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc,
242 const byte* end); 266 const byte* end);
243 } // namespace wasm 267 } // namespace wasm
244 } // namespace internal 268 } // namespace internal
245 } // namespace v8 269 } // namespace v8
246 270
247 #endif // V8_WASM_AST_DECODER_H_ 271 #endif // V8_WASM_AST_DECODER_H_
OLDNEW
« no previous file with comments | « src/wasm/asm-wasm-builder.cc ('k') | src/wasm/ast-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698