diff options
author | Thays Grazia <thaystg@gmail.com> | 2020-07-06 15:04:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 15:04:47 +0300 |
commit | 8b8ee716f4a2d2ce62e4cf68e8f20fa957ee87b0 (patch) | |
tree | e65fb12811a0376deffcc38ca8dae4e9bcb9b0a0 /sdks | |
parent | b6ef72c244bd33623d231ff05bc3d120ad36b4e9 (diff) |
[wasm][debugger] Don't download unnecessary assemblies to DebugProxy (#20032)
* Identifying if an assembly has debug info and only download it to debug proxy if it has, this will speed up a lot the debugger initialisation.
Diffstat (limited to 'sdks')
-rw-r--r-- | sdks/wasm/src/driver.c | 6 | ||||
-rw-r--r-- | sdks/wasm/src/library_mono.js | 16 |
2 files changed, 15 insertions, 7 deletions
diff --git a/sdks/wasm/src/driver.c b/sdks/wasm/src/driver.c index d99c885da95..7aca18f48a4 100644 --- a/sdks/wasm/src/driver.c +++ b/sdks/wasm/src/driver.c @@ -9,6 +9,7 @@ #include <mono/metadata/assembly.h> #include <mono/metadata/tokentype.h> #include <mono/metadata/threads.h> +#include <mono/metadata/image.h> #include <mono/utils/mono-logger.h> #include <mono/utils/mono-dl-fallback.h> #include <mono/jit/jit.h> @@ -138,7 +139,7 @@ struct WasmAssembly_ { static WasmAssembly *assemblies; static int assembly_count; -EMSCRIPTEN_KEEPALIVE void +EMSCRIPTEN_KEEPALIVE int mono_wasm_add_assembly (const char *name, const unsigned char *data, unsigned int size) { int len = strlen (name); @@ -147,7 +148,7 @@ mono_wasm_add_assembly (const char *name, const unsigned char *data, unsigned in //FIXME handle debugging assemblies with .exe extension strcpy (&new_name [len - 3], "dll"); mono_register_symfile_for_assembly (new_name, data, size); - return; + return 1; } WasmAssembly *entry = g_new0 (WasmAssembly, 1); entry->assembly.name = strdup (name); @@ -156,6 +157,7 @@ mono_wasm_add_assembly (const char *name, const unsigned char *data, unsigned in entry->next = assemblies; assemblies = entry; ++assembly_count; + return mono_has_pdb_checksum (data, size); } EMSCRIPTEN_KEEPALIVE void diff --git a/sdks/wasm/src/library_mono.js b/sdks/wasm/src/library_mono.js index dbe79e9b321..92960f45479 100644 --- a/sdks/wasm/src/library_mono.js +++ b/sdks/wasm/src/library_mono.js @@ -607,7 +607,8 @@ var MonoSupportLib = { mono_load_runtime_and_bcl: function (vfs_prefix, deploy_prefix, enable_debugging, file_list, loaded_cb, fetch_file_cb) { var pending = file_list.length; var loaded_files = []; - var mono_wasm_add_assembly = Module.cwrap ('mono_wasm_add_assembly', null, ['string', 'number', 'number']); + var loaded_files_with_debug_info = []; + var mono_wasm_add_assembly = Module.cwrap ('mono_wasm_add_assembly', 'number', ['string', 'number', 'number']); if (!fetch_file_cb) { if (ENVIRONMENT_IS_NODE) { @@ -656,7 +657,7 @@ var MonoSupportLib = { } } else { - loaded_files.push (response.url); + loaded_files.push ({ url: response.url, file: file_name}); return response ['arrayBuffer'] (); } }).then (function (blob) { @@ -664,12 +665,17 @@ var MonoSupportLib = { var memory = Module._malloc(asm.length); var heapBytes = new Uint8Array(Module.HEAPU8.buffer, memory, asm.length); heapBytes.set (asm); - mono_wasm_add_assembly (file_name, memory, asm.length); - + var hasPpdb = mono_wasm_add_assembly (file_name, memory, asm.length); + + if (!hasPpdb) { + var index = loaded_files.findIndex(element => element.file == file_name); + loaded_files.splice(index, 1); + } //console.log ("MONO_WASM: Loaded: " + file_name); --pending; if (pending == 0) { - MONO.loaded_files = loaded_files; + loaded_files.forEach(value => loaded_files_with_debug_info.push(value.url)); + MONO.loaded_files = loaded_files_with_debug_info; var load_runtime = Module.cwrap ('mono_wasm_load_runtime', null, ['string', 'number']); console.log ("MONO_WASM: Initializing mono runtime"); |