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] cleanup of early startup code #83411

Merged
merged 6 commits into from
Apr 28, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
<PlatformManifestFileEntry Include="runtime.es6.iffe.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.es6.pre.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.es6.lib.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.es6.post.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.es6.extpost.js" IsNative="true" />
<PlatformManifestFileEntry Include="corebindings.c" IsNative="true" />
<PlatformManifestFileEntry Include="driver.c" IsNative="true" />
Expand Down
33 changes: 15 additions & 18 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,23 @@

"use strict";

import createDotnetRuntime from './dotnet.js'
import { dotnet, exit } from './dotnet.js'

try {
const runtime = await createDotnetRuntime(({ INTERNAL }) => ({
configSrc: "./mono-config.json",
onConfigLoaded: (config) => {
config.environmentVariables["DOTNET_MODIFIABLE_ASSEMBLIES"] = "debug";
/* For custom logging patch the functions below
config.diagnosticTracing = true;
config.environmentVariables["MONO_LOG_LEVEL"] = "debug";
config.environmentVariables["MONO_LOG_MASK"] = "all";
INTERNAL.logging = {
trace: (domain, log_level, message, isFatal, dataPtr) => console.log({ domain, log_level, message, isFatal, dataPtr }),
debugger: (level, message) => console.log({ level, message }),
};
*/
},
}));
const runtime = await dotnet
.withEnvironmentVariable("DOTNET_MODIFIABLE_ASSEMBLIES", "debug")
// For custom logging patch the functions below
//.withDiagnosticTracing(true)
//.withEnvironmentVariable("MONO_LOG_LEVEL", "debug")
//.withEnvironmentVariable("MONO_LOG_MASK", "all")
.create();
/*runtime.INTERNAL.logging = {
trace: (domain, log_level, message, isFatal, dataPtr) => console.log({ domain, log_level, message, isFatal, dataPtr }),
debugger: (level, message) => console.log({ level, message }),
};*/
App.runtime = runtime;
await App.init();
} catch (err) {
console.log(`WASM ERROR ${err}`);
}
catch (err) {
exit(2, err);
}
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ target_link_libraries(dotnet
${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a)

set_target_properties(dotnet PROPERTIES
LINK_DEPENDS "${NATIVE_BIN_DIR}/src/emcc-default.rsp;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.pre.js;${NATIVE_BIN_DIR}/src/es6/runtime.es6.iffe.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.lib.js;${NATIVE_BIN_DIR}/src/pal_random.lib.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.post.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js;"
LINK_FLAGS "@${NATIVE_BIN_DIR}/src/emcc-default.rsp @${NATIVE_BIN_DIR}/src/emcc-link.rsp ${CONFIGURATION_LINK_FLAGS} --extern-pre-js ${NATIVE_BIN_DIR}/src/es6/runtime.es6.iffe.js --pre-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.pre.js --js-library ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.lib.js --js-library ${NATIVE_BIN_DIR}/src/pal_random.lib.js --post-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.post.js --extern-post-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js "
LINK_DEPENDS "${NATIVE_BIN_DIR}/src/emcc-default.rsp;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.pre.js;${NATIVE_BIN_DIR}/src/es6/runtime.es6.iffe.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.lib.js;${NATIVE_BIN_DIR}/src/pal_random.lib.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js;"
LINK_FLAGS "@${NATIVE_BIN_DIR}/src/emcc-default.rsp @${NATIVE_BIN_DIR}/src/emcc-link.rsp ${CONFIGURATION_LINK_FLAGS} --extern-pre-js ${NATIVE_BIN_DIR}/src/es6/runtime.es6.iffe.js --pre-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.pre.js --js-library ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.lib.js --js-library ${NATIVE_BIN_DIR}/src/pal_random.lib.js --extern-post-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js "
RUNTIME_OUTPUT_DIRECTORY "${NATIVE_BIN_DIR}")

set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}")
Expand Down
7 changes: 4 additions & 3 deletions src/mono/wasm/runtime/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

import cwraps from "./cwraps";
import { mono_wasm_load_icu_data } from "./icu";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, Module, runtimeHelpers } from "./imports";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, Module, runtimeHelpers } from "./globals";
import { parseSymbolMapFile } from "./logging";
import { mono_wasm_load_bytes_into_heap } from "./memory";
import { endMeasure, MeasuredBlock, startMeasure } from "./profiler";
import { createPromiseController, PromiseAndController } from "./promise-controller";
import { delay } from "./promise-utils";
import { abort_startup, beforeOnRuntimeInitialized, memorySnapshotSkippedOrDone } from "./startup";
import { AssetBehaviours, AssetEntry, AssetEntryInternal, LoadingResource, mono_assert, ResourceRequest } from "./types";
import { AssetEntryInternal, mono_assert } from "./types";
import { AssetBehaviours, AssetEntry, LoadingResource, ResourceRequest } from "./types-api";
import { InstantiateWasmSuccessCallback, VoidPtr } from "./types/emscripten";

const allAssetsInMemory = createPromiseController<void>();
Expand Down Expand Up @@ -314,7 +315,7 @@ async function start_asset_download_sources(asset: AssetEntryInternal): Promise<
const loadingResource = download_resource(asset);
asset.pendingDownloadInternal = loadingResource;
response = await loadingResource.response;
if (!response.ok) {
if (!response || !response.ok) {
continue;// next source
}
return response;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/blazor/BootConfig.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { Module } from "../imports";
import { WebAssemblyBootResourceType } from "./WebAssemblyStartOptions";
import { Module } from "../globals";
import { WebAssemblyBootResourceType } from "../types-api";

type LoadBootResourceCallback = (type: WebAssemblyBootResourceType, name: string, defaultUri: string, integrity: string) => string | Promise<Response> | null | undefined;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { WebAssemblyBootResourceType, WebAssemblyStartOptions } from "../types-api";
import { toAbsoluteUri } from "./_Polyfill";
import { BootJsonData, ResourceList } from "./BootConfig";
import { WebAssemblyStartOptions, WebAssemblyBootResourceType } from "./WebAssemblyStartOptions";
const networkFetchCacheMode = "no-cache";

export class WebAssemblyResourceLoader {
Expand Down
30 changes: 0 additions & 30 deletions src/mono/wasm/runtime/blazor/WebAssemblyStartOptions.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/mono/wasm/runtime/blazor/_Integration.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { INTERNAL, Module } from "../imports";
import { AssetEntry, LoadingResource, MonoConfigInternal } from "../types";
import { INTERNAL, Module } from "../globals";
import { MonoConfigInternal } from "../types";
import { AssetEntry, LoadingResource, WebAssemblyBootResourceType } from "../types-api";
import { BootConfigResult, BootJsonData, ICUDataMode } from "./BootConfig";
import { WebAssemblyResourceLoader } from "./WebAssemblyResourceLoader";
import { WebAssemblyBootResourceType } from "./WebAssemblyStartOptions";
import { hasDebuggingEnabled } from "./_Polyfill";

export async function loadBootConfig(config: MonoConfigInternal,) {
Expand Down
28 changes: 28 additions & 0 deletions src/mono/wasm/runtime/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { DotnetModuleInternal, MonoConfigInternal } from "./types";
import { DotnetModuleConfig } from "./types-api";

export function deep_merge_config(target: MonoConfigInternal, source: MonoConfigInternal): MonoConfigInternal {
const providedConfig: MonoConfigInternal = { ...source };
if (providedConfig.assets) {
providedConfig.assets = [...(target.assets || []), ...(providedConfig.assets || [])];
}
if (providedConfig.environmentVariables) {
providedConfig.environmentVariables = { ...(target.environmentVariables || {}), ...(providedConfig.environmentVariables || {}) };
}
if (providedConfig.startupOptions) {
providedConfig.startupOptions = { ...(target.startupOptions || {}), ...(providedConfig.startupOptions || {}) };
}
if (providedConfig.runtimeOptions) {
providedConfig.runtimeOptions = [...(target.runtimeOptions || []), ...(providedConfig.runtimeOptions || [])];
}
return Object.assign(target, providedConfig);
}

export function deep_merge_module(target: DotnetModuleInternal, source: DotnetModuleConfig): DotnetModuleInternal {
const providedConfig: DotnetModuleConfig = { ...source };
if (providedConfig.config) {
if (!target.config) target.config = {};
providedConfig.config = deep_merge_config(target.config, providedConfig.config);
}
return Object.assign(target, providedConfig);
}
2 changes: 1 addition & 1 deletion src/mono/wasm/runtime/cwraps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
} from "./types";
import type { VoidPtr, CharPtrPtr, Int32Ptr, CharPtr, ManagedPointer } from "./types/emscripten";
import WasmEnableLegacyJsInterop from "consts:WasmEnableLegacyJsInterop";
import { disableLegacyJsInterop, Module } from "./imports";
import { disableLegacyJsInterop, Module } from "./globals";

type SigLine = [lazy: boolean, name: string, returnType: string | null, argTypes?: string[], opts?: any];

Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/runtime/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

import BuildConfiguration from "consts:configuration";
import { INTERNAL, Module, runtimeHelpers } from "./imports";
import { INTERNAL, Module, runtimeHelpers } from "./globals";
import { toBase64StringImpl } from "./base64";
import cwraps from "./cwraps";
import { VoidPtr, CharPtr } from "./types/emscripten";
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/runtime/diagnostics/browser/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

import cwraps from "../../cwraps";
import { INTERNAL } from "../../imports";
import { INTERNAL } from "../../globals";
import { withStackAlloc, getI32 } from "../../memory";
import { Thread, waitForThread } from "../../pthreads/browser";
import { isDiagnosticMessage, makeDiagnosticServerControlCommand } from "../shared/controller-commands";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import monoDiagnosticsMock from "consts:monoDiagnosticsMock";
import { assertNever } from "../../types";
import { pthread_self } from "../../pthreads/worker";
import { Module } from "../../imports";
import { Module } from "../../globals";
import cwraps from "../../cwraps";
import { EventPipeSessionIDImpl } from "../shared/types";
import { CharPtr } from "../../types/emscripten";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

import monoDiagnosticsMock from "consts:monoDiagnosticsMock";
import { runtimeHelpers } from "../../imports";
import { runtimeHelpers } from "../../globals";
import type { Mock } from "../mock";
import { mock } from "../mock";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { assertNever } from "../../types";
import { VoidPtr } from "../../types/emscripten";
import { Module } from "../../imports";
import { Module } from "../../globals";
import type { CommonSocket } from "./common-socket";
enum ListenerState {
Sending,
Expand Down
Loading