summaryrefslogtreecommitdiff
path: root/Build/source/libs/luajit/TLPATCHES/patch-05-LuaJITTeX
blob: 884d3392bf7acfbd897fe7c5d731e4052d106276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
diff -bur LuaJIT-src-orig/src/lj_def.h LuaJIT-src/src/lj_def.h
--- LuaJIT-src-orig/src/lj_def.h	2016-03-07 09:43:42.728069718 +0100
+++ LuaJIT-src/src/lj_def.h	2016-03-07 12:23:43.327910115 +0100
@@ -66,7 +66,7 @@
 #define LJ_MAX_BCINS	(1<<26)		/* Max. # of bytecode instructions. */
 #define LJ_MAX_SLOTS	250		/* Max. # of slots in a Lua func. */
 #define LJ_MAX_LOCVAR	200		/* Max. # of local variables. */
-#define LJ_MAX_UPVAL	60		/* Max. # of upvalues. */
+#define LJ_MAX_UPVAL	249		/* Max. # of upvalues. */
 
 #define LJ_MAX_IDXCHAIN	100		/* __index/__newindex chain limit. */
 #define LJ_STACK_EXTRA	(5+2*LJ_FR2)	/* Extra stack space (metamethods). */

diff -bur LuaJIT-src-orig/src/lj_str.c LuaJIT-src/src/lj_str.c
--- LuaJIT-src-orig/src/lj_str.c	2016-03-07 09:43:42.696069718 +0100
+++ LuaJIT-src/src/lj_str.c	2016-03-07 12:25:22.031908474 +0100
@@ -118,6 +118,16 @@
   g->strhash = newhash;
 }
 
+/*
+** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to
+** compute its hash
+*/
+#if !defined(LUAI_HASHLIMIT)
+#define LUAI_HASHLIMIT		5
+#endif
+
+#define cast(t, exp)	((t)(exp))
+int luajittex_choose_hash_function = 0 ; 
 /* Intern a string and return string object. */
 GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx)
 {
@@ -126,9 +136,22 @@
   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 (luajittex_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>>LUAI_HASHLIMIT)+1;  /* if string is too long, don't hash all its chars */
+    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);
@@ -142,11 +165,15 @@
     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)) {

diff -bur LuaJIT-src-orig/src/lj_err.c LuaJIT-src/src/lj_err.c
--- LuaJIT-src-orig/src/lj_err.c	2016-03-15 12:06:56.844436191 +0100
+++ LuaJIT-src/src/lj_err.c	2016-03-15 11:58:30.000000000 +0100
@@ -310,7 +310,6 @@
 #define _US_FORCE_UNWIND                8
 
 typedef struct _Unwind_Control_Block _Unwind_Control_Block;
-typedef struct _Unwind_Context _Unwind_Context;
 
 struct _Unwind_Control_Block {
   uint64_t exclass;