interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / omc / tests / pools / g9.om

87 lines · 1380 bytes Raw Blame History
1note gate-pools 9: a 2 GiB pool with one page touched adds about one page of VmRSS. Prints the length,
2note then VmRSS (kB) before the grow, after touching one page, and after touching 1024 more (the control).
3global P uchar *
4global sb uchar 4096
5global ob uchar 24
6text pth "/proc/self/status"
7fn pnum v ulong to void
8put ob 23 10
9i = ulong 23
10x = v
11go = true
12while go bound 21
13i = sub i 1
14put ob i uchar add rem x 10 48
15x = div x 10
16go = ne x 0
17end
18k = write 1 ob i sub 24 i
19end
20fn plong v long to void
21if lt v 0
22put ob 0 uchar 45
23k = write 1 ob 0 1
24pnum ulong neg v
25else
26pnum ulong v
27end
28end
29fn hit i ulong to bool
30a = and eq get sb i 86 eq get sb add i 1 109
31b = and eq get sb add i 2 82 eq get sb add i 5 58
32ret and a b
33end
34fn rss to ulong
35fd = fopen pth 0 len pth 0 0
36if lt fd 0
37ret 0
38end
39n = read int fd sb 0 4096
40fd = fclose int fd
41if le n 0
42ret 0
43end
44lim = ulong n
45i = ulong 0
46while lt add i 6 lim bound 4096
47if hit i
48break
49end
50i = add i 1
51end
52i = add i 6
53v = ulong 0
54while lt i lim bound 4096
55ch = get sb i
56if and ge ch 48 le ch 57
57v = add mul v 10 ulong sub ch 48
58else
59if and ne ch 32 ne ch 9
60break
61end
62end
63i = add i 1
64end
65ret v
66end
67fn main to int
68a = rss
69a = rss
70r = enlarge P ulong 2147483648
71if ne r 0
72ret 3
73end
74put P 12345678 1
75b = rss
76i = ulong 0
77while lt i 1024
78put P add 1000000000 mul i 4096 1
79i = add i 1
80end
81c = rss
82pnum len P
83pnum a
84pnum b
85pnum c
86ret 0
87end