Skip to content

Commit

Permalink
[browser] disable enablePerfMeasure by default (#86237)
Browse files Browse the repository at this point in the history
* disable enablePerfMeasure by default
* fixed wrong order of config initialization
  • Loading branch information
pavelsavara authored May 15, 2023
1 parent 35e61de commit 1dff328
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/mono/wasm/runtime/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function passEmscriptenInternals(internals: EmscriptenInternals): void {
runtimeHelpers.ExitStatus = internals.ExitStatus;
}

// NOTE: this is called AFTER the config is loaded
export function setRuntimeGlobals(globalObjects: GlobalObjects) {
if (_runtimeModuleLoaded) {
throw new Error("Runtime module already loaded");
Expand All @@ -44,9 +45,6 @@ export function setRuntimeGlobals(globalObjects: GlobalObjects) {
exportedRuntimeAPI = globalObjects.api;

Object.assign(runtimeHelpers, {
mono_wasm_bindings_is_ready: false,
javaScriptExports: {} as any,
enablePerfMeasure: true,
allAssetsInMemory: createPromiseController<void>(),
dotnetReady: createPromiseController<any>(),
memorySnapshotSkippedOrDone: createPromiseController<void>(),
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/runtime/loader/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function deep_merge_module(target: DotnetModuleInternal, source: DotnetMo
return Object.assign(target, providedConfig);
}

// NOTE: this is called before setRuntimeGlobals
export function normalizeConfig() {
// normalize
const config = loaderHelpers.config;
Expand Down
14 changes: 14 additions & 0 deletions src/mono/wasm/runtime/loader/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ export let exportedRuntimeAPI: RuntimeAPI = null as any;
export let INTERNAL: any;
export let _loaderModuleLoaded = false; // please keep it in place also as rollup guard

export const globalObjectsRoot: GlobalObjects = {
mono: {},
binding: {},
internal: {},
module: {},
loaderHelpers: {},
runtimeHelpers: {},
api: {}
} as any;

setLoaderGlobals(globalObjectsRoot);

export function setLoaderGlobals(
globalObjects: GlobalObjects,
) {
Expand All @@ -39,6 +51,8 @@ export function setLoaderGlobals(
config: { environmentVariables: {} }
});
Object.assign(runtimeHelpers, {
mono_wasm_bindings_is_ready: false,
javaScriptExports: {} as any,
config: globalObjects.module.config,
diagnosticTracing: false,
});
Expand Down
15 changes: 2 additions & 13 deletions src/mono/wasm/runtime/loader/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.

import type { MonoConfig, DotnetHostBuilder, DotnetModuleConfig, RuntimeAPI, WebAssemblyStartOptions } from "../types";
import type { MonoConfigInternal, GlobalObjects, EmscriptenModuleInternal, RuntimeModuleExportsInternal, NativeModuleExportsInternal, } from "../types/internal";
import type { MonoConfigInternal, EmscriptenModuleInternal, RuntimeModuleExportsInternal, NativeModuleExportsInternal, } from "../types/internal";

import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_WEB, exportedRuntimeAPI, setLoaderGlobals } from "./globals";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_WEB, exportedRuntimeAPI, globalObjectsRoot } from "./globals";
import { deep_merge_config, deep_merge_module, mono_wasm_load_config } from "./config";
import { mono_exit } from "./exit";
import { setup_proxy_console } from "./logging";
Expand All @@ -15,17 +15,6 @@ import { init_globalization } from "./icu";
import { setupPreloadChannelToMainThread } from "./worker";


export const globalObjectsRoot: GlobalObjects = {
mono: {},
binding: {},
internal: {},
module: {},
loaderHelpers: {},
runtimeHelpers: {},
api: {}
} as any;

setLoaderGlobals(globalObjectsRoot);
const module = globalObjectsRoot.module;
const monoConfig = module.config as MonoConfigInternal;

Expand Down

0 comments on commit 1dff328

Please sign in to comment.