diff options
author | Erlang/OTP <[email protected]> | 2010-02-17 15:48:13 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-02-17 15:48:13 +0000 |
commit | 8b39d0582bee5d4071b7ae4c7407d6662c0414a9 (patch) | |
tree | 75b0787b36ae39f477c46e8daadfdf2647b93a1a /lib/hipe/cerl/erl_bif_types.erl | |
parent | edac07ff1e8b49a1ddfd69c712fb2ab3ce37b5ab (diff) | |
parent | abe48c24c115fd629063653eef7bdabd0f82fbbc (diff) | |
download | otp-8b39d0582bee5d4071b7ae4c7407d6662c0414a9.tar.gz otp-8b39d0582bee5d4071b7ae4c7407d6662c0414a9.tar.bz2 otp-8b39d0582bee5d4071b7ae4c7407d6662c0414a9.zip |
Merge branch 'ks/hipe' into ccase/r13b04_dev
* ks/hipe:
dialyzer: Fix system_limit exception in race analysis
syntax_tools: Add types and specs for most exported functions
syntax_tools: Support the --enable-native-libs configure option
syntax_tools: Remove $Id$ annotations
dialyzer: New version for the R13B04 release
hipe: Miscellaneous additions
typer: New version for the R13B04 release
Fix a HiPE compiler bug evaluating an expression that throws system_limit
OTP-8460 ks/hipe
Diffstat (limited to 'lib/hipe/cerl/erl_bif_types.erl')
-rw-r--r-- | lib/hipe/cerl/erl_bif_types.erl | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl index 21e41ef45e..38342870e5 100644 --- a/lib/hipe/cerl/erl_bif_types.erl +++ b/lib/hipe/cerl/erl_bif_types.erl @@ -102,6 +102,7 @@ t_list_elements/1, t_list_termination/1, t_mfa/0, + t_module/0, t_nil/0, t_node/0, t_none/0, @@ -694,6 +695,8 @@ type(erlang, binary_to_list, 3, Xs) -> fun (_) -> t_list(t_byte()) end); type(erlang, binary_to_term, 1, Xs) -> strict(arg_types(erlang, binary_to_term, 1), Xs, fun (_) -> t_any() end); +type(erlang, binary_to_term, 2, Xs) -> + strict(arg_types(erlang, binary_to_term, 2), Xs, fun (_) -> t_any() end); type(erlang, bitsize, 1, Xs) -> % XXX: TAKE OUT type(erlang, bit_size, 1, Xs); type(erlang, bit_size, 1, Xs) -> @@ -3150,21 +3153,26 @@ arith(Op, X1, X2) -> end, %% 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))} + false -> + %% 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. @@ -3356,8 +3364,7 @@ arg_types(erlang, abs, 1) -> arg_types(erlang, append_element, 2) -> [t_tuple(), t_any()]; arg_types(erlang, apply, 2) -> - [t_sup(t_tuple([t_sup(t_atom(), % module name - t_tuple()), % parameterized module + [t_sup(t_tuple([t_module(), t_atom()]), t_fun()), t_list()]; @@ -3377,6 +3384,8 @@ arg_types(erlang, binary_to_list, 3) -> [t_binary(), t_pos_integer(), t_pos_integer()]; % I want fixnum, but cannot arg_types(erlang, binary_to_term, 1) -> [t_binary()]; +arg_types(erlang, binary_to_term, 2) -> + [t_binary(), t_list(t_atom('safe'))]; arg_types(erlang, bitsize, 1) -> % XXX: TAKE OUT arg_types(erlang, bit_size, 1); arg_types(erlang, bit_size, 1) -> @@ -4379,6 +4388,7 @@ structure_inspecting_args(erlang, is_pid, 1) -> [1]; structure_inspecting_args(erlang, is_port, 1) -> [1]; structure_inspecting_args(erlang, is_reference, 1) -> [1]; structure_inspecting_args(erlang, is_tuple, 1) -> [1]; +structure_inspecting_args(erlang, length, 1) -> [1]; %%structure_inspecting_args(erlang, setelement, 3) -> [2]. structure_inspecting_args(_, _, _) -> []. % XXX: assume no arg needs inspection |