about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-10-05 18:44:39 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-10-05 18:44:39 -0700
commit8ecbe49a8fa8b4bb17c2d798d5de6fc0303c5bc6 (patch)
tree11c52a82f424b8782e7dd13e7965e580dbf01c5d /src
parentd1e59d691039731b8ae05aadf8358c499dfa5b89 (diff)
downloadrust-8ecbe49a8fa8b4bb17c2d798d5de6fc0303c5bc6.tar.gz
rust-8ecbe49a8fa8b4bb17c2d798d5de6fc0303c5bc6.zip
Add -minimal mode to rustboot that skips emitting code that's broken or unneeded for rustc. Shrink rustc by 300kb. Back under 1mb.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile3
-rw-r--r--src/boot/be/abi.ml3
-rw-r--r--src/boot/be/x86.ml8
-rw-r--r--src/boot/driver/main.ml5
-rw-r--r--src/boot/driver/session.ml1
-rw-r--r--src/boot/me/trans.ml34
6 files changed, 38 insertions, 16 deletions
diff --git a/src/Makefile b/src/Makefile
index a0fe6cc3f1d..758488a27d9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -368,7 +368,8 @@ endif
 
 $(CFG_COMPILER): $(COMPILER_INPUTS) $(CFG_BOOT) $(CFG_RUNTIME) $(CFG_STDLIB)
 	@$(call CFG_ECHO, compile: $<)
-	$(CFG_QUIET)OCAMLRUNPARAM="b1" $(CFG_BOOT) $(CFG_BOOT_FLAGS) -o $@ $<
+	$(CFG_QUIET)OCAMLRUNPARAM="b1" $(CFG_BOOT) $(CFG_BOOT_FLAGS) \
+      -minimal -o $@ $<
 	$(CFG_QUIET)chmod 0755 $@
 
 self: $(CFG_COMPILER)
diff --git a/src/boot/be/abi.ml b/src/boot/be/abi.ml
index c16fec3608c..a7b98c2cd6a 100644
--- a/src/boot/be/abi.ml
+++ b/src/boot/be/abi.ml
@@ -126,7 +126,8 @@ type abi =
                                -> Common.nabi
                                  -> Common.fixup (* grow_task *)
                                    -> bool       (* is_obj_fn *)
-                                     -> unit);
+                                     -> bool     (* minimal *)
+                                       -> unit);
 
     abi_emit_fn_epilogue: (Il.emitter -> unit);
 
diff --git a/src/boot/be/x86.ml b/src/boot/be/x86.ml
index 468d1ab1b5b..dd21c329195 100644
--- a/src/boot/be/x86.ml
+++ b/src/boot/be/x86.ml
@@ -1236,6 +1236,7 @@ let fn_prologue
     (nabi:nabi)
     (grow_task_fixup:fixup)
     (is_obj_fn:bool)
+    (minimal:bool)
     : unit =
 
   let esi_n = word_n (h esi) in
@@ -1372,8 +1373,11 @@ let fn_prologue
       in
 
         (* "Full" frame size-check. *)
-        stack_growth_check e nabi grow_task_fixup
-          dynamic_frame_sz dynamic_grow_jmp restart_pc (h esi) (h edi);
+        match dynamic_grow_jmp with
+            None when minimal -> ()
+          | _ ->
+              stack_growth_check e nabi grow_task_fixup
+                dynamic_frame_sz dynamic_grow_jmp restart_pc (h esi) (h edi);
 
 
         (* Establish a frame, wherever we landed. *)
diff --git a/src/boot/driver/main.ml b/src/boot/driver/main.ml
index 3c37a03250a..eacecc2d4f2 100644
--- a/src/boot/driver/main.ml
+++ b/src/boot/driver/main.ml
@@ -24,6 +24,7 @@ let (sess:Session.sess) =
     Session.sess_out = None;
     Session.sess_library_mode = false;
     Session.sess_alt_backend = false;
+    Session.sess_minimal = false;
     Session.sess_use_pexps = false;
     (* FIXME (issue #69): need something fancier here for unix
      * sub-flavours.
@@ -229,6 +230,10 @@ let argspecs =
     (flag (fun _ -> sess.Session.sess_use_pexps <- true)
        "-pexp"         "use pexp portion of AST");
 
+    (flag (fun _ -> sess.Session.sess_minimal <- true)
+       "-minimal"     ("reduce code size by disabling various features"
+                       ^ " (use at own risk)"));
+
     ("-zc", Arg.Int (fun i -> sess.Session.sess_fuzz_item_count <- i),
      "count of items to generate when fuzzing");
 
diff --git a/src/boot/driver/session.ml b/src/boot/driver/session.ml
index ae16c1395bc..8d7c331965c 100644
--- a/src/boot/driver/session.ml
+++ b/src/boot/driver/session.ml
@@ -13,6 +13,7 @@ type sess =
   mutable sess_out: filename option;
   mutable sess_library_mode: bool;
   mutable sess_alt_backend: bool;
+  mutable sess_minimal: bool;
   mutable sess_use_pexps: bool;
   mutable sess_targ: target;
   mutable sess_log_lex: bool;
diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml
index bb0d28a97c2..83c675797bd 100644
--- a/src/boot/me/trans.ml
+++ b/src/boot/me/trans.ml
@@ -1488,6 +1488,7 @@ let trans_visitor
     let frame_fns =
       match fnid with
           None -> zero
+        | Some _ when cx.ctxt_sess.Session.sess_minimal -> zero
         | Some fnid -> get_frame_glue_fns fnid
     in
     let crate_ptr_reg = next_vreg () in
@@ -1499,14 +1500,19 @@ let trans_visitor
       mov (word_at (fp_imm frame_fns_disp)) frame_fns
 
   and check_interrupt_flag _ =
-    let dom = next_vreg_cell wordptr_ty in
-    let flag = next_vreg_cell word_sty in
-      mov dom (Il.Cell (tp_imm (word_n Abi.task_field_dom)));
-      mov flag (Il.Cell (deref_imm dom
-                           (word_n Abi.dom_field_interrupt_flag)));
-      let null_jmp = null_check flag in
-        trans_yield ();
-        patch null_jmp
+    if cx.ctxt_sess.Session.sess_minimal
+    then ()
+    else
+      begin
+        let dom = next_vreg_cell wordptr_ty in
+        let flag = next_vreg_cell word_sty in
+          mov dom (Il.Cell (tp_imm (word_n Abi.task_field_dom)));
+          mov flag (Il.Cell (deref_imm dom
+                               (word_n Abi.dom_field_interrupt_flag)));
+          let null_jmp = null_check flag in
+            trans_yield ();
+            patch null_jmp
+      end
 
   and trans_glue_frame_entry
       (callsz:size)
@@ -1534,7 +1540,8 @@ let trans_visitor
       push_new_emitter_with_vregs None;
       iflog (fun _ -> annotate "prologue");
       abi.Abi.abi_emit_fn_prologue (emitter())
-        framesz callsz nabi_rust (upcall_fixup "upcall_grow_task") false;
+        framesz callsz nabi_rust (upcall_fixup "upcall_grow_task")
+        false cx.ctxt_sess.Session.sess_minimal;
       write_frame_info_ptrs None;
       (* FIXME: not clear why, but checking interrupt in glue context
        * causes many.rs to crash when run on a sufficiently large number
@@ -4766,7 +4773,8 @@ let trans_visitor
       push_new_emitter_with_vregs (Some id);
       iflog (fun _ -> annotate "prologue");
       abi.Abi.abi_emit_fn_prologue (emitter())
-        framesz callsz nabi_rust (upcall_fixup "upcall_grow_task") false;
+        framesz callsz nabi_rust (upcall_fixup "upcall_grow_task")
+        false cx.ctxt_sess.Session.sess_minimal;
       write_frame_info_ptrs None;
       iflog (fun _ -> annotate "finished prologue");
       trans_block fe.Ast.for_each_body;
@@ -5371,7 +5379,8 @@ let trans_visitor
                                   (string_of_size callsz)));
       abi.Abi.abi_emit_fn_prologue
         (emitter()) framesz callsz nabi_rust
-        (upcall_fixup "upcall_grow_task") obj_fn;
+        (upcall_fixup "upcall_grow_task") obj_fn
+        cx.ctxt_sess.Session.sess_minimal;
 
       write_frame_info_ptrs (Some fnid);
       if yield_check
@@ -5765,7 +5774,8 @@ let trans_visitor
       push_new_emitter_with_vregs (Some b.id);
       iflog (fun _ -> annotate "prologue");
       abi.Abi.abi_emit_fn_prologue (emitter())
-        framesz callsz nabi_rust (upcall_fixup "upcall_grow_task") true;
+        framesz callsz nabi_rust (upcall_fixup "upcall_grow_task")
+        true cx.ctxt_sess.Session.sess_minimal;
       write_frame_info_ptrs None;
       iflog (fun _ -> annotate "finished prologue");
       trans_block b;