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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // Returns "<WASM UNNAMED>" if no instance is passed, the function is unnamed or | 361 // Returns "<WASM UNNAMED>" if no instance is passed, the function is unnamed or |
362 // the name is not a valid UTF-8 string. | 362 // the name is not a valid UTF-8 string. |
363 // TODO(5620): Refactor once we always get a wasm instance. | 363 // TODO(5620): Refactor once we always get a wasm instance. |
364 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> instance, | 364 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> instance, |
365 uint32_t func_index); | 365 uint32_t func_index); |
366 | 366 |
367 // Get the debug info associated with the given wasm object. | 367 // Get the debug info associated with the given wasm object. |
368 // If no debug info exists yet, it is created automatically. | 368 // If no debug info exists yet, it is created automatically. |
369 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); | 369 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); |
370 | 370 |
371 // Return the number of functions in the given wasm object. | |
372 int GetNumberOfFunctions(Handle<JSObject> wasm); | |
373 | |
374 // Check whether the given object represents a WebAssembly.Instance instance. | 371 // Check whether the given object represents a WebAssembly.Instance instance. |
375 // This checks the number and type of internal fields, so it's not 100 percent | 372 // This checks the number and type of internal fields, so it's not 100 percent |
376 // secure. If it turns out that we need more complete checks, we could add a | 373 // secure. If it turns out that we need more complete checks, we could add a |
377 // special marker as internal field, which will definitely never occur anywhere | 374 // special marker as internal field, which will definitely never occur anywhere |
378 // else. | 375 // else. |
379 bool IsWasmInstance(Object* instance); | 376 bool IsWasmInstance(Object* instance); |
380 | 377 |
381 // Check whether the wasm module was generated from asm.js code. | 378 // Check whether the wasm module was generated from asm.js code. |
382 bool WasmIsAsmJs(Object* instance, Isolate* isolate); | 379 bool WasmIsAsmJs(Object* instance, Isolate* isolate); |
383 | 380 |
384 // Get the script of the wasm module. If the origin of the module is asm.js, the | 381 // Get the script of the wasm module. If the origin of the module is asm.js, the |
385 // returned Script will be a JavaScript Script of Script::TYPE_NORMAL, otherwise | 382 // returned Script will be a JavaScript Script of Script::TYPE_NORMAL, otherwise |
386 // it's of type TYPE_WASM. | 383 // it's of type TYPE_WASM. |
387 Handle<Script> GetScript(Handle<JSObject> instance); | 384 Handle<Script> GetScript(Handle<JSObject> instance); |
388 | 385 |
389 // Compute the disassembly of a wasm function. | 386 // Compute the disassembly of a wasm function. |
390 // Returns the disassembly string and a list of <byte_offset, line, column> | 387 // Returns the disassembly string and a list of <byte_offset, line, column> |
391 // entries, mapping wasm byte offsets to line and column in the disassembly. | 388 // entries, mapping wasm byte offsets to line and column in the disassembly. |
392 // The list is guaranteed to be ordered by the byte_offset. | 389 // The list is guaranteed to be ordered by the byte_offset. |
393 // Returns an empty string and empty vector if the function index is invalid. | 390 // Returns an empty string and empty vector if the function index is invalid. |
394 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>> | 391 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>> |
395 DisassembleFunction(Handle<WasmCompiledModule> compiled_module, int func_index); | 392 DisassembleFunction(Handle<WasmCompiledModule> compiled_module, int func_index); |
396 | 393 |
397 // Get the asm.js source position for the given byte offset in the given | |
398 // function. | |
399 int GetAsmWasmSourcePosition(Handle<JSObject> instance, int func_index, | |
400 int byte_offset); | |
401 | |
402 V8_EXPORT_PRIVATE MaybeHandle<WasmModuleObject> CreateModuleObjectFromBytes( | 394 V8_EXPORT_PRIVATE MaybeHandle<WasmModuleObject> CreateModuleObjectFromBytes( |
403 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, | 395 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, |
404 ModuleOrigin origin, Handle<Script> asm_js_script, | 396 ModuleOrigin origin, Handle<Script> asm_js_script, |
405 const byte* asm_offset_tables_start, const byte* asm_offset_tables_end); | 397 const byte* asm_offset_tables_start, const byte* asm_offset_tables_end); |
406 | 398 |
407 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start, | 399 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start, |
408 const byte* end, | 400 const byte* end, |
409 ErrorThrower* thrower, | 401 ErrorThrower* thrower, |
410 ModuleOrigin origin); | 402 ModuleOrigin origin); |
411 | 403 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); | 439 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); |
448 void ValidateOrphanedInstance(Isolate* isolate, | 440 void ValidateOrphanedInstance(Isolate* isolate, |
449 Handle<WasmInstanceObject> instance); | 441 Handle<WasmInstanceObject> instance); |
450 | 442 |
451 } // namespace testing | 443 } // namespace testing |
452 } // namespace wasm | 444 } // namespace wasm |
453 } // namespace internal | 445 } // namespace internal |
454 } // namespace v8 | 446 } // namespace v8 |
455 | 447 |
456 #endif // V8_WASM_MODULE_H_ | 448 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |