Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][interp] When local space overflows, retry compilation with optimization enabled #94381

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all 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
17 changes: 12 additions & 5 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -11157,11 +11157,16 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
td->seq_points = g_ptr_array_new ();
td->verbose_level = mono_interp_traceopt;
td->prof_coverage = mono_profiler_coverage_instrumentation_enabled (method);
td->disable_inlining = !rtm->optimized;
if (retry_compilation)
if (retry_compilation) {
// Optimizing the method can lead to deadce and better var offset allocation
// reducing the likelihood of local space overflow.
td->optimized = rtm->optimized = TRUE;
td->disable_inlining = TRUE;
} else {
td->optimized = rtm->optimized;
td->disable_inlining = !td->optimized;
}
rtm->data_items = td->data_items;
td->optimized = rtm->optimized;

if (td->prof_coverage)
td->coverage_info = mono_profiler_coverage_alloc (method, header->code_size);
Expand Down Expand Up @@ -11221,7 +11226,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
generate_compacted_code (rtm, td);

if (td->total_locals_size >= G_MAXUINT16) {
if (td->disable_inlining) {
if (td->disable_inlining && td->optimized) {
char *name = mono_method_get_full_name (method);
char *msg = g_strdup_printf ("Unable to run method '%s': locals size too big.", name);
g_free (name);
Expand All @@ -11230,7 +11235,9 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
retry_compilation = FALSE;
goto exit;
} else {
// We give the method another chance to compile with inlining disabled
// We give the method another chance to compile with inlining disabled and optimization enabled
if (td->verbose_level)
g_print ("Local space overflow. Retrying compilation\n");
retry_compilation = TRUE;
goto exit;
}
Expand Down
Loading