Skip to content

Commit d23bbf0

Browse files
committed
JIT: make imported functions available to compiler
Optimize + and - as well as < and > when types are integers of known range. Also fix array functions of armv6m backend for higher indexes (>= 32). Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent e9f3fe2 commit d23bbf0

23 files changed

+1276
-81
lines changed

libs/estdlib/src/code_server.erl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
atom_resolver/2,
4040
literal_resolver/2,
4141
type_resolver/2,
42+
import_resolver/2,
4243
set_native_code/3
4344
]).
4445

@@ -135,6 +136,15 @@ literal_resolver(_Module, _Index) ->
135136
type_resolver(_Module, _Index) ->
136137
erlang:nif_error(undefined).
137138

139+
%% @doc Get an imported function triplet from its index
140+
%% @return The imported function as {Module, Function, Arity}
141+
%% @param Module module to get the imported function from
142+
%% @param Index imported function index in the module
143+
-spec import_resolver(Module :: module(), Index :: non_neg_integer()) ->
144+
{atom(), atom(), non_neg_integer()}.
145+
import_resolver(_Module, _Index) ->
146+
erlang:nif_error(undefined).
147+
138148
%% @doc Associate a native code stream with a module
139149
%% @return ok
140150
%% @param Module module to set the native code of
@@ -164,13 +174,17 @@ load(Module) ->
164174
code_server:literal_resolver(Module, Index)
165175
end,
166176
TypeResolver = fun(Index) -> code_server:type_resolver(Module, Index) end,
177+
ImportResolver = fun(Index) ->
178+
code_server:import_resolver(Module, Index)
179+
end,
167180
{StreamModule, Stream0} = jit:stream(jit_mmap_size(byte_size(Code))),
168181
{BackendModule, BackendState0} = jit:backend(StreamModule, Stream0),
169182
{LabelsCount, BackendState1} = jit:compile(
170183
Code,
171184
AtomResolver,
172185
LiteralResolver,
173186
TypeResolver,
187+
ImportResolver,
174188
BackendModule,
175189
BackendState0
176190
),

0 commit comments

Comments
 (0)