Skip to content

Commit 442e882

Browse files
authored
[browser] mono_wasm_enable_gc and pump_count cleanup (#111198)
1 parent 61b7e83 commit 442e882

File tree

5 files changed

+9
-48
lines changed

5 files changed

+9
-48
lines changed

src/mono/browser/runtime/runtime.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@
6262
#define EMSCRIPTEN_KEEPALIVE
6363
#endif
6464

65-
int mono_wasm_enable_gc = 1;
66-
6765
/* Missing from public headers */
6866
char *mono_fixup_symbol_name (const char *prefix, const char *key, const char *suffix);
6967
void mono_icall_table_init (void);

src/mono/browser/runtime/runtime.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <mono/metadata/object.h>
1414
#include <mono/metadata/debug-helpers.h>
1515

16-
extern int mono_wasm_enable_gc;
17-
1816
MonoDomain *mono_wasm_load_runtime_common (int debug_level, MonoLogCallback log_callback, const char *interp_opts);
1917
MonoAssembly *mono_wasm_assembly_load (const char *name);
2018
MonoClass *mono_wasm_assembly_find_class (MonoAssembly *assembly, const char *namespace, const char *name);

src/mono/browser/runtime/scheduling.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Module, loaderHelpers } from "./globals";
88
import { forceThreadMemoryViewRefresh } from "./memory";
99

1010
let spread_timers_maximum = 0;
11-
let pump_count = 0;
1211

1312
export function prevent_timer_throttling (): void {
1413
if (WasmEnableThreads) return;
@@ -37,7 +36,6 @@ function prevent_timer_throttling_tick () {
3736
}
3837
try {
3938
cwraps.mono_wasm_execute_timer();
40-
pump_count++;
4139
} catch (ex) {
4240
loaderHelpers.mono_exit(1, ex);
4341
}
@@ -46,24 +44,24 @@ function prevent_timer_throttling_tick () {
4644

4745
function mono_background_exec_until_done () {
4846
if (WasmEnableThreads) return;
47+
lastScheduledBackground = undefined;
4948
Module.maybeExit();
49+
if (!loaderHelpers.is_runtime_running()) {
50+
return;
51+
}
5052
try {
51-
while (pump_count > 0) {
52-
--pump_count;
53-
if (!loaderHelpers.is_runtime_running()) {
54-
return;
55-
}
56-
cwraps.mono_background_exec();
57-
}
53+
cwraps.mono_background_exec();
5854
} catch (ex) {
5955
loaderHelpers.mono_exit(1, ex);
6056
}
6157
}
6258

59+
let lastScheduledBackground: any = undefined;
6360
export function schedule_background_exec (): void {
6461
if (WasmEnableThreads) return;
65-
++pump_count;
66-
Module.safeSetTimeout(mono_background_exec_until_done, 0);
62+
if (!lastScheduledBackground) {
63+
lastScheduledBackground = Module.safeSetTimeout(mono_background_exec_until_done, 0);
64+
}
6765
}
6866

6967
let lastScheduledTimeoutId: any = undefined;
@@ -86,7 +84,6 @@ function mono_wasm_schedule_timer_tick () {
8684
lastScheduledTimeoutId = undefined;
8785
try {
8886
cwraps.mono_wasm_execute_timer();
89-
pump_count++;
9087
} catch (ex) {
9188
loaderHelpers.mono_exit(1, ex);
9289
}

src/mono/mono/metadata/sgen-mono.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,10 +2067,6 @@ pin_handle_stack_interior_ptrs (void **ptr_slot, void *user_data)
20672067
sgen_conservatively_pin_objects_from (ptr_slot, ptr_slot+1, ud->start_nursery, ud->end_nursery, PIN_TYPE_STACK);
20682068
}
20692069

2070-
#if defined(HOST_WASM) || defined(HOST_WASI)
2071-
extern gboolean mono_wasm_enable_gc;
2072-
#endif
2073-
20742070
/*
20752071
* Mark from thread stacks and registers.
20762072
*/
@@ -2079,11 +2075,6 @@ sgen_client_scan_thread_data (void *start_nursery, void *end_nursery, gboolean p
20792075
{
20802076
scan_area_arg_start = start_nursery;
20812077
scan_area_arg_end = end_nursery;
2082-
#if defined(HOST_WASM) || defined(HOST_WASI)
2083-
//Under WASM we don't scan thread stacks and we can't trust the values we find there either.
2084-
if (!mono_wasm_enable_gc)
2085-
return;
2086-
#endif
20872078

20882079
SGEN_TV_DECLARE (scan_thread_data_start);
20892080
SGEN_TV_DECLARE (scan_thread_data_end);

src/mono/mono/sgen/sgen-gc.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,32 +2733,9 @@ gc_pump_callback (void)
27332733
}
27342734
#endif
27352735

2736-
#if defined(HOST_BROWSER) || defined(HOST_WASI)
2737-
extern gboolean mono_wasm_enable_gc;
2738-
#endif
2739-
27402736
void
27412737
sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean forced_serial, gboolean stw)
27422738
{
2743-
#if defined(HOST_BROWSER) && defined(DISABLE_THREADS)
2744-
if (!mono_wasm_enable_gc) {
2745-
g_assert (stw); //can't handle non-stw mode (IE, domain unload)
2746-
//we ignore forced_serial
2747-
2748-
//There's a window for racing where we're executing other bg jobs before the GC, they trigger a GC request and it overrides this one.
2749-
//I belive this case to be benign as it will, in the worst case, upgrade a minor to a major collection.
2750-
if (gc_request.generation_to_collect <= generation_to_collect) {
2751-
gc_request.requested_size = requested_size;
2752-
gc_request.generation_to_collect = generation_to_collect;
2753-
gc_request.reason = reason;
2754-
sgen_client_schedule_background_job (gc_pump_callback);
2755-
}
2756-
2757-
sgen_degraded_mode = 1; //enable degraded mode so allocation can continue
2758-
return;
2759-
}
2760-
#endif
2761-
27622739
sgen_perform_collection_inner (requested_size, generation_to_collect, reason, forced_serial, stw);
27632740
}
27642741
/*

0 commit comments

Comments
 (0)