From 1fa2ed988cf693141d4da9d760f0cad914046fbb Mon Sep 17 00:00:00 2001
From: Kostis Sagonas <kostis@it.uu.se>
Date: Tue, 19 Feb 2013 14:08:40 +0100
Subject: Native code compilation changes

Add more files to be compiled to native code and
do the native code compilation in parallel if there are enough cores.
---
 lib/dialyzer/src/dialyzer_cl.erl | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

(limited to 'lib/dialyzer')

diff --git a/lib/dialyzer/src/dialyzer_cl.erl b/lib/dialyzer/src/dialyzer_cl.erl
index 6732d96b98..967aa989fb 100644
--- a/lib/dialyzer/src/dialyzer_cl.erl
+++ b/lib/dialyzer/src/dialyzer_cl.erl
@@ -488,6 +488,7 @@ expand_dependent_modules_1([Mod|Mods], Included, ModDeps) ->
 expand_dependent_modules_1([], Included, _ModDeps) ->
   Included.
 
+-define(MIN_PARALLELISM, 7).
 -define(MIN_FILES_FOR_NATIVE_COMPILE, 20).
 
 -spec hipe_compile([file:filename()], #options{}) -> 'ok'.
@@ -501,11 +502,14 @@ hipe_compile(Files, #options{erlang_mode = ErlangMode} = Options) ->
       case erlang:system_info(hipe_architecture) of
 	undefined -> ok;
 	_ ->
-	  Mods = [lists, dict, gb_sets, gb_trees, ordsets, sets,
+	  Mods = [lists, dict, digraph, digraph_utils, ets,
+		  gb_sets, gb_trees, ordsets, sets, sofs,
 		  cerl, cerl_trees, erl_types, erl_bif_types,
-		  dialyzer_analysis_callgraph, dialyzer_codeserver,
-		  dialyzer_dataflow, dialyzer_dep, dialyzer_plt,
-		  dialyzer_succ_typings, dialyzer_typesig],
+		  dialyzer_analysis_callgraph, dialyzer, dialyzer_behaviours,
+		  dialyzer_codeserver, dialyzer_contracts,
+		  dialyzer_coordinator, dialyzer_dataflow, dialyzer_dep,
+		  dialyzer_plt, dialyzer_succ_typings, dialyzer_typesig,
+		  dialyzer_typesig, dialyzer_worker],
 	  report_native_comp(Options),
 	  {T1, _} = statistics(wall_clock),
 	  native_compile(Mods),
@@ -515,12 +519,12 @@ hipe_compile(Files, #options{erlang_mode = ErlangMode} = Options) ->
   end.
 
 native_compile(Mods) ->
-  case erlang:system_info(schedulers) of
-    %% N when N > 1 ->
-    %%   Parent = self(),
-    %%   Pids = [spawn(fun () -> Parent ! {self(), hc(M)} end) || M <- Mods],
-    %%   lists:foreach(fun (Pid) -> receive {Pid, Res} -> Res end end, Pids);
-    _ -> % 1 ->
+  case dialyzer_utils:parallelism() > ?MIN_PARALLELISM of
+    true ->
+      Parent = self(),
+      Pids = [spawn(fun () -> Parent ! {self(), hc(M)} end) || M <- Mods],
+      lists:foreach(fun (Pid) -> receive {Pid, Res} -> Res end end, Pids);
+    false ->
       lists:foreach(fun (Mod) -> hc(Mod) end, Mods)
   end.
 
@@ -529,6 +533,7 @@ hc(Mod) ->
   case code:is_module_native(Mod) of
     true -> ok;
     false ->
+      %% io:format(" ~s", [Mod]),
       {ok, Mod} = hipe:c(Mod),
       ok
   end.
-- 
cgit v1.2.3