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 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>> | 390 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>> |
394 DisassembleFunction(Handle<WasmCompiledModule> compiled_module, int func_index); | 391 DisassembleFunction(Handle<WasmCompiledModule> compiled_module, int func_index); |
395 | 392 |
396 // Get the asm.js source position for the given byte offset in the given | |
397 // function. | |
398 int GetAsmWasmSourcePosition(Handle<JSObject> instance, int func_index, | |
399 int byte_offset); | |
400 | |
401 V8_EXPORT_PRIVATE MaybeHandle<WasmModuleObject> CreateModuleObjectFromBytes( | 393 V8_EXPORT_PRIVATE MaybeHandle<WasmModuleObject> CreateModuleObjectFromBytes( |
402 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, | 394 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, |
403 ModuleOrigin origin, Handle<Script> asm_js_script, | 395 ModuleOrigin origin, Handle<Script> asm_js_script, |
404 const byte* asm_offset_tables_start, const byte* asm_offset_tables_end); | 396 const byte* asm_offset_tables_start, const byte* asm_offset_tables_end); |
405 | 397 |
406 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start, | 398 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start, |
407 const byte* end, | 399 const byte* end, |
408 ErrorThrower* thrower, | 400 ErrorThrower* thrower, |
409 ModuleOrigin origin); | 401 ModuleOrigin origin); |
410 | 402 |
(...skipping 29 matching lines...) Expand all Loading... |
440 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); | 432 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); |
441 void ValidateOrphanedInstance(Isolate* isolate, | 433 void ValidateOrphanedInstance(Isolate* isolate, |
442 Handle<WasmInstanceObject> instance); | 434 Handle<WasmInstanceObject> instance); |
443 | 435 |
444 } // namespace testing | 436 } // namespace testing |
445 } // namespace wasm | 437 } // namespace wasm |
446 } // namespace internal | 438 } // namespace internal |
447 } // namespace v8 | 439 } // namespace v8 |
448 | 440 |
449 #endif // V8_WASM_MODULE_H_ | 441 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |