-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scriptcomp: Merge multiple MODIFY_STACK_POINTER instructions (#78)
When the codegen produces multiple MODIFY_STACK_POINTER instructions in a row, we instead just keep the one and modify the value. Plus some scaffolding to make this and future changes easier Partial fix for #70 ## Testing Test script: ```nss void main() { if (1) { string s = "AAA"; } } ``` Before this change, it compiles as ``` 0 JSR, 8 6 RET 8 CONSTANT, TYPE_INTEGER, 1 14 JZ, 41 20 RUNSTACK_ADD, TYPE_STRING 22 CONSTANT, TYPE_STRING, "AAA" 29 ASSIGNMENT, TYPE_VOID, -8, 4 37 MODIFY_STACK_POINTER, -4 43 MODIFY_STACK_POINTER, -4 49 JMP, 6 55 RET ``` and after: ``` 0 JSR, 8 6 RET 8 CONSTANT, TYPE_INTEGER, 1 14 JZ, 35 20 RUNSTACK_ADD, TYPE_STRING 22 CONSTANT, TYPE_STRING, "AAA" 29 ASSIGNMENT, TYPE_VOID, -8, 4 37 MODIFY_STACK_POINTER, -8 43 JMP, 6 49 RET ``` No changelog entry for now, as it's minor on its own, but other such things will come. ## Licence - [x] I am licencing my change under the project's MIT licence, including all changes to GPL-3.0 licenced parts of the codebase.
- Loading branch information
Showing
3 changed files
with
59 additions
and
105 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