lua-users home
lua-l archive

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

Mark Hamburg wrote:
> Is the NaN-based representation portable back to the stock Lua
> distribution particularly if one restricts the target to 32-bit
> machines? The memory bandwidth win seems like a fairly
> straightforward performance gain if the representation doesn't
> pose too many other challenges.

I'm not sure you'd be able to see much of a difference, except for
big arrays. The dispatch/decode overhead in the Lua interpreter
might shadow the effects.

But AFAIR it's not that much code that needs to be changed. Split
the internal and external tag representation and adjust the macros
that deal with tagged values. You'll need to add explicit tests
for numbers in a couple places, instead of a switch () on the tag.

And, most importantly, canonicalize all NaNs at the ingress points
to the VM! For Lua that's only lua_pushnumber, string-to-number
conversions and maybe the bytecode loader. Although I've mentioned
this important measure before, WebKit apparently omitted it and
that was the key ingredient of the iPhone jailbreak.