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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 const byte* base; // base of the module bytes, for error reporting | 215 const byte* base; // base of the module bytes, for error reporting |
216 const byte* start; // start of the function body | 216 const byte* start; // start of the function body |
217 const byte* end; // end of the function body | 217 const byte* end; // end of the function body |
218 }; | 218 }; |
219 | 219 |
220 static inline FunctionBody FunctionBodyForTesting(const byte* start, | 220 static inline FunctionBody FunctionBodyForTesting(const byte* start, |
221 const byte* end) { | 221 const byte* end) { |
222 return {nullptr, nullptr, start, start, end}; | 222 return {nullptr, nullptr, start, start, end}; |
223 } | 223 } |
224 | 224 |
225 struct Tree; | 225 struct DecodeStruct { |
226 typedef Result<Tree*> TreeResult; | 226 int unused; |
| 227 }; |
| 228 typedef Result<DecodeStruct*> DecodeResult; |
| 229 inline std::ostream& operator<<(std::ostream& os, const DecodeStruct& tree) { |
| 230 return os; |
| 231 } |
227 | 232 |
228 std::ostream& operator<<(std::ostream& os, const Tree& tree); | 233 DecodeResult VerifyWasmCode(base::AccountingAllocator* allocator, |
229 | 234 FunctionBody& body); |
230 TreeResult VerifyWasmCode(base::AccountingAllocator* allocator, | 235 DecodeResult BuildTFGraph(base::AccountingAllocator* allocator, |
231 FunctionBody& body); | 236 TFBuilder* builder, FunctionBody& body); |
232 TreeResult BuildTFGraph(base::AccountingAllocator* allocator, | |
233 TFBuilder* builder, FunctionBody& body); | |
234 bool PrintAst(base::AccountingAllocator* allocator, const FunctionBody& body, | 237 bool PrintAst(base::AccountingAllocator* allocator, const FunctionBody& body, |
235 std::ostream& os, | 238 std::ostream& os, |
236 std::vector<std::tuple<uint32_t, int, int>>* offset_table); | 239 std::vector<std::tuple<uint32_t, int, int>>* offset_table); |
237 | 240 |
238 // A simplified form of AST printing, e.g. from a debugger. | 241 // A simplified form of AST printing, e.g. from a debugger. |
239 void PrintAstForDebugging(const byte* start, const byte* end); | 242 void PrintAstForDebugging(const byte* start, const byte* end); |
240 | 243 |
241 inline TreeResult VerifyWasmCode(base::AccountingAllocator* allocator, | 244 inline DecodeResult VerifyWasmCode(base::AccountingAllocator* allocator, |
242 ModuleEnv* module, FunctionSig* sig, | 245 ModuleEnv* module, FunctionSig* sig, |
243 const byte* start, const byte* end) { | 246 const byte* start, const byte* end) { |
244 FunctionBody body = {module, sig, nullptr, start, end}; | 247 FunctionBody body = {module, sig, nullptr, start, end}; |
245 return VerifyWasmCode(allocator, body); | 248 return VerifyWasmCode(allocator, body); |
246 } | 249 } |
247 | 250 |
248 inline TreeResult BuildTFGraph(base::AccountingAllocator* allocator, | 251 inline DecodeResult BuildTFGraph(base::AccountingAllocator* allocator, |
249 TFBuilder* builder, ModuleEnv* module, | 252 TFBuilder* builder, ModuleEnv* module, |
250 FunctionSig* sig, const byte* start, | 253 FunctionSig* sig, const byte* start, |
251 const byte* end) { | 254 const byte* end) { |
252 FunctionBody body = {module, sig, nullptr, start, end}; | 255 FunctionBody body = {module, sig, nullptr, start, end}; |
253 return BuildTFGraph(allocator, builder, body); | 256 return BuildTFGraph(allocator, builder, body); |
254 } | 257 } |
255 | 258 |
256 struct AstLocalDecls { | 259 struct AstLocalDecls { |
257 // The size of the encoded declarations. | 260 // The size of the encoded declarations. |
258 uint32_t decls_encoded_size; // size of encoded declarations | 261 uint32_t decls_encoded_size; // size of encoded declarations |
259 | 262 |
260 // Total number of locals. | 263 // Total number of locals. |
261 uint32_t total_local_count; | 264 uint32_t total_local_count; |
(...skipping 14 matching lines...) Expand all Loading... |
276 unsigned OpcodeLength(const byte* pc, const byte* end); | 279 unsigned OpcodeLength(const byte* pc, const byte* end); |
277 | 280 |
278 // Computes the arity (number of sub-nodes) of the opcode at the given address. | 281 // Computes the arity (number of sub-nodes) of the opcode at the given address. |
279 unsigned OpcodeArity(const byte* pc, const byte* end); | 282 unsigned OpcodeArity(const byte* pc, const byte* end); |
280 | 283 |
281 } // namespace wasm | 284 } // namespace wasm |
282 } // namespace internal | 285 } // namespace internal |
283 } // namespace v8 | 286 } // namespace v8 |
284 | 287 |
285 #endif // V8_WASM_AST_DECODER_H_ | 288 #endif // V8_WASM_AST_DECODER_H_ |
OLD | NEW |