Increasing max UPVALUES

classic Classic list List threaded Threaded
5 messages Options
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Increasing max UPVALUES

Hi
  One of our users is getting surprising failures in compilation
because he's written a function that accesses 12 global variables:
lua: /mmc/autorun.lua:53: function at line 45 has more than 10 upvalues

Rather than forcing people to learn about closures and local
variablesa and tables and stuff to work around this limit, is it OK if
I increase src/lua/luaconf.h::LUAI_MAXUPVALUES from 10 to the same
value as standard Lua, 60 so that any code that works in standard Lua
5.1.4 will also work in eLua?

  In Lua 4, this constant used to have an impact on the C stack usage,
but now it only requires 2 bytes of RAM per value during the parsing
of a function, which is just an extra 100 bytes total during parsing,
or 200 if you have functions within functions.

Bogdan, since you hold the sceptre of power? :)

     M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: Increasing max UPVALUES

Hi,

On Wed, Oct 5, 2011 at 7:30 PM, Martin Guy <[hidden email]> wrote:
Hi
 One of our users is getting surprising failures in compilation
because he's written a function that accesses 12 global variables:
lua: /mmc/autorun.lua:53: function at line 45 has more than 10 upvalues

Rather than forcing people to learn about closures and local
variablesa and tables and stuff to work around this limit, is it OK if
I increase src/lua/luaconf.h::LUAI_MAXUPVALUES from 10 to the same
value as standard Lua, 60 so that any code that works in standard Lua
5.1.4 will also work in eLua?

 In Lua 4, this constant used to have an impact on the C stack usage,
but now it only requires 2 bytes of RAM per value during the parsing
of a function, which is just an extra 100 bytes total during parsing,
or 200 if you have functions within functions. 

Bogdan, since you hold the sceptre of power? :)

There's no universal answer to this. I decreased that value as a result of getting "out of memory" errors on platforms with little RAM. Platforms with more RAM, of course, shouldn't need to worry about this. So I'd make it configurable, either as a command line macro (-DPLATFORM_UPVALUES=xxx) or (preferred) in platform_conf.h (#define PLATFORM_UPVALUES xxx). Then, in luaconf.h:

#ifdef PLATFORM_UPVALUES
#define LUAI_MAXUPVALUES PLATFORM_UPVALUES
#else
#define LUAI_MAXUPVALUES 10 // since this is the current default for all platforms
#endif

Best,
Bogdan


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: Increasing max UPVALUES

On 5 October 2011 18:47, Bogdan Marinescu <[hidden email]> wrote:
> There's no universal answer to this. I decreased that value as a result of
> getting "out of memory" errors on platforms with little RAM. Platforms with
> more RAM, of course, shouldn't need to worry about this. So I'd make it
> configurable, either as a command line macro (-DPLATFORM_UPVALUES=xxx) or
> (preferred) in platform_conf.h (#define PLATFORM_UPVALUES xxx). Then, in
> luaconf.h:

For a hundred bytes so much extra complexity?

Sorry, we have short times, and our company is looking at failing
economically if we don't get a product out onto the market.  Can we
shortcut the three-month discussions about every detail, which is
paralysing, and just do something now immediately wiki wiki short and
simple right now without complications?

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: Increasing max UPVALUES



On Thu, Oct 6, 2011 at 12:12 AM, Martin Guy <[hidden email]> wrote:
On 5 October 2011 18:47, Bogdan Marinescu <[hidden email]> wrote:
> There's no universal answer to this. I decreased that value as a result of
> getting "out of memory" errors on platforms with little RAM. Platforms with
> more RAM, of course, shouldn't need to worry about this. So I'd make it
> configurable, either as a command line macro (-DPLATFORM_UPVALUES=xxx) or
> (preferred) in platform_conf.h (#define PLATFORM_UPVALUES xxx). Then, in
> luaconf.h:

For a hundred bytes so much extra complexity?

Sorry, we have short times, and our company is looking at failing
economically if we don't get a product out onto the market.  Can we
shortcut the three-month discussions about every detail, which is
paralysing, and just do something now immediately wiki wiki short and
simple right now without complications?

Does my proposed solution really sound that complex to you? If so, go ahead and modify luaconf.h directly, we'll see how (if) this will affect the rest of our boards in the future.

Best,
Bogdan


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: Increasing max UPVALUES

Yes. Thanks.
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev