Skip to content

Commit

Permalink
Table, hashing, meta-table (tagged method).
Browse files Browse the repository at this point in the history
  • Loading branch information
middlefeng committed Oct 22, 2013
1 parent 0489b61 commit 6a2199a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lgc.c
Expand Up @@ -16,7 +16,9 @@ General Process
6. A current-white object MUST be unreachable at "atomic" step because at that
point all reachable and some just-becoming-unreachable objects have all been marked.
7. At "atomic" step, all current-white objects are added to the sweep lists, and
then they become other-white because the while flag is flipped.
then they become other-white because the while flag is flipped. After "atomic" step,
all "other-white" objects are guranteed to be unreachable until the next "pause"
step.



Expand Down Expand Up @@ -80,6 +82,10 @@ isdeadm(ow,m)
Ture if "m" has "other_than_current_white" marked.


linktable(h,p)
================================================================================
Link table "h" on to list "p". The *next* pointer is h->gclist.


static GCObject *udata2finalize (global_State *g)
================================================================================
Expand Down
13 changes: 13 additions & 0 deletions lobject.h
Expand Up @@ -34,6 +34,19 @@ GCObject
-------------------------------------------------


-------------------------------------------------
GCObject* next |
lu_byte tt | Common header
lu_byte marked |
-------------------------------------------------
lu_byte extra |
unsigned int hash | tsv
size_t len |
-------------------------------------------------






UpVal
Expand Down
40 changes: 40 additions & 0 deletions ltable.c
Expand Up @@ -8,3 +8,43 @@ t: table
Return the hashed slot corresponding to "n" in table "t".




hashmod(t,n)
==========================================================================
This method differs from "hashpow2()" in that the underlying algorithm of
moduling is the ordinary "C" moduling rather than a bit-manipulating one optimized
for 2-base-powered size of "t".

"n" is actually moduled by size of t minues 1, rather than size of t.





const TValue *luaH_getstr (Table *t, TString *key)
==========================================================================
Get value if "key" is a short-string.




static Node *mainposition (const Table *t, const TValue *key)
==========================================================================
Get the main hash-ed position for "key".




static Node *hashnum (const Table *t, lua_Number n)
==========================================================================
Return the main hash-ed position for "n".




luai_hashnum(i,n)
==========================================================================
Compute the hashcode of "n" and put it to "i".


5 changes: 5 additions & 0 deletions ltm.c
@@ -0,0 +1,5 @@



const TValue *luaT_gettm (Table *events, TMS event, TString *ename)
======================================================================
20 changes: 20 additions & 0 deletions lua.h
@@ -0,0 +1,20 @@


Basic Types
-----------------------------------------------------------
The enum of "basic types" is: LUA_T...
A "basic type" enum occupies only the right-most forth bits.
The fifth right-most bit represent the "sub-type":
- short/long string
- c/Lua closure
...
The seventh right-most bit represent if the type is collectable.


/*
** tags for Tagged Values have the following use of bits:
** bits 0-3: actual tag (a LUA_T* value)
** bits 4-5: variant bits
** bit 6: whether value is collectable
*/

0 comments on commit 6a2199a

Please sign in to comment.