diff options
author | Björn-Egil Dahlberg <[email protected]> | 2015-05-14 13:10:55 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2015-05-21 15:44:01 +0200 |
commit | ecb596c47674045c29890074269e25eb753a3b69 (patch) | |
tree | 45cce421437f9f0ad738850d1239a05f2a830dbc | |
parent | 75f6480ba7ee4d22a1a882420e50a588cbe2a43b (diff) | |
download | otp-ecb596c47674045c29890074269e25eb753a3b69.tar.gz otp-ecb596c47674045c29890074269e25eb753a3b69.tar.bz2 otp-ecb596c47674045c29890074269e25eb753a3b69.zip |
v3_life: Refactor variable db
-rw-r--r-- | lib/compiler/src/v3_life.erl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/compiler/src/v3_life.erl b/lib/compiler/src/v3_life.erl index 4b1f1c3f71..ee0565efb6 100644 --- a/lib/compiler/src/v3_life.erl +++ b/lib/compiler/src/v3_life.erl @@ -411,7 +411,7 @@ is_gc_bif(Bif, Arity) -> %% must be sorted. init_vars(Vs) -> - sort([{V,0,0} || {var,V} <- Vs]). + vdb_new(Vs). new_vars([], _, Vdb) -> Vdb; new_vars([V], I, Vdb) -> vdb_store_new(V, {V,I,I}, Vdb); @@ -430,6 +430,16 @@ use_vars(Vs, I, Vdb) -> vdb_update_vars(Vs, Vdb, I). add_var(V, F, L, Vdb) -> vdb_store_new(V, {V,F,L}, Vdb). +%% is_in_guard() -> true|false. + +is_in_guard() -> + get(guard_refc) > 0. + +%% vdb + +vdb_new(Vs) -> + sort([{V,0,0} || {var,V} <- Vs]). + vdb_find(V, Vdb) -> case lists:keyfind(V, 1, Vdb) of false -> error; @@ -471,8 +481,3 @@ vdb_sub(Min, Max, Vdb) -> [ if L >= Max -> {V,F,locked}; true -> Vd end || {V,F,L}=Vd <- Vdb, F < Min, L >= Min ]. - -%% is_in_guard() -> true|false. - -is_in_guard() -> - get(guard_refc) > 0. |