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_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/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
10 #include "src/signature.h" | 10 #include "src/signature.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 uint32_t depth; | 179 uint32_t depth; |
180 Control* target; | 180 Control* target; |
181 unsigned length; | 181 unsigned length; |
182 inline BreakDepthOperand(Decoder* decoder, const byte* pc) { | 182 inline BreakDepthOperand(Decoder* decoder, const byte* pc) { |
183 depth = decoder->checked_read_u32v(pc, 1, &length, "break depth"); | 183 depth = decoder->checked_read_u32v(pc, 1, &length, "break depth"); |
184 target = nullptr; | 184 target = nullptr; |
185 } | 185 } |
186 }; | 186 }; |
187 | 187 |
188 struct CallIndirectOperand { | 188 struct CallIndirectOperand { |
| 189 uint32_t table_index; |
189 uint32_t index; | 190 uint32_t index; |
190 FunctionSig* sig; | 191 FunctionSig* sig; |
191 unsigned length; | 192 unsigned length; |
192 inline CallIndirectOperand(Decoder* decoder, const byte* pc) { | 193 inline CallIndirectOperand(Decoder* decoder, const byte* pc) { |
193 unsigned len1 = 0; | 194 unsigned len1 = 1; |
194 unsigned len2 = 0; | 195 unsigned len2 = 0; |
| 196 table_index = decoder->checked_read_u8(pc, 1, "table index"); |
| 197 if (table_index != 0) { |
| 198 decoder->error(pc, pc + 1, "expected table index 0, found %u", |
| 199 table_index); |
| 200 } |
195 index = decoder->checked_read_u32v(pc, 1 + len1, &len2, "signature index"); | 201 index = decoder->checked_read_u32v(pc, 1 + len1, &len2, "signature index"); |
196 length = len1 + len2; | 202 length = len1 + len2; |
197 sig = nullptr; | 203 sig = nullptr; |
198 } | 204 } |
199 }; | 205 }; |
200 | 206 |
201 struct CallFunctionOperand { | 207 struct CallFunctionOperand { |
202 uint32_t index; | 208 uint32_t index; |
203 FunctionSig* sig; | 209 FunctionSig* sig; |
204 unsigned length; | 210 unsigned length; |
205 inline CallFunctionOperand(Decoder* decoder, const byte* pc) { | 211 inline CallFunctionOperand(Decoder* decoder, const byte* pc) { |
206 unsigned len1 = 0; | 212 unsigned len1 = 0; |
207 unsigned len2 = 0; | 213 unsigned len2 = 0; |
208 index = decoder->checked_read_u32v(pc, 1 + len1, &len2, "function index"); | 214 index = decoder->checked_read_u32v(pc, 1 + len1, &len2, "function index"); |
209 length = len1 + len2; | 215 length = len1 + len2; |
210 sig = nullptr; | 216 sig = nullptr; |
211 } | 217 } |
212 }; | 218 }; |
213 | 219 |
| 220 struct MemoryIndexOperand { |
| 221 uint32_t index; |
| 222 unsigned length; |
| 223 inline MemoryIndexOperand(Decoder* decoder, const byte* pc) { |
| 224 index = decoder->checked_read_u8(pc, 1, "memory index"); |
| 225 if (index != 0) { |
| 226 decoder->error(pc, pc + 1, "expected memory index 0, found %u", index); |
| 227 } |
| 228 length = 1; |
| 229 } |
| 230 }; |
| 231 |
214 struct BranchTableOperand { | 232 struct BranchTableOperand { |
215 uint32_t table_count; | 233 uint32_t table_count; |
216 const byte* start; | 234 const byte* start; |
217 const byte* table; | 235 const byte* table; |
218 inline BranchTableOperand(Decoder* decoder, const byte* pc) { | 236 inline BranchTableOperand(Decoder* decoder, const byte* pc) { |
219 DCHECK_EQ(kExprBrTable, decoder->checked_read_u8(pc, 0, "opcode")); | 237 DCHECK_EQ(kExprBrTable, decoder->checked_read_u8(pc, 0, "opcode")); |
220 start = pc + 1; | 238 start = pc + 1; |
221 unsigned len1 = 0; | 239 unsigned len1 = 0; |
222 table_count = decoder->checked_read_u32v(pc, 1, &len1, "table count"); | 240 table_count = decoder->checked_read_u32v(pc, 1, &len1, "table count"); |
223 if (table_count > (UINT_MAX / sizeof(uint32_t)) - 1 || | 241 if (table_count > (UINT_MAX / sizeof(uint32_t)) - 1 || |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 436 } |
419 | 437 |
420 bool has_next() { return pc_ < end_; } | 438 bool has_next() { return pc_ < end_; } |
421 }; | 439 }; |
422 | 440 |
423 } // namespace wasm | 441 } // namespace wasm |
424 } // namespace internal | 442 } // namespace internal |
425 } // namespace v8 | 443 } // namespace v8 |
426 | 444 |
427 #endif // V8_WASM_AST_DECODER_H_ | 445 #endif // V8_WASM_AST_DECODER_H_ |
OLD | NEW |