Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Are there too many OpCall here? #615

Unanswered
zhuliquan asked this question in General
Discussion options

I find there are many type of OpCall OpCode in below code.

expr/vm/opcodes.go

Lines 55 to 59 in 7772ea0

OpCall0
OpCall1
OpCall2
OpCall3
OpCallN

I read the code of cmpiler.go as below:

expr/compiler/compiler.go

Lines 157 to 171 in 7772ea0

func (c *compiler) emitFunction(fn *builtin.Function, argsLen int) {
switch argsLen {
case 0:
c.emit(OpCall0, c.addFunction(fn.Name, fn.Func))
case 1:
c.emit(OpCall1, c.addFunction(fn.Name, fn.Func))
case 2:
c.emit(OpCall2, c.addFunction(fn.Name, fn.Func))
case 3:
c.emit(OpCall3, c.addFunction(fn.Name, fn.Func))
default:
c.emit(OpLoadFunc, c.addFunction(fn.Name, fn.Func))
c.emit(OpCallN, argsLen)
}
}

I got that you want to generate special bytecode based on the number of arguments of the function. However, OpCallN is also can cover the OpCall0 to the OpCall3. Now, is it a reasonable choice to delete those OpCode (i.e. OpCall0 to OpCall3) now?
You must be logged in to vote

Replies: 1 comment

Comment options

All of those opcodes are needed. OpCall1-3 is a special fast call type. OpCallN is a generic fallback.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /