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

Faster, smaller wasm runtime #51446

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/mono/wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ifeq ($(ENABLE_METADATA_UPDATE),true)
endif

EMCC_DEBUG_FLAGS =-g -Os -s ASSERTIONS=1 -DDEBUG=1
EMCC_RELEASE_FLAGS=-Oz --llvm-opts 2
EMCC_RELEASE_FLAGS=-O3 --llvm-opts 3

ifeq ($(NOSTRIP),)
STRIP_CMD=&& $(EMSDK_PATH)/upstream/bin/wasm-opt --strip-dwarf $(NATIVE_BIN_DIR)/dotnet.wasm -o $(NATIVE_BIN_DIR)/dotnet.wasm
Expand Down Expand Up @@ -108,13 +108,13 @@ $(BUILDS_OBJ_DIR)/pinvoke-table.h: $(PINVOKE_TABLE) | $(BUILDS_OBJ_DIR)
if cmp -s $(PINVOKE_TABLE) $$@ ; then : ; else cp $(PINVOKE_TABLE) $$@ ; fi

$(BUILDS_OBJ_DIR)/driver.o: runtime/driver.c | $(BUILDS_OBJ_DIR)
$(EMCC) $(EMCC_FLAGS) $(1) -Oz -DCORE_BINDINGS -I$(BUILDS_OBJ_DIR) -I$(MONO_INCLUDE_DIR) runtime/driver.c -c -o $$@
$(EMCC) $(EMCC_FLAGS) $(1) -O3 -DCORE_BINDINGS -I$(BUILDS_OBJ_DIR) -I$(MONO_INCLUDE_DIR) runtime/driver.c -c -o $$@

$(BUILDS_OBJ_DIR)/pinvoke.o: runtime/pinvoke.c runtime/pinvoke.h $(BUILDS_OBJ_DIR)/pinvoke-table.h | $(BUILDS_OBJ_DIR)
$(EMCC) $(EMCC_FLAGS) $(1) -Oz -DGEN_PINVOKE=1 -I$(BUILDS_OBJ_DIR) runtime/pinvoke.c -c -o $$@
$(EMCC) $(EMCC_FLAGS) $(1) -O3 -DGEN_PINVOKE=1 -I$(BUILDS_OBJ_DIR) runtime/pinvoke.c -c -o $$@

$(BUILDS_OBJ_DIR)/corebindings.o: runtime/corebindings.c | $(BUILDS_OBJ_DIR)
$(EMCC) $(EMCC_FLAGS) $(1) -Oz -I$(MONO_INCLUDE_DIR) runtime/corebindings.c -c -o $$@
$(EMCC) $(EMCC_FLAGS) $(1) -O3 -I$(MONO_INCLUDE_DIR) runtime/corebindings.c -c -o $$@

$(NATIVE_BIN_DIR)/src/emcc-flags.txt: | $(NATIVE_BIN_DIR)/src Makefile
echo "$(call escape_quote,$(EMCC_FLAGS)) $(1)" > $$@
Expand Down
9 changes: 4 additions & 5 deletions src/mono/wasm/runtime/binding_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ var BindingSupportLib = {
((typeof js_obj === "object" || typeof js_obj === "function") && typeof js_obj.then === "function")
}

var result;
switch (true) {
case js_obj === null:
case typeof js_obj === "undefined":
Expand Down Expand Up @@ -962,7 +963,7 @@ var BindingSupportLib = {

var conv = primitiveConverters.get (key);
if (!conv)
throw new Error ("Unknown parameter type " + type);
throw new Error ("Unknown parameter type " + key);

var localStep = Object.create (conv.steps[0]);
localStep.size = conv.size;
Expand Down Expand Up @@ -1300,7 +1301,7 @@ var BindingSupportLib = {
converter, buffer, resultRoot, exceptionRoot, argsRootBuffer, is_result_marshaled
) {
this._handle_exception_for_call (converter, buffer, resultRoot, exceptionRoot, argsRootBuffer);

var result;
if (is_result_marshaled)
result = this._unbox_mono_obj_root (resultRoot);
else
Expand Down Expand Up @@ -1443,7 +1444,7 @@ var BindingSupportLib = {
"return result;"
);

bodyJs = body.join ("\r\n");
var bodyJs = body.join ("\r\n");

if (friendly_name) {
var escapeRE = /[^A-Za-z0-9_]/g;
Expand Down Expand Up @@ -1699,7 +1700,6 @@ var BindingSupportLib = {

var js_args = BINDING.mono_wasm_parse_args(args);

var res;
try {
var m = obj [js_name];
if (typeof m === "undefined")
Expand Down Expand Up @@ -1731,7 +1731,6 @@ var BindingSupportLib = {
return BINDING.js_string_to_mono_string ("Invalid property name object '" + js_name + "'");
}

var res;
try {
var m = obj [js_name];
if (m === Object(m) && obj.__is_mono_proxied__)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/runtime/corebindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ EM_JS(MonoObject*, compile_function, (int snippet_ptr, int len, int *is_exceptio
}
catch (e)
{
res = e.toString ();
var res = e.toString ();
setValue (is_exception, 1, "i32");
if (res === null || res === undefined)
res = "unknown exception";
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/runtime/dotnet_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var DotNetSupportLib = {
var funcNameJsString = DOTNET.conv_string(functionName);
var argsJsonJsString = argsJson && DOTNET.conv_string (argsJson);

var dotNetExports = globaThis.DotNet;
var dotNetExports = globalThis.DotNet;
if (!dotNetExports) {
throw new Error('The Microsoft.JSInterop.js library is not loaded.');
}
Expand Down
Loading