Skip to content

Commit f51c397

Browse files
committed
rebase
1 parent 93010da commit f51c397

File tree

8 files changed

+36
-12
lines changed

8 files changed

+36
-12
lines changed

src/mono/browser/browser.proj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,7 @@
369369
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Debug'">-g -Os -s -DDEBUG=1 -DENABLE_AOT_PROFILER=1 -DENABLE_BROWSER_PROFILER=1</CMakeConfigurationEmccFlags>
370370
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Release'">-Oz -DENABLE_BROWSER_PROFILER=1</CMakeConfigurationEmccFlags>
371371

372-
<CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Debug'" >$(CMakeConfigurationEmccFlags) -s ASSERTIONS=1 </CMakeConfigurationLinkFlags>
373-
<CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Release'">-O2</CMakeConfigurationLinkFlags>
372+
<CMakeConfigurationLinkFlags >$(CMakeConfigurationEmccFlags) -s ASSERTIONS=1 </CMakeConfigurationLinkFlags>
374373

375374
<!-- -lexports.js has the magical property of disabling minification of export names -->
376375
<CMakeConfigurationLinkFlags>$(CMakeConfigurationLinkFlags) -s EXPORT_ES6=1 -lexports.js</CMakeConfigurationLinkFlags>

src/mono/browser/build/BrowserWasmApp.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@
432432
<_EmccLDSFlags Include="-s STACK_SIZE=$(EmccStackSize)" />
433433
<_EmccLDSFlags Include="-s WASM_BIGINT=1" />
434434
<_EmccLDSFlags Condition="'$(EmccEnvironment)' != ''" Include="-s ENVIRONMENT=&quot;$(EmccEnvironment)&quot;" />
435-
<_EmccLDSFlags Condition="'$(EmccEnableAssertions)' == 'true'" Include="-s ASSERTIONS=1" />
435+
<_EmccLDSFlags Include="-s ASSERTIONS=1" />
436436

437437
<_WasmNativeFileForLinking Include="%(_BitcodeFile.ObjectFile)" />
438438
<_WasmNativeFileForLinking Include="%(_WasmSourceFileToCompile.ObjectFile)" />

src/mono/browser/runtime/invoke-js.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { wrap_as_cancelable_promise } from "./cancelable-promise";
1818
import { threads_c_functions as tcwraps } from "./cwraps";
1919
import { monoThreadInfo } from "./pthreads";
2020
import { stringToUTF16Ptr } from "./strings";
21+
import { monoSafeSetTimeout } from "./scheduling";
2122

2223
export const js_import_wrapper_by_fn_handle: Function[] = <any>[null];// 0th slot is dummy, main thread we free them on shutdown. On web worker thread we free them when worker is detached.
2324

@@ -501,9 +502,9 @@ export function assert_c_interop (): void {
501502
// make sure we are not blocking em_task_queue_execute up the call stack
502503
// so that when we call back to managed, the FS calls could still be processed by the UI thread
503504
// see also emscripten_yield which can process the FS calls inside the spin wait
504-
export function invoke_later_when_on_ui_thread_sync (fn: Function, args: JSMarshalerArguments) {
505+
export function invoke_later_when_on_ui_thread_sync (fn: (() => void), args: JSMarshalerArguments) {
505506
if (WasmEnableThreads && monoThreadInfo.isUI) {
506-
Module.safeSetTimeout(() => {
507+
monoSafeSetTimeout(() => {
507508
fn();
508509
// see also mono_threads_wasm_sync_run_in_target_thread_vii_cb
509510
const done_semaphore = get_sync_done_semaphore_ptr(args);
@@ -516,9 +517,9 @@ export function invoke_later_when_on_ui_thread_sync (fn: Function, args: JSMarsh
516517

517518
// make sure we are not blocking em_task_queue_execute up the call stack
518519
// so that when we call back to managed, the FS calls could still be processed by the UI thread
519-
export function invoke_later_when_on_ui_thread_async (fn: Function) {
520+
export function invoke_later_when_on_ui_thread_async (fn: (() => void)) {
520521
if (WasmEnableThreads && monoThreadInfo.isUI) {
521-
Module.safeSetTimeout(fn, 0);
522+
monoSafeSetTimeout(fn, 0);
522523
} else {
523524
fn();
524525
}

src/mono/browser/runtime/pthreads/deputy-thread.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Module, loaderHelpers, runtimeHelpers } from "../globals";
1010
import { start_runtime } from "../startup";
1111
import { WorkerToMainMessageType } from "../types/internal";
1212
import { forceThreadMemoryViewRefresh } from "../memory";
13+
import { monoSafeSetTimeout } from "../scheduling";
1314

1415
export function mono_wasm_start_deputy_thread_async () {
1516
if (!WasmEnableThreads) return;
@@ -27,7 +28,7 @@ export function mono_wasm_start_deputy_thread_async () {
2728
info: monoThreadInfo,
2829
});
2930
Module.runtimeKeepalivePush();
30-
Module.safeSetTimeout(async () => {
31+
monoSafeSetTimeout(async () => {
3132
try {
3233
forceThreadMemoryViewRefresh();
3334

src/mono/browser/runtime/pthreads/shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { set_thread_prefix } from "../logging";
1111
import { monoMessageSymbol, PThreadPtrNull, WorkerToMainMessageType } from "../types/internal";
1212
import { threads_c_functions as tcwraps } from "../cwraps";
1313
import { forceThreadMemoryViewRefresh } from "../memory";
14+
import { monoSafeSetTimeout } from "../scheduling";
1415

1516
// A duplicate in loader/assets.ts
1617
export const worker_empty_prefix = " - ";
@@ -86,7 +87,7 @@ export function exec_synchronization_context_pump (): void {
8687

8788
export function mono_wasm_schedule_synchronization_context (): void {
8889
if (!WasmEnableThreads) return;
89-
Module.safeSetTimeout(exec_synchronization_context_pump, 0);
90+
monoSafeSetTimeout(exec_synchronization_context_pump, 0);
9091
}
9192

9293
export function mono_wasm_pthread_ptr (): PThreadPtr {

src/mono/browser/runtime/scheduling.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function mono_background_exec_until_done () {
6363
export function schedule_background_exec (): void {
6464
if (WasmEnableThreads) return;
6565
++pump_count;
66-
Module.safeSetTimeout(mono_background_exec_until_done, 0);
66+
monoSafeSetTimeout(mono_background_exec_until_done, 0);
6767
}
6868

6969
let lastScheduledTimeoutId: any = undefined;
@@ -73,7 +73,7 @@ export function mono_wasm_schedule_timer (shortestDueTimeMs: number): void {
7373
globalThis.clearTimeout(lastScheduledTimeoutId);
7474
lastScheduledTimeoutId = undefined;
7575
}
76-
lastScheduledTimeoutId = Module.safeSetTimeout(mono_wasm_schedule_timer_tick, shortestDueTimeMs);
76+
lastScheduledTimeoutId = monoSafeSetTimeout(mono_wasm_schedule_timer_tick, shortestDueTimeMs);
7777
}
7878

7979
function mono_wasm_schedule_timer_tick () {
@@ -93,3 +93,21 @@ function mono_wasm_schedule_timer_tick () {
9393
loaderHelpers.mono_exit(1, ex);
9494
}
9595
}
96+
97+
98+
export function monoSafeSetTimeout (userCallback: (() => void), timeout: number): number {
99+
Module.runtimeKeepalivePush();
100+
return setTimeout(() => {
101+
try {
102+
if (!loaderHelpers.is_runtime_running()) {
103+
return;
104+
}
105+
Module.maybeExit();
106+
Module.runtimeKeepalivePop();
107+
userCallback();
108+
Module.maybeExit();
109+
} catch (e) {
110+
loaderHelpers.mono_exit(1, e);
111+
}
112+
}, timeout);
113+
}

src/mono/mono.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@
413413
<!-- WASM specific options -->
414414
<PropertyGroup Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">
415415
<_MonoMinimal Condition="'$(Configuration)' == 'Release'">,debugger_agent,log_dest</_MonoMinimal>
416-
<_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages</_MonoMinimal>
416+
<_MonoMinimal Condition="'$(Configuration)' == 'Release'">$(_MonoMinimal),assert_messages</_MonoMinimal>
417417
<_MonoMinimal Condition="'$(WasmEnableThreads)' != 'true'">$(_MonoMinimal),threads</_MonoMinimal>
418418
</PropertyGroup>
419419
<ItemGroup Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">

src/native/libs/System.Native/pal_time.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ int32_t SystemNative_UTimensat(const char* path, TimeSpec* times)
3434

3535
updatedTimes[1].tv_sec = (time_t)times[1].tv_sec;
3636
updatedTimes[1].tv_nsec = (long)times[1].tv_nsec;
37+
#if defined(TARGET_BROWSER)
38+
while (CheckInterrupted(result = utimensat(AT_FDCWD, path, updatedTimes, 0)));
39+
#else
3740
while (CheckInterrupted(result = utimensat(AT_FDCWD, path, updatedTimes, AT_SYMLINK_NOFOLLOW)));
41+
#endif
3842
#else
3943
struct timeval updatedTimes[2];
4044
updatedTimes[0].tv_sec = (long)times[0].tv_sec;

0 commit comments

Comments
 (0)