about summary refs log tree commit diff stats
path: root/037abandon.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-06-24 09:16:17 -0700
committerKartik Agaram <vc@akkartik.com>2018-06-24 09:18:20 -0700
commit23d3a02226973f80188e84fa5dcedb14413c5b7f (patch)
tree3c73284cb795e74d78e53b72df470cafca4c70cf /037abandon.cc
parent377b00b045289a3fa8e88d4b2f129d797c687e2f (diff)
downloadmu-23d3a02226973f80188e84fa5dcedb14413c5b7f.tar.gz
4266 - space for alloc-id in heap allocations
This has taken me almost 6 weeks :(
Diffstat (limited to '037abandon.cc')
-rw-r--r--037abandon.cc32
1 files changed, 16 insertions, 16 deletions
diff --git a/037abandon.cc b/037abandon.cc
index 74256687..ca7c242c 100644
--- a/037abandon.cc
+++ b/037abandon.cc
@@ -2,15 +2,15 @@
 
 :(scenario new_reclaim)
 def main [
-  1:&:num <- new number:type
-  2:num <- deaddress 1:&:num  # because 1 will get reset during abandon below
-  abandon 1:&:num
-  3:&:num <- new number:type  # must be same size as abandoned memory to reuse
-  4:num <- deaddress 3:&:num
-  5:bool <- equal 2:num, 4:num
+  10:&:num <- new number:type
+  20:num <- deaddress 10:&:num
+  abandon 10:&:num
+  30:&:num <- new number:type  # must be same size as abandoned memory to reuse
+  40:num <- deaddress 30:&:num
+  50:bool <- equal 20:num, 40:num
 ]
 # both allocations should have returned the same address
-+mem: storing 1 in location 5
++mem: storing 1 in location 50
 
 //: When abandoning addresses we'll save them to a 'free list', segregated by size.
 
@@ -39,7 +39,7 @@ case ABANDON: {
   for (int i = 0;  i < SIZE(current_instruction().ingredients);  ++i) {
     reagent/*copy*/ ingredient = current_instruction().ingredients.at(i);
     canonize(ingredient);
-    abandon(get_or_insert(Memory, ingredient.value), payload_size(ingredient));
+    abandon(get_or_insert(Memory, ingredient.value+/*skip alloc id*/1), payload_size(ingredient));
   }
   break;
 }
@@ -58,7 +58,7 @@ void abandon(int address, int payload_size) {
 int payload_size(reagent/*copy*/ x) {
   x.properties.push_back(pair<string, string_tree*>("lookup", NULL));
   lookup_memory_core(x, /*check_for_null*/false);
-  return size_of(x);
+  return size_of(x)+/*alloc id*/1;
 }
 
 :(after "Allocate Special-cases")
@@ -91,12 +91,12 @@ def main [
 
 :(scenario new_reclaim_array)
 def main [
-  1:&:@:num <- new number:type, 2
-  2:num <- deaddress 1:&:@:num
-  abandon 1:&:@:num
-  3:&:@:num <- new number:type, 2  # same size
-  4:num <- deaddress 3:&:@:num
-  5:bool <- equal 2:num, 4:num
+  10:&:@:num <- new number:type, 2
+  20:num <- deaddress 10:&:@:num
+  abandon 10:&:@:num
+  30:&:@:num <- new number:type, 2  # same size
+  40:num <- deaddress 30:&:@:num
+  50:bool <- equal 20:num, 40:num
 ]
 # both calls to new returned identical addresses
-+mem: storing 1 in location 5
++mem: storing 1 in location 50
n&id=f8997ec06c0cdda1a16c5d99f96c447ce6809185'>^
79eef536 ^
21c27706 ^
79eef536 ^
a796831f ^


































d5f89e0f ^
a796831f ^




4ad0f652 ^
a796831f ^


08cf048f ^
79eef536 ^
b74443e5 ^
eb4eecea ^
a17f9186 ^
79eef536 ^
a17f9186 ^
a796831f ^


ae256ea1 ^
f3760b0f ^
b69daf78 ^
795f5244 ^
a796831f ^
4f32f024 ^
a796831f ^



79eef536 ^
a796831f ^
a072f674 ^
eb4eecea ^
a072f674 ^

a796831f ^

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127