Skip to content

Commit

Permalink
Precompile runtime module paths
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Dec 8, 2022
1 parent bca3145 commit 8f86710
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 0 additions & 6 deletions lib/elixir/lib/kernel/parallel_compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,6 @@ defmodule Kernel.ParallelCompiler do
for {{:module, module}, binary} when is_binary(binary) <- result,
do: module

runtime_modules =
for module <- runtime_modules,
path = :code.which(module),
is_list(path) and path != [],
do: {module, path}

profile_checker(profile, compiled_modules, runtime_modules, fn ->
Module.ParallelChecker.verify(checker, runtime_modules)
end)
Expand Down
7 changes: 5 additions & 2 deletions lib/elixir/lib/module/parallel_checker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ defmodule Module.ParallelChecker do
if is_map(info) do
info
else
info |> File.read!() |> maybe_module_map(module)
case File.read(info) do
{:ok, binary} -> maybe_module_map(binary, module)
{:error, _} -> nil
end
end

module_map && cache_from_module_map(ets, module_map)
Expand Down Expand Up @@ -138,7 +141,7 @@ defmodule Module.ParallelChecker do
the modules and adds the ExCk chunk to the binaries. Returns the updated
list of warnings from the verification.
"""
@spec verify(pid(), [{module(), binary()}]) :: [warning()]
@spec verify(pid(), [{module(), Path.t()}]) :: [warning()]
def verify(checker, runtime_files) do
for {module, file} <- runtime_files do
spawn({self(), checker}, module, file)
Expand Down
6 changes: 5 additions & 1 deletion lib/mix/lib/mix/compilers/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,11 @@ defmodule Mix.Compilers.Elixir do
|> Map.from_keys(true)

{_, runtime_modules} = fixpoint_runtime_modules(sources, modules_set)
{{:runtime, runtime_modules, warnings}, state}

runtime_paths =
Enum.map(runtime_modules, &{&1, Path.join(compile_path, Atom.to_string(&1) <> ".beam")})

{{:runtime, runtime_paths, warnings}, state}
else
Mix.Utils.compiling_n(length(changed), :ex)

Expand Down

0 comments on commit 8f86710

Please sign in to comment.