From de32d56b85ed9c645bc96c78ba5dd8f73af844dc Mon Sep 17 00:00:00 2001 From: luigi Date: Wed, 5 Mar 2014 18:14:21 +0000 Subject: [PATCH] sync experimental with trunk -- added patches for standard lua and standard luajit git-svn-id: https://foundry.supelec.fr/svn/luatex/trunk@4848 0b2b3880-5936-4365-a048-eb17d2e5a6bf --- .../libs/lua52/lua-5.2.3-PATCHES/patch-02-lstring | 10 +++ .../luajit/LuaJIT-2.0.2-PATCHES/patch-04-lj_str | 82 ++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 source/libs/lua52/lua-5.2.3-PATCHES/patch-02-lstring create mode 100644 source/libs/luajit/LuaJIT-2.0.2-PATCHES/patch-04-lj_str diff --git a/source/libs/lua52/lua-5.2.3-PATCHES/patch-02-lstring b/source/libs/lua52/lua-5.2.3-PATCHES/patch-02-lstring new file mode 100644 index 000000000..36eb9c3f7 --- /dev/null +++ b/source/libs/lua52/lua-5.2.3-PATCHES/patch-02-lstring @@ -0,0 +1,10 @@ +diff -ur lua-5.2.3.orig/src/lstring.c lua-5.2.3/src/lstring.c +--- lua-5.2.3.orig/src/lstring.c2014-03-05 17:53:51.829468849 +0100 ++++ lua-5.2.3/src/lstring.c2014-03-03 16:20:33.000000000 +0100 +@@ -23,7 +23,7 @@ + ** compute its hash + */ + #if !defined(LUAI_HASHLIMIT) +-#define LUAI_HASHLIMIT5 ++#define LUAI_HASHLIMIT6 + #endif diff --git a/source/libs/luajit/LuaJIT-2.0.2-PATCHES/patch-04-lj_str b/source/libs/luajit/LuaJIT-2.0.2-PATCHES/patch-04-lj_str new file mode 100644 index 000000000..ad8a56fe4 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.2-PATCHES/patch-04-lj_str @@ -0,0 +1,82 @@ +diff -ur LuaJIT-2.0.2.orig/src/lj_str.c LuaJIT-2.0.2/src/lj_str.c +--- LuaJIT-2.0.2.orig/src/lj_str.c2014-03-01 10:22:27.000000000 +0100 ++++ LuaJIT-2.0.2/src/lj_str.c2014-03-03 22:56:57.000000000 +0100 +@@ -90,6 +90,8 @@ + g->strhash = newhash; + } + ++#define cast(t, exp)((t)(exp)) ++int luajitex_choose_hash_function = 0; + /* Intern a string and return string object. */ + GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) + { +@@ -98,27 +100,44 @@ + GCobj *o; + MSize len = (MSize)lenx; + MSize a, b, h = len; ++ size_t step ; ++ size_t l1 ; + if (lenx >= LJ_MAX_STR) + lj_err_msg(L, LJ_ERR_STROV); + g = G(L); ++ ++ if (len==0) ++ return &g->strempty; ++ if (luajitex_choose_hash_function==0) { ++ /* Lua 5.1.5 hash function */ ++ /* for 5.2 max methods we also need to patch the vm eq */ ++ step = (len>>6)+1; /* if string is too long, don't hash all its chars Was 5, we try 6*/ ++ for (l1=len; l1>=step; l1-=step) /* compute hash */ ++ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); ++ } else { ++ /* LuaJIT 2.0.2 hash function */ + /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */ +- if (len >= 4) { /* Caveat: unaligned access! */ +- a = lj_getu32(str); +- h ^= lj_getu32(str+len-4); +- b = lj_getu32(str+(len>>1)-2); +- h ^= b; h -= lj_rol(b, 14); +- b += lj_getu32(str+(len>>2)-1); +- } else if (len > 0) { +- a = *(const uint8_t *)str; +- h ^= *(const uint8_t *)(str+len-1); +- b = *(const uint8_t *)(str+(len>>1)); +- h ^= b; h -= lj_rol(b, 14); +- } else { +- return &g->strempty; +- } +- a ^= h; a -= lj_rol(h, 11); +- b ^= a; b -= lj_rol(a, 25); +- h ^= b; h -= lj_rol(b, 16); ++ if (len >= 4) { /* Caveat: unaligned access! */ ++ a = lj_getu32(str); ++ h ^= lj_getu32(str+len-4); ++ b = lj_getu32(str+(len>>1)-2); ++ h ^= b; h -= lj_rol(b, 14); ++ b += lj_getu32(str+(len>>2)-1); ++ } else if (len > 0) { ++ a = *(const uint8_t *)str; ++ h ^= *(const uint8_t *)(str+len-1); ++ b = *(const uint8_t *)(str+(len>>1)); ++ h ^= b; h -= lj_rol(b, 14); ++ } else { ++ /* Already done, kept for reference */ ++ return &g->strempty; ++ } ++ a ^= h; a -= lj_rol(h, 11); ++ b ^= a; b -= lj_rol(a, 25); ++ h ^= b; h -= lj_rol(b, 16); ++ } ++ ++ + /* Check if the string has already been interned. */ + o = gcref(g->strhash[h & g->strmask]); + if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { +@@ -143,7 +162,6 @@ + } + } + /* Nope, create a new string. */ +- printf("lj_str_new: create a new string for %s, l=%d\n",str,lenx); + s = lj_mem_newt(L, sizeof(GCstr)+len+1, GCstr); + newwhite(g, s); + s->gct = ~LJ_TSTR; -- 2.11.4.GIT