[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: how to load a very large table with more than 2^18 literal strings?
- From: Joshua Jensen <jjensen@...>
- Date: Sat, 12 Sep 2009 08:08:23 -0600
----- Original Message -----
From: Mike Pall
Date: 9/11/2009 8:14 PM
I run into the table size problem often enough to be annoying. Is it
possible to apply your work in LJ2 as a standard Lua 5.1 patch?
But there is. I'm not sure whether I've mentioned this, but LJ2
puts no limit (other than memory size) on the number of constant
keys/values of a table constructor.
The parser stores all constant key/value pairs into a lazily
allocated template table. It only emits store instructions for
variable keys or values. If a template table has been created,
it's put into the constant section. The table creation instruction
TNEW is then patched to the table duplication instruction TDUP.
Note that neither "x", "y", nor "foo" appear in the bytecode or
the constants, because they are only part of the template table.
Ah, before I forget: duplicating a large table of constants is of
course a lot faster than filling it by executing tons of bytecodes.