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/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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 inline uint32_t read_entry(Decoder* decoder, unsigned i) { | 178 inline uint32_t read_entry(Decoder* decoder, unsigned i) { |
179 DCHECK(i <= table_count); | 179 DCHECK(i <= table_count); |
180 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; | 180 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; |
181 } | 181 } |
182 }; | 182 }; |
183 | 183 |
184 struct MemoryAccessOperand { | 184 struct MemoryAccessOperand { |
185 uint32_t alignment; | 185 uint32_t alignment; |
186 uint32_t offset; | 186 uint32_t offset; |
187 unsigned length; | 187 unsigned length; |
188 inline MemoryAccessOperand(Decoder* decoder, const byte* pc) { | 188 inline MemoryAccessOperand(Decoder* decoder, const byte* pc, |
| 189 uint32_t max_alignment) { |
189 unsigned alignment_length; | 190 unsigned alignment_length; |
190 alignment = | 191 alignment = |
191 decoder->checked_read_u32v(pc, 1, &alignment_length, "alignment"); | 192 decoder->checked_read_u32v(pc, 1, &alignment_length, "alignment"); |
| 193 if (max_alignment < alignment) { |
| 194 decoder->error(pc, pc + 1, |
| 195 "invalid alignment; expected maximum alignment is %u, " |
| 196 "actual alignment is %u", |
| 197 max_alignment, alignment); |
| 198 } |
192 unsigned offset_length; | 199 unsigned offset_length; |
193 offset = decoder->checked_read_u32v(pc, 1 + alignment_length, | 200 offset = decoder->checked_read_u32v(pc, 1 + alignment_length, |
194 &offset_length, "offset"); | 201 &offset_length, "offset"); |
195 length = alignment_length + offset_length; | 202 length = alignment_length + offset_length; |
196 } | 203 } |
197 }; | 204 }; |
198 | 205 |
199 struct ReturnArityOperand { | 206 struct ReturnArityOperand { |
200 uint32_t arity; | 207 uint32_t arity; |
201 unsigned length; | 208 unsigned length; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 339 } |
333 | 340 |
334 bool has_next() { return pc_ < end_; } | 341 bool has_next() { return pc_ < end_; } |
335 }; | 342 }; |
336 | 343 |
337 } // namespace wasm | 344 } // namespace wasm |
338 } // namespace internal | 345 } // namespace internal |
339 } // namespace v8 | 346 } // namespace v8 |
340 | 347 |
341 #endif // V8_WASM_AST_DECODER_H_ | 348 #endif // V8_WASM_AST_DECODER_H_ |
OLD | NEW |