Skip to content

Commit 108f975

Browse files
committed
Remove locals tracker
1 parent 43e2b9d commit 108f975

File tree

5 files changed

+18
-447
lines changed

5 files changed

+18
-447
lines changed

lib/elixir/lib/module/locals_tracker.ex

Lines changed: 0 additions & 258 deletions
This file was deleted.

lib/elixir/src/elixir_compiler.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ bootstrap_files() ->
190190
[
191191
<<"list/chars.ex">>,
192192
<<"bitwise.ex">>,
193-
<<"module/locals_tracker.ex">>,
194193
<<"module/parallel_checker.ex">>,
195194
<<"module/behaviour.ex">>,
196195
<<"module/types/helpers.ex">>,

lib/elixir/src/elixir_locals.erl

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,28 @@
11
%% Module responsible for tracking invocations of module calls.
22
-module(elixir_locals).
33
-export([
4-
setup/1, stop/1, cache_env/1, get_cached_env/1,
5-
record_local/5, record_import/4, record_defaults/5,
6-
yank/2, reattach/6, ensure_no_import_conflict/3,
4+
setup/1, cache_env/1, get_cached_env/1,
5+
record_import/4,
6+
ensure_no_import_conflict/3,
77
format_error/1
88
]).
99

1010
-include("elixir.hrl").
1111
-define(cache_key, {elixir, cache_env}).
12-
-define(locals_key, {elixir, locals}).
13-
-define(locals, 'Elixir.Module.LocalsTracker').
1412

1513
setup({DataSet, _DataBag}) ->
1614
ets:insert(DataSet, {?cache_key, 0}),
17-
18-
case elixir_config:is_bootstrap() of
19-
false -> ets:insert(DataSet, {?locals_key, true});
20-
true -> ok
21-
end,
22-
2315
ok.
2416

25-
stop({DataSet, _DataBag}) ->
26-
ets:delete(DataSet, ?locals_key).
27-
28-
yank(Tuple, Module) ->
29-
if_tracker(Module, fun(Tracker) -> ?locals:yank(Tracker, Tuple) end).
30-
31-
reattach(Tuple, Kind, Module, Function, Neighbours, Meta) ->
32-
if_tracker(Module, fun(Tracker) -> ?locals:reattach(Tracker, Tuple, Kind, Function, Neighbours, Meta) end).
33-
34-
record_local(_Tuple, _Module, nil, _Meta, _IsMacroDispatch) ->
35-
ok;
36-
record_local(Tuple, Module, Function, Meta, IsMacroDispatch) ->
37-
if_tracker(Module, fun(Tracker) -> ?locals:add_local(Tracker, Function, Tuple, Meta, IsMacroDispatch), ok end).
38-
3917
record_import(_Tuple, Receiver, Module, Function)
4018
when Function == nil; Module == Receiver -> false;
41-
record_import(Tuple, Receiver, Module, Function) ->
42-
if_tracker(Module, fun(Tracker) -> ?locals:add_import(Tracker, Function, Receiver, Tuple), ok end).
43-
44-
record_defaults(_Tuple, _Kind, _Module, 0, _Meta) ->
45-
ok;
46-
record_defaults(Tuple, Kind, Module, Defaults, Meta) ->
47-
if_tracker(Module, fun(Tracker) -> ?locals:add_defaults(Tracker, Kind, Tuple, Defaults, Meta), ok end).
48-
49-
if_tracker(Module, Callback) ->
50-
if_tracker(Module, ok, Callback).
51-
52-
if_tracker(Module, Default, Callback) ->
19+
record_import(Tuple, Receiver, Module, _Function) ->
5320
try
54-
{DataSet, _} = Tables = elixir_module:data_tables(Module),
55-
{ets:member(DataSet, ?locals_key), Tables}
56-
of
57-
{true, Tracker} -> Callback(Tracker);
58-
{false, _} -> Default
21+
{Set, _Bag} = elixir_module:data_tables(Module),
22+
ets:insert(Set, {{import, Tuple}, Receiver}),
23+
true
5924
catch
60-
error:badarg -> Default
25+
error:badarg -> false
6126
end.
6227

6328
%% CACHING
@@ -89,13 +54,16 @@ get_cached_env(Env) ->
8954

9055
ensure_no_import_conflict('Elixir.Kernel', _All, _E) ->
9156
ok;
92-
ensure_no_import_conflict(Module, All, E) ->
93-
if_tracker(Module, ok, fun(Tracker) ->
94-
[elixir_errors:module_error(Meta, E, ?MODULE, {function_conflict, Error})
95-
|| {Meta, Error} <- ?locals:collect_imports_conflicts(Tracker, All)],
96-
ok
97-
end).
57+
ensure_no_import_conflict(Module, AllDefinitions, E) ->
58+
{Set, _} = elixir_module:data_tables(Module),
59+
60+
[try
61+
Receiver = ets:lookup_element(Set, {import, Pair}, 2),
62+
elixir_errors:module_error(Meta, E, ?MODULE, {import_conflict, Receiver, Pair})
63+
catch
64+
error:badarg -> false
65+
end || {Pair, _, Meta, _} <- AllDefinitions].
9866

99-
format_error({function_conflict, {Receiver, {Name, Arity}}}) ->
67+
format_error({import_conflict, Receiver, {Name, Arity}}) ->
10068
io_lib:format("imported ~ts.~ts/~B conflicts with local function",
10169
[elixir_aliases:inspect(Receiver), Name, Arity]).

lib/elixir/src/elixir_module.erl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ compile(Meta, Module, ModuleAsCharlist, Block, Vars, Prune, E) ->
148148
validate_nifs_attribute(NifsAttribute, AllDefinitions, Line, E),
149149
elixir_locals:ensure_no_import_conflict(Module, AllDefinitions, E),
150150

151-
%% We stop tracking locals here to avoid race conditions in case after_load
152-
%% evaluates code in a separate process that may write to locals table.
153-
elixir_locals:stop({DataSet, DataBag}),
154151
make_readonly(Module),
155152

156153
(not elixir_config:is_bootstrap()) andalso

0 commit comments

Comments
 (0)