aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-30 21:32:56 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-09-03 14:41:30 -0700
commitbeb08e214984a234c82d3a2fd7e984dffdf2f5dc (patch)
tree560045c39234230ca0253f385da5c10e582fef90 /src/runtime.js
parentd6e21d7851004b2853327d1de468e25ee97fe595 (diff)
clean up shared modules when dlclose()d
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime.js b/src/runtime.js
index e42f90e3..9104c55d 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -403,6 +403,20 @@ var Runtime = {
}
});
}
+
+ var newLength = table.length;
+ jsModule.cleanups.push(function() {
+ if (table.length === newLength) {
+ table.length = from; // nothing added since, just shrink
+ } else {
+ // something was added above us, clear and leak the span
+ for (var i = 0; i < num; i++) {
+ table[from + i] = null;
+ }
+ }
+ while (table.length > 0 && table[table.length-1] === null) table.pop();
+ });
+
// patch js module dynCall_* to use functionTable
sigs.forEach(function(sig) {
jsModule['dynCall_' + sig] = function() {