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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const byte* end) { | 213 const byte* end) { |
214 FunctionBody body = {module, sig, nullptr, start, end}; | 214 FunctionBody body = {module, sig, nullptr, start, end}; |
215 return BuildTFGraph(allocator, builder, body); | 215 return BuildTFGraph(allocator, builder, body); |
216 } | 216 } |
217 | 217 |
218 enum ReadUnsignedLEB128ErrorCode { kNoError, kInvalidLEB128, kMissingLEB128 }; | 218 enum ReadUnsignedLEB128ErrorCode { kNoError, kInvalidLEB128, kMissingLEB128 }; |
219 | 219 |
220 ReadUnsignedLEB128ErrorCode ReadUnsignedLEB128Operand(const byte*, const byte*, | 220 ReadUnsignedLEB128ErrorCode ReadUnsignedLEB128Operand(const byte*, const byte*, |
221 int*, uint32_t*); | 221 int*, uint32_t*); |
222 | 222 |
223 std::vector<LocalType>* DecodeLocalDeclsForTesting( | 223 struct AstLocalDecls { |
224 base::AccountingAllocator* allocator, const byte* start, const byte* end); | 224 // The size of the encoded declarations. |
| 225 uint32_t decls_encoded_size; // size of encoded declarations |
| 226 |
| 227 // Total number of locals. |
| 228 uint32_t total_local_count; |
| 229 |
| 230 // List of {local type, count} pairs. |
| 231 ZoneVector<std::pair<LocalType, uint32_t>> local_types; |
| 232 |
| 233 // Constructor initializes the vector. |
| 234 explicit AstLocalDecls(Zone* zone) |
| 235 : decls_encoded_size(0), total_local_count(0), local_types(zone) {} |
| 236 }; |
| 237 |
| 238 bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, const byte* end); |
225 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 239 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
226 const byte* start, const byte* end); | 240 const byte* start, const byte* end); |
227 | 241 |
228 // Computes the length of the opcode at the given address. | 242 // Computes the length of the opcode at the given address. |
229 int OpcodeLength(const byte* pc, const byte* end); | 243 int OpcodeLength(const byte* pc, const byte* end); |
230 | 244 |
231 // Computes the arity (number of sub-nodes) of the opcode at the given address. | 245 // Computes the arity (number of sub-nodes) of the opcode at the given address. |
232 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc, | 246 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc, |
233 const byte* end); | 247 const byte* end); |
234 } // namespace wasm | 248 } // namespace wasm |
235 } // namespace internal | 249 } // namespace internal |
236 } // namespace v8 | 250 } // namespace v8 |
237 | 251 |
238 #endif // V8_WASM_AST_DECODER_H_ | 252 #endif // V8_WASM_AST_DECODER_H_ |
OLD | NEW |