This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
forked from 0xPolygonZero/plonky2
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 0xPolygonZero#1305 from topos-protocol/memset
Speed-up memset and fix it to write 0 values
- Loading branch information
Showing
4 changed files
with
30 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,45 @@ | ||
// Sets `count` values to `value` at | ||
// Sets `count` values to 0 at | ||
// DST = (dst_ctx, dst_segment, dst_addr). | ||
// This tuple definition is used for brevity in the stack comments below. | ||
global memset: | ||
// stack: DST, value, count, retdest | ||
DUP5 | ||
// stack: count, DST, value, count, retdest | ||
ISZERO | ||
// stack: count == 0, DST, value, count, retdest | ||
%jumpi(memset_finish) | ||
// stack: DST, value, count, retdest | ||
DUP4 | ||
// stack: value, DST, value, count, retdest | ||
DUP4 | ||
// stack: DST, count, retdest | ||
DUP4 | ||
DUP4 | ||
// stack: DST, value, DST, value, count, retdest | ||
MSTORE_GENERAL | ||
// stack: DST, value, count, retdest | ||
// stack: count, DST, count, retdest | ||
%lt_const(0x20) | ||
// stack: count < 32, DST, count, retdest | ||
%jumpi(memset_finish) | ||
// stack: DST, count, retdest | ||
PUSH 32 | ||
PUSH 0 | ||
DUP5 | ||
DUP5 | ||
DUP5 | ||
// stack: DST, 0, 32, DST, count, retdest | ||
MSTORE_32BYTES | ||
// stack: DST, count, retdest | ||
|
||
// Increment dst_addr. | ||
SWAP2 | ||
%increment | ||
%add_const(0x20) | ||
SWAP2 | ||
// Decrement count. | ||
SWAP4 | ||
%decrement | ||
%sub_const(0x20) | ||
SWAP4 | ||
|
||
// Continue the loop. | ||
%jump(memset) | ||
|
||
memset_finish: | ||
// stack: DST, value, count, retdest | ||
%pop5 | ||
// stack: DST, final_count, retdest | ||
DUP4 | ||
PUSH 0 | ||
DUP5 | ||
DUP5 | ||
DUP5 | ||
// stack: DST, 0, final_count, DST, final_count, retdest | ||
MSTORE_32BYTES | ||
// stack: DST, final_count, retdest | ||
%pop4 | ||
// stack: retdest | ||
JUMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters