lua-users home
lua-l archive

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


I just integrated work2 a little over a week ago. I guess I now get to go
pick up work3. Doing such integrations forces me to review our list of
patches to Lua and I thought it might be worth sharing that list here.


* We added a linedefinedend field to lua_Debug. We added a lineDefinedEnd to
Proto. (The difference in capitalization matches the difference between
linedefined and lineDefined.) We maintain these fields at essentially the
same places as the definition start fields.


* In luaD_throw, we set L->status = errcode before calling the panic
function.


* We patched luaC_checkGC so that it doesn't do anything while executing a
hook proc. This was to deal with recursion issues in work0 while executing
__gc metamethods

#define luaC_checkGC(L) { if (L->allowhook && G(L)->totalbytes >=
G(L)->GCthreshold) \
    luaC_step(L); }


* We modified luaL_argerror so that it deals with the case of not having a
stack frame.

  if(!lua_getstack(L, 0, &ar)) {
      return luaL_error(L, "bad value at stack index #%d (%s)",
                            narg, extramsg);
  }

This replaces the call to lua_getstack.


* We cut the threshold computation in the GC so that it uses:

  g->GCthreshold = g->estimate + (g->estimate/8);

This is in an effort to keep memory consumption down. I have noticed that
memory consumption runs a little high so we may want to change this.


* We added a __methods metatable entry that is just like __index but is only
accessed on method calls (OP_SELF). The logic it uses is that when doing
method lookup where we would have looked for __index, we now look for
__methods and then __index.


* We've added a tag field to full userdata. This gets used so that we can
recognize bridged Objective-C objects without doing a metatable test. The
tag is a byte and we have to carefully manage the space of IDs, but for
items where we want fast recognition it seems useful. I don't have any
profiling data to back up how useful.


Of these, the ones I would advocate for inclusion in the main Lua
distribution are:

* Track end of definition lines along with start of definition.

* Have luaD_throw set the status for the state before calling the panic
function.

* Fix luaL_argerror to deal with the case where there is no stack frame.

* Fix in some way the recursion problem in the GC when processing __gc
metamethods. Checking L->allowhook seems like a reasonable approach.

* Provide an option in luaconf.h to set the rate at which the GCThreshold
grows. It could be something like:

    g->GCthreshold = g->estimate + ( g->estimate / GC_GROWTH_FACTOR );

Higher values of GC_GROWTH_FACTOR result in slower growth. (A better name to
reflect that relationship might be in order.)


I have mixed feelings about tagging userdata and about the __methods
metatable entry. Both certainly help speed the bridge between Lua and native
code, but I don't know by how much net effect they have. The __methods entry
also helps catch accidental use of the . operator in method calls.

Mark