aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKostis Sagonas <[email protected]>2010-01-26 17:38:55 +0200
committerBjörn Gustavsson <[email protected]>2010-02-14 12:23:03 +0100
commit63c13786ec04bba57acaea6dee1f2fbc77c7b5e1 (patch)
tree4e7dacfc05f5286a187cb851e840083a83fafa99 /lib
parent9a8bcc769b6e2bda63b8337e631d2d2f408f0dd8 (diff)
downloadotp-63c13786ec04bba57acaea6dee1f2fbc77c7b5e1.tar.gz
otp-63c13786ec04bba57acaea6dee1f2fbc77c7b5e1.tar.bz2
otp-63c13786ec04bba57acaea6dee1f2fbc77c7b5e1.zip
Fix a HiPE compiler bug evaluating an expression that throws system_limit
Diffstat (limited to 'lib')
-rw-r--r--lib/hipe/cerl/erl_bif_types.erl33
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl
index 756fcb8bbf..8aa2cc76c7 100644
--- a/lib/hipe/cerl/erl_bif_types.erl
+++ b/lib/hipe/cerl/erl_bif_types.erl
@@ -3128,20 +3128,25 @@ arith(Op, X1, X2) ->
%% io:format("done arith ~p = ~p~n", [Op, {NewMin, NewMax}]),
{ok, t_from_range(NewMin, NewMax)};
false ->
- AllVals =
- case Op of
- '+' -> [X + Y || X <- L1, Y <- L2];
- '-' -> [X - Y || X <- L1, Y <- L2];
- '*' -> [X * Y || X <- L1, Y <- L2];
- 'div' -> [X div Y || X <- L1, Y <- L2,Y =/= 0];
- 'rem' -> [X rem Y || X <- L1, Y <- L2,Y =/= 0];
- 'bsl' -> [X bsl Y || X <- L1, Y <- L2];
- 'bsr' -> [X bsr Y || X <- L1, Y <- L2];
- 'band' -> [X band Y || X <- L1, Y <- L2];
- 'bor' -> [X bor Y || X <- L1, Y <- L2];
- 'bxor' -> [X bxor Y || X <- L1, Y <- L2]
- end,
- {ok, t_integers(ordsets:from_list(AllVals))}
+ %% Some of these arithmetic operations might throw a system_limit
+ %% exception; for example, when trying to evaluate 1 bsl 100000000.
+ try case Op of
+ '+' -> [X + Y || X <- L1, Y <- L2];
+ '-' -> [X - Y || X <- L1, Y <- L2];
+ '*' -> [X * Y || X <- L1, Y <- L2];
+ 'div' -> [X div Y || X <- L1, Y <- L2,Y =/= 0];
+ 'rem' -> [X rem Y || X <- L1, Y <- L2,Y =/= 0];
+ 'bsl' -> [X bsl Y || X <- L1, Y <- L2];
+ 'bsr' -> [X bsr Y || X <- L1, Y <- L2];
+ 'band' -> [X band Y || X <- L1, Y <- L2];
+ 'bor' -> [X bor Y || X <- L1, Y <- L2];
+ 'bxor' -> [X bxor Y || X <- L1, Y <- L2]
+ end of
+ AllVals ->
+ {ok, t_integers(ordsets:from_list(AllVals))}
+ catch
+ error:system_limit -> error
+ end
end
end.