Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/coreclr/hosts/corerun/wasm/libCorerun.extpost.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function selfRun() {
runtimeId: 0,
runtimeBuildInfo: {
productVersion: "corerun",
gitHash: "corerun",
gitHash: null,
buildConfiguration: "corerun",
wasmEnableThreads: false,
wasmEnableSIMD: true,
Expand Down
5 changes: 5 additions & 0 deletions src/native/corehost/browserhost/host/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { InternalExchange, BrowserHostExports, RuntimeAPI, BrowserHostExpor
import { InternalExchangeIndex } from "./types";
import { } from "./cross-linked"; // ensure ambient symbols are declared

import GitHash from "consts:gitHash";

import { runMain, runMainAndExit, registerDllBytes, installVfsFile, loadIcuData, initializeCoreCLR } from "./host";

export function dotnetInitializeModule(internals: InternalExchange): void {
Expand All @@ -16,6 +18,9 @@ export function dotnetInitializeModule(internals: InternalExchange): void {
const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");
Object.assign(runtimeApi, runtimeApiLocal);
if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== GitHash) {
throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, BrowserHost: ${GitHash}`);
}

internals[InternalExchangeIndex.BrowserHostExportsTable] = browserHostExportsToTable({
registerDllBytes,
Expand Down
10 changes: 10 additions & 0 deletions src/native/libs/System.Native.Browser/diagnostics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

import type { DiagnosticsExportsTable, InternalExchange, DiagnosticsExports } from "./types";
import { InternalExchangeIndex } from "../types";

import GitHash from "consts:gitHash";

import { dotnetUpdateInternals, dotnetUpdateInternalsSubscriber } from "./cross-module";
import { registerExit } from "./exit";
import { symbolicateStackTrace } from "./symbolicate";
Expand All @@ -11,6 +14,13 @@ import { installLoggingProxy } from "./console-proxy";
export function dotnetInitializeModule(internals: InternalExchange): void {
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");

const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");

if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== GitHash) {
throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, Diagnostics: ${GitHash}`);
}

internals[InternalExchangeIndex.DiagnosticsExportsTable] = diagnosticsExportsToTable({
symbolicateStackTrace,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
}
},
dotnetInitializeModule: exports.dotnetInitializeModule,
gitHash: exports.gitHash,
},
$DOTNET__deps: commonDeps,
$DOTNET__postset: "DOTNET.selfInitialize()",
};

for (const exportName of Reflect.ownKeys(exports)) {
const name = String(exportName);
if (name === "dotnetInitializeModule") continue;
if (name === "dotnetInitializeModule" || name === "gitHash") continue;
const fn = lib[name] = exports[name];
if (fn.__deps) {
lib[name + "__deps"] = fn.__deps;
Expand Down
12 changes: 12 additions & 0 deletions src/native/libs/System.Native.Browser/native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@
import type { InternalExchange, NativeBrowserExports, NativeBrowserExportsTable } from "../types";
import { InternalExchangeIndex } from "../types";

import GitHash from "consts:gitHash";

export { SystemJS_RandomBytes } from "./crypto";
export { SystemJS_GetLocaleInfo } from "./globalization-locale";
export { SystemJS_RejectMainPromise, SystemJS_ResolveMainPromise, SystemJS_ConsoleClear } from "./main";
export { SystemJS_ScheduleTimer, SystemJS_ScheduleBackgroundJob } from "./timer";

export const gitHash = GitHash;
export function dotnetInitializeModule(internals: InternalExchange): void {
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");

const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");

if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== DOTNET.gitHash) {
throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, DOTNET: ${DOTNET.gitHash}`);
}

internals[InternalExchangeIndex.NativeBrowserExportsTable] = nativeBrowserExportsToTable({
});
dotnetUpdateInternals(internals, dotnetUpdateInternalsSubscriber);
Expand Down
10 changes: 9 additions & 1 deletion src/native/libs/System.Native.Browser/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { InternalExchange, BrowserUtilsExports, RuntimeAPI, BrowserUtilsExp
import { InternalExchangeIndex } from "../types";
import { } from "./cross-module"; // ensure ambient symbols are declared

import GitHash from "consts:gitHash";

import {
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,
Expand All @@ -20,9 +22,15 @@ import { registerRuntime } from "./runtime-list";
import { registerCDAC } from "./cdac";

export function dotnetInitializeModule(internals: InternalExchange): void {
initPolyfills();
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");
const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");

if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== GitHash) {
throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, BrowserUtils: ${GitHash}`);
}

initPolyfills();
registerRuntime(runtimeApi);
registerCDAC(runtimeApi);

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

import type { InternalExchange, RuntimeAPI, RuntimeExports, RuntimeExportsTable } from "./types";
import { InternalExchangeIndex } from "../types";

import GitHash from "consts:gitHash";

import { dotnetUpdateInternals, dotnetUpdateInternalsSubscriber } from "./cross-module";
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 runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");

if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== GitHash) {
throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, Runtime: ${GitHash}`);
}

const runtimeApiLocal: Partial<RuntimeAPI> = {
getAssemblyExports,
setModuleImports,
};
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
}
},
dotnetInitializeModule: exports.dotnetInitializeModule,
gitHash: exports.gitHash,
},
$DOTNET_INTEROP__postset: "DOTNET_INTEROP.selfInitialize()",
$DOTNET_INTEROP__deps: commonDeps,
};

for (const exportName of Reflect.ownKeys(exports)) {
const name = String(exportName);
if (name === "dotnetInitializeModule") continue;
if (name === "dotnetInitializeModule" || name === "gitHash") continue;
lib[name] = exports[name];
}

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

import { } from "../../Common/JavaScript/cross-linked";

declare global {
export const DOTNET_INTEROP: any;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ import type { InternalExchange, InteropJavaScriptExports, InteropJavaScriptExpor
import { InternalExchangeIndex } from "../types";
import { } from "./cross-linked"; // ensure ambient symbols are declared

import GitHash from "consts:gitHash";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function SystemInteropJS_InvokeJSImportST(function_handle: JSFnHandle, args: JSMarshalerArguments) {
// WASM-TODO implementation
dotnetLogger.error("SystemInteropJS_InvokeJSImportST called");
return - 1;
}

export const gitHash = GitHash;
export function dotnetInitializeModule(internals: InternalExchange): void {
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");
const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");

if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== DOTNET_INTEROP.gitHash) {
throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, DOTNET_INTEROP: ${DOTNET_INTEROP.gitHash}`);
}

internals[InternalExchangeIndex.InteropJavaScriptExportsTable] = interopJavaScriptExportsToTable({
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
Loading