Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions libs/estdlib/src/code_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ load(Module) ->
code_server:literal_resolver(Module, Index)
end,
TypeResolver = fun(Index) -> code_server:type_resolver(Module, Index) end,
Stream0 = jit:stream(jit_mmap_size(byte_size(Code))),
{BackendModule, BackendState0} = jit:backend(Stream0),
{StreamModule, Stream0} = jit:stream(jit_mmap_size(byte_size(Code))),
{BackendModule, BackendState0} = jit:backend(StreamModule, Stream0),
{LabelsCount, BackendState1} = jit:compile(
Code,
AtomResolver,
Expand All @@ -175,7 +175,8 @@ load(Module) ->
BackendState0
),
Stream1 = BackendModule:stream(BackendState1),
code_server:set_native_code(Module, LabelsCount, Stream1),
Stream2 = StreamModule:flush(Stream1),
code_server:set_native_code(Module, LabelsCount, Stream2),
End = erlang:system_time(millisecond),
io:format("~B ms (bytecode: ~B bytes, native code: ~B bytes)\n", [
End - Start, byte_size(Code), BackendModule:offset(BackendState1)
Expand Down
7 changes: 4 additions & 3 deletions libs/jit/src/jit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

-export([
stream/1,
backend/1,
backend/2,
beam_chunk_header/3,
compile/6
]).
Expand Down Expand Up @@ -148,7 +148,8 @@ compile(
},
{State1, MSt2} = first_pass(Opcodes, MMod, MSt1, State0),
MSt3 = second_pass(MMod, MSt2, State1),
{LabelsCount, MSt3};
MSt4 = MMod:flush(MSt3),
{LabelsCount, MSt4};
compile(
<<16:32, 0:32, OpcodeMax:32, _LabelsCount:32, _FunctionsCount:32, _Opcodes/binary>>,
_AtomResolver,
Expand Down Expand Up @@ -3852,7 +3853,7 @@ variant() ->

%% @doc Instantiate backend for this platform
%% @return A tuple with the backend module and the backend state for this platform
backend({StreamModule, Stream}) ->
backend(StreamModule, Stream) ->
BackendModule = ?MODULE:backend_module(),
Variant = ?MODULE:variant(),
BackendState = BackendModule:new(Variant, StreamModule, Stream),
Expand Down
11 changes: 11 additions & 0 deletions libs/jit/src/jit_aarch64.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
new/3,
stream/1,
offset/1,
flush/1,
debugger/1,
used_regs/1,
available_regs/1,
Expand Down Expand Up @@ -259,6 +260,16 @@ stream(#state{stream = Stream}) ->
offset(#state{stream_module = StreamModule, stream = Stream}) ->
StreamModule:offset(Stream).

%%-----------------------------------------------------------------------------
%% @doc Flush the current state (unused on aarch64)
%% @end
%% @param State current backend state
%% @return The flushed state
%%-----------------------------------------------------------------------------
-spec flush(state()) -> state().
flush(#state{} = State) ->
State.

%%-----------------------------------------------------------------------------
%% @doc Emit a debugger of breakpoint instruction. This is used for debugging
%% and not in production.
Expand Down
Loading
Loading