Commits

Anonymous committed 96b8108

emit_alpha, asmlink: generation d'une directive .file.
closure: mecanique de partage des cas de switch revue.
cmmgen: on evite d'emettre plusieurs fois la meme fonction (peut se
produire suite a un departage de orpat).

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@95f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

Comments (0)

Files changed (4)

asmcomp/asmlink.ml

 let make_startup_file filename info_list =
   let oc = open_out filename in
   Emitaux.output_channel := oc;
+  Location.input_name := "startup"; (* set the name of the "current" input *)
   Compilenv.reset "startup" 0; (* set the name of the "current" compunit *)
   Emit.begin_assembly();
   let name_list = List.map (fun ui -> ui.ui_name) info_list in

asmcomp/closure.ml

 
 and close_switch fenv cenv num_keys cases =
   let index = Array.new num_keys 0 in
-  let num_cases = ref 0 and ucases = ref [] in
+  let ucases = ref []
+  and num_cases = ref 0
+  and cases_processed = ref [] in
   if List.length cases < num_keys then begin
     num_cases := 1;
     ucases := [Ustaticfail]
   end;
   List.iter
-    (function
-        (key, Lshared(lam, r)) ->
-          begin match !r with
-            None ->
-              let (ulam, _) = close fenv cenv lam in
-              ucases := ulam :: !ucases;
-              index.(key) <- !num_cases;
-              r := Some !num_cases;
-              incr num_cases
-          | Some n ->
-              index.(key) <- n
-          end
-      | (key, lam) ->
-          let (ulam, _) = close fenv cenv lam in
-          ucases := ulam :: !ucases;
-          index.(key) <- !num_cases;
-          incr num_cases)
-    cases;
-  List.iter
-    (function
-        (key, Lshared(lam, r)) -> r := None
-      | (key, lam) -> ())
+    (function (key, lam) ->
+      try
+        index.(key) <- List.assq lam !cases_processed
+      with Not_found ->
+        let (ulam, _) = close fenv cenv lam in
+        ucases := ulam :: !ucases;
+        index.(key) <- !num_cases;
+        cases_processed := (lam, !num_cases) :: !cases_processed;
+        incr num_cases)
     cases;
   (index, Array.of_list(List.rev !ucases))
 
 
 let intro lam =
   let (ulam, approx) = close Tbl.empty Tbl.empty lam in ulam
-

asmcomp/cmmgen.ml

 
 (* Translate all function definitions *)
 
-let rec transl_all_functions cont =
+module StringSet =
+  Set.Make(struct
+    type t = string
+    let compare = compare
+  end)
+
+let rec transl_all_functions already_translated cont =
   try
     let (lbl, params, body) = Queue.take functions in
-    transl_all_functions(transl_function lbl params body :: cont)
+    if StringSet.mem lbl already_translated then
+      transl_all_functions already_translated cont
+    else
+      transl_all_functions (StringSet.add lbl already_translated)
+                           (transl_function lbl params body :: cont)
   with Queue.Empty ->
     cont
 
   structured_constants := [];
   let c1 = [Cfunction {fun_name = glob ^ "_entry"; fun_args = [];
                        fun_body = transl ulam; fun_fast = false}] in
-  let c2 = transl_all_functions c1 in
+  let c2 = transl_all_functions StringSet.empty c1 in
   let c3 = emit_all_constants c2 in
   Cdata [Cdefine_symbol glob; Cint 0] :: c3
 

asmcomp/emit_alpha.mlp

   `	.noalias $17,$sp; .noalias $17,$15; .noalias $18,$sp; .noalias $18,$15\n`;
   `	.noalias $19,$sp; .noalias $19,$15; .noalias $20,$sp; .noalias $20,$15\n`;
   `	.noalias $21,$sp; .noalias $21,$15; .noalias $22,$sp; .noalias $22,$15\n`;
-  `	.noalias $23,$sp; .noalias $23,$15\n\n`
+  `	.noalias $23,$sp; .noalias $23,$15\n\n`;
+  (* The following .file directive is intended to prevent the generation
+     of line numbers for the debugger, 'cos they make .o files larger
+     and slow down linking. *)
+  `	.file	1 \"{emit_string !Location.input_name}\"\n\n`
 
 let end_assembly () =
   let lbl = Compilenv.current_unit_name() ^ "_frametable" in
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.