aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--patches/sauer261
1 files changed, 228 insertions, 33 deletions
diff --git a/patches/sauer b/patches/sauer
index 23147f1d..ce846e85 100644
--- a/patches/sauer
+++ b/patches/sauer
@@ -1,27 +1,38 @@
diff --git a/patches/README b/patches/README
--- a/patches/README
+++ b/patches/README
-@@ -4,5 +4,5 @@
+@@ -4,7 +4,7 @@
ln -s patches .hg/patches
-After doing so, |hg qpush| sauer, and then running |python tests/runner.py| will run only sauer, using v8, and without optimizations or relooping.
+After doing so, |hg qpush| sauer, and then running |python tests/runner.py| will run only sauer, using v8, and without relooping.
+ Note to patch queue maintainer: You need to manually copy from .hg/patches into this directory, after |qrefresh|ing the patch.
+
diff --git a/src/settings.js b/src/settings.js
--- a/src/settings.js
+++ b/src/settings.js
-@@ -1,3 +1,4 @@
--OPTIMIZE = 1;
+@@ -1,5 +1,5 @@
+ OPTIMIZE = 1;
-RELOOP = 1;
-+OPTIMIZE = 1; // Safe
-+RELOOP = 0; // Very slow, perhaps neverending?
+-SAFE_HEAP = 0;
++RELOOP = 0;
++SAFE_HEAP = 1;
+ LABEL_DEBUG = 0;
-+
diff --git a/tests/runner.py b/tests/runner.py
--- a/tests/runner.py
+++ b/tests/runner.py
-@@ -143,7 +143,7 @@
+@@ -85,6 +85,7 @@
+ if output is not None and 'Traceback' in output: print output; assert (0) # 'generating JavaScript failed'
+ if DEBUG: print "\nGenerated JavaScript:\n\n===\n\n%s\n\n===\n\n" % output
+ # if not DEBUG:
++ raise Exception("Moshe");
+ js_output = timeout_run(Popen([JS_ENGINE] + JS_ENGINE_OPTS + [filename + '.o.js'] + args, stdout=PIPE, stderr=STDOUT), 20, 'Execution')
+ if output_nicerizer is not None:
+ js_output = output_nicerizer(js_output)
+@@ -148,7 +149,7 @@
print "Expected to NOT find '%s' in '%s'" % (value, string)
self.assertTrue(value not in string)
@@ -30,7 +41,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
int main()
-@@ -154,7 +154,7 @@
+@@ -159,7 +160,7 @@
'''
self.do_test(src, 'hello, world!')
@@ -39,7 +50,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
int global = 20;
-@@ -183,7 +183,7 @@
+@@ -188,7 +189,7 @@
'''
self.do_test(src, '*5,23,10,19,121,1,37,1,0*')
@@ -48,7 +59,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
int main()
-@@ -197,7 +197,7 @@
+@@ -202,7 +203,7 @@
'''
self.do_test(src, '*1,10,10.5,1,1.2339')
@@ -57,7 +68,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
int main()
-@@ -211,7 +211,7 @@
+@@ -216,7 +217,7 @@
'''
self.do_test(src, '*yes*')
@@ -66,7 +77,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
int main()
-@@ -225,7 +225,7 @@
+@@ -230,7 +231,7 @@
'''
self.do_test(src, '*3600*')
@@ -75,7 +86,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
#include <stdlib.h>
-@@ -240,7 +240,7 @@
+@@ -245,7 +246,7 @@
'''
self.do_test(src, '*4*wowie*too*76*', ['wowie', 'too', '74'], lambda x: x.replace('\n', '*'))
@@ -84,7 +95,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
int funcy(int x)
-@@ -255,7 +255,7 @@
+@@ -260,7 +261,7 @@
'''
self.do_test(src, '*72,90*')
@@ -93,13 +104,13 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
struct S
-@@ -297,13 +297,13 @@
+@@ -304,13 +305,13 @@
}
'''
- def test_mallocstruct(self):
+ def zzztest_mallocstruct(self):
- self.do_test(self.gen_struct_src.replace('{{gen_struct}}', '(S*)malloc(sizeof(S))').replace('{{del_struct}}', 'free'), '*51,62*')
+ self.do_test(self.gen_struct_src.replace('{{gen_struct}}', '(S*)malloc(ES_SIZEOF(S))').replace('{{del_struct}}', 'free'), '*51,62*')
- def test_newstruct(self):
+ def zzztest_newstruct(self):
@@ -110,7 +121,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
void alter(int *y)
-@@ -320,7 +320,7 @@
+@@ -327,7 +328,7 @@
'''
self.do_test(src, '*7*')
@@ -119,16 +130,25 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
struct worker_args {
-@@ -347,7 +347,7 @@
+@@ -372,7 +373,7 @@
'''
- self.do_test(src, '*960*')
+ self.do_test(src, '*1410,0*')
+
+- def test_assert(self):
++ def zzztest_assert(self):
+ src = '''
+ #include <stdio.h>
+ #include <assert.h>
+@@ -384,7 +385,7 @@
+ '''
+ self.do_test(src, 'Assertion failed: 1 == false')
- def test_class(self):
+ def zzztest_class(self):
src = '''
#include <stdio.h>
struct Random {
-@@ -376,7 +376,7 @@
+@@ -413,7 +414,7 @@
'''
self.do_test(src, '*0*')
@@ -137,7 +157,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
struct Parent {
-@@ -404,7 +404,7 @@
+@@ -441,7 +442,7 @@
'''
self.do_test(src, '*51,87,78,550,100,78,550*')
@@ -146,7 +166,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
struct Parent {
-@@ -423,7 +423,7 @@
+@@ -460,7 +461,7 @@
'''
self.do_test(src, '*11,74*')
@@ -155,7 +175,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
-@@ -464,7 +464,7 @@
+@@ -501,7 +502,7 @@
'''
self.do_test(src, '*97,15,3*')
@@ -164,7 +184,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
struct IUB {
-@@ -487,7 +487,7 @@
+@@ -524,7 +525,7 @@
'''
self.do_test(src, '*97,15,3,3029*')
@@ -173,25 +193,25 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
-@@ -509,7 +509,7 @@
+@@ -546,7 +547,7 @@
runner.assertEquals(filter(lambda line: 'Warning' in line, output.split('\n')).__len__(), 4)
self.do_test(src, '*5*', output_processor=check_warnings)
-- def test_memcpy(self):
-+ def zzztest_memcpy(self):
+- def test_sizeof(self):
++ def zzztest_sizeof(self):
src = '''
#include <stdio.h>
#include <string.h>
-@@ -532,7 +532,7 @@
+@@ -582,7 +583,7 @@
'''
- self.do_test(src, '*2,2,5,8,8*\n*8,8,5,8,8*')
+ self.do_test(src, '*2,2,5,8,8*\n*8,8,5,8,8*\n*7,2,6,990,7,2*')
- def test_llvmswitch(self):
+ def zzztest_llvmswitch(self):
src = '''
#include <stdio.h>
#include <string.h>
-@@ -557,7 +557,7 @@
+@@ -607,7 +608,7 @@
'''
self.do_test(src, '*96,97,98,101,101*')
@@ -200,7 +220,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
#include "stdarg.h"
-@@ -579,7 +579,7 @@
+@@ -629,7 +630,7 @@
'''
self.do_test(src, '*cheez: 10+24*')
@@ -209,7 +229,7 @@ diff --git a/tests/runner.py b/tests/runner.py
src = '''
#include <stdio.h>
#include <stdlib.h>
-@@ -596,13 +596,13 @@
+@@ -646,13 +647,13 @@
'''
self.do_test(src, '*cleaned*')
@@ -225,7 +245,7 @@ diff --git a/tests/runner.py b/tests/runner.py
results = [ (1,'''GG*ctt**tgagc**'''), (20,'''GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTT*cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg**tacgtgtagcctagtgtttgtgttgcgttatagtctatttgtggacacagtatggtcaaa**tgacgtcttttgatctgacggcgttaacaaagatactctg**'''),
(50,'''GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA*TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACAT*cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg**tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa**NtactMcSMtYtcMgRtacttctWBacgaa**agatactctgggcaacacacatacttctctcatgttgtttcttcggacctttcataacct**ttcctggcacatggttagctgcacatcacaggattgtaagggtctagtggttcagtgagc**ggaatatcattcgtcggtggtgttaatctatctcggtgtagcttataaatgcatccgtaa**gaatattatgtttatttgtcggtacgttcatggtagtggtgtcgccgatttagacgtaaa**ggcatgtatg**''') ]
for i, j in results:
-@@ -611,7 +611,7 @@
+@@ -661,7 +662,7 @@
# XXX Warning: Running this in SpiderMonkey can lead to an extreme amount of memory being
# used, see Mozilla bug 593659.
@@ -234,6 +254,181 @@ diff --git a/tests/runner.py b/tests/runner.py
self.do_test(path_from_root(['tests', 'sauer']), 'Hello sauer world!', main_file='command.cpp')
if __name__ == '__main__':
+diff --git a/tests/sauer/command.cpp b/tests/sauer/command.cpp
+--- a/tests/sauer/command.cpp
++++ b/tests/sauer/command.cpp
+@@ -1,6 +1,8 @@
+ // command.cpp: implements the parsing and execution of a tiny script language which
+ // is largely backwards compatible with the quake console language.
+
++// XXX Emscripten: changed all sizeof to ES_SIZEOF
++
+ // XXX Emscripten
+ #define STANDALONE
+
+@@ -1312,7 +1314,7 @@
+ void conoutfv(int type, const char *fmt, va_list args)
+ {
+ static char buf[CONSTRLEN];
+- vformatstring(buf, fmt, args, sizeof(buf));
++ vformatstring(buf, fmt, args, ES_SIZEOF(char)*CONSTRLEN); // XXX Emscripten?
+ conline(type, buf);
+ //filtertext(buf, buf); // XXX Emscripten
+ puts(buf);
+@@ -1404,6 +1406,11 @@
+ {
+ execute("echo Hello from sauer");
+
++ ident moshe, david;
++ printf("cheezme1 %d,%d\n", int(&moshe), int(&(moshe.type)));
++ moshe = david;
++ printf("cheezme2\n");
++
+ return 0;
+ }
+
+diff --git a/tests/sauer/command.h b/tests/sauer/command.h
+--- a/tests/sauer/command.h
++++ b/tests/sauer/command.h
+@@ -84,7 +84,7 @@
+
+ virtual ~ident() {}
+
+- ident &operator=(const ident &o) { memcpy(this, &o, sizeof(ident)); return *this; } // force vtable copy, ugh
++ ident &operator=(const ident &o) { memcpy(this, &o, ES_SIZEOF(ident)); return *this; } // force vtable copy, ugh
+
+ virtual void changed() { if(fun) fun(); }
+ };
+diff --git a/tests/sauer/tools.h b/tests/sauer/tools.h
+--- a/tests/sauer/tools.h
++++ b/tests/sauer/tools.h
+@@ -3,6 +3,8 @@
+ #ifndef _TOOLS_H
+ #define _TOOLS_H
+
++#include "emscripten.h" // XXX Emscripten
++
+ #ifdef NULL
+ #undef NULL
+ #endif
+@@ -173,7 +175,7 @@
+ void put(const T *vals, int numvals)
+ {
+ if(maxlen-len<numvals) flags |= OVERWROTE;
+- memcpy(&buf[len], vals, min(maxlen-len, numvals)*sizeof(T));
++ memcpy(&buf[len], vals, min(maxlen-len, numvals)*ES_SIZEOF(T));
+ len += min(maxlen-len, numvals);
+ }
+
+@@ -181,7 +183,7 @@
+ {
+ int read = min(maxlen-len, numvals);
+ if(read<numvals) flags |= OVERREAD;
+- memcpy(vals, &buf[len], read*sizeof(T));
++ memcpy(vals, &buf[len], read*ES_SIZEOF(T));
+ len += read;
+ return read;
+ }
+@@ -207,7 +209,7 @@
+ template<class T, class U>
+ static inline void quicksort(T *buf, int n, int (__cdecl *func)(U *, U *))
+ {
+- qsort(buf, n, sizeof(T), (int (__cdecl *)(const void *,const void *))func);
++ qsort(buf, n, ES_SIZEOF(T), (int (__cdecl *)(const void *,const void *))func);
+ }
+
+ template <class T> struct vector
+@@ -268,7 +270,7 @@
+ else
+ {
+ growbuf(ulen+v.ulen);
+- if(v.ulen) memcpy(&buf[ulen], v.buf, v.ulen*sizeof(T));
++ if(v.ulen) memcpy(&buf[ulen], v.buf, v.ulen*ES_SIZEOF(T));
+ ulen += v.ulen;
+ v.ulen = 0;
+ }
+@@ -309,10 +311,10 @@
+ if(!alen) alen = max(MINSIZE, sz);
+ else while(alen < sz) alen *= 2;
+ if(alen <= olen) return;
+- uchar *newbuf = new uchar[alen*sizeof(T)];
++ uchar *newbuf = new uchar[alen*ES_SIZEOF(T)];
+ if(olen > 0)
+ {
+- memcpy(newbuf, buf, olen*sizeof(T));
++ memcpy(newbuf, buf, olen*ES_SIZEOF(T));
+ delete[] (uchar *)buf;
+ }
+ buf = (T *)newbuf;
+@@ -515,6 +517,7 @@
+ numelems = 0;
+ chunks = NULL;
+ unused = NULL;
++ printf("unused is at %d : %d\n", int(&unused), int(unused));
+ chains = new chain *[size];
+ loopi(size) chains[i] = NULL;
+ }
+@@ -527,6 +530,7 @@
+
+ chain *insert(uint h)
+ {
++ printf("Insert. Unused: %d, addr of next is offset to: %d\n", int(unused), int(&(unused->next)));
+ if(!unused)
+ {
+ chainchunk *chunk = new chainchunk;
+@@ -535,9 +539,13 @@
+ loopi(CHUNKSIZE-1) chunk->chains[i].next = &chunk->chains[i+1];
+ chunk->chains[CHUNKSIZE-1].next = unused;
+ unused = chunk->chains;
++ loopi(CHUNKSIZE) printf("chunk %d is at %d, and points to %d\n", i, int(&(chunk->chains[i])), int(chunk->chains[i].next));
++ printf("PRE YO unused is NOW at %d : %d, %d, %d\n", int(&unused), int(unused), int(unused->next), int(unused->next->next));
+ }
+ chain *c = unused;
++ //printf("unused PRE: %d : %d, %d, %d\n", int(&unused), int(unused), int(unused->next), int(unused->next->next));
+ unused = unused->next;
++ //printf("unused POST: %d : %d, %d, %d\n", int(&unused), int(unused), int(unused->next), int(unused->next->next));
+ c->next = chains[h];
+ chains[h] = c;
+ numelems++;
+@@ -545,11 +553,11 @@
+ }
+
+ #define HTFIND(key, success, fail) \
+- uint h = hthash(key)&(this->size-1); \
++ printf("HTFIND a\n"); uint h = hthash(key)&(this->size-1); \
+ for(chain *c = this->chains[h]; c; c = c->next) \
+- { \
++ { printf("HTFIND b\n"); \
+ if(htcmp(key, c->elem)) return (success); \
+- } \
++ } printf("HTFIND c\n"); \
+ return (fail);
+
+ template<class K>
+@@ -644,7 +652,9 @@
+
+ entry &insert(const K &key, uint h)
+ {
++ printf("hashTABLE insert\n");
+ chain *c = hashset<entry>::insert(h);
++ printf("hashTABLE insert moving on\n");
+ c->elem.key = key;
+ return c->elem;
+ }
+@@ -863,11 +873,11 @@
+ virtual int printf(const char *fmt, ...) { return -1; }
+ virtual uint getcrc() { return 0; }
+
+- template<class T> bool put(T n) { return write(&n, sizeof(n)) == sizeof(n); }
++ template<class T> bool put(T n) { return write(&n, ES_SIZEOV(n)) == ES_SIZEOV(n); }
+ template<class T> bool putlil(T n) { return put<T>(lilswap(n)); }
+ template<class T> bool putbig(T n) { return put<T>(bigswap(n)); }
+
+- template<class T> T get() { T n; return read(&n, sizeof(n)) == sizeof(n) ? n : 0; }
++ template<class T> T get() { T n; return read(&n, ES_SIZEOV(n)) == ES_SIZEOV(n) ? n : 0; }
+ template<class T> T getlil() { return lilswap(get<T>()); }
+ template<class T> T getbig() { return bigswap(get<T>()); }
+ };
diff --git a/tests/settings.py b/tests/settings.py
--- a/tests/settings.py
+++ b/tests/settings.py