blob: b5f9c4368156d3969e2a45e11dbe520ea72966da (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
(load "mu.arc")
; memory map: 0-2 for convenience constants
(enq (fn ()
(run `(((0 integer) <- literal 0)
((1 integer) <- literal 1)
((2 integer) <- literal 2))))
initialization-fns*)
(enq (fn ()
(build-type-table)
initialization-fns*)
(= Free 3)
(= Type-array Free)
(def build-type-table ()
(allocate-type-array)
(build-types)
(fill-in-type-array))
(def allocate-type-array ()
(= memory*.Free len.types*)
(++ Free)
(++ Free len.types*))
(def build-types ()
(each type types* ; todo
(
(def sizeof (typeinfo)
(if (~or typeinfo!record typeinfo!array)
typeinfo!size
typeinfo!record
(sum idfn
(accum yield
(each elem typeinfo!elems
(yield (sizeof type*.elem)))))
typeinfo!array
(* (sizeof (type* typeinfo!elem))
(
;; 'new' - simple slab allocator. Intended only to carve out isolated memory
;; for different threads/routines as they request.
; memory map: 3 for root custodian (size 1)
(= Root_custodian 3)
(= Allocator_start 1000) ; lower locations reserved
(enq (fn ()
(run `(((,Root_custodian location) <- literal ,Allocator_start))))
initialization-fns*)
; (type-addr val) <- new (custodian x), (type t)
; memory map: 4-5 locals for slab allocator
(init-fn new
((4 integer-address) <- copy (3 location))
((3 location) <- add (3 location) (1 integer))
(reply (4 integer-address)))
|