| 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 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "src/base/atomic-utils.h" | 7 #include "src/base/atomic-utils.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 | 9 |
| 10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 WasmCompiledModule::GetFunctionName(compiled_module, func_index); | 1863 WasmCompiledModule::GetFunctionName(compiled_module, func_index); |
| 1864 if (!maybe_name.is_null()) return maybe_name.ToHandleChecked(); | 1864 if (!maybe_name.is_null()) return maybe_name.ToHandleChecked(); |
| 1865 } | 1865 } |
| 1866 return isolate->factory()->NewStringFromStaticChars("<WASM UNNAMED>"); | 1866 return isolate->factory()->NewStringFromStaticChars("<WASM UNNAMED>"); |
| 1867 } | 1867 } |
| 1868 | 1868 |
| 1869 bool wasm::IsWasmInstance(Object* object) { | 1869 bool wasm::IsWasmInstance(Object* object) { |
| 1870 return WasmInstanceObject::IsWasmInstanceObject(object); | 1870 return WasmInstanceObject::IsWasmInstanceObject(object); |
| 1871 } | 1871 } |
| 1872 | 1872 |
| 1873 WasmCompiledModule* wasm::GetCompiledModule(Object* object) { | |
| 1874 return WasmInstanceObject::cast(object)->get_compiled_module(); | |
| 1875 } | |
| 1876 | |
| 1877 bool wasm::WasmIsAsmJs(Object* instance, Isolate* isolate) { | 1873 bool wasm::WasmIsAsmJs(Object* instance, Isolate* isolate) { |
| 1878 if (instance->IsUndefined(isolate)) return false; | 1874 if (instance->IsUndefined(isolate)) return false; |
| 1879 DCHECK(IsWasmInstance(instance)); | 1875 DCHECK(IsWasmInstance(instance)); |
| 1880 WasmCompiledModule* compiled_module = | 1876 WasmCompiledModule* compiled_module = |
| 1881 GetCompiledModule(JSObject::cast(instance)); | 1877 WasmInstanceObject::cast(instance)->get_compiled_module(); |
| 1882 DCHECK_EQ(compiled_module->has_asm_js_offset_tables(), | 1878 DCHECK_EQ(compiled_module->has_asm_js_offset_tables(), |
| 1883 compiled_module->script()->type() == Script::TYPE_NORMAL); | 1879 compiled_module->script()->type() == Script::TYPE_NORMAL); |
| 1884 return compiled_module->has_asm_js_offset_tables(); | 1880 return compiled_module->has_asm_js_offset_tables(); |
| 1885 } | 1881 } |
| 1886 | 1882 |
| 1887 Handle<Script> wasm::GetScript(Handle<JSObject> instance) { | 1883 Handle<Script> wasm::GetScript(Handle<JSObject> instance) { |
| 1888 DCHECK(IsWasmInstance(*instance)); | 1884 WasmCompiledModule* compiled_module = |
| 1889 WasmCompiledModule* compiled_module = GetCompiledModule(*instance); | 1885 WasmInstanceObject::cast(*instance)->get_compiled_module(); |
| 1890 DCHECK(compiled_module->has_script()); | 1886 DCHECK(compiled_module->has_script()); |
| 1891 return compiled_module->script(); | 1887 return compiled_module->script(); |
| 1892 } | 1888 } |
| 1893 | 1889 |
| 1894 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>> | 1890 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>> |
| 1895 wasm::DisassembleFunction(Handle<WasmCompiledModule> compiled_module, | 1891 wasm::DisassembleFunction(Handle<WasmCompiledModule> compiled_module, |
| 1896 int func_index) { | 1892 int func_index) { |
| 1897 std::ostringstream disassembly_os; | 1893 std::ostringstream disassembly_os; |
| 1898 std::vector<std::tuple<uint32_t, int, int>> offset_table; | 1894 std::vector<std::tuple<uint32_t, int, int>> offset_table; |
| 1899 | 1895 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1910 | 1906 |
| 1911 return {disassembly_os.str(), std::move(offset_table)}; | 1907 return {disassembly_os.str(), std::move(offset_table)}; |
| 1912 } | 1908 } |
| 1913 | 1909 |
| 1914 int wasm::GetAsmWasmSourcePosition(Handle<JSObject> instance, int func_index, | 1910 int wasm::GetAsmWasmSourcePosition(Handle<JSObject> instance, int func_index, |
| 1915 int byte_offset) { | 1911 int byte_offset) { |
| 1916 return WasmDebugInfo::GetAsmJsSourcePosition(GetDebugInfo(instance), | 1912 return WasmDebugInfo::GetAsmJsSourcePosition(GetDebugInfo(instance), |
| 1917 func_index, byte_offset); | 1913 func_index, byte_offset); |
| 1918 } | 1914 } |
| 1919 | 1915 |
| 1920 Handle<SeqOneByteString> wasm::GetWasmBytes(Handle<JSObject> object) { | |
| 1921 return Handle<WasmInstanceObject>::cast(object) | |
| 1922 ->get_compiled_module() | |
| 1923 ->module_bytes(); | |
| 1924 } | |
| 1925 | |
| 1926 Handle<WasmDebugInfo> wasm::GetDebugInfo(Handle<JSObject> object) { | 1916 Handle<WasmDebugInfo> wasm::GetDebugInfo(Handle<JSObject> object) { |
| 1927 auto instance = Handle<WasmInstanceObject>::cast(object); | 1917 auto instance = Handle<WasmInstanceObject>::cast(object); |
| 1928 if (instance->has_debug_info()) { | 1918 if (instance->has_debug_info()) { |
| 1929 Handle<WasmDebugInfo> info(instance->get_debug_info(), | 1919 Handle<WasmDebugInfo> info(instance->get_debug_info(), |
| 1930 instance->GetIsolate()); | 1920 instance->GetIsolate()); |
| 1931 return info; | 1921 return info; |
| 1932 } | 1922 } |
| 1933 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(instance); | 1923 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(instance); |
| 1934 instance->set_debug_info(*new_info); | 1924 instance->set_debug_info(*new_info); |
| 1935 return new_info; | 1925 return new_info; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2203 MaybeHandle<String> WasmCompiledModule::GetFunctionName( | 2193 MaybeHandle<String> WasmCompiledModule::GetFunctionName( |
| 2204 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) { | 2194 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) { |
| 2205 DCHECK_LT(func_index, compiled_module->module()->functions.size()); | 2195 DCHECK_LT(func_index, compiled_module->module()->functions.size()); |
| 2206 WasmFunction& function = compiled_module->module()->functions[func_index]; | 2196 WasmFunction& function = compiled_module->module()->functions[func_index]; |
| 2207 Isolate* isolate = compiled_module->GetIsolate(); | 2197 Isolate* isolate = compiled_module->GetIsolate(); |
| 2208 MaybeHandle<String> string = ExtractStringFromModuleBytes( | 2198 MaybeHandle<String> string = ExtractStringFromModuleBytes( |
| 2209 isolate, compiled_module, function.name_offset, function.name_length); | 2199 isolate, compiled_module, function.name_offset, function.name_length); |
| 2210 if (!string.is_null()) return string.ToHandleChecked(); | 2200 if (!string.is_null()) return string.ToHandleChecked(); |
| 2211 return {}; | 2201 return {}; |
| 2212 } | 2202 } |
| OLD | NEW |