Skip to content

Commit cc5837c

Browse files
committed
Pass signatures on the side instead of module map
1 parent 1738ed4 commit cc5837c

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

lib/elixir/lib/module/parallel_checker.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ defmodule Module.ParallelChecker do
6363
@doc """
6464
Spawns a process that runs the parallel checker.
6565
"""
66-
def spawn({pid, {checker, table}}, module, module_map, beam_location, log?) do
66+
def spawn({pid, {checker, table}}, module, module_map, signatures, beam_location, log?) do
6767
# Protocols may have been consolidated. So if we know their beam location,
6868
# we discard their module map on purpose and start from file.
6969
info =
7070
if beam_location != [] and Keyword.has_key?(module_map.attributes, :__protocol__) do
7171
List.to_string(beam_location)
7272
else
73-
cache_from_module_map(table, module_map)
73+
cache_from_module_map(table, module_map, signatures)
7474
end
7575

7676
inner_spawn(pid, checker, table, module, info, log?)
@@ -477,12 +477,12 @@ defmodule Module.ParallelChecker do
477477
if Keyword.has_key?(attributes, :__protocol__), do: :protocol, else: :elixir
478478
end
479479

480-
defp cache_from_module_map(table, map) do
480+
defp cache_from_module_map(table, map, signatures) do
481481
exports =
482482
behaviour_exports(map) ++
483483
for({function, :def, _meta, _clauses} <- map.definitions, do: function)
484484

485-
cache_info(table, map.module, exports, Map.new(map.deprecated), map.signatures)
485+
cache_info(table, map.module, exports, Map.new(map.deprecated), signatures)
486486
{elixir_mode(map.attributes), module_map_to_module_tuple(map)}
487487
end
488488

lib/elixir/src/elixir_erl.erl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
%% Compiler backend to Erlang.
66

77
-module(elixir_erl).
8-
-export([elixir_to_erl/1, elixir_to_erl/2, definition_to_anonymous/5, compile/1, consolidate/4,
8+
-export([elixir_to_erl/1, elixir_to_erl/2, definition_to_anonymous/5, compile/2, consolidate/4,
99
get_ann/1, debug_info/4, scope/2, checker_version/0, format_error/1]).
1010
-include("elixir.hrl").
1111
-define(typespecs, 'Elixir.Kernel.Typespec').
@@ -142,7 +142,7 @@ consolidate(Map, Checker, TypeSpecs, DocsChunk) ->
142142

143143
%% Dynamic compilation hook, used in regular compiler
144144

145-
compile(#{module := Module, anno := Anno} = BaseMap) ->
145+
compile(#{module := Module, anno := Anno} = BaseMap, Signatures) ->
146146
Map =
147147
case elixir_erl_compiler:env_compiler_options() of
148148
[] -> BaseMap;
@@ -164,7 +164,7 @@ compile(#{module := Module, anno := Anno} = BaseMap) ->
164164

165165
ChunkOpts = chunk_opts(Map),
166166
DocsChunk = docs_chunk(Map, Set, Module, Anno, Def, Defmacro, Types, Callbacks, ChunkOpts),
167-
CheckerChunk = checker_chunk(Map, Def, ChunkOpts),
167+
CheckerChunk = checker_chunk(Map, Def, Signatures, ChunkOpts),
168168
load_form(Map, Prefix, Forms, TypeSpecs, DocsChunk ++ CheckerChunk).
169169

170170
chunk_opts(Map) ->
@@ -519,10 +519,8 @@ load_form(#{file := File, compile_opts := Opts} = Map, Prefix, Forms, Specs, Chu
519519
Binary.
520520

521521
debug_opts(Map, Specs, Opts) ->
522-
%% Signatures are moved to ExCk, no need to duplicate in chunks
523-
Keys = [signatures],
524522
case take_debug_opts(Opts) of
525-
{true, Rest} -> [{debug_info, {?MODULE, {elixir_v1, maps:without(Keys, Map), Specs}}} | Rest];
523+
{true, Rest} -> [{debug_info, {?MODULE, {elixir_v1, Map, Specs}}} | Rest];
526524
{false, Rest} -> [{debug_info, {?MODULE, none}} | Rest]
527525
end.
528526

@@ -649,9 +647,8 @@ checker_chunk(nil, _ChunkOpts) ->
649647
checker_chunk(Contents, ChunkOpts) ->
650648
[{<<"ExCk">>, term_to_binary({checker_version(), Contents}, ChunkOpts)}].
651649

652-
checker_chunk(Map, Def, ChunkOpts) ->
653-
#{deprecated := Deprecated, defines_behaviour := DefinesBehaviour,
654-
signatures := Signatures, attributes := Attributes} = Map,
650+
checker_chunk(Map, Def, Signatures, ChunkOpts) ->
651+
#{deprecated := Deprecated, defines_behaviour := DefinesBehaviour, attributes := Attributes} = Map,
655652
DeprecatedMap = maps:from_list(Deprecated),
656653

657654
Exports =

lib/elixir/src/elixir_module.erl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,13 @@ compile(Meta, Module, ModuleAsCharlist, Block, Vars, Prune, E) ->
219219
deprecated => get_deprecated(DataBag),
220220
defines_behaviour => defines_behaviour(DataBag),
221221
impls => Impls,
222-
unreachable => Unreachable,
223-
signatures => Signatures
222+
unreachable => Unreachable
224223
},
225224

226225
compile_error_if_tainted(DataSet, E),
227-
Binary = elixir_erl:compile(ModuleMap),
226+
Binary = elixir_erl:compile(ModuleMap, Signatures),
228227
Autoload = Forceload or proplists:get_value(autoload, CompileOpts, false),
229-
spawn_parallel_checker(CheckerInfo, Module, ModuleMap, BeamLocation),
228+
spawn_parallel_checker(CheckerInfo, Module, ModuleMap, Signatures, BeamLocation),
230229
{Binary, PersistedAttributes, Autoload}
231230
end),
232231

@@ -581,15 +580,15 @@ checker_info() ->
581580
_ -> 'Elixir.Module.ParallelChecker':get()
582581
end.
583582

584-
spawn_parallel_checker({_, nil}, _Module, _ModuleMap, _BeamLocation) ->
583+
spawn_parallel_checker({_, nil}, _Module, _ModuleMap, _Signatures, _BeamLocation) ->
585584
ok;
586-
spawn_parallel_checker(CheckerInfo, Module, ModuleMap, BeamLocation) ->
585+
spawn_parallel_checker(CheckerInfo, Module, ModuleMap, Signatures, BeamLocation) ->
587586
Log =
588587
case erlang:get(elixir_code_diagnostics) of
589588
{_, false} -> false;
590589
_ -> true
591590
end,
592-
'Elixir.Module.ParallelChecker':spawn(CheckerInfo, Module, ModuleMap, BeamLocation, Log).
591+
'Elixir.Module.ParallelChecker':spawn(CheckerInfo, Module, ModuleMap, Signatures, BeamLocation, Log).
593592

594593
make_module_available(Module, Binary, Loaded) ->
595594
case get(elixir_module_binaries) of

0 commit comments

Comments
 (0)