aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js7
-rwxr-xr-xtests/runner.py45
2 files changed, 35 insertions, 17 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 1662d249..ee54f17c 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1316,6 +1316,7 @@ function JSify(data, functionsOnly, givenFunctions) {
} else {
callIdent = ident;
}
+
var args = [];
var argsTypes = [];
var varargs = [];
@@ -1418,6 +1419,12 @@ function JSify(data, functionsOnly, givenFunctions) {
returnType = getReturnType(type);
}
+ if (callIdent in DEAD_FUNCTIONS) {
+ var ret = 'abort(7)';
+ if (ASM_JS) ret = asmCoercion(ret, returnType);
+ return ret;
+ }
+
if (byPointer) {
var sig = Functions.getSignature(returnType, argsTypes, hasVarArgs);
if (ASM_JS) {
diff --git a/tests/runner.py b/tests/runner.py
index 8e767e16..b8b539f7 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7697,7 +7697,7 @@ def process(filename):
Settings.DEAD_FUNCTIONS = []
# Run the same code with argc that uses the dead function, see abort
- test(('ReferenceError: _unused is not defined', 'is not a function'), args=['a', 'b'], no_build=True)
+ test(('abort', 'is not a function'), args=['a', 'b'], no_build=True)
# Normal stuff
run_all('normal', r'''
@@ -7742,6 +7742,33 @@ def process(filename):
}
''')
+ def test_asm_pgo(self):
+ if not Settings.ASM_JS: return self.skip('this is a test for PGO for asm (NB: not *in* asm)')
+
+ src = open(path_from_root('tests', 'hello_libcxx.cpp')).read()
+ output = 'hello, world!'
+
+ self.do_run(src, output)
+ shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('normal.js'))
+
+ self.emcc_args = map(lambda x: 'ASM_JS=0' if x == 'ASM_JS=1' else x, self.emcc_args)
+ Settings.PGO = 1
+ self.do_run(src, output)
+ Settings.PGO = 0
+ self.emcc_args = map(lambda x: 'ASM_JS=1' if x == 'ASM_JS=0' else x, self.emcc_args)
+
+ shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgo.js'))
+ pgo_output = run_js(self.in_dir('pgo.js'))
+
+ open('pgo_data', 'w').write(pgo_output.split('\n')[1])
+ self.emcc_args += ['@pgo_data']
+ self.do_run(src, output)
+ shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgoed.js'))
+
+ before = len(open('normal.js').read())
+ after = len(open('pgoed.js').read())
+ assert after < 0.66 * before, [before, after] # expect a big size reduction
+
def test_scriptaclass(self):
if self.emcc_args is None: return self.skip('requires emcc')
if Settings.ASM_JS: return self.skip('asm does not bindings generator yet')
@@ -9039,22 +9066,6 @@ f.close()
assert debug_size > unminified_size
assert 'function _malloc' in src
- def test_asm_pgo(self):
- Popen([PYTHON, EMXX, '-O2', '-s', 'ASM_JS=1', path_from_root('tests', 'hello_libcxx.cpp'), '-o', 'normal.js']).communicate()
- self.assertContained('hello, world!', run_js(self.in_dir('normal.js')))
-
- Popen([PYTHON, EMXX, '-O2', '-s', 'PGO=1', path_from_root('tests', 'hello_libcxx.cpp'), '-o', 'pgo.js']).communicate()
- pgo_output = run_js(self.in_dir('pgo.js'))
- self.assertContained('hello, world!', pgo_output)
-
- open('pgo_data', 'w').write(pgo_output.split('\n')[1])
- Popen([PYTHON, EMXX, '-O2', '-s', 'ASM_JS=1', path_from_root('tests', 'hello_libcxx.cpp'), '-o', 'pgoed.js', '@pgo_data']).communicate()
- self.assertContained('hello, world!', run_js(self.in_dir('pgoed.js')))
-
- before = len(open('normal.js').read())
- after = len(open('pgoed.js').read())
- assert after < 0.66 * before, [before, after] # expect a big size reduction
-
def test_l_link(self):
# Linking with -lLIBNAME and -L/DIRNAME should work