mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 23:33:07 +00:00
Use mstore_32bytes to optimize decode_int_given_len (#1413)
This commit is contained in:
parent
edfc86c393
commit
7efd147e08
@ -131,37 +131,19 @@ decode_rlp_list_len_big:
|
|||||||
// Pre stack: pos, len, retdest
|
// Pre stack: pos, len, retdest
|
||||||
// Post stack: pos', int
|
// Post stack: pos', int
|
||||||
global decode_int_given_len:
|
global decode_int_given_len:
|
||||||
%stack (pos, len, retdest) -> (pos, len, pos, retdest)
|
DUP2 ISZERO %jumpi(empty_int)
|
||||||
|
%stack (pos, len, retdest) -> (pos, len, pos, len, retdest)
|
||||||
ADD
|
ADD
|
||||||
// stack: end_pos, pos, retdest
|
%stack(pos_two, pos, len, retdest) -> (pos, len, pos_two, retdest)
|
||||||
SWAP1
|
PUSH @SEGMENT_RLP_RAW
|
||||||
// stack: pos, end_pos, retdest
|
PUSH 0 //context
|
||||||
PUSH 0 // initial accumulator state
|
MLOAD_32BYTES
|
||||||
// stack: acc, pos, end_pos, retdest
|
// stack: int, pos', retdest
|
||||||
|
%stack(int, pos, retdest) -> (retdest, pos, int)
|
||||||
decode_int_given_len_loop:
|
|
||||||
// stack: acc, pos, end_pos, retdest
|
|
||||||
DUP3
|
|
||||||
DUP3
|
|
||||||
EQ
|
|
||||||
// stack: pos == end_pos, acc, pos, end_pos, retdest
|
|
||||||
%jumpi(decode_int_given_len_finish)
|
|
||||||
// stack: acc, pos, end_pos, retdest
|
|
||||||
%shl_const(8)
|
|
||||||
// stack: acc << 8, pos, end_pos, retdest
|
|
||||||
DUP2
|
|
||||||
// stack: pos, acc << 8, pos, end_pos, retdest
|
|
||||||
%mload_kernel(@SEGMENT_RLP_RAW)
|
|
||||||
// stack: byte, acc << 8, pos, end_pos, retdest
|
|
||||||
ADD
|
|
||||||
// stack: acc', pos, end_pos, retdest
|
|
||||||
// Increment pos.
|
|
||||||
SWAP1
|
|
||||||
%increment
|
|
||||||
SWAP1
|
|
||||||
// stack: acc', pos', end_pos, retdest
|
|
||||||
%jump(decode_int_given_len_loop)
|
|
||||||
|
|
||||||
decode_int_given_len_finish:
|
|
||||||
%stack (acc, pos, end_pos, retdest) -> (retdest, pos, acc)
|
|
||||||
JUMP
|
JUMP
|
||||||
|
|
||||||
|
empty_int:
|
||||||
|
// stack: pos, len, retdest
|
||||||
|
%stack(pos, len, retdest) -> (retdest, pos, 0)
|
||||||
|
JUMP
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user