Experiment: Estimate opcode sizes #21
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Premise: reduce the size of VM opcode encoding would make the VM faster.
The goal of this branch is to estimate by how much opcode size shrinks with various strategies. It's not meant to be merged, does not actually implement the strategies.
Most of the changes were made to find accurately which operands are used by each opcode handler.
Strategy 1: Slim ops
Strategy 2: Variable arity ops
handlers[handler_id]
)Example for an opcode needing op1, op2, op1_type, result:
zend_vm_gen.php
could generate structs like that for for every opcode and each size, so handlers can access fields as usual as long as the names match, and fields are properly aligned.We could also generate decoder functions for each handler and size (
decode(void *opaque_opline, zend_op *op1, zend_op *op2, ...)
) so that slow paths outside of handlers can decode compressed oplines. Types can be inferred from the handler (minus the OBSERVER case).Results
Results on Symfony Demo (numbers are the total size, in bytes, of compiled opcodes) :
When not forcing OBSERVER handlers to fetch the original op:
Notes: