[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A question of type assertion
- From: Dibyendu Majumdar <mobile@...>
- Date: Tue, 10 Nov 2015 11:25:57 +0000
On Tuesday, 10 November 2015, Roberto Ierusalimschy <email@example.com> 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)
> 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!