Skip to content

Add option to opt-out of optimization pass#458

Open
daniellerozenblit wants to merge 3 commits intofacebook:devfrom
daniellerozenblit:export-D95084139
Open

Add option to opt-out of optimization pass#458
daniellerozenblit wants to merge 3 commits intofacebook:devfrom
daniellerozenblit:export-D95084139

Conversation

@daniellerozenblit
Copy link
Contributor

Summary:

Stack

The purpose of this stack is to enhance the sddl2 compiler so it can produce code compatible with the sddl2 virtual machine.

Diff

This diff adds a with_optimization() / with_no_optimization() option to Compiler::Options, allowing callers to skip the optimizer pass entirely.

  • Added bool optimize field to Compiler::Options (defaults to true so existing behavior is unchanged).
  • Added with_optimization(bool) and with_no_optimization() builder methods following the existing Options pattern.
  • Made the optimization pass in Compiler::compile() conditional on this flag, passing the unoptimized AST directly to codegen when disabled.

Differential Revision: D95084139

@meta-codesync
Copy link

meta-codesync bot commented Mar 3, 2026

@daniellerozenblit has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95084139.

daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 3, 2026
Summary:
Pull Request resolved: facebook#458

# Stack
The purpose of this stack is to enhance the sddl2 compiler so it can produce code compatible with the sddl2 virtual machine.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

- Added `bool optimize` field to `Compiler::Options` (defaults to `true` so existing behavior is unchanged).
- Added `with_optimization(bool)` and `with_no_optimization()` builder methods following the existing Options pattern.
- Made the optimization pass in `Compiler::compile()` conditional on this flag, passing the unoptimized AST directly to codegen when disabled.

Differential Revision: D95084139
Summary:

Extend the optimizer to mark ASTVar nodes when they are the final
value-reference to their variable. This metadata allows (1) the optimizer to remove variable assignments if they are never referenced (2) codegen to release variable storage after its last use.

Differential Revision: D94932644
Summary:

# Stack
The purpose of this stack is to enhance the sddl2 compiler so it can produce code compatible with the sddl2 virtual machine.

# Diff
This diff adds register-based variable operations (`var.store`, `var.load`, `var.clear`) to the SDDL2 VM. These enable saving and restoring intermediate values across stack operations without complex stack manipulation.

- Defined `var.store` (0x0001), `var.load` (0x0002), and `var.clear` (0x0003) opcodes in the VAR family.
- Implemented a 256-register `SDDL2_Var_registers` register file that tracks occupancy, so loading from an uninitialized or cleared register produces a clear error.
- Implemented the three VM operations in `sddl2_vm.c` and wired them into the interpreter dispatch loop.
- Regenerated assembler opcode tables and disassembly headers.
- Updated assembly opcode documentation.

Differential Revision: D94396847
Summary:

# Stack
The purpose of this stack is to enhance the sddl2 compiler so it can produce code compatible with the sddl2 virtual machine.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

- Added `bool optimize` field to `Compiler::Options` (defaults to `true` so existing behavior is unchanged).
- Added `with_optimization(bool)` and `with_no_optimization()` builder methods following the existing Options pattern.
- Made the optimization pass in `Compiler::compile()` conditional on this flag, passing the unoptimized AST directly to codegen when disabled.

Differential Revision: D95084139
daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 3, 2026
Summary:

# Stack
The purpose of this stack is to enhance the sddl2 compiler so it can produce code compatible with the sddl2 virtual machine.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

Differential Revision: D95084139
daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 5, 2026
Summary:

# Stack
The goal of this stack is to add support for variable assignments and assume operations to SDDL2.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

Differential Revision: D95084139
daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 5, 2026
Summary:

# Stack
The goal of this stack is to add support for variable assignments and assume operations to SDDL2.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

Differential Revision: D95084139
daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 5, 2026
Summary:
Pull Request resolved: facebook#458

# Stack
The goal of this stack is to add support for variable assignments and assume operations to SDDL2.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

Differential Revision: D95084139
daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 5, 2026
Summary:

# Stack
The goal of this stack is to add support for variable assignments and assume operations to SDDL2.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

Differential Revision: D95084139
daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 5, 2026
Summary:

# Stack
The goal of this stack is to add support for variable assignments and assume operations to SDDL2.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

Differential Revision: D95084139
daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 5, 2026
Summary:
Pull Request resolved: facebook#458

# Stack
The goal of this stack is to add support for variable assignments and assume operations to SDDL2.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

Differential Revision: D95084139
daniellerozenblit added a commit to daniellerozenblit/openzl-1 that referenced this pull request Mar 5, 2026
Summary:
Pull Request resolved: facebook#458

# Stack
The goal of this stack is to add support for variable assignments and assume operations to SDDL2.

# Diff
This diff adds a `with_optimization()` / `with_no_optimization()` option to `Compiler::Options`, allowing callers to skip the optimizer pass entirely.

Differential Revision: D95084139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant