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

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

Issue 2612643002: [wasm] simplify dependencies between graph builder and function decoder (Closed)
Patch Set: Created 3 years, 11 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/compiler/wasm-compiler.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_FUNCTION_BODY_DECODER_H_ 5 #ifndef V8_WASM_FUNCTION_BODY_DECODER_H_
6 #define V8_WASM_FUNCTION_BODY_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"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 max_alignment, alignment); 301 max_alignment, alignment);
302 } 302 }
303 unsigned offset_length; 303 unsigned offset_length;
304 offset = decoder->checked_read_u32v(pc, 1 + alignment_length, 304 offset = decoder->checked_read_u32v(pc, 1 + alignment_length,
305 &offset_length, "offset"); 305 &offset_length, "offset");
306 length = alignment_length + offset_length; 306 length = alignment_length + offset_length;
307 } 307 }
308 }; 308 };
309 309
310 typedef compiler::WasmGraphBuilder TFBuilder; 310 typedef compiler::WasmGraphBuilder TFBuilder;
311 struct ModuleEnv; // forward declaration of module interface. 311 struct WasmModule; // forward declaration of module interface.
312 312
313 // All of the various data structures necessary to decode a function body. 313 // All of the various data structures necessary to decode a function body.
314 struct FunctionBody { 314 struct FunctionBody {
315 ModuleEnv* module; // module environment
316 FunctionSig* sig; // function signature 315 FunctionSig* sig; // function signature
317 const byte* base; // base of the module bytes, for error reporting 316 const byte* base; // base of the module bytes, for error reporting
318 const byte* start; // start of the function body 317 const byte* start; // start of the function body
319 const byte* end; // end of the function body 318 const byte* end; // end of the function body
320 }; 319 };
321 320
322 static inline FunctionBody FunctionBodyForTesting(const byte* start, 321 static inline FunctionBody FunctionBodyForTesting(const byte* start,
323 const byte* end) { 322 const byte* end) {
324 return {nullptr, nullptr, start, start, end}; 323 return {nullptr, start, start, end};
325 } 324 }
326 325
327 struct DecodeStruct { 326 struct DecodeStruct {
328 int unused; 327 int unused;
329 }; 328 };
330 typedef Result<DecodeStruct*> DecodeResult; 329 typedef Result<DecodeStruct*> DecodeResult;
331 inline std::ostream& operator<<(std::ostream& os, const DecodeStruct& tree) { 330 inline std::ostream& operator<<(std::ostream& os, const DecodeStruct& tree) {
332 return os; 331 return os;
333 } 332 }
334 333
335 V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator, 334 V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
335 const wasm::WasmModule* module,
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 PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body, 339 bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
340 std::ostream& os, 340 const wasm::WasmModule* module, 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);
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 PrintWasmCodeForDebugging(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 const WasmModule* 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 = {sig, nullptr, start, end};
350 return VerifyWasmCode(allocator, body); 350 return VerifyWasmCode(allocator, module, 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, FunctionSig* sig,
355 FunctionSig* sig, const byte* start, 355 const byte* start, const byte* end) {
356 const byte* end) { 356 FunctionBody body = {sig, nullptr, start, end};
357 FunctionBody body = {module, sig, nullptr, start, end};
358 return BuildTFGraph(allocator, builder, body); 357 return BuildTFGraph(allocator, builder, body);
359 } 358 }
360 359
361 struct BodyLocalDecls { 360 struct BodyLocalDecls {
362 // The size of the encoded declarations. 361 // The size of the encoded declarations.
363 uint32_t decls_encoded_size; // size of encoded declarations 362 uint32_t decls_encoded_size; // size of encoded declarations
364 363
365 // Total number of locals. 364 // Total number of locals.
366 uint32_t total_local_count; 365 uint32_t total_local_count;
367 366
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 469 }
471 470
472 bool has_next() { return pc_ < end_; } 471 bool has_next() { return pc_ < end_; }
473 }; 472 };
474 473
475 } // namespace wasm 474 } // namespace wasm
476 } // namespace internal 475 } // namespace internal
477 } // namespace v8 476 } // namespace v8
478 477
479 #endif // V8_WASM_FUNCTION_BODY_DECODER_H_ 478 #endif // V8_WASM_FUNCTION_BODY_DECODER_H_
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/function-body-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698