dillon1000/react
Commit
Browse files [rust] New data model for HIR
This change is motivated by starting to explore porting EnterSSA to Rust. It's a good medium complexity pass and quickly demonstrates why a direct port of our existing data model and algorithms won't work so well. For examples just these first lines at the top of the transform create multiple references to the function body/blocks: https://github.com/facebook/react-forget/blob/58da89888eabde17ede649d348b307ee01fc15e1/forget/packages/babel-plugin-react-forget/src/SSA/EnterSSA.ts#L230-L231 But more generally it's always felt wrong that instructions have an LValue that isn't really used. So here i'm exploring making operands a newtype index into a single instructions array (shared for the entire function), and using different types for identifier references in SetLocal and LoadLocal. Incidentally this also declutters the printed HIR quite a bit. I'm not going to land this until i actually finish enter_ssa() and some other passes. We definitely need to balance fidelity to the existing code (to facilitate porting) with using idiomatic Rust (to facilitate porting in the sense of not fighting the borrow checker).
Changed paths22 files
First-parent comparisoncompiler/forget/Cargo.lock ModifiedM compiler/forget/Cargo.toml ModifiedM compiler/forget/crates/build-hir/src/build.rs ModifiedM compiler/forget/crates/build-hir/src/builder.rs ModifiedM compiler/forget/crates/build-hir/src/error.rs ModifiedM compiler/forget/crates/fixtures/tests/fixtures_test.rs ModifiedM compiler/forget/crates/fixtures/tests/snapshots/[email protected] ModifiedM compiler/forget/crates/fixtures/tests/snapshots/[email protected] ModifiedM compiler/forget/crates/fixtures/tests/snapshots/[email protected] ModifiedM compiler/forget/crates/fixtures/tests/snapshots/[email protected] ModifiedA compiler/forget/crates/hir-ssa/Cargo.toml AddedA compiler/forget/crates/hir-ssa/README.md AddedA compiler/forget/crates/hir-ssa/src/enter.rs AddedA compiler/forget/crates/hir-ssa/src/leave.rs AddedA compiler/forget/crates/hir-ssa/src/lib.rs AddedA compiler/forget/crates/hir-ssa/src/minimize_phis.rs AddedM compiler/forget/crates/hir/src/basic_block.rs ModifiedM compiler/forget/crates/hir/src/function.rs ModifiedM compiler/forget/crates/hir/src/id_types.rs ModifiedM compiler/forget/crates/hir/src/instruction.rs ModifiedM compiler/forget/crates/hir/src/print.rs ModifiedM compiler/forget/crates/hir/src/terminal.rs ModifiedPatch
Files changed
Rendering syntax-highlighted changes…