[m-rev.] for review: set optimization options just once

Julien Fischer jfischer at opturion.com
Sun Oct 11 21:06:51 AEDT 2020


On Sun, 11 Oct 2020, Julien Fischer wrote:

> On Sun, 11 Oct 2020, Zoltan Somogyi wrote:
>
>>  For review by Julien, since it is an attempt to fix a bug he reported,
>>  Mantis 522. The optimization improvement mentioned in the log message
>>  has bootchecked, but I haven't tried it out on this code yet.
>
> I will try it out after you commit.

It helps, but it's still not sufficient.  Shifting some of the field
updates in a separate predicate (as in the diff below) avoids the limit.
I'll commit that unless there are any objections.

Julien.

diff --git a/compiler/handle_options.m b/compiler/handle_options.m
index abf3118..d853f04 100644
--- a/compiler/handle_options.m
+++ b/compiler/handle_options.m
@@ -2580,20 +2580,40 @@ convert_options_to_globals(OptionTable0, !.OptTuple, OpMode, Target, GC_Method,
          globals.set_option(can_compare_constants_as_ints, bool(no), !Globals)
      ),

-    !OptTuple ^ ot_allow_inlining := OT_AllowInlining,
-    !OptTuple ^ ot_opt_common_structs := OT_OptCommonStructs,
-    !OptTuple ^ ot_prop_constraints := OT_PropConstraints,
-    !OptTuple ^ ot_prop_local_constraints := OT_PropLocalConstraints,
-    !OptTuple ^ ot_opt_dup_calls := OT_OptDupCalls,
-    !OptTuple ^ ot_prop_constants := OT_PropConstants,
-    !OptTuple ^ ot_opt_svcell := OT_OptSVCell,
-    !OptTuple ^ ot_opt_loop_invariants := OT_OptLoopInvariants,
-    !OptTuple ^ ot_elim_excess_assigns := OT_ElimExcessAssigns,
-    !OptTuple ^ ot_opt_test_after_switch := OT_OptTestAfterSwitch,
-    !OptTuple ^ ot_opt_follow_code := OT_OptFollowCode,
-    !OptTuple ^ ot_opt_unused_args := OT_OptUnusedArgs,
-    !OptTuple ^ ot_opt_unused_args_intermod := OT_OptUnusedArgsIntermod,
-    !OptTuple ^ ot_opt_higher_order := OT_OptHigherOrder,
+    % XXX When compiling to Java, the following commented out updates cause us
+    % to generate code that exceeds the maximum method size in the JVM.
+    % We shift some of the updates into a separate predicate,
+    % update_opt_tuple/16, in order to avoid this.
+
+    %!OptTuple ^ ot_allow_inlining := OT_AllowInlining,
+    %!OptTuple ^ ot_opt_common_structs := OT_OptCommonStructs,
+    %!OptTuple ^ ot_prop_constraints := OT_PropConstraints,
+    %!OptTuple ^ ot_prop_local_constraints := OT_PropLocalConstraints,
+    %!OptTuple ^ ot_opt_dup_calls := OT_OptDupCalls,
+    %!OptTuple ^ ot_prop_constants := OT_PropConstants,
+    %!OptTuple ^ ot_opt_svcell := OT_OptSVCell,
+    %!OptTuple ^ ot_opt_loop_invariants := OT_OptLoopInvariants,
+    %!OptTuple ^ ot_elim_excess_assigns := OT_ElimExcessAssigns,
+    %!OptTuple ^ ot_opt_test_after_switch := OT_OptTestAfterSwitch,
+    %!OptTuple ^ ot_opt_follow_code := OT_OptFollowCode,
+    %!OptTuple ^ ot_opt_unused_args := OT_OptUnusedArgs,
+    %!OptTuple ^ ot_opt_unused_args_intermod := OT_OptUnusedArgsIntermod,
+    %!OptTuple ^ ot_opt_higher_order := OT_OptHigherOrder,
+    update_opt_tuple(OT_AllowInlining,
+        OT_OptCommonStructs,
+        OT_PropConstraints,
+        OT_PropLocalConstraints,
+        OT_OptDupCalls,
+        OT_PropConstants,
+        OT_OptSVCell,
+        OT_OptLoopInvariants,
+        OT_ElimExcessAssigns,
+        OT_OptTestAfterSwitch,
+        OT_OptFollowCode,
+        OT_OptUnusedArgs,
+        OT_OptUnusedArgsIntermod,
+        OT_OptHigherOrder,
+        !OptTuple),
      !OptTuple ^ ot_higher_order_size_limit := OT_HigherOrderSizeLimit,
      !OptTuple ^ ot_spec_types := OT_SpecTypes,
      !OptTuple ^ ot_spec_types_user_guided := OT_SpecTypesUserGuided,
@@ -2619,6 +2639,53 @@ convert_options_to_globals(OptionTable0, !.OptTuple, OpMode, Target, GC_Method,
      postprocess_options_libgrades(!Globals, !Specs),
      globals_init_mutables(!.Globals, !IO).

+:- pred update_opt_tuple(
+    maybe_allow_inlining::in,
+    maybe_opt_common_structs::in,
+    maybe_prop_constraints::in,
+    maybe_prop_local_constraints::in,
+    maybe_opt_dup_calls::in,
+    maybe_prop_constants::in,
+    maybe_opt_svcell::in,
+    maybe_opt_loop_invariants::in,
+    maybe_elim_excess_assigns::in,
+    maybe_opt_test_after_switch::in,
+    maybe_opt_follow_code::in,
+    maybe_opt_unused_args::in,
+    maybe_opt_unused_args_intermod::in,
+    maybe_opt_higher_order::in,
+    opt_tuple::in, opt_tuple::out) is det.
+
+update_opt_tuple(OT_AllowInlining,
+        OT_OptCommonStructs,
+        OT_PropConstraints,
+        OT_PropLocalConstraints,
+        OT_OptDupCalls,
+        OT_PropConstants,
+        OT_OptSVCell,
+        OT_OptLoopInvariants,
+        OT_ElimExcessAssigns,
+        OT_OptTestAfterSwitch,
+        OT_OptFollowCode,
+        OT_OptUnusedArgs,
+        OT_OptUnusedArgsIntermod,
+        OT_OptHigherOrder,
+        !OptTuple) :-
+    !OptTuple ^ ot_allow_inlining := OT_AllowInlining,
+    !OptTuple ^ ot_opt_common_structs := OT_OptCommonStructs,
+    !OptTuple ^ ot_prop_constraints := OT_PropConstraints,
+    !OptTuple ^ ot_prop_local_constraints := OT_PropLocalConstraints,
+    !OptTuple ^ ot_opt_dup_calls := OT_OptDupCalls,
+    !OptTuple ^ ot_prop_constants := OT_PropConstants,
+    !OptTuple ^ ot_opt_svcell := OT_OptSVCell,
+    !OptTuple ^ ot_opt_loop_invariants := OT_OptLoopInvariants,
+    !OptTuple ^ ot_elim_excess_assigns := OT_ElimExcessAssigns,
+    !OptTuple ^ ot_opt_test_after_switch := OT_OptTestAfterSwitch,
+    !OptTuple ^ ot_opt_follow_code := OT_OptFollowCode,
+    !OptTuple ^ ot_opt_unused_args := OT_OptUnusedArgs,
+    !OptTuple ^ ot_opt_unused_args_intermod := OT_OptUnusedArgsIntermod,
+    !OptTuple ^ ot_opt_higher_order := OT_OptHigherOrder.
+
      % These option implications only affect the low-level (LLDS) code
      % generator. They may in fact be harmful if set for the high-level
      % code generator, because sometimes the same option has different



More information about the reviews mailing list