optimization for function call without paremters

php.internals

Lin Yo-An

10 years ago
Hi Dmitry, I found that INIT_FCALL doesn't use opline->result.var and DO_ICALL doesn't use op1 or op2. The original purpose of separating these two op was for sending parameters. However, if a function doesn't need parameters and it's an internal function, I think the operation could be merged into INIT_FCALL. So I guess we can do this below to reduce one bytecode for each function call without parameters: if (opline->extended_value == 0) { // call the function directly and store the value in the result. } Your thoughts? Best Regards, Yo-An Lin

Lin Yo-An

10 years ago
I think this optimization could be done by two approach: 1. Add another FCALL op, which init a function call and call that function directly for functions without parameters. 2. Let the original INIT_FCALL support "call function when the number of parameter == 0" On Fri, Apr 15, 2016 at 5:27 PM, Lin Yo-An <cornelius.howl@gmail.com> wrote:
> Hi Dmitry, > > > I found that INIT_FCALL doesn't use opline->result.var and DO_ICALL > doesn't use op1 or op2. The original purpose of separating these two op was > for sending parameters. > > However, if a function doesn't need parameters and it's an internal > function, I think the operation could be merged into INIT_FCALL. > > So I guess we can do this below to reduce one bytecode for each function > call without parameters: > > if (opline->extended_value == 0) { > // call the function directly and store the value in the result. > } > > Your thoughts? > > > > > Best Regards, > > Yo-An Lin >
-- Best Regards, Yo-An Lin