lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Tuesday, 10 November 2015, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> Come to think of it actually it could be a noop function - i.e. the
> function call would cause the code generator to insert type coercion
> operations but then the VM would recognise the noop function and do
> nothing. So I can imagine a function called cast() which is this magic
> noop function.
>
> local i: integer = cast(x[1])
>
> Would cause the code generator to emit TOINT opcode after calling the
> function cast(). But the VM would not call any function at all as it
> would recognize 'cast()' as noop.

What do you mean by "the VM" in this sentence? If the code generator can
recognize the noop funcion (so that it does not insert a call to it),
couldn't it recognize a cast function and inline it?

Yes you are right. I use the term VM to mean the interpreter and the generated JIT code; typically I first prove the concept in interpreter mode and then implement the JIT code generation.

I think though the VM will have a hard time recognising the special functions ... So maybe the parser needs to recognise and generate a new bytecode instruction. Not looking forward to that!

Regards
Dibyendu