aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/rtl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hipe/rtl')
-rw-r--r--lib/hipe/rtl/hipe_rtl_binary.erl18
-rw-r--r--lib/hipe/rtl/hipe_rtl_primops.erl20
-rw-r--r--lib/hipe/rtl/hipe_tagscheme.erl14
3 files changed, 28 insertions, 24 deletions
diff --git a/lib/hipe/rtl/hipe_rtl_binary.erl b/lib/hipe/rtl/hipe_rtl_binary.erl
index 9b400f4c93..291f920fcf 100644
--- a/lib/hipe/rtl/hipe_rtl_binary.erl
+++ b/lib/hipe/rtl/hipe_rtl_binary.erl
@@ -106,10 +106,20 @@ create_lbls(0) ->
%%------------------------------------------------------------------------------
get_word_integer(Var, Register, SystemLimitLblName, FalseLblName) ->
- [EndLbl] = create_lbls(1),
- EndName = hipe_rtl:label_name(EndLbl),
- get_word_integer(Var, Register,SystemLimitLblName, FalseLblName, EndName, EndName,
- [EndLbl]).
+ case hipe_rtl:is_imm(Var) of
+ true ->
+ TaggedVal = hipe_rtl:imm_value(Var),
+ true = hipe_tagscheme:is_fixnum(TaggedVal),
+ Val = hipe_tagscheme:fixnum_val(TaggedVal),
+ if Val < 0 -> [hipe_rtl:mk_goto(FalseLblName)];
+ true -> [hipe_rtl:mk_move(Register, hipe_rtl:mk_imm(Val))]
+ end;
+ false ->
+ [EndLbl] = create_lbls(1),
+ EndName = hipe_rtl:label_name(EndLbl),
+ get_word_integer(Var, Register,SystemLimitLblName, FalseLblName,
+ EndName, EndName, [EndLbl])
+ end.
get_word_integer(Var, Register, SystemLimitLblName, FalseLblName, TrueLblName,
BigLblName, Tail) ->
diff --git a/lib/hipe/rtl/hipe_rtl_primops.erl b/lib/hipe/rtl/hipe_rtl_primops.erl
index 062fab842f..154c2a8c57 100644
--- a/lib/hipe/rtl/hipe_rtl_primops.erl
+++ b/lib/hipe/rtl/hipe_rtl_primops.erl
@@ -760,12 +760,9 @@ gen_fun_thing_skeleton(FunP, FunName={_Mod,_FunId,Arity}, NumFree,
%% And creates a fe (at load time).
FeVar = hipe_rtl:mk_new_reg(),
PidVar = hipe_rtl:mk_new_reg_gcsafe(),
- NativeVar = hipe_rtl:mk_new_reg(),
[hipe_rtl:mk_load_address(FeVar, {FunName, MagicNr, Index}, closure),
store_struct_field(FunP, ?EFT_FE, FeVar),
- load_struct_field(NativeVar, FeVar, ?EFE_NATIVE_ADDRESS),
- store_struct_field(FunP, ?EFT_NATIVE_ADDRESS, NativeVar),
store_struct_field(FunP, ?EFT_ARITY, hipe_rtl:mk_imm(Arity-NumFree)),
@@ -845,7 +842,7 @@ gen_free_vars([], _, _, _, AccCode) -> AccCode.
%% call_fun (also handles enter_fun when Continuation = [])
gen_call_fun(Dst, ArgsAndFun, Continuation, Fail) ->
- NAddressReg = hipe_rtl:mk_new_reg(),
+ NCNAddressReg = hipe_rtl:mk_new_reg(),
ArityReg = hipe_rtl:mk_new_reg_gcsafe(),
[Fun|RevArgs] = lists:reverse(ArgsAndFun),
@@ -856,7 +853,7 @@ gen_call_fun(Dst, ArgsAndFun, Continuation, Fail) ->
BadFunLabName = hipe_rtl:label_name(NonClosureLabel),
BadFunCode =
[NonClosureLabel,
- hipe_rtl:mk_call([NAddressReg],
+ hipe_rtl:mk_call([NCNAddressReg],
'nonclosure_address',
[Fun, hipe_rtl:mk_imm(length(Args))],
hipe_rtl:label_name(CallNonClosureLabel),
@@ -865,25 +862,26 @@ gen_call_fun(Dst, ArgsAndFun, Continuation, Fail) ->
CallNonClosureLabel,
case Continuation of
[] ->
- hipe_rtl:mk_enter(NAddressReg, Args, not_remote);
+ hipe_rtl:mk_enter(NCNAddressReg, Args, not_remote);
_ ->
- hipe_rtl:mk_call(Dst, NAddressReg, Args,
+ hipe_rtl:mk_call(Dst, NCNAddressReg, Args,
Continuation, Fail, not_remote)
end],
{BadArityLabName, BadArityCode} = gen_fail_code(Fail, {badarity, Fun}),
- CheckGetCode =
- hipe_tagscheme:if_fun_get_arity_and_address(ArityReg, NAddressReg,
+ CNAddressReg = hipe_rtl:mk_new_reg(),
+ CheckGetCode =
+ hipe_tagscheme:if_fun_get_arity_and_address(ArityReg, CNAddressReg,
Fun, BadFunLabName,
0.9),
CheckArityCode = check_arity(ArityReg, length(RevArgs), BadArityLabName),
CallCode =
case Continuation of
[] -> %% This is a tailcall
- [hipe_rtl:mk_enter(NAddressReg, ArgsAndFun, not_remote)];
+ [hipe_rtl:mk_enter(CNAddressReg, ArgsAndFun, not_remote)];
_ -> %% Ordinary call
- [hipe_rtl:mk_call(Dst, NAddressReg, ArgsAndFun,
+ [hipe_rtl:mk_call(Dst, CNAddressReg, ArgsAndFun,
Continuation, Fail, not_remote)]
end,
[CheckGetCode, CheckArityCode, CallCode, BadFunCode, BadArityCode].
diff --git a/lib/hipe/rtl/hipe_tagscheme.erl b/lib/hipe/rtl/hipe_tagscheme.erl
index 8825a3ade3..8cf45772b5 100644
--- a/lib/hipe/rtl/hipe_tagscheme.erl
+++ b/lib/hipe/rtl/hipe_tagscheme.erl
@@ -68,9 +68,7 @@
-include("hipe_rtl.hrl").
-include("hipe_literals.hrl").
--ifdef(EFT_NATIVE_ADDRESS).
-export([if_fun_get_arity_and_address/5]).
--endif.
-undef(TAG_PRIMARY_BOXED).
-undef(TAG_IMMED2_MASK).
@@ -282,7 +280,6 @@ test_ref(X, TrueLab, FalseLab, Pred) ->
TrueLab, FalseLab, Pred)
].
--ifdef(EFT_NATIVE_ADDRESS).
test_closure(X, TrueLab, FalseLab, Pred) ->
Tmp = hipe_rtl:mk_new_reg_gcsafe(),
HalfTrueLab = hipe_rtl:mk_new_label(),
@@ -291,7 +288,6 @@ test_closure(X, TrueLab, FalseLab, Pred) ->
get_header(Tmp, X),
mask_and_compare(Tmp, ?TAG_HEADER_MASK, ?TAG_HEADER_FUN,
TrueLab, FalseLab, Pred)].
--endif.
test_fun(X, TrueLab, FalseLab, Pred) ->
Hdr = hipe_rtl:mk_new_reg_gcsafe(),
@@ -781,10 +777,9 @@ tag_fun(Res, X) ->
%% untag_fun(Res, X) ->
%% hipe_rtl:mk_alu(Res, X, 'sub', hipe_rtl:mk_imm(?TAG_PRIMARY_BOXED)).
--ifdef(EFT_NATIVE_ADDRESS).
if_fun_get_arity_and_address(ArityReg, AddressReg, FunP, BadFunLab, Pred) ->
%% EmuAddressPtrReg = hipe_rtl:mk_new_reg(),
- %% FEPtrReg = hipe_rtl:mk_new_reg(),
+ FEPtrReg = hipe_rtl:mk_new_reg(),
%% ArityReg = hipe_rtl:mk_new_reg(),
%% NumFreeReg = hipe_rtl:mk_new_reg(),
%% RealArityReg = hipe_rtl:mk_new_reg(),
@@ -797,11 +792,12 @@ if_fun_get_arity_and_address(ArityReg, AddressReg, FunP, BadFunLab, Pred) ->
hipe_rtl:mk_load(ArityReg, FunP,
hipe_rtl:mk_imm(-(?TAG_PRIMARY_BOXED)+
?EFT_ARITY)),
- hipe_rtl:mk_load(AddressReg, FunP,
+ hipe_rtl:mk_load(FEPtrReg, FunP,
hipe_rtl:mk_imm(-(?TAG_PRIMARY_BOXED)+
- ?EFT_NATIVE_ADDRESS))],
+ ?EFT_FE)),
+ hipe_rtl:mk_load(AddressReg, FEPtrReg,
+ hipe_rtl:mk_imm(?EFE_NATIVE_ADDRESS))],
IsFunCode ++ GetArityCode.
--endif.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%