| 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_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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 387 | 387 | 
| 388 #define CORE_WCM_PROPERTY_TABLE(MACRO)                \ | 388 #define CORE_WCM_PROPERTY_TABLE(MACRO)                \ | 
| 389   MACRO(OBJECT, FixedArray, code_table)               \ | 389   MACRO(OBJECT, FixedArray, code_table)               \ | 
| 390   MACRO(OBJECT, FixedArray, imports)                  \ | 390   MACRO(OBJECT, FixedArray, imports)                  \ | 
| 391   MACRO(OBJECT, FixedArray, exports)                  \ | 391   MACRO(OBJECT, FixedArray, exports)                  \ | 
| 392   MACRO(OBJECT, FixedArray, inits)                    \ | 392   MACRO(OBJECT, FixedArray, inits)                    \ | 
| 393   MACRO(OBJECT, FixedArray, startup_function)         \ | 393   MACRO(OBJECT, FixedArray, startup_function)         \ | 
| 394   MACRO(OBJECT, FixedArray, indirect_function_tables) \ | 394   MACRO(OBJECT, FixedArray, indirect_function_tables) \ | 
| 395   MACRO(OBJECT, SeqOneByteString, module_bytes)       \ | 395   MACRO(OBJECT, SeqOneByteString, module_bytes)       \ | 
| 396   MACRO(OBJECT, ByteArray, function_names)            \ | 396   MACRO(OBJECT, ByteArray, function_names)            \ | 
|  | 397   MACRO(OBJECT, Script, asm_js_script)                \ | 
|  | 398   MACRO(OBJECT, ByteArray, asm_js_offset_tables)      \ | 
| 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  Loading... | 
| 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 // Return the compiled module object for this wasm object. | 
|  | 505 WasmCompiledModule* GetCompiledModule(JSObject* wasm); | 
|  | 506 | 
|  | 507 // Check whether the wasm module was generated from asm.js code. | 
|  | 508 bool WasmIsAsmJs(Object* wasm, Isolate* isolate); | 
|  | 509 | 
|  | 510 // Get the script for the asm.js origin of the wasm module. | 
|  | 511 Handle<Script> GetAsmWasmScript(Handle<JSObject> wasm); | 
|  | 512 | 
|  | 513 // Get the asm.js source position for the given byte offset in the given | 
|  | 514 // function. | 
|  | 515 int GetAsmWasmSourcePosition(Handle<JSObject> wasm, int func_index, | 
|  | 516                              int byte_offset); | 
|  | 517 | 
| 502 // Update memory references of code objects associated with the module | 518 // Update memory references of code objects associated with the module | 
| 503 bool UpdateWasmModuleMemory(Handle<JSObject> object, Address old_start, | 519 bool UpdateWasmModuleMemory(Handle<JSObject> object, Address old_start, | 
| 504                             Address new_start, uint32_t old_size, | 520                             Address new_start, uint32_t old_size, | 
| 505                             uint32_t new_size); | 521                             uint32_t new_size); | 
| 506 | 522 | 
| 507 // Constructs a single function table as a FixedArray of double size, | 523 // Constructs a single function table as a FixedArray of double size, | 
| 508 // populating it with function signature indices and function indices. | 524 // populating it with function signature indices and function indices. | 
| 509 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index, | 525 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index, | 
| 510                                       const WasmModule* module); | 526                                       const WasmModule* module); | 
| 511 | 527 | 
| 512 // Populates a function table by replacing function indices with handles to | 528 // Populates a function table by replacing function indices with handles to | 
| 513 // the compiled code. | 529 // the compiled code. | 
| 514 void PopulateFunctionTable(Handle<FixedArray> table, uint32_t table_size, | 530 void PopulateFunctionTable(Handle<FixedArray> table, uint32_t table_size, | 
| 515                            const std::vector<Handle<Code>>* code_table); | 531                            const std::vector<Handle<Code>>* code_table); | 
| 516 | 532 | 
| 517 Handle<JSObject> CreateCompiledModuleObject( | 533 Handle<JSObject> CreateCompiledModuleObject( | 
| 518     Isolate* isolate, Handle<WasmCompiledModule> compiled_module, | 534     Isolate* isolate, Handle<WasmCompiledModule> compiled_module, | 
| 519     ModuleOrigin origin); | 535     ModuleOrigin origin); | 
| 520 | 536 | 
| 521 V8_EXPORT_PRIVATE MaybeHandle<JSObject> CreateModuleObjectFromBytes( | 537 V8_EXPORT_PRIVATE MaybeHandle<JSObject> CreateModuleObjectFromBytes( | 
| 522     Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, | 538     Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, | 
| 523     ModuleOrigin origin); | 539     ModuleOrigin origin, Handle<Script> asm_js_script, | 
|  | 540     const byte* asm_offset_tables_start, const byte* asm_offset_tables_end); | 
| 524 | 541 | 
| 525 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start, | 542 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start, | 
| 526                                            const byte* end, | 543                                            const byte* end, | 
| 527                                            ErrorThrower* thrower, | 544                                            ErrorThrower* thrower, | 
| 528                                            ModuleOrigin origin); | 545                                            ModuleOrigin origin); | 
| 529 | 546 | 
| 530 // Get the number of imported functions for a WASM instance. | 547 // Get the number of imported functions for a WASM instance. | 
| 531 int GetNumImportedFunctions(Handle<JSObject> wasm_object); | 548 int GetNumImportedFunctions(Handle<JSObject> wasm_object); | 
| 532 | 549 | 
| 533 // Assumed to be called with a code object associated to a wasm module instance. | 550 // Assumed to be called with a code object associated to a wasm module instance. | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 546                             int instance_count); | 563                             int instance_count); | 
| 547 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); | 564 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); | 
| 548 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); | 565 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); | 
| 549 | 566 | 
| 550 }  // namespace testing | 567 }  // namespace testing | 
| 551 }  // namespace wasm | 568 }  // namespace wasm | 
| 552 }  // namespace internal | 569 }  // namespace internal | 
| 553 }  // namespace v8 | 570 }  // namespace v8 | 
| 554 | 571 | 
| 555 #endif  // V8_WASM_MODULE_H_ | 572 #endif  // V8_WASM_MODULE_H_ | 
| OLD | NEW | 
|---|