lua-users home
lua-l archive

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

Friday, July 14, 2006, 12:15:07 AM, Peter Loveday wrote:

> Rather than requiring a larger instruction word (and be incompatible with
> any libraries that contain 'compiled' code rather than text), I have added
> an OP_PRELOADK, which loads a prefix number for the high-bits of the
> constant index.  This is only used if the constant table reference would
> exceed the Bx field size.  Then the OP_LOADK will use this prefix value
> shifted up by SIZE_Bx, or'ed with its normal constant index.

Instead, why not add OP_POSTLOADK that modifies (e.g., ORs) the
value initialized by OP_LOADK with some additional bits. Then you
wouldn't need a "prefix number" variable.

> I have added a varable to the lua_state to keep this prefix between opcodes,
> but I am a little concerned about the non-atomicity of this.  While its
> always the case that an OP_PRELOADK will be followed by an OP_LOADK, if
> somehow (maybe with a hook), execution were yielded in-between my 
> OP_PRELOADK and the OP_LOADK instructions, could this cause an issue?  or is
> the lua_state not shared between co-routines?

Without the "prefix number" variable there would be no problem.