4 ms·
To be clear, what optimization are you proposing? Replacing "JMPNZ true" with "JMP"? So every time a loop is compiled (which by default is every request) there
by ajanuary 12y ago
To be clear, what optimization are you proposing? Replacing "JMPNZ true" with "JMP"?
So every time a loop is compiled (which by default is every request) there is the added overhead of "if opcode is JMPNZ and the first operand is the literal true, replace opcode with JMP and remove first operand".
This saves the "if operand is non-zero" check for all iterations of loops where the first operand is a constant "true".
Which means you've increased the cost of every loop on every request by a constant amount to decrease the cost of each iteration of "while (\true)".
Obviously you'd have to measure the actual costs, but it doesn't seem worth it to me.
- masklinn 12y ago> To be clear, what optimization are you proposing? Replacing "JMPNZ true" with "JMP"? Yup. And remove FETCH_CONSTANT as well. > So every time a loop is compiled (which by default is every request) there is the added overhead of "if opcode is JMPNZ and the first operand is the literal true, replace opcode with JMP and remove first operand". Sure, or perform it while compiling the bytecode itself. > This saves the "if operand is non-zero" check for all iterations of loops where the first operand is a constant "true". It also saves loading the operand, because I expect most PHP code trying to loop forever doesn't use `\true`, and it can be applied to `for(;;)` to boot (a pretty common construct for those coming from C). > Obviously you'd have to measure the actual costs Obviously.