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
2 changes: 1 addition & 1 deletion src/libAtomVM/opcodesswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -6576,7 +6576,7 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
uint32_t fail;
DECODE_LABEL(fail, pc);
uint32_t alloc;
DECODE_LITERAL(alloc, pc);
DECODE_ALLOCATOR_LIST(alloc, pc);
uint32_t live;
DECODE_LITERAL(live, pc);
uint32_t unit;
Expand Down
15 changes: 14 additions & 1 deletion tests/erlang_tests/test_op_bs_create_bin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ start() ->
ok = test_bs_create_bin_utf16(),
ok = test_bs_create_bin_utf32(),
ok = test_bs_create_bin_integer(),
ok = test_bs_create_bin_binary();
ok = test_bs_create_bin_binary(),
ok = test_bs_create_bin_alloc_list();
true ->
ok
end,
Expand Down Expand Up @@ -266,3 +267,15 @@ test_bs_create_bin_binary() ->
error:badarg -> unexpected
end,
ok.

test_bs_create_bin_alloc_list() ->
%% Test that bs_create_bin with allocator list works correctly
%% Expected result: <<0,0,0,42>> (42 as 32-bit big-endian integer)
Expected = <<0, 0, 0, 42>>,
Result = test_op_bs_create_bin_asm:bs_create_bin_alloc_list(42),
case Result of
Expected ->
ok;
_ ->
error({unexpected_result, Result, expected, Expected})
end.
14 changes: 12 additions & 2 deletions tests/erlang_tests/test_op_bs_create_bin_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
{bs_create_bin_integer_no_fail, 3},
{bs_create_bin_integer_fail, 3},
{bs_create_bin_binary_no_fail, 3},
{bs_create_bin_binary_fail, 3}
{bs_create_bin_binary_fail, 3},
{bs_create_bin_alloc_list, 1}
]}.

{attributes, []}.

{labels, 26}.
{labels, 28}.

{function, bs_create_bin_utf8_no_fail, 3, 2}.
{label, 1}.
Expand Down Expand Up @@ -122,3 +123,12 @@ return.
{label, 26}.
{move, {atom, fail}, {x, 0}}.
return.

{function, bs_create_bin_alloc_list, 1, 28}.
{label, 27}.
{func_info, {atom, test_op_bs_create_bin_asm}, {atom, bs_create_bin_alloc_list}, 1}.
{label, 28}.
%% Test bs_create_bin with allocator list instead of simple literal
{bs_create_bin, {f, 0}, {alloc, [{words, 2}, {floats, 1}, {funs, 1}]}, 1, 1, {x, 0},
{list, [{atom, integer}, 1, 1, nil, {x, 0}, {integer, 32}]}}.
return.
Loading