diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-08-31 22:29:43 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-03 14:41:31 -0700 |
commit | 2a29c25394abf9941f4a768a810c417f506e1678 (patch) | |
tree | 0dc413fd38c0c28ff339eb64d72f6c1a8f46aa19 | |
parent | f55d0566d4bcbe83edbeedbc1dca30817d7da9ce (diff) |
do not eliminate supposedly stub functions in side modules, as they may be imported from the parent
-rw-r--r-- | src/modules.js | 1 | ||||
-rw-r--r-- | tests/dlmalloc_proxy.c | 20 | ||||
-rw-r--r-- | tests/test_core.py | 12 |
3 files changed, 14 insertions, 19 deletions
diff --git a/src/modules.js b/src/modules.js index fa6c0983..373e60d9 100644 --- a/src/modules.js +++ b/src/modules.js @@ -443,6 +443,7 @@ var LibraryManager = { }, isStubFunction: function(ident) { + if (SIDE_MODULE == 1) return false; // cannot eliminate these, as may be implement in the main module and imported by us var libCall = LibraryManager.library[ident.substr(1)]; return typeof libCall === 'function' && libCall.toString().replace(/\s/g, '') === 'function(){}' && !(ident in Functions.implementedFunctions); diff --git a/tests/dlmalloc_proxy.c b/tests/dlmalloc_proxy.c index 33435dd8..06137c42 100644 --- a/tests/dlmalloc_proxy.c +++ b/tests/dlmalloc_proxy.c @@ -14,7 +14,7 @@ mallocer mallocproxy = NULL; freeer freeproxy = NULL; void get_lib() { - printf("get lib\n"); + //printf("get lib\n"); lib_handle = dlopen("liblib.so", RTLD_NOW); assert(lib_handle != NULL); handles++; @@ -26,7 +26,7 @@ void get_lib() { } void unget_lib() { - printf("unget lib\n"); + //printf("unget lib\n"); assert(lib_handle); dlclose(lib_handle); handles--; @@ -37,8 +37,8 @@ int main() { int n = 0, total = 0, l = 0; void *allocs[50]; allocs[10] = malloc(10); // pull in real malloc - for (int i = 0; i < 500; i++) { - printf("%d: total ever %d MB, current MB %d, total libs %d\n", i, total, n, l); + for (int i = 0; i < 1000; i++) { + //printf("%d: total ever %d MB, current MB %d, total libs %d\n", i, total, n, l); if (i % 5 == 0) { if (handles < 10) { get_lib(); @@ -52,27 +52,27 @@ int main() { if (handles > 0) { if (n < 10) { if (i % 2 == 0) { - printf("alloc\n"); + //printf("alloc\n"); allocs[n++] = mallocproxy(1024*1024); } else { - printf("real alloc\n"); + //printf("real alloc\n"); allocs[n++] = malloc(1024*1024); } total++; } else { - printf("real free\n"); + //printf("real free\n"); free(allocs[--n]); // real free } } } if (i % 4 == 0) { if (handles > 0 && n > 0) { - printf("free\n"); + //printf("free\n"); if (i % 2 == 0) { - printf("free\n"); + //printf("free\n"); freeproxy(allocs[--n]); } else { - printf("real free\n"); + //printf("real free\n"); free(allocs[--n]); } } diff --git a/tests/test_core.py b/tests/test_core.py index d7e60345..6bb5ccb6 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -6199,6 +6199,8 @@ ok ''', force_c=True, post_build=self.dlfcn_post_build) def test_dlfcn_mallocs(self): + if not Settings.ASM_JS: return self.skip('needs asm') + if not self.can_dlfcn(): return Settings.TOTAL_MEMORY = 64*1024*1024 # will be exhausted without functional malloc/free @@ -6222,15 +6224,7 @@ ok self.prep_dlfcn_main() src = open(path_from_root('tests', 'dlmalloc_proxy.c')).read() Settings.EXPORTED_FUNCTIONS = ['_main', '_malloc', '_free'] - self.do_run(src, '''go -main. -main 201 -void 0 -void 1 -int 0 54 -int 1 9000 -ok -''', force_c=True, post_build=self.dlfcn_post_build) + self.do_run(src, '''*294,153*''', force_c=True, post_build=self.dlfcn_post_build) def test_rand(self): return self.skip('rand() is now random') # FIXME |