aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-07-30 10:26:30 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-07-30 10:26:30 -0700
commitf6e02c614a905658fe164e19548d4436854253bd (patch)
treebf054e29b2455430d03108b00180ca607eb9dea4
parent778b071526306906ecf3c09aa307ededa1c4eddf (diff)
workarounds for js engine bugs
-rwxr-xr-xemscripten.py11
-rw-r--r--src/compiler.js18
-rw-r--r--tests/runner.py5
-rw-r--r--tools/shared.py4
4 files changed, 22 insertions, 16 deletions
diff --git a/emscripten.py b/emscripten.py
index b77c361d..a770cdd6 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -150,13 +150,12 @@ def emscript(infile, settings, outfile):
defined in src/settings.js.
outfile: The file where the output is written.
"""
- data = open(infile, 'r').read()
+ settings_file = get_temp_file('.txt').name # Save settings to a file to work around v8 issue 1579
+ s = open(settings_file, 'w')
+ s.write(settings)
+ s.close()
compiler = path_from_root('src', 'compiler.js')
- subprocess.Popen(shared.COMPILER_ENGINE + [compiler],
- stdin=subprocess.PIPE,
- stdout=outfile,
- cwd=path_from_root('src'),
- stderr=subprocess.STDOUT).communicate(settings + '\n' + data)
+ shared.run_js(shared.COMPILER_ENGINE, compiler, [settings_file, infile], stdout=outfile, stderr=subprocess.STDOUT, cwd=path_from_root('src'))
outfile.close()
diff --git a/src/compiler.js b/src/compiler.js
index 8cb023d9..8980da93 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -12,6 +12,9 @@ if (!this['load']) {
if (!this['read']) {
read = function(f) { snarf(f) };
}
+if (!this['arguments']) {
+ arguments = scriptArgs;
+}
// Basic utilities
@@ -21,7 +24,10 @@ load('utility.js');
load('settings.js');
-var settings = JSON.parse(readline());
+var settings_file = arguments[0];
+var ll_file = arguments[1];
+
+var settings = JSON.parse(read(settings_file));
for (setting in settings) {
this[setting] = settings[setting];
}
@@ -64,13 +70,9 @@ eval(processMacros(preprocess(read('runtime.js'))));
// Read llvm
-var lines = [];
-var line;
-do {
- line = readline();
- if (line == null) break;
- lines.push(line);
-} while(true);
+var raw = read(ll_file);
+var lines = raw.split('\n');
+raw = null;
// Do it
diff --git a/tests/runner.py b/tests/runner.py
index a0c95c7b..8e1fdfa5 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -181,6 +181,7 @@ class RunnerCore(unittest.TestCase):
pass
settings = ['-s %s=%s' % (k, json.dumps(v)) for k, v in exported_settings.items()]
compiler_output = timeout_run(Popen([EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE, stderr=STDOUT), TIMEOUT, 'Compiling')
+ #print compiler_output
# Detect compilation crashes and errors
if compiler_output is not None and 'Traceback' in compiler_output and 'in test_' in compiler_output: print compiler_output; assert 0
@@ -2674,6 +2675,7 @@ if 'benchmark' not in sys.argv:
self.do_ll_test(path_from_root('tests', 'lua', 'lua.ll'),
'hello lua world!\n17\n1\n2\n3\n4\n7',
+ js_engines=[V8_ENGINE], # XXX Moz bug 675269
args=['-e', '''print("hello lua world!");print(17);for x = 1,4 do print(x) end;print(10-3)'''],
output_nicerizer=lambda string: string.replace('\n\n', '\n').replace('\n\n', '\n'))
@@ -2862,6 +2864,7 @@ if 'benchmark' not in sys.argv:
global USE_TYPED_ARRAYS
global CORRECT_SIGNS
if USE_TYPED_ARRAYS == 2:
+ return self.skip() # XXX Moz bug 675269
CORRECT_SIGNS = 1
else:
CORRECT_SIGNS = 2
@@ -2942,6 +2945,7 @@ if 'benchmark' not in sys.argv:
os.path.join(self.get_building_dir(), 'openjpeg')],
force_c=True,
post_build=post,
+ js_engines=[V8_ENGINE], # XXX Moz bug 675269
output_nicerizer=image_compare)# build_ll_hook=self.do_autodebug)
def test_python(self):
@@ -2955,6 +2959,7 @@ if 'benchmark' not in sys.argv:
self.do_ll_test(path_from_root('tests', 'python', 'python.ll'),
'hello python world!\n[0, 2, 4, 6]\n5\n22\n5.470000',
+ js_engines=[V8_ENGINE], # XXX Moz bug 675269
args=['-S', '-c' '''print "hello python world!"; print [x*2 for x in range(4)]; t=2; print 10-3-t; print (lambda x: x*2)(11); print '%f' % 5.47'''])
# Test cases in separate files. Note that these files may contain invalid .ll!
diff --git a/tools/shared.py b/tools/shared.py
index dcf6eb31..811f56f5 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -43,9 +43,9 @@ def timeout_run(proc, timeout, note):
raise Exception("Timed out: " + note)
return proc.communicate()[0]
-def run_js(engine, filename, args, check_timeout=False, stdout=PIPE, stderr=STDOUT):
+def run_js(engine, filename, args, check_timeout=False, stdout=PIPE, stderr=STDOUT, cwd=None):
return timeout_run(Popen(engine + [filename] + (['--'] if 'v8' in engine[0] else []) + args,
- stdout=stdout, stderr=stderr), 15*60 if check_timeout else None, 'Execution')
+ stdout=stdout, stderr=stderr, cwd=cwd), 15*60 if check_timeout else None, 'Execution')
def to_cc(cxx):
# By default, LLVM_GCC and CLANG are really the C++ versions. This gets an explicit C version