Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/wasm/ast-decoder.h

Issue 2050213002: [wasm] Implement AST printing into an ostream (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@refactor-function-names-table
Patch Set: address ahaas' comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ostreams.cc ('k') | src/wasm/ast-decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 // All of the various data structures necessary to decode a function body. 207 // All of the various data structures necessary to decode a function body.
208 struct FunctionBody { 208 struct FunctionBody {
209 ModuleEnv* module; // module environment 209 ModuleEnv* module; // module environment
210 FunctionSig* sig; // function signature 210 FunctionSig* sig; // function signature
211 const byte* base; // base of the module bytes, for error reporting 211 const byte* base; // base of the module bytes, for error reporting
212 const byte* start; // start of the function body 212 const byte* start; // start of the function body
213 const byte* end; // end of the function body 213 const byte* end; // end of the function body
214 }; 214 };
215 215
216 static inline FunctionBody FunctionBodyForTesting(const byte* start,
217 const byte* end) {
218 return {nullptr, nullptr, start, start, end};
219 }
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::vector<std::tuple<uint32_t, int, int>>* offset_table);
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
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_
OLDNEW
« no previous file with comments | « src/ostreams.cc ('k') | src/wasm/ast-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698