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

Side by Side Diff: src/wasm/function-body-decoder.h

Issue 2594973003: [wasm] Rename ast-decoder.* to function-body-decoder.* (Closed)
Patch Set: Created 4 years 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/wasm/ast-decoder.cc ('k') | src/wasm/function-body-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_FUNCTION_BODY_DECODER_H_
6 #define V8_WASM_AST_DECODER_H_ 6 #define V8_WASM_FUNCTION_BODY_DECODER_H_
7 7
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "src/base/compiler-specific.h" 10 #include "src/base/compiler-specific.h"
11 #include "src/base/iterator.h" 11 #include "src/base/iterator.h"
12 #include "src/globals.h" 12 #include "src/globals.h"
13 #include "src/signature.h" 13 #include "src/signature.h"
14 #include "src/wasm/decoder.h" 14 #include "src/wasm/decoder.h"
15 #include "src/wasm/wasm-opcodes.h" 15 #include "src/wasm/wasm-opcodes.h"
16 #include "src/wasm/wasm-result.h" 16 #include "src/wasm/wasm-result.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 }; 329 };
330 typedef Result<DecodeStruct*> DecodeResult; 330 typedef Result<DecodeStruct*> DecodeResult;
331 inline std::ostream& operator<<(std::ostream& os, const DecodeStruct& tree) { 331 inline std::ostream& operator<<(std::ostream& os, const DecodeStruct& tree) {
332 return os; 332 return os;
333 } 333 }
334 334
335 V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator, 335 V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
336 FunctionBody& body); 336 FunctionBody& body);
337 DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, 337 DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder,
338 FunctionBody& body); 338 FunctionBody& body);
339 bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body, 339 bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
340 std::ostream& os, 340 std::ostream& os,
341 std::vector<std::tuple<uint32_t, int, int>>* offset_table); 341 std::vector<std::tuple<uint32_t, int, int>>* offset_table);
Clemens Hammacher 2016/12/21 12:32:42 At some point I should remove this offset_table. I
342 342
343 // A simplified form of AST printing, e.g. from a debugger. 343 // A simplified form of AST printing, e.g. from a debugger.
344 void PrintAstForDebugging(const byte* start, const byte* end); 344 void PrintWasmCodeForDebugging(const byte* start, const byte* end);
345 345
346 inline DecodeResult VerifyWasmCode(AccountingAllocator* allocator, 346 inline DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
347 ModuleEnv* module, FunctionSig* sig, 347 ModuleEnv* module, FunctionSig* sig,
348 const byte* start, const byte* end) { 348 const byte* start, const byte* end) {
349 FunctionBody body = {module, sig, nullptr, start, end}; 349 FunctionBody body = {module, sig, nullptr, start, end};
350 return VerifyWasmCode(allocator, body); 350 return VerifyWasmCode(allocator, body);
351 } 351 }
352 352
353 inline DecodeResult BuildTFGraph(AccountingAllocator* allocator, 353 inline DecodeResult BuildTFGraph(AccountingAllocator* allocator,
354 TFBuilder* builder, ModuleEnv* module, 354 TFBuilder* builder, ModuleEnv* module,
355 FunctionSig* sig, const byte* start, 355 FunctionSig* sig, const byte* start,
356 const byte* end) { 356 const byte* end) {
357 FunctionBody body = {module, sig, nullptr, start, end}; 357 FunctionBody body = {module, sig, nullptr, start, end};
358 return BuildTFGraph(allocator, builder, body); 358 return BuildTFGraph(allocator, builder, body);
359 } 359 }
360 360
361 struct AstLocalDecls { 361 struct BodyLocalDecls {
362 // The size of the encoded declarations. 362 // The size of the encoded declarations.
363 uint32_t decls_encoded_size; // size of encoded declarations 363 uint32_t decls_encoded_size; // size of encoded declarations
364 364
365 // Total number of locals. 365 // Total number of locals.
366 uint32_t total_local_count; 366 uint32_t total_local_count;
367 367
368 // List of {local type, count} pairs. 368 // List of {local type, count} pairs.
369 ZoneVector<std::pair<LocalType, uint32_t>> local_types; 369 ZoneVector<std::pair<LocalType, uint32_t>> local_types;
370 370
371 // Constructor initializes the vector. 371 // Constructor initializes the vector.
372 explicit AstLocalDecls(Zone* zone) 372 explicit BodyLocalDecls(Zone* zone)
373 : decls_encoded_size(0), total_local_count(0), local_types(zone) {} 373 : decls_encoded_size(0), total_local_count(0), local_types(zone) {}
374 }; 374 };
375 375
376 V8_EXPORT_PRIVATE bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, 376 V8_EXPORT_PRIVATE bool DecodeLocalDecls(BodyLocalDecls& decls,
377 const byte* end); 377 const byte* start, const byte* end);
378 V8_EXPORT_PRIVATE BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, 378 V8_EXPORT_PRIVATE BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone,
379 size_t num_locals, 379 size_t num_locals,
380 const byte* start, 380 const byte* start,
381 const byte* end); 381 const byte* end);
382 382
383 // Computes the length of the opcode at the given address. 383 // Computes the length of the opcode at the given address.
384 V8_EXPORT_PRIVATE unsigned OpcodeLength(const byte* pc, const byte* end); 384 V8_EXPORT_PRIVATE unsigned OpcodeLength(const byte* pc, const byte* end);
385 385
386 // A simple forward iterator for bytecodes. 386 // A simple forward iterator for bytecodes.
387 class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) { 387 class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 const byte* start_; 437 const byte* start_;
438 friend class BytecodeIterator; 438 friend class BytecodeIterator;
439 offset_iterator(const byte* start, const byte* ptr, const byte* end) 439 offset_iterator(const byte* start, const byte* ptr, const byte* end)
440 : iterator_base(ptr, end), start_(start) {} 440 : iterator_base(ptr, end), start_(start) {}
441 }; 441 };
442 442
443 // Create a new {BytecodeIterator}. If the {decls} pointer is non-null, 443 // Create a new {BytecodeIterator}. If the {decls} pointer is non-null,
444 // assume the bytecode starts with local declarations and decode them. 444 // assume the bytecode starts with local declarations and decode them.
445 // Otherwise, do not decode local decls. 445 // Otherwise, do not decode local decls.
446 BytecodeIterator(const byte* start, const byte* end, 446 BytecodeIterator(const byte* start, const byte* end,
447 AstLocalDecls* decls = nullptr); 447 BodyLocalDecls* decls = nullptr);
448 448
449 base::iterator_range<opcode_iterator> opcodes() { 449 base::iterator_range<opcode_iterator> opcodes() {
450 return base::iterator_range<opcode_iterator>(opcode_iterator(pc_, end_), 450 return base::iterator_range<opcode_iterator>(opcode_iterator(pc_, end_),
451 opcode_iterator(end_, end_)); 451 opcode_iterator(end_, end_));
452 } 452 }
453 453
454 base::iterator_range<offset_iterator> offsets() { 454 base::iterator_range<offset_iterator> offsets() {
455 return base::iterator_range<offset_iterator>( 455 return base::iterator_range<offset_iterator>(
456 offset_iterator(start_, pc_, end_), 456 offset_iterator(start_, pc_, end_),
457 offset_iterator(start_, end_, end_)); 457 offset_iterator(start_, end_, end_));
(...skipping 11 matching lines...) Expand all
469 } 469 }
470 } 470 }
471 471
472 bool has_next() { return pc_ < end_; } 472 bool has_next() { return pc_ < end_; }
473 }; 473 };
474 474
475 } // namespace wasm 475 } // namespace wasm
476 } // namespace internal 476 } // namespace internal
477 } // namespace v8 477 } // namespace v8
478 478
479 #endif // V8_WASM_AST_DECODER_H_ 479 #endif // V8_WASM_FUNCTION_BODY_DECODER_H_
OLDNEW
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | src/wasm/function-body-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698