Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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 @@ -239,6 +239,7 @@
<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="dotnet.es6.externs.js" IsNative="true" />
<PlatformManifestFileEntry Include="corebindings.c" IsNative="true" />
<PlatformManifestFileEntry Include="driver.c" IsNative="true" />
<PlatformManifestFileEntry Include="pinvoke.c" IsNative="true" />
Expand Down
13 changes: 11 additions & 2 deletions src/mono/wasm/build/WasmApp.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
<WasmNativeStrip Condition="'$(WasmNativeStrip)' == '' and '$(Configuration)' == 'Debug' and '$(WasmBuildingForNestedPublish)' != 'true'">false</WasmNativeStrip>
<WasmNativeStrip Condition="'$(WasmNativeStrip)' == ''">true</WasmNativeStrip>
<WasmNativeDebugSymbols Condition="'$(WasmNativeDebugSymbols)' == ''">true</WasmNativeDebugSymbols>
<WasmAggressivelyMinifyJs Condition="'$(WasmAggressivelyMinifyJs)' == '' and '$(Configuration)' == 'Release' and '$(WasmNativeStrip)' == 'true'">true</WasmAggressivelyMinifyJs>
<WasmAggressivelyMinifyJs Condition="'$(WasmAggressivelyMinifyJs)' == ''">false</WasmAggressivelyMinifyJs>
<WasmLinkIcalls Condition="'$(WasmLinkIcalls)' == ''">$(WasmBuildNative)</WasmLinkIcalls>

<_WasmICallTablePath>$(_WasmIntermediateOutputPath)icall-table.h</_WasmICallTablePath>
Expand Down Expand Up @@ -254,9 +256,11 @@
<JSFileType Include="lib.js" Kind="js-library" />
<JSFileType Include="post.js" Kind="post-js" />
<JSFileType Include="extpost.js" Kind="extern-post-js" />
<ExtFileType Include="externs.js" Kind="closure-args=--externs=" />

<_WasmExtraJSFile Include="$(_WasmRuntimePackSrcDir)\*.%(JSFileType.Identity)" Kind="%(JSFileType.Kind)" />
<_WasmExtraJSFile Include="$(_WasmRuntimePackSrcDir)\es6\*.%(JSFileType.Identity)" Kind="%(JSFileType.Kind)" />
<_WasmExtraExtFile Include="$(_WasmRuntimePackSrcDir)/es6/*.%(ExtFileType.Identity)" Kind="%(ExtFileType.Kind)" />

<_WasmNativeFileForLinking Include="@(NativeFileReference)" />

Expand Down Expand Up @@ -401,6 +405,9 @@
<_EmccLinkStepArgs Include="--%(_WasmExtraJSFile.Kind) &quot;%(_WasmExtraJSFile.Identity)&quot;" Condition="'%(_WasmExtraJSFile.Kind)' != ''" />
<_WasmLinkDependencies Include="@(_WasmExtraJSFile)" />

<_EmccLinkStepArgs Condition="'$(WasmAggressivelyMinifyJs)' == 'true'" Include="--closure 1" />
<_EmccLinkStepArgs Include="--%(_WasmExtraExtFile.Kind)&quot;%(_WasmExtraExtFile.Identity)&quot;" Condition="'$(WasmAggressivelyMinifyJs)' == 'true' and '%(_WasmExtraExtFile.Kind)' != ''" />

<_EmccLinkStepArgs Include="&quot;%(_WasmNativeFileForLinking.Identity)&quot;" />
<_WasmLinkDependencies Include="@(_WasmNativeFileForLinking)" />

Expand All @@ -412,8 +419,10 @@

<_EmccLinkStepArgs Include="$(EmccExtraLDFlags)" />
</ItemGroup>

<WriteLinesToFile Lines="@(_EmccLinkStepArgs)" File="$(_EmccLinkRsp)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<PropertyGroup>
<_EmccLinkStepArgs2>@(_EmccLinkStepArgs, '&#x0a;')</_EmccLinkStepArgs2>
</PropertyGroup>
<WriteLinesToFile Lines="$(_EmccLinkStepArgs2.Replace('\','/'))" File="$(_EmccLinkRsp)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_EmccLinkRsp)" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- $(WasmNativeDebugSymbols) - Build with native debug symbols, useful only with `$(RunAOTCompilation)`, or `$(WasmBuildNative)`
Defaults to true.
- $(WasmEmitSymbolMap) - Generates a `dotnet.js.symbols` file with a map of wasm function number to name.
- $(WasmAggressivelyMinifyJs) - Use closure compiler to aggressively minify dotnet.js.
- $(WasmDedup) - Whenever to dedup generic instances when using AOT. Defaults to true.

- $(WasmProfilers) - Profilers to use
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,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.post.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.externs.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 --closure-args=--externs=${NATIVE_BIN_DIR}/src/es6/dotnet.es6.externs.js"
RUNTIME_OUTPUT_DIRECTORY "${NATIVE_BIN_DIR}")

set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}")
Expand Down
86 changes: 86 additions & 0 deletions src/mono/wasm/runtime/es6/dotnet.es6.externs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* @fileoverview https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler
* @externs
*/


const MONO = {}, BINDING = {}, INTERNAL = {}, IMPORTS = {};

const __dotnet_runtime = {};

/** @interface */
function EarlyImports() { }
EarlyImports.prototype.isGlobal = false;
EarlyImports.prototype.isNode = false;
EarlyImports.prototype.isWorker = false;
EarlyImports.prototype.isShell = false;
EarlyImports.prototype.isPThread = false;
EarlyImports.prototype.quit_ = function () { };
EarlyImports.prototype.ExitStatus = {};
EarlyImports.prototype.requirePromise = {};


/** @interface */
function EarlyExports() { }
EarlyExports.prototype.mono = {};
EarlyExports.prototype.binding = {};
EarlyExports.prototype.internal = {};
EarlyExports.prototype.module = {};
EarlyExports.prototype.marshaled_imports = {};

/** @interface */
function EarlyReplacements() { }
EarlyReplacements.prototype.fetch = function () { };
EarlyReplacements.prototype.require = function () { };
EarlyReplacements.prototype.requirePromise = {};
EarlyReplacements.prototype.noExitRuntime = false;
EarlyReplacements.prototype.updateGlobalBufferAndViews = function () { };
EarlyReplacements.prototype.pthreadReplacements = {};
EarlyReplacements.prototype.scriptDirectory = "";
EarlyReplacements.prototype.scriptUrl = "";


/**
* @param {EarlyImports} imports
* @param {EarlyExports} exports
* @param {EarlyReplacements} replacements
* @param {Object} callbackAPI: any
*/
const __initializeImportsAndExports = function (
imports,
exports,
replacements,
callbackAPI) { };
const __requirePromise = {};


/** @interface */
function t_FS() { }
t_FS.prototype.isDir = function () { };

/**
* @type {t_FS}
* @suppress {duplicate}
*/
var FS = {}

/** @interface */
function CreateDotnetRuntime() { }
CreateDotnetRuntime.prototype.locateFile = function () { };
CreateDotnetRuntime.prototype.__locateFile = function () { };
CreateDotnetRuntime.prototype.ready = {};
CreateDotnetRuntime.prototype.FS = FS;
CreateDotnetRuntime.prototype.HEAPU8 = {};
CreateDotnetRuntime.prototype.HEAP8 = {};
CreateDotnetRuntime.prototype.HEAPU16 = {};
CreateDotnetRuntime.prototype.HEAP16 = {};
CreateDotnetRuntime.prototype.HEAPU32 = {};
CreateDotnetRuntime.prototype.HEAP32 = {};
CreateDotnetRuntime.prototype.HEAPF32 = {};
CreateDotnetRuntime.prototype.HEAPF64 = {};

/**
* @type {CreateDotnetRuntime}
* @suppress {duplicate}
*/
var createDotnetRuntime = {}
7 changes: 7 additions & 0 deletions src/mono/wasm/runtime/es6/dotnet.es6.extpost.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const ENVIRONMENT_IS_WEB = typeof window == "object";
const ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
const MONO = {}, BINDING = {}, INTERNAL = {}, IMPORTS = {};
var fetch = fetch || undefined;
var require = require || undefined;
var __dirname = __dirname || '';
__dotnet_runtime.__setEmscriptenEntrypoint(createDotnetRuntime);
const __initializeImportsAndExports = __dotnet_runtime.__initializeImportsAndExports;
const __requirePromise = ENVIRONMENT_IS_NODE ? import(/* webpackIgnore: true */'module').then(mod => mod.createRequire(import.meta.url)) : undefined;
const dotnet = __dotnet_runtime.moduleExports.dotnet;
const exit = __dotnet_runtime.moduleExports.exit;
export { dotnet, exit, INTERNAL };
32 changes: 16 additions & 16 deletions src/mono/wasm/runtime/es6/dotnet.es6.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"use strict";

#if USE_PTHREADS
const usePThreads = `true`;
const usePThreads = true;
const isPThread = `ENVIRONMENT_IS_PTHREAD`;
#else
const usePThreads = `false`;
const usePThreads = false;
const isPThread = `false`;
#endif

const DotnetSupportLib = {
$DOTNET: {},
// this line will be placed early on emscripten runtime creation, passing import and export objects into __dotnet_runtime IFFE
// this line will be placed early on emscripten runtime creation, passing import and export objects into __dotnet_runtime IIFE
// Emscripten uses require function for nodeJS even in ES6 module. We need https://nodejs.org/api/module.html#modulecreaterequirefilename
// We use dynamic import because there is no "module" module in the browser.
// This is async init of it, note it would become available only after first tick.
Expand All @@ -23,33 +23,33 @@ const DotnetSupportLib = {
// We also replace implementation of fetch
$DOTNET__postset: `
let __dotnet_replacement_PThread = ${usePThreads} ? {} : undefined;
if (${usePThreads}) {
__dotnet_replacement_PThread.loadWasmModuleToWorker = PThread.loadWasmModuleToWorker;
__dotnet_replacement_PThread.threadInitTLS = PThread.threadInitTLS;
__dotnet_replacement_PThread.allocateUnusedWorker = PThread.allocateUnusedWorker;
}
${usePThreads ? `
__dotnet_replacement_PThread.loadWasmModuleToWorker = PThread.loadWasmModuleToWorker;
__dotnet_replacement_PThread.threadInitTLS = PThread.threadInitTLS;
__dotnet_replacement_PThread.allocateUnusedWorker = PThread.allocateUnusedWorker;
` : ''}
let __dotnet_replacements = {scriptUrl: import.meta.url, fetch: globalThis.fetch, require, updateGlobalBufferAndViews, pthreadReplacements: __dotnet_replacement_PThread};
if (ENVIRONMENT_IS_NODE) {
__dotnet_replacements.requirePromise = import(/* webpackIgnore: true */'module').then(mod => mod.createRequire(import.meta.url));
__dotnet_replacements.requirePromise = __requirePromise;
}
let __dotnet_exportedAPI = __dotnet_runtime.__initializeImportsAndExports(
let __dotnet_exportedAPI = __initializeImportsAndExports(
{ isGlobal:false, isNode:ENVIRONMENT_IS_NODE, isWorker:ENVIRONMENT_IS_WORKER, isShell:ENVIRONMENT_IS_SHELL, isWeb:ENVIRONMENT_IS_WEB, isPThread:${isPThread}, quit_, ExitStatus, requirePromise:__dotnet_replacements.requirePromise },
{ mono:MONO, binding:BINDING, internal:INTERNAL, module:Module, marshaled_imports: IMPORTS },
__dotnet_replacements, __callbackAPI);
updateGlobalBufferAndViews = __dotnet_replacements.updateGlobalBufferAndViews;
var fetch = __dotnet_replacements.fetch;
fetch = __dotnet_replacements.fetch;
_scriptDir = __dirname = scriptDirectory = __dotnet_replacements.scriptDirectory;
if (ENVIRONMENT_IS_NODE) {
__dotnet_replacements.requirePromise.then(someRequire => {
require = someRequire;
});
}
var noExitRuntime = __dotnet_replacements.noExitRuntime;
if (${usePThreads}) {
PThread.loadWasmModuleToWorker = __dotnet_replacements.pthreadReplacements.loadWasmModuleToWorker;
PThread.threadInitTLS = __dotnet_replacements.pthreadReplacements.threadInitTLS;
PThread.allocateUnusedWorker = __dotnet_replacements.pthreadReplacements.allocateUnusedWorker;
}
${usePThreads ? `
PThread.loadWasmModuleToWorker = __dotnet_replacements.pthreadReplacements.loadWasmModuleToWorker;
PThread.threadInitTLS = __dotnet_replacements.pthreadReplacements.threadInitTLS;
PThread.allocateUnusedWorker = __dotnet_replacements.pthreadReplacements.allocateUnusedWorker;
` : ''}
`,
};

Expand Down
2 changes: 0 additions & 2 deletions src/mono/wasm/runtime/es6/dotnet.es6.pre.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var require = require || undefined;
var __dirname = __dirname || '';
var __callbackAPI = { MONO, BINDING, INTERNAL, IMPORTS };
if (typeof createDotnetRuntime === "function") {
__callbackAPI.Module = Module = { ready: Module.ready };
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/runtime/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function initializeImportsAndExports(
const module = exports.module as DotnetModule;
const globalThisAny = globalThis as any;

// we want to have same instance of MONO, BINDING and Module in dotnet iffe
// we want to have same instance of MONO, BINDING and Module in dotnet iife
set_imports_exports(imports, exports);
set_legacy_exports(exports);
init_polyfills(replacements);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/logging.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Licensed to the .NET Foundation under one or more agreements.
//! The .NET Foundation licenses this file to you under the MIT license.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import BuildConfiguration from "consts:configuration";
import { INTERNAL, Module, runtimeHelpers } from "./imports";
Expand Down
4 changes: 0 additions & 4 deletions src/mono/wasm/runtime/run-outer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export interface DotnetHostBuilder {
run(): Promise<number>
}

// these constants duplicate detection inside emscripten internals, but happen earlier
const ENVIRONMENT_IS_WEB = typeof window == "object";
const ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";

class HostBuilder implements DotnetHostBuilder {
private instance?: RuntimeAPI;
private applicationArguments?: string[];
Expand Down
3 changes: 3 additions & 0 deletions src/mono/wasm/runtime/types/consts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ declare module "consts:monoDiagnosticsMock" {
const constant: boolean;
export default constant;
}

declare const ENVIRONMENT_IS_NODE: boolean;
declare const ENVIRONMENT_IS_WEB: boolean;
6 changes: 5 additions & 1 deletion src/mono/wasm/wasm.proj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<_EmccCompileRspPath>$(NativeBinDir)src\emcc-compile.rsp</_EmccCompileRspPath>
<_EmccLinkRspPath>$(NativeBinDir)src\emcc-link.rsp</_EmccLinkRspPath>
<WasmNativeStrip Condition="'$(ContinuousIntegrationBuild)' == 'true'">false</WasmNativeStrip>
<WasmAggressivelyMinifyJs Condition="'$(ContinuousIntegrationBuild)' != 'true' and '$(Configuration)' != 'Debug'">true</WasmAggressivelyMinifyJs>
</PropertyGroup>

<Target Name="CheckEnv">
Expand Down Expand Up @@ -254,10 +255,12 @@
<PInvokeTableFile>$(ArtifactsObjDir)wasm/pinvoke-table.h</PInvokeTableFile>
<InterpToNativeTableFile>$(ArtifactsObjDir)wasm/wasm_m2n_invoke.g.h</InterpToNativeTableFile>
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Debug'">-g -Os -s -DDEBUG=1 -DENABLE_AOT_PROFILER=1 -DENABLE_BROWSER_PROFILER=1</CMakeConfigurationEmccFlags>
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Release'">-Oz -DENABLE_BROWSER_PROFILER=1</CMakeConfigurationEmccFlags>
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Release'">-Oz -DENABLE_BROWSER_PROFILER=1</CMakeConfigurationEmccFlags>

<CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Debug'" >$(CMakeConfigurationEmccFlags)</CMakeConfigurationLinkFlags>
<CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Release'">-O2</CMakeConfigurationLinkFlags>

<CMakeConfigurationLinkFlags Condition="'$(WasmAggressivelyMinifyJs)' == 'true'">$(CMakeConfigurationLinkFlags) --closure 1</CMakeConfigurationLinkFlags>
<CMakeConfigurationLinkFlags>$(CMakeConfigurationLinkFlags) -s EXPORT_ES6=1</CMakeConfigurationLinkFlags>
<CMakeConfigurationLinkFlags Condition="'$(MonoWasmThreads)' == 'true'">$(CMakeConfigurationLinkFlags) -Wno-pthreads-mem-growth</CMakeConfigurationLinkFlags>
<CMakeConfigurationLinkFlags >$(CMakeConfigurationLinkFlags) --emit-symbol-map</CMakeConfigurationLinkFlags>
Expand Down Expand Up @@ -306,6 +309,7 @@
<Copy SourceFiles="runtime/es6/dotnet.es6.pre.js;
runtime/es6/dotnet.es6.lib.js;
runtime/es6/dotnet.es6.post.js;
runtime/es6/dotnet.es6.externs.js;
runtime/es6/dotnet.es6.extpost.js;"
DestinationFolder="$(NativeBinDir)src/es6"
SkipUnchangedFiles="true" />
Expand Down
15 changes: 8 additions & 7 deletions src/native/libs/System.Native/pal_random.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

const DotNetEntropyLib = {
$DOTNETENTROPY: {
// batchedQuotaMax is the max number of bytes as specified by the api spec.
// If the byteLength of array is greater than 65536, throw a QuotaExceededError and terminate the algorithm.
// https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
batchedQuotaMax: 65536,
getBatchedRandomValues: function (buffer, bufferLength) {
// batchedQuotaMax is the max number of bytes as specified by the api spec.
// If the byteLength of array is greater than 65536, throw a QuotaExceededError and terminate the algorithm.
// https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
const batchedQuotaMax = 65536;

// Chrome doesn't want SharedArrayBuffer to be passed to crypto APIs
const needTempBuf = typeof SharedArrayBuffer !== 'undefined' && Module.HEAPU8.buffer instanceof SharedArrayBuffer;
// if we need a temporary buffer, make one that is big enough and write into it from the beginning
Expand All @@ -16,14 +17,14 @@ const DotNetEntropyLib = {
const offset = needTempBuf ? 0 : buffer;
// for modern web browsers
// map the work array to the memory buffer passed with the length
for (let i = 0; i < bufferLength; i += this.batchedQuotaMax) {
const view = new Uint8Array(buf, offset + i, Math.min(bufferLength - i, this.batchedQuotaMax));
for (let i = 0; i < bufferLength; i += batchedQuotaMax) {
const view = new Uint8Array(buf, offset + i, Math.min(bufferLength - i, batchedQuotaMax));
crypto.getRandomValues(view)
}
if (needTempBuf) {
// copy data out of the temporary buffer into the wasm instance memory
const heapView = new Uint8Array(Module.HEAPU8.buffer, buffer, bufferLength);
heapView.set(new Uint8Array (buf));
heapView.set(new Uint8Array(buf));
}
}
},
Expand Down