-
Notifications
You must be signed in to change notification settings - Fork 3
JIT: introduce filtering of modules with --arch and --platform arguments #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,8 @@ | |
prune => boolean(), | ||
start_module => module() | undefined, | ||
application_module => module() | undefined, | ||
include_lines => boolean() | ||
include_lines => boolean(), | ||
arch => atom() | ||
}. | ||
|
||
-export_type([ | ||
|
@@ -68,7 +69,9 @@ | |
prune => false, | ||
start_module => undefined, | ||
application_module => undefined, | ||
include_lines => true | ||
include_lines => true, | ||
arch => undefined, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was going to make the |
||
platform => generic_unix | ||
}). | ||
|
||
%% | ||
|
@@ -88,7 +91,9 @@ | |
%% prune => false, | ||
%% start_module => undefined, | ||
%% application_module => undefined, | ||
%% include_lines => false | ||
%% include_lines => false, | ||
%% arch => undefined, | ||
%% platform => generic_unix | ||
%% }' | ||
%% | ||
%% @end | ||
|
@@ -122,15 +127,20 @@ create(OutputPath, InputPaths, Options) -> | |
prune := Prune, | ||
start_module := StartModule, | ||
application_module := ApplicationModule, | ||
include_lines := IncludeLines | ||
include_lines := IncludeLines, | ||
arch := Arch, | ||
platform := Platform | ||
} = maps:merge(?DEFAULT_OPTIONS, Options), | ||
ParsedFiles = parse_files(InputPaths, StartModule, IncludeLines), | ||
Files0 = parse_files(InputPaths, StartModule, IncludeLines), | ||
Files1 = filter_jit(Files0, Arch, Platform), | ||
Files2 = | ||
if | ||
Prune -> prune(Files1, ApplicationModule); | ||
true -> Files1 | ||
end, | ||
write_packbeam( | ||
OutputPath, | ||
case Prune of | ||
true -> prune(ParsedFiles, ApplicationModule); | ||
_ -> ParsedFiles | ||
end | ||
Files2 | ||
). | ||
|
||
%%----------------------------------------------------------------------------- | ||
|
@@ -782,9 +792,14 @@ ends_with(String, Suffix) -> | |
|
||
%% @private | ||
filter_chunks(Chunks, IncludeLines) -> | ||
AllowedChunks = allowed_chunks(IncludeLines), | ||
AllowedChunks0 = allowed_chunks(IncludeLines), | ||
AllowedChunks1 = | ||
case lists:keymember("avmN", 1, Chunks) of | ||
true -> AllowedChunks0 -- ["Code", "Type"]; | ||
false -> AllowedChunks0 -- ["avmN"] | ||
end, | ||
lists:filter( | ||
fun({Tag, _Data}) -> lists:member(Tag, AllowedChunks) end, | ||
fun({Tag, _Data}) -> lists:member(Tag, AllowedChunks1) end, | ||
Chunks | ||
). | ||
|
||
|
@@ -853,3 +868,60 @@ deduplicate([]) -> | |
[]; | ||
deduplicate([H | T]) -> | ||
[H | [X || X <- deduplicate(T), X /= H]]. | ||
|
||
filter_jit(Files0, undefined, generic_unix) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whether or not we use |
||
Files0; | ||
filter_jit(Files0, aarch64, generic_unix) -> | ||
lists:filter( | ||
fun(File) -> | ||
filter_jit0(File, [ | ||
"jit.beam", "jit_stream_mmap.beam", "jit_aarch64.beam", "jit_aarch64_asm.beam" | ||
]) | ||
end, | ||
Files0 | ||
); | ||
filter_jit(Files0, x86_64, generic_unix) -> | ||
lists:filter( | ||
fun(File) -> | ||
filter_jit0(File, [ | ||
"jit.beam", "jit_stream_mmap.beam", "jit_x86_64.beam", "jit_x86_64_asm.beam" | ||
]) | ||
end, | ||
Files0 | ||
); | ||
filter_jit(Files0, armv6m, generic_unix) -> | ||
lists:filter( | ||
fun(File) -> | ||
filter_jit0(File, [ | ||
"jit.beam", "jit_stream_mmap.beam", "jit_armv6m.beam", "jit_armv6m_asm.beam" | ||
]) | ||
end, | ||
Files0 | ||
); | ||
filter_jit(Files0, armv6m, rp2) -> | ||
lists:filter( | ||
fun(File) -> | ||
filter_jit0(File, [ | ||
"jit.beam", "jit_stream_flash.beam", "jit_armv6m.beam", "jit_armv6m_asm.beam" | ||
]) | ||
end, | ||
Files0 | ||
); | ||
filter_jit(Files0, armv6m, stm32) -> | ||
lists:filter( | ||
fun(File) -> | ||
filter_jit0(File, [ | ||
"jit.beam", "jit_stream_flash.beam", "jit_armv6m.beam", "jit_armv6m_asm.beam" | ||
]) | ||
end, | ||
Files0 | ||
). | ||
|
||
filter_jit0(File, JITModules) -> | ||
ModuleName = lists:flatten(get_element_name(File)), | ||
case ModuleName of | ||
"jit" ++ _ -> | ||
lists:member(ModuleName, JITModules); | ||
_ -> | ||
true | ||
end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to add these parameters to the
print_help()
function in packbeam.erl.