Skip to content

Optimize variable assignement #446

@bertysentry

Description

@bertysentry

Problem

Each variable assignment requires 3 opcodes: POP + PUSH + ASSIGN. See example below:

282: POP
283 : PUSH_LONG, -2
284 : ASSIGN, 11, true

285 : POP
286 : PUSH_LONG, 2
287 : ASSIGN, 12, true

288 : POP
289 : PUSH_LONG, 4
290 : ASSIGN, 13, true

Specification

Assigning a variable with hardcoded value shouldn't require to PUSH and then ASSIGN. We should have ASSIGN_LONG, ASSIGN_DOUBLE, ASSIGN_STRING opcodes to assign a variable to a hardcoded value.

Many variable assignments don't need to be pushed on the stack, just to be poped immediately and discarded. Combinations of ASSIGN + POP + PUSH should be simplified so that ASSIGN doesn't push to the stack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions