Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser] loader ES6 module #85730

Merged
merged 30 commits into from
May 11, 2023
Merged

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented May 3, 2023

Split the dotnet.js into 3 ES6 modules.

  • new smaller dotnet.js
    • this is "loader", small module which
    • is produced from code in the src\mono\wasm\runtime\loader\ folder
    • loads the mono-config.json or boot.config.json
    • loads dotnet.runtime.js and dotnet.nativejs by looking at the config.assets
  • dotnet.runtime.js
    • this is "runtime", the main JS logic we have in typescript
    • is produced from code in the src\mono\wasm\runtime\ folder except /loader folder
    • in the future we could further split off legacy intero and jiterp into separate JS files
  • dotnet.native.js
    • is the emscripten module, it changes on rebuild with workload
    • this one also brings the other dotnet.native.wasm, dotnet.native.symbols.js, dotnet.native.worker.js
    • because dotnet.native is the new prefix name.

future benefits

  • we could have hash in names of all of them but the loader, dotnet.js . The loader would not change on re-link with workload.
  • "loader" could do feature detection in the future and load different assets instead.
  • further unify/simplify blazor startup code
  • drop DLL cache, because of the hashes

Other changes

  • config has new assetUniqueQuery which is appended to asset names (so that we could have multiple instances of ES6 modules)
  • loaderHelpers is similar to runtimeHelpers but is populated by "loader". It passes methods and state between modules.
  • find_corlib_class and find_class_in_assembly would not always throw when they don't find the class.
  • updated WBT
  • moved files and types
  • added rollup assert, so that code doesn't bleed between modules
  • added startup assert to throw if the same ES6 module is initialized multiple times
  • fixed memory snapshot to play well with the new layout
  • new asset types js-module-runtime, js-module-dotnet, js-module-native
  • removed Module.imports functionality, dropped DotnetModuleConfigImports
  • removed MONO.mono_wasm_load_config from legacy API
  • simplified require polyfill on NodeJS
  • simplified locateFile polyfill
  • createEmscripten is worth review
  • fixed SelfContained
  • worker module dotnet.native.worker.js now loads dotnet.js loader first

@pavelsavara pavelsavara added this to the 8.0.0 milestone May 3, 2023
@pavelsavara pavelsavara requested a review from maraf May 3, 2023 20:02
@pavelsavara pavelsavara self-assigned this May 3, 2023
@ghost
Copy link

ghost commented May 3, 2023

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

wip

Author: pavelsavara
Assignees: pavelsavara
Labels:

arch-wasm, area-System.Runtime.InteropServices.JavaScript

Milestone: 8.0.0

# Conflicts:
#	src/mono/wasm/runtime/jiterpreter-trace-generator.ts
@pavelsavara pavelsavara changed the title [draft][browser] loader [browser] loader May 9, 2023
@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@pavelsavara pavelsavara marked this pull request as ready for review May 11, 2023 12:40
@pavelsavara
Copy link
Member Author

pavelsavara commented May 11, 2023

WBT fails with /root/helix/work/workitem/e/wbt/nuget/lqnz5tnh.1uj/microsoft.net.illink.tasks/8.0.0-preview.5.23260.3/build/Microsoft.NET.ILLink.targets(196,5): error NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app. which I think is unrelated.

All other CI failures are known.

Copy link
Member

@ilonatommy ilonatommy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

/**
* query string to be used for asset loading
*/
assetUniqueQuery?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit over WebAssemblyStartOptions.loadBootResource?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could unify those later. Right now, the loadBootResource is not there for non-blazor templates.

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara pavelsavara changed the title [browser] loader [browser] loader ES6 module May 11, 2023
Copy link
Member

@maraf maraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@pavelsavara pavelsavara merged commit c6e435b into dotnet:main May 11, 2023
@lewing
Copy link
Member

lewing commented May 12, 2023

This appears to have caused a massive regression in jsimport/export in browserbench?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants