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 <functional> | |
9 | |
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 typedef compiler::WasmGraphBuilder TFBuilder; | 206 typedef compiler::WasmGraphBuilder TFBuilder; |
205 struct ModuleEnv; // forward declaration of module interface. | 207 struct ModuleEnv; // forward declaration of module interface. |
206 | 208 |
207 // All of the various data structures necessary to decode a function body. | 209 // All of the various data structures necessary to decode a function body. |
208 struct FunctionBody { | 210 struct FunctionBody { |
209 ModuleEnv* module; // module environment | 211 ModuleEnv* module; // module environment |
210 FunctionSig* sig; // function signature | 212 FunctionSig* sig; // function signature |
211 const byte* base; // base of the module bytes, for error reporting | 213 const byte* base; // base of the module bytes, for error reporting |
212 const byte* start; // start of the function body | 214 const byte* start; // start of the function body |
213 const byte* end; // end of the function body | 215 const byte* end; // end of the function body |
216 static FunctionBody ForTesting(const byte* start, const byte* end) { | |
titzer
2016/06/10 10:57:40
Can you please move this out to the top level? (st
Clemens Hammacher
2016/06/13 09:45:17
Done.
Not sure though if style guide really advise
| |
217 return {nullptr, nullptr, start, start, end}; | |
218 } | |
214 }; | 219 }; |
215 | 220 |
216 struct Tree; | 221 struct Tree; |
217 typedef Result<Tree*> TreeResult; | 222 typedef Result<Tree*> TreeResult; |
218 | 223 |
219 std::ostream& operator<<(std::ostream& os, const Tree& tree); | 224 std::ostream& operator<<(std::ostream& os, const Tree& tree); |
220 | 225 |
221 TreeResult VerifyWasmCode(base::AccountingAllocator* allocator, | 226 TreeResult VerifyWasmCode(base::AccountingAllocator* allocator, |
222 FunctionBody& body); | 227 FunctionBody& body); |
223 TreeResult BuildTFGraph(base::AccountingAllocator* allocator, | 228 TreeResult BuildTFGraph(base::AccountingAllocator* allocator, |
224 TFBuilder* builder, FunctionBody& body); | 229 TFBuilder* builder, FunctionBody& body); |
225 void PrintAst(base::AccountingAllocator* allocator, FunctionBody& body); | 230 bool PrintAst(base::AccountingAllocator* allocator, const FunctionBody& body, |
231 std::ostream& os, | |
232 std::function<void(uint32_t)> instruction_callback = {}); | |
titzer
2016/06/10 10:57:40
There isn't a usecase for the instruction_callback
Clemens Hammacher
2016/06/13 09:45:17
Done.
| |
226 | 233 |
227 // A simplified form of AST printing, e.g. from a debugger. | 234 // A simplified form of AST printing, e.g. from a debugger. |
228 void PrintAstForDebugging(const byte* start, const byte* end); | 235 void PrintAstForDebugging(const byte* start, const byte* end); |
229 | 236 |
230 inline TreeResult VerifyWasmCode(base::AccountingAllocator* allocator, | 237 inline TreeResult VerifyWasmCode(base::AccountingAllocator* allocator, |
231 ModuleEnv* module, FunctionSig* sig, | 238 ModuleEnv* module, FunctionSig* sig, |
232 const byte* start, const byte* end) { | 239 const byte* start, const byte* end) { |
233 FunctionBody body = {module, sig, nullptr, start, end}; | 240 FunctionBody body = {module, sig, nullptr, start, end}; |
234 return VerifyWasmCode(allocator, body); | 241 return VerifyWasmCode(allocator, body); |
235 } | 242 } |
(...skipping 29 matching lines...) Expand all Loading... | |
265 int OpcodeLength(const byte* pc, const byte* end); | 272 int OpcodeLength(const byte* pc, const byte* end); |
266 | 273 |
267 // Computes the arity (number of sub-nodes) of the opcode at the given address. | 274 // Computes the arity (number of sub-nodes) of the opcode at the given address. |
268 int OpcodeArity(const byte* pc, const byte* end); | 275 int OpcodeArity(const byte* pc, const byte* end); |
269 | 276 |
270 } // namespace wasm | 277 } // namespace wasm |
271 } // namespace internal | 278 } // namespace internal |
272 } // namespace v8 | 279 } // namespace v8 |
273 | 280 |
274 #endif // V8_WASM_AST_DECODER_H_ | 281 #endif // V8_WASM_AST_DECODER_H_ |
OLD | NEW |