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

CSE Machine: Avoid pushing unnecessary env instructions (exhaustive version) #1706

Merged
merged 29 commits into from
Sep 11, 2024

Conversation

DiligentPenguinn
Copy link
Contributor

Description

This PR aims to implement an exhaustive version of PR #1699 and #1687 .
A ControlItem is environment-dependent if its evaluation depends on the current environment, OR its evaluation introduces environment-dependent items onto the control.
At each step, if the current control is free of environment-dependent items then we can avoid pushing environment instruction.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvements

Some of my concerns

  1. How exhaustive should the logic be? I think it’s enough to cover all node types and instructions allowed to be used in Source. Any remaining node types can default to being environment-independent

  2. I initially wanted to place the logic in the AST file along with statementSeqTransform but I realized the logic needed to work for control items which can be either nodes or instructions. Instructions are only defined within the CSE Machine context so currently I place the logic there.

  3. I modified the test cases to use generateCSEMachineStateStream which allows me to check the number of environment-dependent items at each step, but now the test runs synchronously (because generateCSEMachineStateStream runs synchronously). Would this be a problem?

@DiligentPenguinn DiligentPenguinn added the Enhancement New feature or request label May 15, 2024
@DiligentPenguinn DiligentPenguinn self-assigned this May 15, 2024
@coveralls
Copy link

coveralls commented May 15, 2024

Pull Request Test Coverage Report for Build 10793927514

Details

  • 76 of 76 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 81.61%

Totals Coverage Status
Change from base Build 10793919938: 0.06%
Covered Lines: 10983
Relevant Lines: 13081

💛 - Coveralls

Copy link
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, did a quick look and just some questions below

src/cse-machine/interpreter.ts Outdated Show resolved Hide resolved
src/cse-machine/interpreter.ts Outdated Show resolved Hide resolved
@DiligentPenguinn DiligentPenguinn marked this pull request as ready for review July 21, 2024 13:47
Copy link
Member

@martin-henz martin-henz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. I think this will be a good improvement to reduce the number of env instructions.

@martin-henz martin-henz merged commit 56d8d6b into master Sep 11, 2024
4 checks passed
@martin-henz martin-henz deleted the cse-machine-simplify-env-instr branch September 11, 2024 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

4 participants