diff options
| author | José Valim <jose.valim@plataformatec.com.br> | 2018-05-08 16:29:23 +0200 |
|---|---|---|
| committer | José Valim <jose.valim@plataformatec.com.br> | 2018-05-08 16:34:45 +0200 |
| commit | 40d04a629b12d49b251aeae23dd75d47c6ff8412 (patch) | |
| tree | 2c5c7290e6b3b4715d2ac9587b5fb8574a905bb7 | |
| parent | 96164cfc13549c10eca2fe09c7aaa1e98e88bc7c (diff) | |
| download | elixir-jv-no-19.tar.gz | |
Bypass Erlang linter and expansions for performancejv-no-19
Since a lot of the linting logic was already duplicated
in both Erlang and Elixir, we have moved the remaining of
the logic to Elixir, yileding roughly 5% gain on compilation
performance.
| -rw-r--r-- | lib/elixir/src/elixir_erl.erl | 5 | ||||
| -rw-r--r-- | lib/elixir/src/elixir_erl_compiler.erl | 11 | ||||
| -rw-r--r-- | lib/elixir/src/elixir_module.erl | 4 |
3 files changed, 14 insertions, 6 deletions
diff --git a/lib/elixir/src/elixir_erl.erl b/lib/elixir/src/elixir_erl.erl index c70609e4e..ddc5a813e 100644 --- a/lib/elixir/src/elixir_erl.erl +++ b/lib/elixir/src/elixir_erl.erl @@ -16,10 +16,13 @@ debug_info(erlang_v1, _Module, {elixir_v1, Map, Specs}, _Opts) -> debug_info(core_v1, _Module, {elixir_v1, Map, Specs}, Opts) -> {Prefix, Forms, _, _, _, _} = dynamic_form(Map), #{compile_opts := CompileOpts} = Map, + AllOpts = CompileOpts ++ Opts, %% Do not rely on elixir_erl_compiler because we don't %% warnings nor the other functionality provided there. - try compile:noenv_forms(Prefix ++ Specs ++ Forms, [core, return | CompileOpts] ++ Opts) of + {ok, CoreForms, _} = elixir_erl_compiler:erl_to_core(Prefix ++ Specs ++ Forms, AllOpts), + + try compile:noenv_forms(CoreForms, [from_core, core, return | AllOpts]) of {ok, _, Core, _} -> {ok, Core}; _What -> {error, failed_conversion} catch diff --git a/lib/elixir/src/elixir_erl_compiler.erl b/lib/elixir/src/elixir_erl_compiler.erl index e4fb9f178..2fda35c5f 100644 --- a/lib/elixir/src/elixir_erl_compiler.erl +++ b/lib/elixir/src/elixir_erl_compiler.erl @@ -1,5 +1,5 @@ -module(elixir_erl_compiler). --export([forms/3, noenv_forms/3]). +-export([forms/3, noenv_forms/3, erl_to_core/2]). forms(Forms, File, Opts) -> compile(fun compile:forms/2, Forms, File, Opts). @@ -7,13 +7,20 @@ forms(Forms, File, Opts) -> noenv_forms(Forms, File, Opts) -> compile(fun compile:noenv_forms/2, Forms, File, Opts). +erl_to_core(Forms, Opts) -> + v3_core:module(Forms, Opts). + compile(Fun, Forms, File, Opts) when is_list(Forms), is_list(Opts), is_binary(File) -> + {ok, CoreForms, CoreWarnings} = erl_to_core(Forms, Opts), Source = elixir_utils:characters_to_list(File), - case Fun(Forms, [return, {source, Source} | Opts]) of + + case Fun(CoreForms, [from_core, return, {source, Source} | Opts]) of {ok, Module, Binary, Warnings} -> + format_warnings(Opts, CoreWarnings), format_warnings(Opts, Warnings), {Module, Binary}; {error, Errors, Warnings} -> + format_warnings(Opts, CoreWarnings), format_warnings(Opts, Warnings), format_errors(Errors) end. diff --git a/lib/elixir/src/elixir_module.erl b/lib/elixir/src/elixir_module.erl index b6ea83056..f2bc9361e 100644 --- a/lib/elixir/src/elixir_module.erl +++ b/lib/elixir/src/elixir_module.erl @@ -130,7 +130,6 @@ compile(Line, Module, Block, Vars, E) -> validate_compile_opts(Opts, Defs, Unreachable, File, Line) -> lists:flatmap(fun (Opt) -> validate_compile_opt(Opt, Defs, Unreachable, File, Line) end, Opts). -%% TODO: Make this an error and skip parse transform processing on 2.0. validate_compile_opt({parse_transform, Module} = Opt, _Defs, _Unreachable, File, Line) -> elixir_errors:form_warn([{line, Line}], File, ?MODULE, {parse_transform, Module}), [Opt]; @@ -431,5 +430,4 @@ format_error({module_in_definition, Module, File, Line}) -> format_error({bad_inline, {Name, Arity}}) -> io_lib:format("inlined function ~ts/~B undefined", [Name, Arity]); format_error({parse_transform, Module}) -> - io_lib:format("@compile {:parse_transform, ~ts} is deprecated. Elixir will no longer support " - "Erlang-based transforms in future versions", [elixir_aliases:inspect(Module)]). + io_lib:format("@compile {:parse_transform, ~ts} has no effect as it applies exclusively to Erlang sources", [elixir_aliases:inspect(Module)]). |
