News for hackers. Stuff that matters.
Re:PHP: why GOTO instead of recursion? by masklinn on Tuesday September 23, 2014 @02:05PM (#8356953)
> 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.

There are no comments on this comment yet.