Support matching bitstrings that are in fact binaries (size divisible by 8)#1978
Support matching bitstrings that are in fact binaries (size divisible by 8)#1978mat-hek wants to merge 1 commit intoatomvm:mainfrom
Conversation
bb34fe8 to
7bb58f2
Compare
576fb54 to
ffcc68d
Compare
…408) Closes #393 Once atomvm/AtomVM#1978 is merged and downstreamed, the eval_bits patch won't be needed (unless there are other unrelated patches in there OFC)
ffcc68d to
89e5cf8
Compare
5aa8f8c to
c2b0ede
Compare
bettio
left a comment
There was a problem hiding this comment.
I think there is still an issue.
build-and-test (arm-linux-gnueabihf-gcc, -mcpu=cortex-a7 -mfloat-abi=hard -O2 -mthumb -mthumb-int is failing and this tells me there is a problem with JIT implementation.
We have to fix this before merging this PR. Maybe @pguyot has some advice here.
… by 8) Signed-off-by: Mateusz Front <mateusz.front@swmansion.com>
c2b0ede to
6c9843d
Compare
bettio
left a comment
There was a problem hiding this comment.
Tests keep failing:
test_binary_to_term:
CRASH
======
pid: <0.1.0>
Stacktrace:
[{test_binary_to_term,test_function,0,[{file,"/home/runner/work/AtomVM/AtomVM/tests/erlang_tests/test_binary_to_term.erl"},{line,316}]},{test_binary_to_term,start,0,[{file,"/home/runner/work/AtomVM/AtomVM/tests/erlang_tests/test_binary_to_term.erl"},{line,170}]}]
cp: #CP<module: 0, label: 52, offset: 2272>
x[0]: error
x[1]: {badmatch,<<1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,1,119,19,116,101,115,116,95,98,105,110,97,114,121,95,116,111,95,116,101,114,109,97,5,98,5,26,215,111,88,119,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0,0,0,0,0,0,0,0,0,0,0,97,2>>}
x[2]: {2,2,74,1,[{0,8240},{0,27350}],error}
Stack
-----
<<88,119,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0,0,0,0,0,0,0,0,0,0,0>>
85645167
4
85
21
<<119,19,116,101,115,116,95,98,105,110,97,114,121,95,116,111,95,116,101,114,109>>
<<131,108,0,0,0,2,112,0,0,0,85,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,119,19,116,101,115,116,95,98,105,110,97,114,121,95,116,111,95,116,101,114,109,97,4,98,5,26,215,111,88,119,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,0,87,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,1,119,19,116,101,115,116,95,98,105,110,97,114,121,95,116,111,95,116,101,114,109,97,5,98,5,26,215,111,88,119,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0,0,0,0,0,0,0,0,0,0,0,97,2,106>>
#CP<module: 0, label: 2, offset: 2760>
#CP<module: 0, label: 0, offset: 5424>
Mailbox
-------
Monitors
--------
**End Of Crash Report**
Expected 0 but result is not an integer
test_binary_to_term:FAILED
|
@bettio I'll try looking into it. There's also https://github.com/atomvm/AtomVM/actions/runs/20231091694/job/58073962162?pr=1978#step:18:596 failing, with disabled JIT 🤔 Instead of |
| end, | ||
| MSt12 = cond_jump_to_label({{free, SizeReg}, '<', BSOffsetReg1}, Fail, MMod, MSt11), | ||
| {MSt12, Size bsl 4}; | ||
| {MSt12, (Size * Unit) div 8}; |
There was a problem hiding this comment.
You still need to bsl 4 here as well.
There was a problem hiding this comment.
Actually it seems there is a bug in this opcode. Working on it.
There was a problem hiding this comment.
See #2113
You may want to rebase once it is merged.
| ctx, jit_state, offset, ?UNSUPPORTED_ATOM | ||
| ]); | ||
| true -> | ||
| MMod:sub(MSt10, SizeReg, (Size * Unit) div 8) |
There was a problem hiding this comment.
You still need to bsl 4 the (Size * Unit) div 8. You could write (Size * Unit) bsl 1.
Indeed, SizeReg contains the size in bytes as a term ((Imm bsl 4) bor 16#F).
We could add a comment here to clarify.
In some cases, there's generic code that uses the
bitstringmodifier because it needs to work for both bitstrings and binaries, for example in erl_eval. Currently such code doesn't work even if no actual bitstrings are involved, and this PR attempts to fix it. In other words, this now works:TODO:
jit.erl