shithub: mc

Download patch

ref: b9129f3f0281a4f382b5f437780076384aac826a
parent: e810bb4e2b87089f4910f7e489a429cc5e62e47d
parent: 0ab1465f53e80c1303fe3ef929a668e85ea74a85
author: Ori Bernstein <[email protected]>
date: Thu Jun 12 09:04:06 EDT 2014

Merge https://github.com/oridb/mc

--- a/6/ra.c
+++ b/6/ra.c
@@ -362,6 +362,12 @@
     l->list = wl;
 }
 
+static void wldel(Isel *s, Loc ***wl, size_t *nwl, size_t idx)
+{
+    (*wl)[idx]->list = NULL;
+    ldel(wl, nwl, idx);
+}
+
 static void wlputset(Bitset *bs, regid r)
 {
     bsput(bs, r);
@@ -547,8 +553,9 @@
             continue;
         else if (!istrivial(s, i))
             wlput(&s->wlspill, &s->nwlspill, locmap[i]);
-        else if (moverelated(s, i))
+        else if (moverelated(s, i)) {
             wlput(&s->wlfreeze, &s->nwlfreeze, locmap[i]);
+        }
         else
             wlput(&s->wlsimp, &s->nwlsimp, locmap[i]);
         locmap[i]->reg.colour = 0;
@@ -605,7 +612,7 @@
          */
         found = wlfind(s->wlspill, s->nwlspill, m, &idx);
         if (found)
-            ldel(&s->wlspill, &s->nwlspill, idx);
+            wldel(s, &s->wlspill, &s->nwlspill, idx);
         if (moverelated(s, m)) {
             if (!found)
                 assert(wlfind(s->wlfreeze, s->nwlfreeze, m, &idx));
@@ -656,8 +663,9 @@
     if (!istrivial(s, u))
         return;
 
-    assert(wlfind(s->wlfreeze, s->nwlfreeze, u, &i));
-    ldel(&s->wlfreeze, &s->nwlfreeze, i);
+    assert(locmap[u]->list == &s->wlfreeze || locmap[u]->list == &s->wlsimp);
+    if (wlfind(s->wlfreeze, s->nwlfreeze, u, &i))
+        wldel(s, &s->wlfreeze, &s->nwlfreeze, i);
     wlput(&s->wlsimp, &s->nwlsimp, locmap[u]);
 }
 
@@ -720,9 +728,9 @@
     if (debugopt['r'] > 2)
         printedge(stdout, "combining:", u, v);
     if (wlfind(s->wlfreeze, s->nwlfreeze, v, &idx))
-        ldel(&s->wlfreeze, &s->nwlfreeze, idx);
+        wldel(s, &s->wlfreeze, &s->nwlfreeze, idx);
     else if (wlfind(s->wlspill, s->nwlspill, v, &idx)) {
-        ldel(&s->wlspill, &s->nwlspill, idx);
+        wldel(s, &s->wlspill, &s->nwlspill, idx);
     }
     wlputset(s->coalesced, v);
     s->aliasmap[v] = locmap[u];
@@ -750,7 +758,7 @@
         decdegree(s, t);
     }
     if (!istrivial(s, u) && wlfind(s->wlfreeze, s->nwlfreeze, u, &idx)) {
-        ldel(&s->wlfreeze, &s->nwlfreeze, idx);
+        wldel(s, &s->wlfreeze, &s->nwlfreeze, idx);
         wlput(&s->wlspill, &s->nwlspill, locmap[u]);
     }
 }
@@ -822,7 +830,7 @@
         if (!nodemoves(s, v->reg.id, NULL) && istrivial(s, v->reg.id)) {
             if (!wlfind(s->wlfreeze, s->nwlfreeze, v->reg.id, &idx))
                 die("Reg %zd not in freeze wl\n", v->reg.id);
-            ldel(&s->wlfreeze, &s->nwlfreeze, idx);
+            wldel(s, &s->wlfreeze, &s->nwlfreeze, idx);
             wlput(&s->wlsimp, &s->nwlsimp, v);
         }
 
@@ -851,7 +859,7 @@
         if (!bshas(s->shouldspill, s->wlspill[i]->reg.id))
             continue;
         m = s->wlspill[i];
-        ldel(&s->wlspill, &s->nwlspill, i);
+        wldel(s, &s->wlspill, &s->nwlspill, i);
         break;
     }
     if (!m) {
@@ -861,7 +869,7 @@
                 continue;
             }
             m = s->wlspill[i];
-            ldel(&s->wlspill, &s->nwlspill, i);
+            wldel(s, &s->wlspill, &s->nwlspill, i);
             break;
         }
     }
--- /dev/null
+++ b/bench/intsort.myr
@@ -1,0 +1,18 @@
+use std
+
+const main = {
+    var a
+    var i
+    var rng
+    var t0, t1
+
+    rng = std.mksrng(123)
+    a = std.slalloc(1000000)
+    for i = 0; i < a.len; i++
+        a[i] = std.rand32(rng)
+    ;;
+    t0 = std.now()
+    std.sort(a, std.numcmp)
+    t1 = std.now()
+    std.put("time = %l\n", t1 - t0)
+}
--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -18,6 +18,7 @@
     hasprefix.myr \
     hassuffix.myr \
     htab.myr \
+    ifreq.myr \
     intparse.myr \
     ipparse.myr \
     mk.myr \
@@ -60,6 +61,9 @@
 
 sys.myr: sys-$(SYS).myr
 	cp sys-$(SYS).myr sys.myr
+
+ifreq.myr: ifreq-$(SYS).myr
+	cp ifreq-$(SYS).myr ifreq.myr
 
 waitstatus.myr: waitstatus-$(SYS).myr
 	cp waitstatus-$(SYS).myr waitstatus.myr
--- /dev/null
+++ b/libstd/ifreq-linux.myr
@@ -1,0 +1,67 @@
+use "sys.use"
+
+pkg std =
+	const Ifnamesz = 16
+
+	type ifreq_addr = struct
+		name	: byte[Ifnamesz]
+		addr	: sockaddr
+	;;
+
+	type ifreq_dstaddr = struct
+		name	: byte[Ifnamesz]
+		dstaddr	: sockaddr
+	;;
+
+	type ifreq_broadaddr = struct
+		name	: byte[Ifnamesz]
+		broadaddr	: sockaddr
+	;;
+
+	type ifreq_netmask = struct
+		name	: byte[Ifnamesz]
+		netmask	: sockaddr
+	;;
+
+
+	type ifreq_hwaddr = struct
+		name	: byte[Ifnamesz]
+		hwaddr	: sockaddr
+	;;
+
+	type ifreq_flags = struct
+		name	: byte[Ifnamesz]
+		flags	: int16
+	;;
+
+	type ifreq_ifindex = struct
+		name	: byte[Ifnamesz]
+		index	: int32
+	;;
+
+	type ifreq_metric = struct
+		name	: byte[Ifnamesz]
+		metric	: int32
+	;;
+
+
+	type ifreq_mtu = struct
+		name	: byte[Ifnamesz]
+		mtu	: int32
+	;;
+
+	type ifreq_slave = struct
+		name	: byte[Ifnamesz]
+		slave	: byte[Ifnamesz]
+	;;
+
+	type ifreq_newname = struct
+		name	: byte[Ifnamesz]
+		newname	: byte[Ifnamesz]
+	;;
+
+	type ifreq_data = struct
+		name	: byte[Ifnamesz]
+		data	: void#
+	;;
+;;
--- /dev/null
+++ b/libstd/ifreq-osx.myr
@@ -1,0 +1,67 @@
+use "sys.use"
+
+pkg std =
+	const Ifnamesz = 16
+
+	type ifreq_addr = struct
+		name	: byte[Ifnamesz]
+		addr	: sockaddr
+	;;
+
+	type ifreq_dstaddr = struct
+		name	: byte[Ifnamesz]
+		dstaddr	: sockaddr
+	;;
+
+	type ifreq_broadaddr = struct
+		name	: byte[Ifnamesz]
+		broadaddr	: sockaddr
+	;;
+
+	type ifreq_netmask = struct
+		name	: byte[Ifnamesz]
+		netmask	: sockaddr
+	;;
+
+
+	type ifreq_hwaddr = struct
+		name	: byte[Ifnamesz]
+		hwaddr	: sockaddr
+	;;
+
+	type ifreq_flags = struct
+		name	: byte[Ifnamesz]
+		flags	: int16
+	;;
+
+	type ifreq_ifindex = struct
+		name	: byte[Ifnamesz]
+		index	: int32
+	;;
+
+	type ifreq_metric = struct
+		name	: byte[Ifnamesz]
+		metric	: int32
+	;;
+
+
+	type ifreq_mtu = struct
+		name	: byte[Ifnamesz]
+		mtu	: int32
+	;;
+
+	type ifreq_slave = struct
+		name	: byte[Ifnamesz]
+		slave	: byte[Ifnamesz]
+	;;
+
+	type ifreq_newname = struct
+		name	: byte[Ifnamesz]
+		newname	: byte[Ifnamesz]
+	;;
+
+	type ifreq_data = struct
+		name	: byte[Ifnamesz]
+		data	: void#
+	;;
+;;