Skip to content

Commit

Permalink
fixes reactive-bahana with ghcjs
Browse files Browse the repository at this point in the history
  • Loading branch information
alios committed Oct 17, 2015
1 parent 37c6655 commit cef0064
Showing 1 changed file with 17 additions and 36 deletions.
53 changes: 17 additions & 36 deletions src/gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,6 @@ function h$gc(t) {
#endif
}

function h$markWeaks() {
var i, w, marked, mark = h$gcMark;
do {
marked = false;
for (i = 0; i < h$weakPointerList.length; ++i) {
w = h$weakPointerList[i];
if (IS_MARKED_M(w.keym)) {
if (w.val !== null && !IS_MARKED(w.val)) {
h$follow(w.val);
marked = true;
}
if (w.finalizer !== null && !IS_MARKED(w.finalizer)) {
h$follow(w.finalizer);
marked = true;
}
}
}
} while(marked);
}


function h$markRetained() {
var iter, marked, w, i, mark = h$gcMark;
var newList = [];
Expand Down Expand Up @@ -321,18 +300,21 @@ function h$markRetained() {
continue;
}

TRACE_GC("mark retained iteration 2/2");
if(w.val !== null) {
w.val = null;
}

if(w.finalizer !== null) {
if(!IS_MARKED(w.finalizer)) {
TRACE_GC("following finalizer");
h$follow(w.finalizer);
}
toFinalize.push(w);
}
TRACE_GC("mark retained iteration 2/2");
if(IS_MARKED_M(w)) {
if(w.val !== null) {
w.val = null;
}

if(w.finalizer !== null) {
if(!IS_MARKED(w.finalizer)) {
TRACE_GC("following finalizer");
h$follow(w.finalizer);
}
toFinalize.push(w);
}
}
}

/*
Expand All @@ -341,7 +323,9 @@ function h$markRetained() {
*/
h$weakPointerList = newList;

// marking the weak pointer objects as reachable is not necessary
for (i = 0; i < h$weakPointerList.length; ++i) {
MARK_OBJ(h$weakPointerList[i]);
}

return toFinalize;
}
Expand Down Expand Up @@ -435,8 +419,6 @@ function h$follow(obj, sp) {
TRACE_GC("adding static marks");
for(var i=0;i<s.length;i++) ADDW(s[i]);
}
} else if(c instanceof h$Weak) {
MARK_OBJ(c);
} else if(c instanceof h$MVar) {
TRACE_GC("marking MVar");
MARK_OBJ(c);
Expand Down Expand Up @@ -566,7 +548,6 @@ function h$resolveDeadlocks() {
TRACE_GC("resolving deadlocks");
var kill, t, iter, bo, mark = h$gcMark;
do {
h$markWeaks();
// deal with unreachable blocked threads: kill an unreachable thread and restart the process
kill = null;
iter = h$blocked.iter();
Expand Down

0 comments on commit cef0064

Please sign in to comment.