ref: a6d583daf31a227466dbcb7dffb0f20c809c8821
parent: 52f3611a79a3c494525e9a80a2e4709729782e0d
author: Ori Bernstein <[email protected]>
date: Wed Jul 25 10:18:42 EDT 2012
Rename 'bin' to 'chunk'. Clearer, makes more sense.
--- a/alloc.myr
+++ b/alloc.myr
@@ -13,7 +13,7 @@
/* null pointers */
const Zbyte = 0 castto(byte*)
const Zslab = 0 castto(slab*)
-const Zbin = 0 castto(bin*)
+const Zchunk = 0 castto(chunk*)
const Pagesz = 4096 /* on the systems this supports, anyways... */
const Cachemax = 16 /* maximum number of slabs in the cache */
const Bucketmax = 1024 /* Pagesz / 8; a balance. */
@@ -29,12 +29,12 @@
type slab = struct
next : slab* /* the next slab on the chain */
- freehd : bin* /* the nodes we're allocating */
+ freehd : chunk* /* the nodes we're allocating */
nfree : size /* the number of free nodes */
;;
-type bin = struct /* NB: must be smaller than sizeof(slab) */
- next : bin* /* the next bin in the free list */
+type chunk = struct /* NB: must be smaller than sizeof(slab) */
+ next : chunk* /* the next chunk in the free list */
;;
var buckets : bucket[32] /* excessive */
@@ -92,7 +92,7 @@
var s
var b
var bnext
- var off /* offset of bin head */
+ var off /* offset of chunk head */
if bkt.ncache > 0
s = bkt.cache
@@ -108,14 +108,14 @@
s.nfree = bkt.nper
/* skip past the slab header */
off = align(sizeof(slab), Align)
- bnext = nextbin(s castto(bin*), off)
+ bnext = nextchunk(s castto(chunk*), off)
s.freehd = bnext
for i = 0; i < bkt.nper; i++
b = bnext
- bnext = nextbin(b, bkt.sz)
+ bnext = nextchunk(b, bkt.sz)
b.next = bnext
;;
- b.next = Zbin
+ b.next = Zchunk
-> s
}
@@ -133,7 +133,7 @@
bkt.slabs = s
;;
- /* grab the first bin on the slab */
+ /* grab the first chunk on the slab */
b = s.freehd
s.freehd = b.next
s.nfree--
@@ -150,7 +150,7 @@
var b
s = mtrunc(m, Pagesz) castto(slab*)
- b = m castto(bin*)
+ b = m castto(chunk*)
if s.nfree == 0
s.next = bkt.slabs
bkt.slabs = s
@@ -181,9 +181,9 @@
die("Size does not match any buckets")
}
-/* bins are variable sizes, so we can't just take a slice */
-const nextbin = {b, sz
- -> ((b castto(intptr)) + sz) castto(bin*)
+/* chunks are variable sizes, so we can't just take a slice */
+const nextchunk = {b, sz
+ -> ((b castto(intptr)) + sz) castto(chunk*)
}
const align = {v, align