Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
2171-beam_ssa_type-Infer-exception-variable-typ...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2171-beam_ssa_type-Infer-exception-variable-types-Class-R.patch of Package erlang
From d066b079890a3a195d470f7a7cb81fb04d7c4ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Wed, 30 Sep 2020 13:58:15 +0200 Subject: [PATCH 1/2] beam_ssa_type: Infer exception variable types (Class:Reason:Stack) --- lib/compiler/src/beam_ssa_type.erl | 12 ++++++++++++ lib/compiler/src/beam_validator.erl | 23 ++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl index d40e7f3fc0..1e4c9ba5a0 100644 --- a/lib/compiler/src/beam_ssa_type.erl +++ b/lib/compiler/src/beam_ssa_type.erl @@ -1671,6 +1671,18 @@ type(call, [#b_literal{val=Fun} | Args], _Anno, _Ts, _Ds) -> %% arguments is wrong. none end; +type(extract, [V, #b_literal{val=Idx}], _Anno, _Ts, Ds) -> + case map_get(V, Ds) of + #b_set{op=landingpad} when Idx =:= 0 -> + %% Class + #t_atom{elements=[error,exit,throw]}; + #b_set{op=landingpad} when Idx =:= 1 -> + %% Reason + any; + #b_set{op=landingpad} when Idx =:= 2 -> + %% Stack trace + any + end; type(get_hd, [Src], _Anno, Ts, _Ds) -> SrcType = #t_cons{} = normalized_type(Src, Ts), %Assertion. {RetType, _, _} = beam_call_types:types(erlang, hd, [SrcType]), diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index d4bd97bae0..70f3581754 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -777,14 +777,22 @@ vi({try_case,Reg}, #vst{current=#st{ct=[Tag|_]}}=Vst0) -> Vst2 = schedule_out(0, Vst1), %% Class:Error:Stacktrace - Vst3 = create_term(#t_atom{}, try_case, [], {x,0}, Vst2), + ClassType = #t_atom{elements=[error,exit,throw]}, + Vst3 = create_term(ClassType, try_case, [], {x,0}, Vst2), Vst = create_term(any, try_case, [], {x,1}, Vst3), create_term(any, try_case, [], {x,2}, Vst); Type -> error({wrong_tag_type,Type}) end; -vi(build_stacktrace=I, Vst) -> - validate_body_call(I, 1, Vst); +vi(build_stacktrace, Vst0) -> + verify_y_init(Vst0), + verify_live(1, Vst0), + + Vst = prune_x_regs(1, Vst0), + Reg = {x,0}, + + assert_durable_term(Reg, Vst), + create_term(#t_list{}, build_stacktrace, [], Reg, Vst); %% %% Map instructions. @@ -980,10 +989,8 @@ vi(if_end, Vst) -> vi({try_case_end,Src}, Vst) -> assert_durable_term(Src, Vst), branch(?EXCEPTION_LABEL, Vst, fun kill_state/1); -vi(raw_raise=I, Vst) -> - branch(?EXCEPTION_LABEL, Vst, - fun(FailVst) -> validate_body_call(I, 3, FailVst) end, - fun kill_state/1); +vi(raw_raise=I, Vst0) -> + validate_body_call(I, 3, Vst0); %% %% Binary construction @@ -2960,6 +2967,8 @@ will_call_succeed({extfunc,M,F,A}, Vst) -> beam_call_types:will_succeed(M, F, get_call_args(A, Vst)); will_call_succeed(bs_init_writable, _Vst) -> yes; +will_call_succeed(raw_raise, _Vst) -> + no; will_call_succeed({f,Lbl}, #vst{ft=Ft}) -> case Ft of #{Lbl := #{always_fails := true}} -> -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor