Avoid slow code loading of BEAM code in a hipe-enabled emulator
Avoid slow code loading of BEAM code in a hipe-enabled emulator

On my Linux computer, building the entire Erlang/OTP system
with hipe disabled took about 8 minutes. With hipe enabled,
but without any native code, the build took about 23 minutes,
i.e. more than 3 times slower. (The computer has 4 cores, and
I used 'make -j6'.)

On my eight-core Mac (running 'make -j10') there was only a slight
slowdown when hipe was enabled.

The culprit is hipe_unified_loader:post_beam_load/1, which will be
called every time a module is loaded (even if the module contains no
native code). If post_beam_load/1 is called in a hipe-enabled
emulator, it will block multi-scheduling, even if no work needs to be
done. Apparently the cost for blocking multi-scheduling can vary
greatly, depending on the operating system and system load.

As a quick and conservative fix, don't call post_beam_load/1 unless
some native code has been previously loaded.

potatosalad/otp,bernardd/otp,bernardd/otp,mujiatong/otp,lianghaivv/otp,potatosalad/otp,c-rack/otp,fenollp/otp,uabboli/otp,mikpe/otp,electricimp/otp,emacsmirror/erlang,massemanet/otp,VincentHHL/otp,falkevik/otp,GinjaNinja32/otp,VincentHHL/otp,ader1990/otp,lemenkov/otp,RaimoNiskanen/otp,RichMorin/otp,mikpe/otp,hairyhum/otp,lhslll/otp,msantos/otp,bjorng/otp,gjaldon/otp,neeraj9/otp,vinoski/otp,paladim/otp,c-rack/otp,lemenkov/otp,RoadRunnr/otp,entropiae/otp,derek121/otp,mikpe/otp,sitexa/otp,haguenau/otp,tuncer/otp,erlang/otp,lemenkov/otp,bjorng/otp,theom/otp,aboroska/otp,Teino1978-Corp/otp,jj1bdx/otp,getong/otp,awetzel/otp,emacsmirror/erlang,sdebnath/otp,lianghaivv/otp,lianghaivv/otp,RJ/otp,Teino1978-Corp/erlang-otp,getong/otp,weisslj/otp,kvakvs/otp,electricimp/otp,tuncer/otp,theom/otp,bugs-erlang-org/otp,goertzenator/otp,neeraj9/otp,hairyhum/otp,derek121/otp,VincentHHL/otp,c-rack/otp,emacsmirror/erlang,lrascao/otp,lianghaivv/otp,psyeugenic/otp,psyeugenic/otp,bernardd/otp,lightcyphers/otp,bugs-erlang-org/otp,release-project/otp,vinoski/otp,tuncer/otp,mujiatong/otp,uabboli/otp,Teino1978-Corp/erlang-otp,RoadRunnr/otp,RoadRunnr/otp,johanclaesson/otp,ahmedshafeeq/otp,tuncer/otp,awetzel/otp,saleyn/otp,potatosalad/otp,awetzel/otp,potatosalad/otp,gjaldon/otp,lucafavatella/otp,g-andrade/otp,RaimoNiskanen/otp,bsmr-erlang/otp,bsmr-erlang/otp,bjorng/otp,RaimoNiskanen/otp,kvakvs/otp,johanclaesson/otp,enikki/otp,goertzenator/otp,getong/otp,electricimp/otp,lhslll/otp,legoscia/otp,stolen/otp,Teino1978-Corp/erlang-otp,vic/otp,RichMorin/otp,rlipscombe/otp,mujiatong/otp,RJ/otp,isvilen/otp,NOMORECOFFEE/otp,jemsbhai/otp,uabboli/otp,RGafiyatullin/otp,lemenkov/otp,vladdu/otp,weisslj/otp,matwey/otp,aboroska/otp,rlipscombe/otp,cnbin/otp,marquisthunder/otp,mujiatong/otp,c-rack/otp,vinoski/otp,entropiae/otp,legoscia/otp,enikki/otp,derek121/otp,cobusc/otp,uabboli/otp,emile/otp,palas/otp,klarna/otp,vinoski/otp,lucafavatella/otp,lhslll/otp,vladdu/otp,johanclaesson/otp,vladdu/otp,getong/otp,johanclaesson/otp,enikki/otp,jamesruan/otp,stolen/otp,vic/otp,jj1bdx/otp,msantos/otp,ahmedshafeeq/otp,theom/otp,derek121/otp,massemanet/otp,potatosalad/otp,RaimoNiskanen/otp,lhslll/otp,schlagert/otp,ader1990/otp,mujiatong/otp,legoscia/otp,johanclaesson/otp,entropiae/otp,palas/otp,paladim/otp,ahmedshafeeq/otp,msantos/otp,saleyn/otp,klarna/otp,hairyhum/otp,vladdu/otp,kvakvs/otp,RGafiyatullin/otp,jamesruan/otp,jamesruan/otp,NOMORECOFFEE/otp,uabboli/otp,lrascao/otp,c-rack/otp,GinjaNinja32/otp,sitexa/otp,theom/otp,awetzel/otp,tuncer/otp,weisslj/otp,beni55/otp,lucafavatella/otp,paladim/otp,paulcager/otp,uabboli/otp,electricimp/otp,erlang/otp,awetzel/otp,g-andrade/otp,schlagert/otp,cnbin/otp,yangchengjian/otp,paulcager/otp,emile/otp,isvilen/otp,lemenkov/otp,saleyn/otp,isvilen/otp,lianghaivv/otp,sdebnath/otp,lucafavatella/otp,psyeugenic/otp,dgud/otp,entropiae/otp,fenollp/otp,klarna/otp,basho/otp,neeraj9/otp,sitexa/otp,aboroska/otp,hairyhum/otp,RoadRunnr/otp,vic/otp,lightcyphers/otp,rlipscombe/otp,sdebnath/otp,stolen/otp,mikpe/otp,kvakvs/otp,neeraj9/otp,massemanet/otp,GinjaNinja32/otp,lucafavatella/otp,Teino1978-Corp/otp,yangchengjian/otp,fenollp/otp,g-andrade/otp,schlagert/otp,beni55/otp,Teino1978-Corp/erlang-otp,palas/otp,neeraj9/otp,RJ/otp,vladdu/otp,kvakvs/otp,beni55/otp,RichMorin/otp,klarna/otp,erlang/otp,entropiae/otp,fenollp/otp,legoscia/otp,dumbbell/otp,mikpe/otp,goertzenator/otp,weisslj/otp,lantti/otp,theom/otp,gjaldon/otp,palas/otp,benoitc/otp-1,electricimp/otp,awetzel/otp,riverrun/otp,paladim/otp,rlipscombe/otp,theom/otp,aboroska/otp,dumbbell/otp,weisslj/otp,vic/otp,lhslll/otp,haguenau/otp,electricimp/otp,RJ/otp,mujiatong/otp,erlang/otp,RoadRunnr/otp,weisslj/otp,cobusc/otp,haguenau/otp,vic/otp,release-project/otp,saleyn/otp,jinshana/otp,dgud/otp,release-project/otp,palas/otp,lucafavatella/otp,lightcyphers/otp,Teino1978-Corp/erlang-otp,tuncer/otp,isvilen/otp,beni55/otp,emile/otp,emile/otp,vic/otp,erlang/otp,lrascao/otp,bernardd/otp,RoadRunnr/otp,GinjaNinja32/otp,potatosalad/otp,RoadRunnr/otp,potatosalad/otp,jinshana/otp,paulcager/otp,riverrun/otp,falkevik/otp,ferd/otp,sdebnath/otp,psyeugenic/otp,riverrun/otp,vladdu/otp,release-project/otp,yangchengjian/otp,release-project/otp,sammoth-wazoku/otp,jinshana/otp,fenollp/otp,erlang/otp,stolen/otp,vic/otp,getong/otp,johanclaesson/otp,krishnakumar4a4/otp,sammoth-wazoku/otp,getong/otp,bjorng/otp,mujiatong/otp,emacsmirror/erlang,klarna/otp,ahmedshafeeq/otp,cobusc/otp,jj1bdx/otp,getong/otp,RoadRunnr/otp,goertzenator/otp,emile/otp,sitexa/otp,gjaldon/otp,massemanet/otp,lightcyphers/otp,lhslll/otp,g-andrade/otp,fenollp/otp,dgud/otp,lantti/otp,lantti/otp,aboroska/otp,platinumthinker/otp,benoitc/otp-1,aboroska/otp,vic/otp,benoitc/otp-1,emile/otp,haguenau/otp,saleyn/otp,sdebnath/otp,paladim/otp,isvilen/otp,RGafiyatullin/otp,saleyn/otp,paladim/otp,marquisthunder/otp,RichMorin/otp,jj1bdx/otp,lrascao/otp,dumbbell/otp,basho/otp,ahmedshafeeq/otp,rlipscombe/otp,release-project/otp,ader1990/otp,theom/otp,psyeugenic/otp,potatosalad/otp,bsmr-erlang/otp,bsmr-erlang/otp,bernardd/otp,gjaldon/otp,fenollp/otp,jinshana/otp,goertzenator/otp,matwey/otp,lantti/otp,massemanet/otp,bjorng/otp,RJ/otp,cnbin/otp,release-project/otp,release-project/otp,falkevik/otp,johanclaesson/otp,beni55/otp,RJ/otp,emile/otp,derek121/otp,bugs-erlang-org/otp,fenollp/otp,NOMORECOFFEE/otp,GinjaNinja32/otp,awetzel/otp,schlagert/otp,Teino1978-Corp/otp,gjaldon/otp,schlagert/otp,rlipscombe/otp,Teino1978-Corp/erlang-otp,vladdu/otp,lrascao/otp,stolen/otp,lrascao/otp,bernardd/otp,g-andrade/otp,dgud/otp,basho/otp,g-andrade/otp,platinumthinker/otp,jemsbhai/otp,ahmedshafeeq/otp,bernardd/otp,aboroska/otp,matwey/otp,sitexa/otp,jinshana/otp,jinshana/otp,platinumthinker/otp,RJ/otp,bjorng/otp,cnbin/otp,lemenkov/otp,platinumthinker/otp,bernardd/otp,jinshana/otp,ader1990/otp,legoscia/otp,stolen/otp,release-project/otp,yangchengjian/otp,mikpe/otp,haguenau/otp,mujiatong/otp,emacsmirror/erlang,GinjaNinja32/otp,fenollp/otp,neeraj9/otp,klarna/otp,bsmr-erlang/otp,krishnakumar4a4/otp,emacsmirror/erlang,bsmr-erlang/otp,tuncer/otp,goertzenator/otp,ferd/otp,saleyn/otp,VincentHHL/otp,matwey/otp,sitexa/otp,yangchengjian/otp,dumbbell/otp,marquisthunder/otp,jemsbhai/otp,lantti/otp,RichMorin/otp,cobusc/otp,marquisthunder/otp,sammoth-wazoku/otp,cnbin/otp,g-andrade/otp,riverrun/otp,basho/otp,bjorng/otp,isvilen/otp,enikki/otp,lrascao/otp,emacsmirror/erlang,emacsmirror/erlang,gjaldon/otp,jinshana/otp,lantti/otp,benoitc/otp-1,potatosalad/otp,jemsbhai/otp,rlipscombe/otp,g-andrade/otp,RGafiyatullin/otp,entropiae/otp,platinumthinker/otp,lightcyphers/otp,erlang/otp,derek121/otp,GinjaNinja32/otp,g-andrade/otp,matwey/otp,massemanet/otp,marquisthunder/otp,rlipscombe/otp,benoitc/otp-1,dumbbell/otp,jamesruan/otp,jamesruan/otp,RaimoNiskanen/otp,msantos/otp,jj1bdx/otp,vinoski/otp,basho/otp,VincentHHL/otp,kvakvs/otp,jj1bdx/otp,lightcyphers/otp,isvilen/otp,RGafiyatullin/otp,sdebnath/otp,lhslll/otp,psyeugenic/otp,massemanet/otp,haguenau/otp,vinoski/otp,basho/otp,cobusc/otp,paulcager/otp,neeraj9/otp,cobusc/otp,riverrun/otp,haguenau/otp,ahmedshafeeq/otp,jamesruan/otp,falkevik/otp,c-rack/otp,beni55/otp,msantos/otp,Teino1978-Corp/erlang-otp,bugs-erlang-org/otp,RichMorin/otp,bernardd/otp,bsmr-erlang/otp,sammoth-wazoku/otp,falkevik/otp,lianghaivv/otp,uabboli/otp,saleyn/otp,krishnakumar4a4/otp,jamesruan/otp,jemsbhai/otp,getong/otp,dgud/otp,entropiae/otp,uabboli/otp,beni55/otp,matwey/otp,bugs-erlang-org/otp,bjorng/otp,krishnakumar4a4/otp,RoadRunnr/otp,sammoth-wazoku/otp,krishnakumar4a4/otp,palas/otp,jj1bdx/otp,msantos/otp,GinjaNinja32/otp,potatosalad/otp,cnbin/otp,cobusc/otp,jj1bdx/otp,vinoski/otp,enikki/otp,falkevik/otp,haguenau/otp,RaimoNiskanen/otp,beni55/otp,lemenkov/otp,riverrun/otp,dumbbell/otp,emile/otp,electricimp/otp,lrascao/otp,ader1990/otp,sitexa/otp,lucafavatella/otp,derek121/otp,weisslj/otp,platinumthinker/otp,ferd/otp,psyeugenic/otp,erlang/otp,RGafiyatullin/otp,johanclaesson/otp,kvakvs/otp,enikki/otp,RaimoNiskanen/otp,Teino1978-Corp/erlang-otp,bjorng/otp,goertzenator/otp,lightcyphers/otp,electricimp/otp,falkevik/otp,uabboli/otp,derek121/otp,krishnakumar4a4/otp,enikki/otp,getong/otp,massemanet/otp,ferd/otp,lucafavatella/otp,legoscia/otp,lianghaivv/otp,bjorng/otp,marquisthunder/otp,weisslj/otp,legoscia/otp,bugs-erlang-org/otp,falkevik/otp,dumbbell/otp,palas/otp,lrascao/otp,isvilen/otp,VincentHHL/otp,mikpe/otp,electricimp/otp,RGafiyatullin/otp,isvilen/otp,bsmr-erlang/otp,ader1990/otp,stolen/otp,benoitc/otp-1,palas/otp,erlang/otp,hairyhum/otp,cobusc/otp,benoitc/otp-1,emacsmirror/erlang,weisslj/otp,klarna/otp,riverrun/otp,Teino1978-Corp/otp,cnbin/otp,NOMORECOFFEE/otp,dumbbell/otp,mikpe/otp,neeraj9/otp,psyeugenic/otp,dgud/otp,paladim/otp,c-rack/otp,vladdu/otp,dgud/otp,RichMorin/otp,RGafiyatullin/otp,saleyn/otp,cnbin/otp,gjaldon/otp,paladim/otp,vladdu/otp,paulcager/otp,ader1990/otp,basho/otp,sammoth-wazoku/otp,awetzel/otp,emacsmirror/erlang,mikpe/otp,krishnakumar4a4/otp,paulcager/otp,lianghaivv/otp,theom/otp,jj1bdx/otp,aboroska/otp,sammoth-wazoku/otp,vinoski/otp,msantos/otp,bugs-erlang-org/otp,jemsbhai/otp,c-rack/otp,isvilen/otp,dgud/otp,g-andrade/otp,sitexa/otp,VincentHHL/otp,emile/otp,platinumthinker/otp,hairyhum/otp,bugs-erlang-org/otp,sdebnath/otp,mikpe/otp,lemenkov/otp,lhslll/otp,ferd/otp,sammoth-wazoku/otp,basho/otp,stolen/otp,Teino1978-Corp/otp,RichMorin/otp,yangchengjian/otp,jj1bdx/otp,sdebnath/otp,vinoski/otp,rlipscombe/otp,bsmr-erlang/otp,falkevik/otp,marquisthunder/otp,vinoski/otp,matwey/otp,benoitc/otp-1,dumbbell/otp,matwey/otp,jemsbhai/otp,ferd/otp,NOMORECOFFEE/otp,hairyhum/otp,ferd/otp,Teino1978-Corp/otp,legoscia/otp,erlang/otp,ahmedshafeeq/otp,dumbbell/otp,getong/otp,riverrun/otp,ferd/otp,paulcager/otp,aboroska/otp,NOMORECOFFEE/otp,ahmedshafeeq/otp,krishnakumar4a4/otp,platinumthinker/otp,RJ/otp,RaimoNiskanen/otp,schlagert/otp,Teino1978-Corp/otp,Teino1978-Corp/otp,jemsbhai/otp,ferd/otp,kvakvs/otp,msantos/otp,tuncer/otp,kvakvs/otp,rlipscombe/otp,enikki/otp,goertzenator/otp,yangchengjian/otp,schlagert/otp,massemanet/otp,dgud/otp,ader1990/otp,NOMORECOFFEE/otp,lightcyphers/otp,goertzenator/otp,marquisthunder/otp,jamesruan/otp,legoscia/otp,basho/otp,yangchengjian/otp,paulcager/otp,klarna/otp,tuncer/otp,NOMORECOFFEE/otp,VincentHHL/otp,dgud/otp,hairyhum/otp,RaimoNiskanen/otp,lantti/otp,entropiae/otp,schlagert/otp,lantti/otp,matwey/otp