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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 table = nullptr; | 158 table = nullptr; |
159 } | 159 } |
160 } | 160 } |
161 inline uint32_t read_entry(Decoder* decoder, int i) { | 161 inline uint32_t read_entry(Decoder* decoder, int i) { |
162 DCHECK(i >= 0 && static_cast<uint32_t>(i) <= table_count); | 162 DCHECK(i >= 0 && static_cast<uint32_t>(i) <= table_count); |
163 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; | 163 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; |
164 } | 164 } |
165 }; | 165 }; |
166 | 166 |
167 struct MemoryAccessOperand { | 167 struct MemoryAccessOperand { |
168 bool aligned; | 168 uint32_t alignment; |
169 uint32_t offset; | 169 uint32_t offset; |
170 int length; | 170 int length; |
171 inline MemoryAccessOperand(Decoder* decoder, const byte* pc) { | 171 inline MemoryAccessOperand(Decoder* decoder, const byte* pc) { |
172 byte bitfield = decoder->checked_read_u8(pc, 1, "memory access byte"); | 172 int alignment_length; |
173 aligned = MemoryAccess::AlignmentField::decode(bitfield); | 173 alignment = |
174 if (MemoryAccess::OffsetField::decode(bitfield)) { | 174 decoder->checked_read_u32v(pc, 1, &alignment_length, "alignment"); |
175 offset = decoder->checked_read_u32v(pc, 2, &length, "memory offset"); | 175 int offset_length; |
176 length++; | 176 offset = decoder->checked_read_u32v(pc, 1 + alignment_length, |
177 } else { | 177 &offset_length, "offset"); |
178 offset = 0; | 178 length = alignment_length + offset_length; |
179 length = 1; | |
180 } | |
181 } | 179 } |
182 }; | 180 }; |
183 | 181 |
184 typedef compiler::WasmGraphBuilder TFBuilder; | 182 typedef compiler::WasmGraphBuilder TFBuilder; |
185 struct ModuleEnv; // forward declaration of module interface. | 183 struct ModuleEnv; // forward declaration of module interface. |
186 | 184 |
187 // All of the various data structures necessary to decode a function body. | 185 // All of the various data structures necessary to decode a function body. |
188 struct FunctionBody { | 186 struct FunctionBody { |
189 ModuleEnv* module; // module environment | 187 ModuleEnv* module; // module environment |
190 FunctionSig* sig; // function signature | 188 FunctionSig* sig; // function signature |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 int OpcodeLength(const byte* pc, const byte* end); | 227 int OpcodeLength(const byte* pc, const byte* end); |
230 | 228 |
231 // Computes the arity (number of sub-nodes) of the opcode at the given address. | 229 // Computes the arity (number of sub-nodes) of the opcode at the given address. |
232 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc, | 230 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc, |
233 const byte* end); | 231 const byte* end); |
234 } // namespace wasm | 232 } // namespace wasm |
235 } // namespace internal | 233 } // namespace internal |
236 } // namespace v8 | 234 } // namespace v8 |
237 | 235 |
238 #endif // V8_WASM_AST_DECODER_H_ | 236 #endif // V8_WASM_AST_DECODER_H_ |
OLD | NEW |