diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-12-04 18:51:43 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-12-04 18:51:43 -0800 |
commit | 51fbd38572cb1cd01950c038e7d7ab9fed8cac2a (patch) | |
tree | 1f720d6e19638f451ce9a4a3aa841584533dc494 | |
parent | 856626b99f8538abba9928aefc7b38e19387a5be (diff) |
fix line numbers with multiple linked files
-rw-r--r-- | src/intertyper.js | 2 | ||||
-rw-r--r-- | src/jsifier.js | 1 | ||||
-rw-r--r-- | tests/runner.py | 64 | ||||
-rw-r--r-- | tools/shared.py | 4 |
4 files changed, 66 insertions, 5 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 417f6588..4d85b8a5 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -109,7 +109,7 @@ function intertyper(data, sidePass, baseLineNums) { } else { ret.push({ lineText: line, - lineNum: i + 1 + baseLineNums[baseLineNumPosition][1] + lineNum: i + 1 + baseLineNums[baseLineNumPosition][1] - baseLineNums[baseLineNumPosition][0] }); if (/^\ +switch\ .*/.test(line)) { // beginning of llvm switch diff --git a/src/jsifier.js b/src/jsifier.js index b6434455..925d9754 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -108,7 +108,6 @@ function JSify(data, functionsOnly, givenFunctions) { } }); - var MAX_BATCH_FUNC_LINES = 1000; while (data.unparsedFunctions.length > 0) { var currFuncLines = []; diff --git a/tests/runner.py b/tests/runner.py index 136c02f4..f1357012 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -3521,6 +3521,7 @@ if 'benchmark' not in str(sys.argv): if Settings.USE_TYPED_ARRAYS == 2: return self.skip('We have slightly different rounding here for some reason. TODO: activate this') + # Note: this is also a good test of per-file and per-line changes (since we have multiple files, and correct specific lines) if Settings.SAFE_HEAP: # Ignore bitfield warnings Settings.SAFE_HEAP = 3 @@ -4262,6 +4263,66 @@ Child2:9 self.do_run(src, '*ok*') + Settings.SAFE_HEAP = 1 + + # Linking multiple files should work too + + module = ''' + #include<stdio.h> + void callFunc() { + int *x = new int; + *x = 20; + float *y = (float*)x; + printf("%f\\n", *y); + } + ''' + module_name = os.path.join(self.get_dir(), 'module.cpp') + open(module_name, 'w').write(module) + + main = ''' + #include<stdio.h> + extern void callFunc(); + int main() { + callFunc(); + int *x = new int; + *x = 20; + float *y = (float*)x; + printf("%f\\n", *y); + printf("*ok*\\n"); + return 0; + } + ''' + main_name = os.path.join(self.get_dir(), 'main.cpp') + open(main_name, 'w').write(main) + + Building.emmaken(module_name, ['-g']) + Building.emmaken(main_name, ['-g']) + all_name = os.path.join(self.get_dir(), 'all.bc') + Building.link([module_name + '.o', main_name + '.o'], all_name) + + try: + self.do_ll_run(all_name, '*nothingatall*') + except Exception, e: + # This test *should* fail, by throwing this exception + assert 'Assertion failed: Load-store consistency assumption failure!' in str(e), str(e) + + # And we should not fail if we disable checking on those lines + + Settings.SAFE_HEAP = 3 + Settings.SAFE_HEAP_LINES = ["module.cpp:7", "main.cpp:9"] + + self.do_ll_run(all_name, '*ok*') + + # But we will fail if we do not disable exactly what we need to - any mistake leads to error + + for lines in [["module.cpp:22", "main.cpp:9"], ["module.cpp:7", "main.cpp:29"], ["module.cpp:127", "main.cpp:449"], ["module.cpp:7"], ["main.cpp:9"]]: + Settings.SAFE_HEAP_LINES = lines + try: + self.do_ll_run(all_name, '*nothingatall*') + except Exception, e: + # This test *should* fail, by throwing this exception + assert 'Assertion failed: Load-store consistency assumption failure!' in str(e), str(e) + def test_check_overflow(self): Settings.CHECK_OVERFLOWS = 1 Settings.CORRECT_OVERFLOWS = 0 @@ -4929,7 +4990,8 @@ else: if __name__ == '__main__': sys.argv = [sys.argv[0]] + ['-v'] + sys.argv[1:] # Verbose output by default - for cmd in [CLANG, LLVM_DIS, SPIDERMONKEY_ENGINE[0], V8_ENGINE[0]]: + # TODO: check for js engines ([] or out of []) + for cmd in [CLANG, LLVM_DIS]: if not os.path.exists(cmd) and not os.path.exists(cmd + '.exe'): # .exe extension required for Windows print 'WARNING: Cannot find', cmd unittest.main() diff --git a/tools/shared.py b/tools/shared.py index 9750cb8a..4def2cee 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -264,12 +264,12 @@ class Building: assert os.path.exists(filename + '.o'), 'Could not create bc file: ' + output @staticmethod # TODO: make this use emcc instead of emmaken - def emmaken(filename, stdout=None, stderr=None, env=None): + def emmaken(filename, args=[], stdout=None, stderr=None, env=None): try: os.remove(filename + '.o') except: pass - Popen([EMMAKEN, filename, '-o', filename + '.o'], stdout=stdout, stderr=stderr, env=env).communicate()[0] + Popen([EMMAKEN, filename] + args + ['-o', filename + '.o'], stdout=stdout, stderr=stderr, env=env).communicate()[0] assert os.path.exists(filename + '.o'), 'Could not create bc file' @staticmethod |