diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-20 14:12:05 +0100 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-20 14:12:05 +0100 |
commit | 9fb4f9c30b4cdbb971f1e189b0eb89045e553184 (patch) | |
tree | 153879b03f145f7781b42fae3810a43653ae04a6 | |
parent | 165962f18b43f4893d1941a847a4b22c6d089532 (diff) |
warn on very large structural types that slow us down
-rw-r--r-- | src/analyzer.js | 1 | ||||
-rwxr-xr-x | tests/runner.py | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index c09739e9..5f62bfd1 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -690,6 +690,7 @@ function analyzer(data, sidePass) { var subType = check[2]; addTypeInternal(subType, data); // needed for anonymous structure definitions (see below) + if (num >= 10*1024*1024) warnOnce('warning: very large fixed-size structural type: ' + type + ' - can you reduce it? (compilation may be slow)'); Types.types[nonPointing] = { name_: nonPointing, fields: range(num).map(function() { return subType }), diff --git a/tests/runner.py b/tests/runner.py index bea617d6..ba5ec148 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -8139,6 +8139,33 @@ f.close() output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp')], stderr=PIPE).communicate() self.assertNotContained('Unresolved symbol: _something\n', output[1]) + def test_toobig(self): + open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r''' + #include <stdio.h> + + #define BYTES 100*1024*1024 + + int main(int argc, char **argv) { + if (argc == 100) { + static char buf[BYTES]; + static char buf2[BYTES]; + for (int i = 0; i < BYTES; i++) { + buf[i] = i*i; + buf2[i] = i/3; + } + for (int i = 0; i < BYTES; i++) { + buf[i] = buf2[i/2]; + buf2[i] = buf[i/3]; + } + printf("%d\n", buf[10] + buf2[20]); + } + return 0; + } + ''') + output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp')], stderr=PIPE).communicate()[1] + assert 'Emscripten failed' in output, output + assert 'warning: very large fixed-size structural type' in output, output + def test_prepost(self): open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(''' #include <stdio.h> |