| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 std::ostream& operator<<(std::ostream& os, const WasmFunction& function); | 352 std::ostream& operator<<(std::ostream& os, const WasmFunction& function); |
| 353 std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name); | 353 std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name); |
| 354 | 354 |
| 355 // Extract a function name from the given wasm instance. | 355 // Extract a function name from the given wasm instance. |
| 356 // Returns "<WASM UNNAMED>" if no instance is passed, the function is unnamed or | 356 // Returns "<WASM UNNAMED>" if no instance is passed, the function is unnamed or |
| 357 // the name is not a valid UTF-8 string. | 357 // the name is not a valid UTF-8 string. |
| 358 // TODO(5620): Refactor once we always get a wasm instance. | 358 // TODO(5620): Refactor once we always get a wasm instance. |
| 359 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> instance, | 359 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> instance, |
| 360 uint32_t func_index); | 360 uint32_t func_index); |
| 361 | 361 |
| 362 // Return the binary source bytes of a wasm module. | |
| 363 Handle<SeqOneByteString> GetWasmBytes(Handle<JSObject> wasm); | |
| 364 | |
| 365 // Get the debug info associated with the given wasm object. | 362 // Get the debug info associated with the given wasm object. |
| 366 // If no debug info exists yet, it is created automatically. | 363 // If no debug info exists yet, it is created automatically. |
| 367 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); | 364 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); |
| 368 | 365 |
| 369 // Return the number of functions in the given wasm object. | 366 // Return the number of functions in the given wasm object. |
| 370 int GetNumberOfFunctions(Handle<JSObject> wasm); | 367 int GetNumberOfFunctions(Handle<JSObject> wasm); |
| 371 | 368 |
| 372 // Check whether the given object represents a WebAssembly.Instance instance. | 369 // Check whether the given object represents a WebAssembly.Instance instance. |
| 373 // This checks the number and type of internal fields, so it's not 100 percent | 370 // This checks the number and type of internal fields, so it's not 100 percent |
| 374 // secure. If it turns out that we need more complete checks, we could add a | 371 // secure. If it turns out that we need more complete checks, we could add a |
| 375 // special marker as internal field, which will definitely never occur anywhere | 372 // special marker as internal field, which will definitely never occur anywhere |
| 376 // else. | 373 // else. |
| 377 bool IsWasmInstance(Object* instance); | 374 bool IsWasmInstance(Object* instance); |
| 378 | 375 |
| 379 // Return the compiled module object for this WASM instance. | |
| 380 WasmCompiledModule* GetCompiledModule(Object* wasm_instance); | |
| 381 | |
| 382 // Check whether the wasm module was generated from asm.js code. | 376 // Check whether the wasm module was generated from asm.js code. |
| 383 bool WasmIsAsmJs(Object* instance, Isolate* isolate); | 377 bool WasmIsAsmJs(Object* instance, Isolate* isolate); |
| 384 | 378 |
| 385 // Get the script of the wasm module. If the origin of the module is asm.js, the | 379 // Get the script of the wasm module. If the origin of the module is asm.js, the |
| 386 // returned Script will be a JavaScript Script of Script::TYPE_NORMAL, otherwise | 380 // returned Script will be a JavaScript Script of Script::TYPE_NORMAL, otherwise |
| 387 // it's of type TYPE_WASM. | 381 // it's of type TYPE_WASM. |
| 388 Handle<Script> GetScript(Handle<JSObject> instance); | 382 Handle<Script> GetScript(Handle<JSObject> instance); |
| 389 | 383 |
| 390 // Compute the disassembly of a wasm function. | 384 // Compute the disassembly of a wasm function. |
| 391 // Returns the disassembly string and a list of <byte_offset, line, column> | 385 // Returns the disassembly string and a list of <byte_offset, line, column> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); | 437 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); |
| 444 void ValidateOrphanedInstance(Isolate* isolate, | 438 void ValidateOrphanedInstance(Isolate* isolate, |
| 445 Handle<WasmInstanceObject> instance); | 439 Handle<WasmInstanceObject> instance); |
| 446 | 440 |
| 447 } // namespace testing | 441 } // namespace testing |
| 448 } // namespace wasm | 442 } // namespace wasm |
| 449 } // namespace internal | 443 } // namespace internal |
| 450 } // namespace v8 | 444 } // namespace v8 |
| 451 | 445 |
| 452 #endif // V8_WASM_MODULE_H_ | 446 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |