Chromium Code Reviews| 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/bits.h" | |
| 9 #include "src/machine-type.h" | |
| 8 #include "src/signature.h" | 10 #include "src/signature.h" |
| 9 #include "src/wasm/decoder.h" | 11 #include "src/wasm/decoder.h" |
| 10 #include "src/wasm/wasm-opcodes.h" | 12 #include "src/wasm/wasm-opcodes.h" |
| 11 #include "src/wasm/wasm-result.h" | 13 #include "src/wasm/wasm-result.h" |
| 12 | 14 |
| 13 namespace v8 { | 15 namespace v8 { |
| 14 namespace internal { | 16 namespace internal { |
| 15 | 17 |
| 16 class BitVector; // forward declaration | 18 class BitVector; // forward declaration |
| 17 | 19 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 inline uint32_t read_entry(Decoder* decoder, unsigned i) { | 178 inline uint32_t read_entry(Decoder* decoder, unsigned i) { |
| 177 DCHECK(i <= table_count); | 179 DCHECK(i <= table_count); |
| 178 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; | 180 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; |
| 179 } | 181 } |
| 180 }; | 182 }; |
| 181 | 183 |
| 182 struct MemoryAccessOperand { | 184 struct MemoryAccessOperand { |
| 183 uint32_t alignment; | 185 uint32_t alignment; |
| 184 uint32_t offset; | 186 uint32_t offset; |
| 185 unsigned length; | 187 unsigned length; |
| 186 inline MemoryAccessOperand(Decoder* decoder, const byte* pc) { | 188 inline MemoryAccessOperand(Decoder* decoder, const byte* pc, |
|
titzer
2016/08/26 08:24:17
Why not just pass the maximum alignment size here?
ahaas
2016/09/01 17:18:29
Done.
| |
| 189 MachineType type) { | |
| 187 unsigned alignment_length; | 190 unsigned alignment_length; |
| 188 alignment = | 191 alignment = |
| 189 decoder->checked_read_u32v(pc, 1, &alignment_length, "alignment"); | 192 decoder->checked_read_u32v(pc, 1, &alignment_length, "alignment"); |
| 193 if (type != MachineType::None() && | |
| 194 ElementSizeLog2Of(type.representation()) < | |
| 195 static_cast<int>(alignment)) { | |
| 196 decoder->error(pc, | |
| 197 "alignment must be less or equal to natural alignment"); | |
| 198 } | |
| 190 unsigned offset_length; | 199 unsigned offset_length; |
| 191 offset = decoder->checked_read_u32v(pc, 1 + alignment_length, | 200 offset = decoder->checked_read_u32v(pc, 1 + alignment_length, |
| 192 &offset_length, "offset"); | 201 &offset_length, "offset"); |
| 193 length = alignment_length + offset_length; | 202 length = alignment_length + offset_length; |
| 194 } | 203 } |
| 195 }; | 204 }; |
| 196 | 205 |
| 197 struct ReturnArityOperand { | 206 struct ReturnArityOperand { |
| 198 uint32_t arity; | 207 uint32_t arity; |
| 199 unsigned length; | 208 unsigned length; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 } | 339 } |
| 331 | 340 |
| 332 bool has_next() { return pc_ < end_; } | 341 bool has_next() { return pc_ < end_; } |
| 333 }; | 342 }; |
| 334 | 343 |
| 335 } // namespace wasm | 344 } // namespace wasm |
| 336 } // namespace internal | 345 } // namespace internal |
| 337 } // namespace v8 | 346 } // namespace v8 |
| 338 | 347 |
| 339 #endif // V8_WASM_AST_DECODER_H_ | 348 #endif // V8_WASM_AST_DECODER_H_ |
| OLD | NEW |