runtime
POLYMORPHIC BYTECODE LLD
Bytecode, VM, polymorphism, and execution internals.
Context Rail
Tags and Themes
On This Page
Polymorphic Bytecode LLD (Current + Roadmap)
1. Purpose
This LLD explains the real status of Mutant polymorphic bytecode support and the safe path to expand it.
2. Current Implementation
Core files:
compiler/polymorphic.gocompiler/compiler.gocompiler/polymorphic_test.gocompiler/opcode_mapping_test.go
Current behavior:
- Polymorphic engine is integrated into compiler flow.
- Mutation level and seed controls are wired via CLI compile paths.
- Polymorphic marker/tagging is applied for non-zero mutation levels.
- Advanced mutation transforms are currently gated by config in
getConfig().
3. Why transforms are gated
Reason: safety and compatibility.
- Transforming instruction streams needs strict operand-boundary correctness.
- Opcode remap needs reversible and VM-safe decoding strategy.
- Constant pool remap needs complete reference correctness across nested compiled functions.
4. Current CLI Controls
Supported controls in compile/release workflows:
-mutation <0-10>-seed <int64>
These controls are available today, even while advanced transforms remain constrained.
5. Design for Full Activation
Phase 1: Safe transform primitives
- Enable and validate instruction-boundary aware NOP insertion.
- Ensure no semantic change under nested control-flow scenarios.
Phase 2: Constant remap hardening
- Verify all constant references update correctly in root and nested functions.
- Add stress tests on closures and composite literals.
Phase 3: Opcode remap protocol
- Define reversible mapping strategy.
- Add robust VM compatibility handling.
- Add fallback behavior for unsupported map versions.
6. Validation Strategy
Unit tests:
- semantic equivalence tests for transformed bytecode
- deterministic seed reproducibility tests
- marker detection and stripping tests
Integration tests:
- compile-run parity tests across mutation levels
- cross-platform test matrix for deterministic behavior
7. Diagram
8. Student Takeaway
Polymorphism in this project is not all-or-nothing.
- Framework is integrated now.
- Some advanced transforms are intentionally gated for correctness and stability.
- The roadmap is about safely increasing mutation depth without breaking VM semantics.