@@ -145,7 +145,7 @@ compile(CodeChunk, _AtomResolver, _LiteralResolver, _TypeResolver, _MMod, _MSt)
145145
146146% 1
147147first_pass (<<? OP_LABEL , Rest0 /binary >>, MMod , MSt , State0 ) ->
148- ? ASSERT_ALL_NATIVE_FREE (MSt0 ),
148+ ? ASSERT_ALL_NATIVE_FREE (MSt ),
149149 {Label , Rest1 } = decode_literal (Rest0 ),
150150 ? TRACE (" OP_LABEL ~p \n " , [Label ]),
151151 MSt0 = ? DWARF_LABEL (MMod , MSt , Label ),
@@ -1201,6 +1201,7 @@ first_pass(<<?OP_BS_GET_INTEGER2, Rest0/binary>>, MMod, MSt, State0) ->
12011201 ]),
12021202 MSt17 = MMod :move_to_vm_register (MSt16 , Result , Dest ),
12031203 MSt18 = MMod :free_native_registers (MSt17 , [Result ]),
1204+ ? ASSERT_ALL_NATIVE_FREE (MSt18 ),
12041205 first_pass (Rest7 , MMod , MSt18 , State0 );
12051206% 118
12061207first_pass (<<? OP_BS_GET_FLOAT2 , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1238,6 +1239,7 @@ first_pass(<<?OP_BS_GET_FLOAT2, Rest0/binary>>, MMod, MSt, State0) ->
12381239 ]),
12391240 MSt16 = MMod :move_to_vm_register (MSt15 , Result , Dest ),
12401241 MSt17 = MMod :free_native_registers (MSt16 , [Result ]),
1242+ ? ASSERT_ALL_NATIVE_FREE (MSt17 ),
12411243 first_pass (Rest7 , MMod , MSt17 , State0 );
12421244% 119
12431245first_pass (<<? OP_BS_GET_BINARY2 , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1270,7 +1272,7 @@ first_pass(<<?OP_BS_GET_BINARY2, Rest0/binary>>, MMod, MSt, State0) ->
12701272 end ),
12711273 MSt8 = MMod :shift_right (MSt7 , BSOffsetReg , 3 ),
12721274 MSt9 = MMod :and_ (MSt8 , BSBinaryReg0 , ? TERM_PRIMARY_CLEAR_MASK ),
1273- {MSt10 , SizeReg } = MMod :get_array_element (MSt9 , BSBinaryReg0 , 1 ),
1275+ {MSt10 , SizeReg } = MMod :get_array_element (MSt9 , { free , BSBinaryReg0 } , 1 ),
12741276 {MSt13 , SizeValue } =
12751277 if
12761278 Size =:= ? ALL_ATOM ->
@@ -1309,7 +1311,7 @@ first_pass(<<?OP_BS_GET_BINARY2, Rest0/binary>>, MMod, MSt, State0) ->
13091311 MSt18 = MMod :free_native_registers (MSt17 , [NewOffsetReg ]),
13101312 {MSt19 , TrimResultReg } = MMod :call_primitive (MSt18 , ? PRIM_TRIM_LIVE_REGS , [ctx , Live ]),
13111313 MSt20 = MMod :free_native_registers (MSt19 , [TrimResultReg ]),
1312- {MSt21 , BSBinaryReg1 } = MMod :get_array_element (MSt20 , MatchStateRegPtr , 1 ),
1314+ {MSt21 , BSBinaryReg1 } = MMod :get_array_element (MSt20 , { free , MatchStateRegPtr } , 1 ),
13131315 MSt22 = MMod :or_ (MSt21 , BSBinaryReg1 , ? TERM_PRIMARY_BOXED ),
13141316 {MSt23 , HeapSizeReg } = MMod :call_primitive (MSt22 , ? PRIM_TERM_SUB_BINARY_HEAP_SIZE , [
13151317 BSBinaryReg1 , SizeValue
@@ -1325,7 +1327,8 @@ first_pass(<<?OP_BS_GET_BINARY2, Rest0/binary>>, MMod, MSt, State0) ->
13251327 Fail , Src , Live , Size , Unit , FlagsValue , Dest
13261328 ]),
13271329 MSt27 = MMod :move_to_vm_register (MSt26 , ResultTerm , Dest ),
1328- MSt28 = MMod :free_native_registers (MSt27 , [ResultTerm ]),
1330+ MSt28 = MMod :free_native_registers (MSt27 , [ResultTerm , Dest ]),
1331+ ? ASSERT_ALL_NATIVE_FREE (MSt28 ),
13291332 first_pass (Rest7 , MMod , MSt28 , State0 );
13301333% 120
13311334first_pass (<<? OP_BS_SKIP_BITS2 , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1574,6 +1577,7 @@ first_pass(<<?OP_BS_GET_UTF32, Rest0/binary>>, MMod, MSt, State0) ->
15741577 ? TRACE (" OP_BS_GET_UTF32 ~p ,~p ,~p ,~p \n " , [Fail , Src , FlagsValue , Dest ]),
15751578 MSt5 = MMod :move_to_vm_register (MSt4 , Value , Dest ),
15761579 MSt6 = MMod :free_native_registers (MSt5 , [Value , Dest ]),
1580+ ? ASSERT_ALL_NATIVE_FREE (MSt6 ),
15771581 first_pass (Rest5 , MMod , MSt6 , State0 );
15781582% 143
15791583first_pass (<<? OP_BS_SKIP_UTF32 , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1588,6 +1592,7 @@ first_pass(<<?OP_BS_SKIP_UTF32, Rest0/binary>>, MMod, MSt, State0) ->
15881592 ]),
15891593 MSt3 = cond_jump_to_label ({{free , Value }, '==' , 0 }, Fail , MMod , MSt2 ),
15901594 ? TRACE (" OP_BS_SKIP_UTF32 ~p ,~p ,~p \n " , [Fail , Src , FlagsValue ]),
1595+ ? ASSERT_ALL_NATIVE_FREE (MSt3 ),
15911596 first_pass (Rest4 , MMod , MSt3 , State0 );
15921597% 152
15931598first_pass (<<? OP_GC_BIF3 , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1615,6 +1620,7 @@ first_pass(<<?OP_GC_BIF3, Rest0/binary>>, MMod, MSt, State0) ->
16151620 ctx , FailLabel , CappedLive , {free , Arg1 }, {free , Arg2 }, {free , Arg3 }
16161621 ]),
16171622 MSt9 = bif_faillabel_test (FailLabel , MMod , MSt8 , {free , ResultReg }, {free , Dest }),
1623+ ? ASSERT_ALL_NATIVE_FREE (MSt9 ),
16181624 first_pass (Rest7 , MMod , MSt9 , State0 );
16191625% 153
16201626first_pass (
@@ -1795,6 +1801,7 @@ first_pass(<<?OP_IS_MAP, Rest0/binary>>, MMod, MSt, State0) ->
17951801 {MSt1 , Arg1 , Rest2 } = decode_compact_term (Rest1 , MMod , MSt0 , State0 ),
17961802 ? TRACE (" OP_IS_MAP ~p , ~p \n " , [Label , Arg1 ]),
17971803 MSt2 = verify_is_boxed_with_tag (Label , Arg1 , ? TERM_BOXED_MAP , MMod , MSt1 ),
1804+ ? ASSERT_ALL_NATIVE_FREE (MSt2 ),
17981805 first_pass (Rest2 , MMod , MSt2 , State0 );
17991806% 157
18001807first_pass (<<? OP_HAS_MAP_FIELDS , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1841,6 +1848,7 @@ first_pass(<<?OP_HAS_MAP_FIELDS, Rest0/binary>>, MMod, MSt, State0) ->
18411848 ),
18421849 ? TRACE (" ]\n " , []),
18431850 MSt7 = MMod :free_native_registers (MSt6 , [Src ]),
1851+ ? ASSERT_ALL_NATIVE_FREE (MSt7 ),
18441852 first_pass (Rest5 , MMod , MSt7 , State0 );
18451853% 158
18461854first_pass (<<? OP_GET_MAP_ELEMENTS , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1897,6 +1905,7 @@ first_pass(<<?OP_GET_MAP_ELEMENTS, Rest0/binary>>, MMod, MSt, State0) ->
18971905 ),
18981906 ? TRACE (" ]\n " , []),
18991907 MSt14 = MMod :free_native_registers (MSt13 , [MapReg , SrcReg ]),
1908+ ? ASSERT_ALL_NATIVE_FREE (MSt14 ),
19001909 first_pass (Rest6 , MMod , MSt14 , State0 );
19011910% 159
19021911first_pass (
@@ -1943,6 +1952,7 @@ first_pass(<<?OP_BUILD_STACKTRACE, Rest0/binary>>, MMod, MSt, State0) ->
19431952 {MSt1 , ResultReg } = MMod :call_primitive (MSt0 , ? PRIM_STACKTRACE_BUILD , [ctx ]),
19441953 MSt2 = MMod :move_to_vm_register (MSt1 , ResultReg , {x_reg , 0 }),
19451954 MSt3 = MMod :free_native_registers (MSt2 , [ResultReg ]),
1955+ ? ASSERT_ALL_NATIVE_FREE (MSt3 ),
19461956 first_pass (Rest0 , MMod , MSt3 , State0 );
19471957% 161
19481958first_pass (<<? OP_RAW_RAISE , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1959,6 +1969,7 @@ first_pass(<<?OP_RAW_RAISE, Rest0/binary>>, MMod, MSt, State0) ->
19591969 MMod :call_primitive_last (BSt0 , ? PRIM_HANDLE_ERROR , [ctx , jit_state , offset ])
19601970 end ),
19611971 MSt5 = MMod :move_to_vm_register (MSt4 , ? BADARG_ATOM , {x_reg , 0 }),
1972+ ? ASSERT_ALL_NATIVE_FREE (MSt5 ),
19621973 first_pass (Rest0 , MMod , MSt5 , State0 );
19631974% 162
19641975first_pass (<<? OP_GET_HD , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1971,6 +1982,7 @@ first_pass(<<?OP_GET_HD, Rest0/binary>>, MMod, MSt, State0) ->
19711982 MSt4 = MMod :and_ (MSt3 , Reg , ? TERM_PRIMARY_CLEAR_MASK ),
19721983 MSt5 = MMod :move_array_element (MSt4 , Reg , ? LIST_HEAD_INDEX , Dest ),
19731984 MSt6 = MMod :free_native_registers (MSt5 , [Dest , Reg ]),
1985+ ? ASSERT_ALL_NATIVE_FREE (MSt6 ),
19741986 first_pass (Rest3 , MMod , MSt6 , State0 );
19751987% 163
19761988first_pass (<<? OP_GET_TL , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -1983,6 +1995,7 @@ first_pass(<<?OP_GET_TL, Rest0/binary>>, MMod, MSt, State0) ->
19831995 MSt4 = MMod :and_ (MSt3 , Reg , ? TERM_PRIMARY_CLEAR_MASK ),
19841996 MSt5 = MMod :move_array_element (MSt4 , Reg , ? LIST_TAIL_INDEX , Dest ),
19851997 MSt6 = MMod :free_native_registers (MSt5 , [Dest , Reg ]),
1998+ ? ASSERT_ALL_NATIVE_FREE (MSt6 ),
19861999 first_pass (Rest3 , MMod , MSt6 , State0 );
19872000% 164
19882001first_pass (<<? OP_PUT_TUPLE2 , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -2076,6 +2089,7 @@ first_pass(<<?OP_BS_SET_POSITION, Rest0/binary>>, MMod, MSt, State0) ->
20762089 {MSt4 , PosVal } = term_to_int (Pos , 0 , MMod , MSt3 ),
20772090 MSt5 = MMod :move_to_array_element (MSt4 , PosVal , MatchStateRegPtr , 2 ),
20782091 MSt6 = MMod :free_native_registers (MSt5 , [PosVal , MatchStateRegPtr ]),
2092+ ? ASSERT_ALL_NATIVE_FREE (MSt6 ),
20792093 first_pass (Rest2 , MMod , MSt6 , State0 );
20802094% 169
20812095first_pass (<<? OP_SWAP , Rest0 /binary >>, MMod , MSt , State ) ->
@@ -2138,6 +2152,7 @@ first_pass(<<?OP_MAKE_FUN3, Rest0/binary>>, MMod, MSt, State0) ->
21382152 MSt5 = MMod :or_ (MSt4 , ResultReg , ? TERM_PRIMARY_BOXED ),
21392153 MSt6 = MMod :move_to_vm_register (MSt5 , ResultReg , Dest ),
21402154 MSt7 = MMod :free_native_registers (MSt6 , [Dest , ResultReg ]),
2155+ ? ASSERT_ALL_NATIVE_FREE (MSt7 ),
21412156 first_pass (Rest4 , MMod , MSt7 , State0 );
21422157% 172
21432158first_pass (<<? OP_INIT_YREGS , Rest0 /binary >>, MMod , MSt , State ) ->
@@ -2337,6 +2352,7 @@ first_pass(<<?OP_CALL_FUN2, Rest0/binary>>, MMod, MSt, State0) ->
23372352 MSt6 = MMod :call_primitive_with_cp (MSt5 , ? PRIM_CALL_FUN , [
23382353 ctx , jit_state , offset , {free , Reg }, ArgsCount
23392354 ]),
2355+ ? ASSERT_ALL_NATIVE_FREE (MSt6 ),
23402356 first_pass (Rest3 , MMod , MSt6 , State0 );
23412357% 180
23422358first_pass (<<? OP_BADRECORD , Rest0 /binary >>, MMod , MSt , State0 ) ->
@@ -2347,6 +2363,7 @@ first_pass(<<?OP_BADRECORD, Rest0/binary>>, MMod, MSt, State0) ->
23472363 MSt2 = MMod :call_primitive_last (MSt1 , ? PRIM_RAISE_ERROR_TUPLE , [
23482364 ctx , jit_state , offset , ? BADRECORD_ATOM , Arg1
23492365 ]),
2366+ ? ASSERT_ALL_NATIVE_FREE (MSt2 ),
23502367 first_pass (Rest1 , MMod , MSt2 , State0 );
23512368% 181
23522369first_pass (
0 commit comments