diff options
Diffstat (limited to 'rts')
-rw-r--r-- | rts/js/mem.js | 8 | ||||
-rw-r--r-- | rts/js/thread.js | 30 |
2 files changed, 26 insertions, 12 deletions
diff --git a/rts/js/mem.js b/rts/js/mem.js index 3dcdc7979f..2f91b80798 100644 --- a/rts/js/mem.js +++ b/rts/js/mem.js @@ -1455,11 +1455,3 @@ function h$pext64(src_b, src_a, mask_b, mask_a) { } RETURN_UBX_TUP2(dst_b, dst_a); } - -function h$getThreadLabel(t) { - if (t.label) { - RETURN_UBX_TUP2(1, t.label); - } else { - RETURN_UBX_TUP2(0, 0); - } -} diff --git a/rts/js/thread.js b/rts/js/thread.js index 081749a015..1c51fa2569 100644 --- a/rts/js/thread.js +++ b/rts/js/thread.js @@ -106,8 +106,8 @@ function h$Thread() { #endif } -function h$rts_getThreadId(t) { - return t.tid; +function h$rts_getThreadId(t) { // returns a CULLong + RETURN_UBX_TUP2((t.tid / Math.pow(2,32))>>>0, (t.tid & 0xFFFFFFFF)>>>0); } function h$cmp_thread(t1,t2) { @@ -121,13 +121,35 @@ function h$threadString(t) { if(t === null) { return "<no thread>"; } else if(t.label) { - var str = h$decodeUtf8z(t.label[0], t.label[1]); + var str = h$decodeUtf8z(t.label, 0); return str + " (" + t.tid + ")"; } else { return (""+t.tid); } } +function h$getThreadLabel(t) { + if (t.label) { + RETURN_UBX_TUP2(1, t.label); + } else { + RETURN_UBX_TUP2(0, 0); + } +} + +function h$listThreads() { + var r = h$newArray(0,null); + + if (h$currentThread) r.push(h$currentThread); + + var threads_iter = h$threads.iter(); + while ((t = threads_iter()) !== null) r.push(t); + + var blocked_iter = h$blocked.iter(); + while ((t = blocked_iter.next()) !== null) r.push(t); + + return r; +} + function h$fork(a, inherit) { h$r1 = h$forkThread(a, inherit); return h$yield(); @@ -1134,7 +1156,7 @@ function h$main(a) { t.stack[8] = a; t.stack[9] = h$return; t.sp = 9; - t.label = [h$encodeUtf8("main"), 0]; + t.label = h$encodeUtf8("main"); h$wakeupThread(t); h$startMainLoop(); return t; |