about summary refs log tree commit diff
path: root/src/boot
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-08-24 11:45:48 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-08-24 11:45:48 -0700
commit8d787d1e082a55db2d2fdcce15ca99d7665c018d (patch)
treecaafca26453fd6dbe6eec61f6bde42df4da83474 /src/boot
parent87c9a9e25d922cd9e00981ac9a3e6fa43df20c0b (diff)
downloadrust-8d787d1e082a55db2d2fdcce15ca99d7665c018d.tar.gz
rust-8d787d1e082a55db2d2fdcce15ca99d7665c018d.zip
Avoid emitting unnecessary frame glue. Wins a couple hundred kb of rustc.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/me/trans.ml107
1 files changed, 74 insertions, 33 deletions
diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml
index 914645ff601..5b36a9f3774 100644
--- a/src/boot/me/trans.ml
+++ b/src/boot/me/trans.ml
@@ -104,10 +104,6 @@ let trans_visitor
     Il.Imm (crate_rel fix, word_ty_signed_mach)
   in
 
-  let table_of_crate_rel_fixups (fixups:fixup array) : Asm.frag =
-    Asm.SEQ (Array.map crate_rel_word fixups)
-  in
-
   let fixup_rel_word (base:fixup) (fix:fixup) =
     Asm.WORD (word_ty_signed_mach,
               Asm.SUB (Asm.M_POS fix, Asm.M_POS base))
@@ -1767,7 +1763,7 @@ let trans_visitor
         trans_copy_ty ty_params true dst ty src ty curr_iso;
         let skip_noninit_jmp = mark() in
           emit (Il.jmp Il.JMP Il.CodeNone);
-          List.iter patch jmps;          
+          List.iter patch jmps;
           trans_copy_ty ty_params false dst ty src ty curr_iso;
           patch skip_noninit_jmp;
     in
@@ -4810,41 +4806,86 @@ let trans_visitor
               end
         end
     in
+    let frame_has_aliases =
+      let r = ref false in
+        iter_frame_and_arg_slots cx fnid
+          begin
+            fun _ _ slot ->
+              match slot.Ast.slot_mode with
+                  Ast.MODE_alias -> r := true
+                | _ -> ()
+          end;
+        !r
+    in
+    let frame_points_to_heap =
+      let r = ref false in
+        iter_frame_and_arg_slots cx fnid
+          begin
+            fun _ slot_id _ ->
+              if type_points_to_heap (slot_ty (get_slot cx slot_id))
+              then r := true
+          end;
+        !r
+    in
+    let null_word = Asm.WORD (word_ty_mach, Asm.IMM 0L) in
+
     trans_crate_rel_data_operand
       (DATA_frame_glue_fns fnid)
       begin
         fun _ ->
-          let mark_frame_glue_fixup =
-            get_frame_glue (GLUE_mark_frame fnid)
-              begin
-                fun _ _ ty_params slot slot_cell ->
-                  mark_slot ty_params slot_cell slot None
-              end
+          let mark_frame_word =
+            if frame_points_to_heap
+            then
+              crate_rel_word
+                begin
+                  get_frame_glue (GLUE_mark_frame fnid)
+                    begin
+                      fun _ _ ty_params slot slot_cell ->
+                        mark_slot ty_params slot_cell slot None
+                    end
+                end
+            else
+              null_word
           in
-          let drop_frame_glue_fixup =
-            get_frame_glue (GLUE_drop_frame fnid)
-              begin
-                fun _ _ ty_params slot slot_cell ->
-                  drop_slot ty_params slot_cell slot None
-              end
+
+          let drop_frame_word =
+            if frame_points_to_heap
+            then
+              crate_rel_word
+                begin
+                  get_frame_glue (GLUE_drop_frame fnid)
+                    begin
+                      fun _ _ ty_params slot slot_cell ->
+                        drop_slot ty_params slot_cell slot None
+                    end
+                end
+            else
+              null_word
           in
-          let reloc_frame_glue_fixup =
-            get_frame_glue (GLUE_reloc_frame fnid)
-              begin
-                fun _ _ _ _ _ ->
-                  ()
-              end
+
+          let reloc_frame_word =
+            if frame_has_aliases
+            then
+              crate_rel_word
+                begin
+                  get_frame_glue (GLUE_reloc_frame fnid)
+                    begin
+                      fun _ _ _ _ _ ->
+                        ()
+                    end
+                end
+            else
+              null_word
           in
-            table_of_crate_rel_fixups
-              [|
-               (* 
-                * NB: this must match the struct-offsets given in ABI
-                * & rust runtime library.
-                *)
-                mark_frame_glue_fixup;
-                drop_frame_glue_fixup;
-                reloc_frame_glue_fixup;
-              |]
+            Asm.SEQ [|
+              (* 
+               * NB: this must match the struct-offsets given in ABI
+               * & rust runtime library.
+               *)
+              mark_frame_word;
+              drop_frame_word;
+              reloc_frame_word;
+            |]
       end
   in