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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 : function_(function), name_(module_env->GetNameOrNull(function)) {} | 366 : function_(function), name_(module_env->GetNameOrNull(function)) {} |
367 | 367 |
368 const WasmFunction* function_; | 368 const WasmFunction* function_; |
369 WasmName name_; | 369 WasmName name_; |
370 }; | 370 }; |
371 | 371 |
372 std::ostream& operator<<(std::ostream& os, const WasmModule& module); | 372 std::ostream& operator<<(std::ostream& os, const WasmModule& module); |
373 std::ostream& operator<<(std::ostream& os, const WasmFunction& function); | 373 std::ostream& operator<<(std::ostream& os, const WasmFunction& function); |
374 std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name); | 374 std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name); |
375 | 375 |
376 // Extract a function name from the given wasm instance. | |
377 // Returns "<WASM UNNAMED>" if no instance is passed, the function is unnamed or | |
378 // the name is not a valid UTF-8 string. | |
379 // TODO(5620): Refactor once we always get a wasm instance. | |
380 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> instance, | |
381 uint32_t func_index); | |
382 | |
383 // Get the debug info associated with the given wasm object. | 376 // Get the debug info associated with the given wasm object. |
384 // If no debug info exists yet, it is created automatically. | 377 // If no debug info exists yet, it is created automatically. |
385 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); | 378 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); |
386 | 379 |
387 // Check whether the given object represents a WebAssembly.Instance instance. | 380 // Check whether the given object represents a WebAssembly.Instance instance. |
388 // This checks the number and type of internal fields, so it's not 100 percent | 381 // This checks the number and type of internal fields, so it's not 100 percent |
389 // secure. If it turns out that we need more complete checks, we could add a | 382 // secure. If it turns out that we need more complete checks, we could add a |
390 // special marker as internal field, which will definitely never occur anywhere | 383 // special marker as internal field, which will definitely never occur anywhere |
391 // else. | 384 // else. |
392 bool IsWasmInstance(Object* instance); | 385 bool IsWasmInstance(Object* instance); |
393 | 386 |
394 // Check whether the wasm module was generated from asm.js code. | |
395 bool WasmIsAsmJs(Object* instance, Isolate* isolate); | |
396 | |
397 // Get the script of the wasm module. If the origin of the module is asm.js, the | 387 // Get the script of the wasm module. If the origin of the module is asm.js, the |
398 // returned Script will be a JavaScript Script of Script::TYPE_NORMAL, otherwise | 388 // returned Script will be a JavaScript Script of Script::TYPE_NORMAL, otherwise |
399 // it's of type TYPE_WASM. | 389 // it's of type TYPE_WASM. |
400 Handle<Script> GetScript(Handle<JSObject> instance); | 390 Handle<Script> GetScript(Handle<JSObject> instance); |
401 | 391 |
402 V8_EXPORT_PRIVATE MaybeHandle<WasmModuleObject> CreateModuleObjectFromBytes( | 392 V8_EXPORT_PRIVATE MaybeHandle<WasmModuleObject> CreateModuleObjectFromBytes( |
403 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, | 393 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, |
404 ModuleOrigin origin, Handle<Script> asm_js_script, | 394 ModuleOrigin origin, Handle<Script> asm_js_script, |
405 const byte* asm_offset_tables_start, const byte* asm_offset_tables_end); | 395 const byte* asm_offset_tables_start, const byte* asm_offset_tables_end); |
406 | 396 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); | 437 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); |
448 void ValidateOrphanedInstance(Isolate* isolate, | 438 void ValidateOrphanedInstance(Isolate* isolate, |
449 Handle<WasmInstanceObject> instance); | 439 Handle<WasmInstanceObject> instance); |
450 | 440 |
451 } // namespace testing | 441 } // namespace testing |
452 } // namespace wasm | 442 } // namespace wasm |
453 } // namespace internal | 443 } // namespace internal |
454 } // namespace v8 | 444 } // namespace v8 |
455 | 445 |
456 #endif // V8_WASM_MODULE_H_ | 446 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |