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

Side by Side Diff: src/wasm/wasm-module.h

Issue 2404253002: [wasm] Provide better stack traces for asm.js code (Closed)
Patch Set: Rebase & fix paths for windows Created 4 years, 2 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
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_MODULE_H_ 5 #ifndef V8_WASM_MODULE_H_
6 #define V8_WASM_MODULE_H_ 6 #define V8_WASM_MODULE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/api.h" 10 #include "src/api.h"
(...skipping 17 matching lines...) Expand all
28 const size_t kMaxModuleSize = 1024 * 1024 * 1024; 28 const size_t kMaxModuleSize = 1024 * 1024 * 1024;
29 const size_t kMaxFunctionSize = 128 * 1024; 29 const size_t kMaxFunctionSize = 128 * 1024;
30 const size_t kMaxStringSize = 256; 30 const size_t kMaxStringSize = 256;
31 const uint32_t kWasmMagic = 0x6d736100; 31 const uint32_t kWasmMagic = 0x6d736100;
32 const uint32_t kWasmVersion = 0x0c; 32 const uint32_t kWasmVersion = 0x0c;
33 33
34 const uint8_t kWasmFunctionTypeForm = 0x40; 34 const uint8_t kWasmFunctionTypeForm = 0x40;
35 const uint8_t kWasmAnyFunctionTypeForm = 0x20; 35 const uint8_t kWasmAnyFunctionTypeForm = 0x20;
36 36
37 enum WasmSectionCode { 37 enum WasmSectionCode {
38 kUnknownSectionCode = 0, // code for unknown sections 38 kUnknownSectionCode = 0, // code for unknown sections
39 kTypeSectionCode = 1, // Function signature declarations 39 kTypeSectionCode = 1, // Function signature declarations
40 kImportSectionCode = 2, // Import declarations 40 kImportSectionCode = 2, // Import declarations
41 kFunctionSectionCode = 3, // Function declarations 41 kFunctionSectionCode = 3, // Function declarations
42 kTableSectionCode = 4, // Indirect function table and other tables 42 kTableSectionCode = 4, // Indirect function table and other tables
43 kMemorySectionCode = 5, // Memory attributes 43 kMemorySectionCode = 5, // Memory attributes
44 kGlobalSectionCode = 6, // Global declarations 44 kGlobalSectionCode = 6, // Global declarations
45 kExportSectionCode = 7, // Exports 45 kExportSectionCode = 7, // Exports
46 kStartSectionCode = 8, // Start function declaration 46 kStartSectionCode = 8, // Start function declaration
47 kElementSectionCode = 9, // Elements section 47 kElementSectionCode = 9, // Elements section
48 kCodeSectionCode = 10, // Function code 48 kCodeSectionCode = 10, // Function code
49 kDataSectionCode = 11, // Data segments 49 kDataSectionCode = 11, // Data segments
50 kNameSectionCode = 12, // Name section (encoded as a string) 50 kNameSectionCode = 12, // Name section (encoded as a string)
51 kAsmOffsetsSectionCode = 13, // Asm.js offset table
51 }; 52 };
52 53
53 inline bool IsValidSectionCode(uint8_t byte) { 54 inline bool IsValidSectionCode(uint8_t byte) {
54 return kTypeSectionCode <= byte && byte <= kDataSectionCode; 55 return kTypeSectionCode <= byte && byte <= kDataSectionCode;
55 } 56 }
56 57
57 const char* SectionName(WasmSectionCode code); 58 const char* SectionName(WasmSectionCode code);
58 59
59 class WasmDebugInfo; 60 class WasmDebugInfo;
60 61
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 388
388 #define CORE_WCM_PROPERTY_TABLE(MACRO) \ 389 #define CORE_WCM_PROPERTY_TABLE(MACRO) \
389 MACRO(OBJECT, FixedArray, code_table) \ 390 MACRO(OBJECT, FixedArray, code_table) \
390 MACRO(OBJECT, FixedArray, imports) \ 391 MACRO(OBJECT, FixedArray, imports) \
391 MACRO(OBJECT, FixedArray, exports) \ 392 MACRO(OBJECT, FixedArray, exports) \
392 MACRO(OBJECT, FixedArray, inits) \ 393 MACRO(OBJECT, FixedArray, inits) \
393 MACRO(OBJECT, FixedArray, startup_function) \ 394 MACRO(OBJECT, FixedArray, startup_function) \
394 MACRO(OBJECT, FixedArray, indirect_function_tables) \ 395 MACRO(OBJECT, FixedArray, indirect_function_tables) \
395 MACRO(OBJECT, SeqOneByteString, module_bytes) \ 396 MACRO(OBJECT, SeqOneByteString, module_bytes) \
396 MACRO(OBJECT, ByteArray, function_names) \ 397 MACRO(OBJECT, ByteArray, function_names) \
398 MACRO(OBJECT, Script, asm_js_script) \
397 MACRO(SMALL_NUMBER, uint32_t, min_memory_pages) \ 399 MACRO(SMALL_NUMBER, uint32_t, min_memory_pages) \
398 MACRO(OBJECT, FixedArray, data_segments_info) \ 400 MACRO(OBJECT, FixedArray, data_segments_info) \
399 MACRO(OBJECT, ByteArray, data_segments) \ 401 MACRO(OBJECT, ByteArray, data_segments) \
400 MACRO(SMALL_NUMBER, uint32_t, globals_size) \ 402 MACRO(SMALL_NUMBER, uint32_t, globals_size) \
401 MACRO(OBJECT, JSArrayBuffer, heap) \ 403 MACRO(OBJECT, JSArrayBuffer, heap) \
402 MACRO(SMALL_NUMBER, ModuleOrigin, origin) \ 404 MACRO(SMALL_NUMBER, ModuleOrigin, origin) \
403 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \ 405 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \
404 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \ 406 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \
405 MACRO(WEAK_LINK, JSObject, owning_instance) \ 407 MACRO(WEAK_LINK, JSObject, owning_instance) \
406 MACRO(WEAK_LINK, JSObject, module_object) 408 MACRO(WEAK_LINK, JSObject, module_object)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 MaybeHandle<ByteArray> signature, 494 MaybeHandle<ByteArray> signature,
493 Handle<JSObject> module_instance); 495 Handle<JSObject> module_instance);
494 496
495 // Check whether the given object is a wasm object. 497 // Check whether the given object is a wasm object.
496 // This checks the number and type of internal fields, so it's not 100 percent 498 // This checks the number and type of internal fields, so it's not 100 percent
497 // secure. If it turns out that we need more complete checks, we could add a 499 // secure. If it turns out that we need more complete checks, we could add a
498 // special marker as internal field, which will definitely never occur anywhere 500 // special marker as internal field, which will definitely never occur anywhere
499 // else. 501 // else.
500 bool IsWasmObject(Object* object); 502 bool IsWasmObject(Object* object);
501 503
504 // Check whether the wasm module was generated from asm.js code.
505 bool WasmIsAsm(Object* wasm, Isolate* isolate);
506
507 // Get the script for the asm.js origin of the wasm module.
508 Handle<Script> GetAsmWasmScript(Handle<JSObject> wasm);
509
510 // Get the asm.js source position for the given byte offset in the given
511 // function.
512 int GetAsmWasmSourcePosition(Handle<JSObject> wasm, int func_index,
513 int byte_offset);
514
502 // Update memory references of code objects associated with the module 515 // Update memory references of code objects associated with the module
503 bool UpdateWasmModuleMemory(Handle<JSObject> object, Address old_start, 516 bool UpdateWasmModuleMemory(Handle<JSObject> object, Address old_start,
504 Address new_start, uint32_t old_size, 517 Address new_start, uint32_t old_size,
505 uint32_t new_size); 518 uint32_t new_size);
506 519
507 // Constructs a single function table as a FixedArray of double size, 520 // Constructs a single function table as a FixedArray of double size,
508 // populating it with function signature indices and function indices. 521 // populating it with function signature indices and function indices.
509 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index, 522 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index,
510 const WasmModule* module); 523 const WasmModule* module);
511 524
512 // Populates a function table by replacing function indices with handles to 525 // Populates a function table by replacing function indices with handles to
513 // the compiled code. 526 // the compiled code.
514 void PopulateFunctionTable(Handle<FixedArray> table, uint32_t table_size, 527 void PopulateFunctionTable(Handle<FixedArray> table, uint32_t table_size,
515 const std::vector<Handle<Code>>* code_table); 528 const std::vector<Handle<Code>>* code_table);
516 529
517 Handle<JSObject> CreateCompiledModuleObject( 530 Handle<JSObject> CreateCompiledModuleObject(
518 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, 531 Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
519 ModuleOrigin origin); 532 ModuleOrigin origin);
520 533
521 V8_EXPORT_PRIVATE MaybeHandle<JSObject> CreateModuleObjectFromBytes( 534 V8_EXPORT_PRIVATE MaybeHandle<JSObject> CreateModuleObjectFromBytes(
522 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, 535 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower,
523 ModuleOrigin origin); 536 ModuleOrigin origin, Handle<Script> asm_js_script);
titzer 2016/10/11 14:51:25 What if, instead of using a special section, we ju
Clemens Hammacher 2016/10/11 17:04:22 That's a very nice idea. Done. It makes things a l
524 537
525 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start, 538 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start,
526 const byte* end, 539 const byte* end,
527 ErrorThrower* thrower, 540 ErrorThrower* thrower,
528 ModuleOrigin origin); 541 ModuleOrigin origin);
529 542
530 // Get the number of imported functions for a WASM instance. 543 // Get the number of imported functions for a WASM instance.
531 int GetNumImportedFunctions(Handle<JSObject> wasm_object); 544 int GetNumImportedFunctions(Handle<JSObject> wasm_object);
532 545
533 // Assumed to be called with a code object associated to a wasm module instance. 546 // Assumed to be called with a code object associated to a wasm module instance.
(...skipping 12 matching lines...) Expand all
546 int instance_count); 559 int instance_count);
547 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); 560 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj);
548 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); 561 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance);
549 562
550 } // namespace testing 563 } // namespace testing
551 } // namespace wasm 564 } // namespace wasm
552 } // namespace internal 565 } // namespace internal
553 } // namespace v8 566 } // namespace v8
554 567
555 #endif // V8_WASM_MODULE_H_ 568 #endif // V8_WASM_MODULE_H_
OLDNEW
« src/isolate.cc ('K') | « src/wasm/wasm-js.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698