Re: question about upvalue bytecode encoding

  • From: Richard Hundt <richardhundt@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 26 Mar 2014 00:19:54 +0100

On 3/25/14 11:44 PM, Francesco Abbate wrote:
> I know that there is a difference between direct upvalues (local
> variables of the enclosing functions) and indirect upvalues but the
> 0x8000 vs 0xc000 is unclear to me.
>
It's just PROTO_UV_LOCAL | PROTO_UV_IMMUTABLE vs PROTO_UV_LOCAL. During
`bcemit_store` the upvalue gets a flag set which records that it's been
written to, in which case you just have 0x8000, otherwise it's
immutable. My guess is that LuaJIT optimizes cases where an upvalue is
only read and not written to. I was just taking a shortcut by not
including this optimization, but it should be easy enough to detect and
add these cases.

Other related posts: