Skip to content
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
20 changes: 17 additions & 3 deletions eng/pipelines/common/evaluate-default-paths.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ parameters:
]
_wasm_src_native: [
src/coreclr/vm/wasm/*
src/coreclr/hosts/*
src/native/minipal/*
src/native/libs/CMakeLists.txt
src/native/libs/configure.cmake
Expand All @@ -61,7 +62,7 @@ parameters:
src/native/libs/System.Globalization.Native/*
src/native/libs/System.IO.Compression.Native/*
src/native/libs/System.Native/*
src/native/corehost/browserhost/*
src/native/corehost/*
src/native/libs/Common/JavaScript/*
src/native/libs/System.Native.Browser/*
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/*
Expand Down Expand Up @@ -270,8 +271,8 @@ jobs:
- ${{ parameters._const_paths._always_exclude }}
- ${{ parameters._const_paths._perf_pipeline_specific_only }}

# wasm/runtimetests need to be run
- subset: wasm_runtimetests
# wasm/runtimetests mono need to be run
- subset: wasm_mono_runtimetests
combined: true
include:
- src/tests/*
Expand All @@ -292,6 +293,19 @@ jobs:
- ${{ parameters._const_paths._always_exclude }}
- ${{ parameters._const_paths._perf_pipeline_specific_only }}

# wasm/runtimetests coreCLR need to be run
- subset: wasm_coreclr_runtimetests
combined: true
include:
- src/tests/*
- src/coreclr/*
- ${{ parameters._const_paths._wasm_src_native }}
exclude:
- src/mono/*
- ${{ parameters._const_paths._wasm_pipelines }}
- ${{ parameters._const_paths._always_exclude }}
- ${{ parameters._const_paths._perf_pipeline_specific_only }}

# Wasm except Wasm.build.Tests, Wasi.build.Tests and debugger
- subset: wasm_specific_except_wbt_dbg
combined: true
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/common/templates/wasm-runtime-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
or(
eq(variables['wasmDarcDependenciesChanged'], true),
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_tools_illink.containsChange'], true),
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_wasm_runtimetests.containsChange'], true))
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_wasm_mono_runtimetests.containsChange'], true))
]
jobParameters:
testGroup: innerloop
Expand Down
4 changes: 3 additions & 1 deletion eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ extends:
timeoutInMinutes: 120
condition: >-
or(
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true),
eq(variables['wasmDarcDependenciesChanged'], true),
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_tools_illink.containsChange'], true),
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_wasm_coreclr_runtimetests.containsChange'], true),
eq(variables['isRollingBuild'], true))

#
Expand Down
9 changes: 5 additions & 4 deletions src/coreclr/hosts/corerun/libCorerun.pre.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
var dotnetInternals = {
runtimeApi: {
var dotnetInternals = [
{
Module: Module,
},
updates: [],
};
[],
];
Module.preRun = () => {
// copy all node/shell env variables to emscripten env
if (globalThis.process && globalThis.process.env) {
for (const [key, value] of Object.entries(process.env)) {
ENV[key] = value;
}
}
ENV["DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"] = "true";
};
11 changes: 7 additions & 4 deletions src/coreclr/hosts/corewasmrun/libCorewasmrun.pre.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
var dotnetInternals = {
runtimeApi: {
var dotnetInternals = [
{
Module: Module,
},
updates: [],
};
[],
];
Module.preRun = () => {
ENV["DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"] = "true";
};
3 changes: 3 additions & 0 deletions src/native/corehost/browserhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ add_definitions(-DFEATURE_STATIC_HOST=1)
add_executable(browserhost ${SOURCES})
set_target_properties(browserhost PROPERTIES OUTPUT_NAME dotnet.native)
set(CMAKE_EXECUTABLE_SUFFIX ".js")
add_dependencies(browserhost System.Native.Browser-Rollup)
add_dependencies(browserhost System.Native.Browser-Static)
add_dependencies(browserhost System.Runtime.InteropServices.JavaScript.Native-Static)

install(TARGETS browserhost DESTINATION corehost COMPONENT runtime)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dotnet.native.wasm DESTINATION corehost COMPONENT runtime)
Expand Down
5 changes: 4 additions & 1 deletion src/native/corehost/browserhost/host/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import { } from "./cross-linked"; // ensure ambient symbols are declared
import { runMain, runMainAndExit, registerDllBytes } from "./host";

export function dotnetInitializeModule(internals: InternalExchange): void {
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");
const runtimeApiLocal: Partial<RuntimeAPI> = {
runMain,
runMainAndExit,
};
Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal);
const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");
Object.assign(runtimeApi, runtimeApiLocal);

internals[InternalExchangeIndex.BrowserHostExportsTable] = browserHostExportsToTable({
registerDllBytes,
Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/browserhost/libBrowserHost.footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
ENV[HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES] = config.environmentVariables[HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES] = config.virtualWorkingDirectory;
ENV[HOST_PROPERTY_APP_PATHS] = config.environmentVariables[HOST_PROPERTY_APP_PATHS] = config.virtualWorkingDirectory;
ENV[HOST_PROPERTY_ENTRY_ASSEMBLY_NAME] = config.environmentVariables[HOST_PROPERTY_ENTRY_ASSEMBLY_NAME] = config.mainAssemblyName;

// WASM-TODO: remove once globalization is loaded via ICU
ENV["DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"] = "true";
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/native/corehost/browserhost/loader/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const scriptUrl = normalizeFileUrl(scriptUrlQuery);
const scriptDirectory = normalizeDirectoryUrl(scriptUrl);

const nativeModulePromiseController = createPromiseController<EmscriptenModuleInternal>(() => {
dotnetUpdateInternals();
dotnetUpdateInternals(dotnetGetInternals());
});

// WASM-TODO: retry logic
Expand Down
17 changes: 8 additions & 9 deletions src/native/corehost/browserhost/loader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { exit } from "./exit";
import { invokeLibraryInitializers } from "./lib-initializers";
import { check, error, info, warn } from "./logging";

import { dotnetAssert, dotnetInternals, dotnetLoaderExports, dotnetLogger, dotnetUpdateInternals, dotnetUpdateInternalsSubscriber } from "./cross-module";
import { dotnetAssert, dotnetLoaderExports, dotnetLogger, dotnetUpdateInternals, dotnetUpdateInternalsSubscriber } from "./cross-module";
import { rejectRunMainPromise, resolveRunMainPromise, getRunMainPromise } from "./run";

export function dotnetInitializeModule(): RuntimeAPI {
Expand All @@ -42,14 +42,13 @@ export function dotnetInitializeModule(): RuntimeAPI {
dotnetApi as RuntimeAPI, //0
[], //1
netLoaderConfig, //2
null as any as LoaderExportsTable, //3
null as any as RuntimeExportsTable, //4
null as any as BrowserHostExportsTable, //5
null as any as InteropJavaScriptExportsTable, //6
null as any as NativeBrowserExportsTable, //7
null as any as BrowserUtilsExportsTable, //8
undefined as any as LoaderExportsTable, //3
undefined as any as RuntimeExportsTable, //4
undefined as any as BrowserHostExportsTable, //5
undefined as any as InteropJavaScriptExportsTable, //6
undefined as any as NativeBrowserExportsTable, //7
undefined as any as BrowserUtilsExportsTable, //8
];
Object.assign(dotnetInternals, internals);
const loaderFunctions: LoaderExports = {
getRunMainPromise,
rejectRunMainPromise,
Expand All @@ -67,7 +66,7 @@ export function dotnetInitializeModule(): RuntimeAPI {
};
Object.assign(dotnetAssert, assert);

dotnetInternals[InternalExchangeIndex.LoaderExportsTable] = loaderExportsToTable(dotnetLogger, dotnetAssert, dotnetLoaderExports);
internals[InternalExchangeIndex.LoaderExportsTable] = loaderExportsToTable(dotnetLogger, dotnetAssert, dotnetLoaderExports);
dotnetUpdateInternals(internals, dotnetUpdateInternalsSubscriber);
return dotnetApi as RuntimeAPI;

Expand Down
40 changes: 17 additions & 23 deletions src/native/libs/Common/JavaScript/cross-module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
import type { DotnetModuleInternal, InternalExchange, RuntimeExports, LoaderExports, RuntimeAPI, LoggerType, AssertType, BrowserHostExports, InteropJavaScriptExports, LoaderExportsTable, RuntimeExportsTable, BrowserHostExportsTable, InteropJavaScriptExportsTable, NativeBrowserExports, NativeBrowserExportsTable, InternalExchangeSubscriber, BrowserUtilsExports, BrowserUtilsExportsTable, VoidPtr, CharPtr, NativePointer } from "../types";
import { InternalExchangeIndex } from "../types";

let dotnetInternals: InternalExchange;
export let Module: DotnetModuleInternal;
export let dotnetApi: RuntimeAPI;
export let dotnetLogger: LoggerType = {} as any;
export let dotnetAssert: AssertType = {} as any;
export let dotnetLoaderExports: LoaderExports = {} as any;
export let dotnetRuntimeExports: RuntimeExports = {} as any;
export let dotnetBrowserHostExports: BrowserHostExports = {} as any;
export let dotnetInteropJSExports: InteropJavaScriptExports = {} as any;
export let dotnetNativeBrowserExports: NativeBrowserExports = {} as any;
export let dotnetBrowserUtilsExports: BrowserUtilsExports = {} as any;
export let dotnetInternals: InternalExchange = {} as any;
export const dotnetLogger: LoggerType = {} as LoggerType;
export const dotnetAssert: AssertType = {} as AssertType;
export const dotnetLoaderExports: LoaderExports = {} as any;
export const dotnetRuntimeExports: RuntimeExports = {} as any;
export const dotnetBrowserHostExports: BrowserHostExports = {} as any;
export const dotnetInteropJSExports: InteropJavaScriptExports = {} as any;
export const dotnetNativeBrowserExports: NativeBrowserExports = {} as any;
export const dotnetBrowserUtilsExports: BrowserUtilsExports = {} as any;

export const VoidPtrNull: VoidPtr = <VoidPtr><any>0;
export const CharPtrNull: CharPtr = <CharPtr><any>0;
Expand All @@ -44,19 +44,21 @@ export function dotnetGetInternals(): InternalExchange {

// this should be called when we want to dispatch new internal functions to other JS modules
// subscriber parameter is the callback function with visibility to the current module's internal closure
export function dotnetUpdateInternals(internals?: InternalExchange, subscriber?: InternalExchangeSubscriber) {
export function dotnetUpdateInternals(internals: InternalExchange, subscriber?: InternalExchangeSubscriber) {
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");
if (!Array.isArray(internals[InternalExchangeIndex.InternalUpdatesCallbacks])) throw new Error("Expected internal updates to be an array");
if (dotnetInternals === undefined) {
dotnetInternals = internals!;
dotnetInternals = internals;
} else if (dotnetInternals !== internals) {
throw new Error("Cannot replace internals");
}
if (dotnetApi === undefined) {
dotnetApi = dotnetInternals[InternalExchangeIndex.RuntimeAPI];
}
if (Module === undefined && dotnetApi) {
if (typeof dotnetApi !== "object") throw new Error("Expected internals to have RuntimeAPI");
if (Module === undefined) {
Module = dotnetApi.Module as any;
}
if (dotnetInternals[InternalExchangeIndex.InternalUpdatesCallbacks] === undefined) {
dotnetInternals[InternalExchangeIndex.InternalUpdatesCallbacks] = [];
}
const updates = dotnetInternals[InternalExchangeIndex.InternalUpdatesCallbacks];
if (subscriber && !updates.includes(subscriber)) {
updates.push(subscriber);
Expand All @@ -73,29 +75,21 @@ export function dotnetUpdateInternalsSubscriber() {
*/

if (Object.keys(dotnetLoaderExports).length === 0 && dotnetInternals[InternalExchangeIndex.LoaderExportsTable]) {
dotnetLoaderExports = {} as LoaderExports;
dotnetLogger = {} as LoggerType;
dotnetAssert = {} as AssertType;
loaderExportsFromTable(dotnetInternals[InternalExchangeIndex.LoaderExportsTable], dotnetLogger, dotnetAssert, dotnetLoaderExports);
}
if (Object.keys(dotnetRuntimeExports).length === 0 && dotnetInternals[InternalExchangeIndex.RuntimeExportsTable]) {
dotnetRuntimeExports = {} as RuntimeExports;
runtimeExportsFromTable(dotnetInternals[InternalExchangeIndex.RuntimeExportsTable], dotnetRuntimeExports);
}
if (Object.keys(dotnetBrowserHostExports).length === 0 && dotnetInternals[InternalExchangeIndex.BrowserHostExportsTable]) {
dotnetBrowserHostExports = {} as BrowserHostExports;
browserHostExportsFromTable(dotnetInternals[InternalExchangeIndex.BrowserHostExportsTable], dotnetBrowserHostExports);
}
if (Object.keys(dotnetBrowserUtilsExports).length === 0 && dotnetInternals[InternalExchangeIndex.BrowserUtilsExportsTable]) {
dotnetBrowserUtilsExports = {} as BrowserUtilsExports;
nativeHelperExportsFromTable(dotnetInternals[InternalExchangeIndex.BrowserUtilsExportsTable], dotnetBrowserUtilsExports);
}
if (Object.keys(dotnetInteropJSExports).length === 0 && dotnetInternals[InternalExchangeIndex.InteropJavaScriptExportsTable]) {
dotnetInteropJSExports = {} as InteropJavaScriptExports;
interopJavaScriptExportsFromTable(dotnetInternals[InternalExchangeIndex.InteropJavaScriptExportsTable], dotnetInteropJSExports);
}
if (Object.keys(dotnetNativeBrowserExports).length === 0 && dotnetInternals[InternalExchangeIndex.NativeBrowserExportsTable]) {
dotnetNativeBrowserExports = {} as NativeBrowserExports;
nativeBrowserExportsFromTable(dotnetInternals[InternalExchangeIndex.NativeBrowserExportsTable], dotnetNativeBrowserExports);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

/* eslint-disable no-undef */
/* eslint-disable space-before-function-paren */
/* eslint-disable @typescript-eslint/no-unused-vars */
var fetch = fetch || undefined; var dotnetNativeModuleLoaded = false; var dotnetInternals = null;
export function dotnetInitializeModule(internals) {
if (dotnetNativeModuleLoaded) throw new Error("Native module already loaded");
dotnetInternals = internals;
dotnetNativeModuleLoaded = true;
return createDotnetRuntime(dotnetInternals[0/*InternalExchangeIndex.RuntimeAPI*/].Module);
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");
dotnetInternals = internals;
const runtimeApi = internals[0/*InternalExchangeIndex.RuntimeAPI*/];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");
if (typeof runtimeApi.Module !== "object") throw new Error("Expected internals to have Module");
return createDotnetRuntime(runtimeApi.Module);
}
5 changes: 4 additions & 1 deletion src/native/libs/System.Native.Browser/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ import { exit, setEnvironmentVariable } from "./host";
import { dotnetUpdateInternals, dotnetUpdateInternalsSubscriber } from "../utils/cross-module";

export function dotnetInitializeModule(internals: InternalExchange): void {
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");
const runtimeApiLocal: Partial<RuntimeAPI> = {
setEnvironmentVariable,
exit,
setHeapB32, setHeapB8, setHeapU8, setHeapU16, setHeapU32, setHeapI8, setHeapI16, setHeapI32, setHeapI52, setHeapU52, setHeapI64Big, setHeapF32, setHeapF64,
getHeapB32, getHeapB8, getHeapU8, getHeapU16, getHeapU32, getHeapI8, getHeapI16, getHeapI32, getHeapI52, getHeapU52, getHeapI64Big, getHeapF32, getHeapF64,
localHeapViewI8, localHeapViewI16, localHeapViewI32, localHeapViewI64Big, localHeapViewU8, localHeapViewU16, localHeapViewU32, localHeapViewF32, localHeapViewF64,
};
Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal);
const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");
Object.assign(runtimeApi, runtimeApiLocal);

internals[InternalExchangeIndex.BrowserUtilsExportsTable] = browserUtilsExportsToTable({
utf16ToString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import { dotnetUpdateInternals, dotnetUpdateInternalsSubscriber } from "./cross-
import { ENVIRONMENT_IS_NODE } from "./per-module";

export function dotnetInitializeModule(internals: InternalExchange): void {
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");
const runtimeApiLocal: Partial<RuntimeAPI> = {
getAssemblyExports,
setModuleImports,
};
Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal);
const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");
Object.assign(runtimeApi, runtimeApiLocal);

internals[InternalExchangeIndex.RuntimeExportsTable] = runtimeExportsToTable({
});
Expand Down
Loading