[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re: NaN packing for TValue
- From: Yura Sokolov <funny.falcon@...>
- Date: Thu, 24 Feb 2011 00:11:14 +0300
Just updated patch. Now it don't use anonymous structs and unions.
While work on patch I use some simplification of table struct declaration
(actually remove TKey struct entirely and use of setobj2t macro in one
place)
(patch included into mail)
-10.01.-28163 22:59, Tony Finch пишет:
On Wed, 23 Feb 2011, Yura Sokolov wrote:
I just made patch for NaN packing of TValue on x86 machines (as in luajit2).
http://lua-users.org/files/wiki_insecure/power_patches/5.1/pack_value.patch
Nice!
I note that your TValuefields macro relies on a gcc extension for
anonymous structures.
Tony.
diff --git a/src/lobject.c b/src/lobject.c
index 4ff5073..08515e9 100644
--- a/src/lobject.c
+++ b/src/lobject.c
@@ -24,7 +24,7 @@
-const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
+const TValue luaO_nilobject_ = {LUA_TVALUE_NIL};
/*
diff --git a/src/lobject.h b/src/lobject.h
index f1e447e..abb088d 100644
--- a/src/lobject.h
+++ b/src/lobject.h
@@ -73,6 +73,7 @@ typedef union {
typedef struct lua_TValue {
TValuefields;
} TValue;
+#define LUA_TVALUE_NIL {NULL}, LUA_TNIL
/* Macros to test type */
@@ -320,18 +321,10 @@ typedef union Closure {
** Tables
*/
-typedef union TKey {
- struct {
- TValuefields;
- struct Node *next; /* for chaining */
- } nk;
- TValue tvk;
-} TKey;
-
-
typedef struct Node {
TValue i_val;
- TKey i_key;
+ TValue i_key;
+ struct Node *next;
} Node;
diff --git a/src/ltable.c b/src/ltable.c
index ec84f4f..dc794fe 100644
--- a/src/ltable.c
+++ b/src/ltable.c
@@ -73,8 +73,9 @@
#define dummynode (&dummynode_)
static const Node dummynode_ = {
- {{NULL}, LUA_TNIL}, /* value */
- {{{NULL}, LUA_TNIL, NULL}} /* key */
+ {LUA_TVALUE_NIL}, /* value */
+ {LUA_TVALUE_NIL}, /* key */
+ NULL /* next */
};
@@ -422,7 +423,7 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
mp = n;
}
}
- gkey(mp)->value = key->value; gkey(mp)->tt = key->tt;
+ setobj2t(L, gkey(mp), key);
luaC_barriert(L, t, key);
lua_assert(ttisnil(gval(mp)));
return gval(mp);
diff --git a/src/ltable.h b/src/ltable.h
index f5b9d5e..de05cf9 100644
--- a/src/ltable.h
+++ b/src/ltable.h
@@ -11,11 +11,11 @@
#define gnode(t,i) (&(t)->node[i])
-#define gkey(n) (&(n)->i_key.nk)
+#define gkey(n) (&(n)->i_key)
#define gval(n) (&(n)->i_val)
-#define gnext(n) ((n)->i_key.nk.next)
+#define gnext(n) ((n)->next)
-#define key2tval(n) (&(n)->i_key.tvk)
+#define key2tval(n) (&(n)->i_key)
LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);