Skip to content

Commit f7cd421

Browse files
authored
Merge pull request #1654 from Unity-Technologies/unity-main-optimize-preemptive-suspend
Avoid coop suspend overhead if not enabled.
2 parents 69c3b9c + af27fee commit f7cd421

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

mono/utils/mono-threads-api.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ This will put the current thread in GC Unsafe mode.
102102
For further explanation of what can and can't be done in GC unsafe mode:
103103
http://www.mono-project.com/docs/advanced/runtime/docs/coop-suspend/#gc-unsafe-mode
104104
*/
105+
106+
#if defined(ENABLE_HYBRID_SUSPEND) || defined(ENABLE_COOP_SUSPEND)
107+
105108
#define MONO_ENTER_GC_UNSAFE\
106109
do { \
107110
MONO_STACKDATA (__gc_unsafe_dummy); \
@@ -133,6 +136,24 @@ For further explanation of what can and can't be done in GC unsafe mode:
133136
MONO_STACKDATA (__gc_safe_unbalanced_dummy); \
134137
mono_threads_enter_gc_safe_region_unbalanced_internal (&__gc_safe_unbalanced_dummy)
135138

139+
#else
140+
141+
#define MONO_ENTER_GC_UNSAFE do {
142+
143+
#define MONO_EXIT_GC_UNSAFE ; } while (0)
144+
145+
#define MONO_ENTER_GC_UNSAFE_UNBALANCED do {
146+
147+
#define MONO_EXIT_GC_UNSAFE_UNBALANCED ; } while (0)
148+
149+
#define MONO_ENTER_GC_SAFE do {
150+
151+
#define MONO_EXIT_GC_SAFE ; } while (0)
152+
153+
#define MONO_ENTER_GC_SAFE_UNBALANCED
154+
155+
#endif
156+
136157
void
137158
mono_threads_enter_no_safepoints_region (const char *func);
138159

0 commit comments

Comments
 (0)