Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize ROT #346

Merged
merged 4 commits into from
Sep 7, 2020
Merged

Optimize ROT #346

merged 4 commits into from
Sep 7, 2020

Conversation

shargon
Copy link
Member

@shargon shargon commented Sep 1, 2020

Close #245

@ShawnYun
Copy link
Contributor

ShawnYun commented Sep 2, 2020

That looks good

@ShawnYun
Copy link
Contributor

ShawnYun commented Sep 2, 2020

What if there is a JMP case?

@shargon
Copy link
Member Author

shargon commented Sep 2, 2020

What if there is a JMP case?

It won't be a push, it will be a label

@ShawnYun
Copy link
Contributor

ShawnYun commented Sep 2, 2020

For example:

            scriptBefore.Emit(VM.OpCode.PUSH5);
            scriptBefore.Emit(VM.OpCode.PUSH4);
            scriptBefore.EmitJump(VM.OpCode.JMP, 2);
            scriptBefore.Emit(VM.OpCode.PUSH1);
            scriptBefore.Emit(VM.OpCode.PUSH2);
            scriptBefore.Emit(VM.OpCode.PUSH3);
            scriptBefore.Emit(VM.OpCode.ROT);

after optimized, it will be:

            scriptBefore.Emit(VM.OpCode.PUSH5);
            scriptBefore.Emit(VM.OpCode.PUSH4);
            scriptBefore.EmitJump(VM.OpCode.JMP, 2);
            scriptBefore.Emit(VM.OpCode.PUSH2);
            scriptBefore.Emit(VM.OpCode.PUSH3);
            scriptBefore.Emit(VM.OpCode.PUSH1);

?

@shargon
Copy link
Member Author

shargon commented Sep 2, 2020

Yes because the JMP is not in the middle.

Before
image
After
image

I added a new UT with JMP,3. Please check it @ShawnYun

@shargon shargon requested a review from erikzhang September 3, 2020 10:28
@shargon
Copy link
Member Author

shargon commented Sep 6, 2020

Ready to merge?

@erikzhang erikzhang merged commit 3ea7af7 into neo-project:master Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create optimization rule for ROT
3 participants