about summary refs log tree commit diff stats
path: root/tools/scripts/setup-php.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/scripts/setup-php.sh')
0 files changed, 0 insertions, 0 deletions
bd5625a24f5184b27ab45d339189e'>^
558bf3d3 ^














1331848b ^

3be3006c ^
872dd001 ^
3be3006c ^
872dd001 ^







3be3006c ^





872dd001 ^



3be3006c ^
21da851e ^
























1331848b ^














3be3006c ^
be6b2492 ^
3be3006c ^



be6b2492 ^
3be3006c ^

1331848b ^



3be3006c ^
1331848b ^



3be3006c ^
1331848b ^

be6b2492 ^
1331848b ^



be6b2492 ^
3be3006c ^
1331848b ^
be6b2492 ^
3be3006c ^





3be3006c ^
be6b2492 ^


3be3006c ^

be6b2492 ^



3be3006c ^



be6b2492 ^
3be3006c ^
be6b2492 ^
3be3006c ^






1331848b ^















558bf3d3 ^




1331848b ^
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177













                                                                            
                              
 














                                                                  

                              
                             
                               
          







                                                                              





                                              



                                                                       
 
























                                                                              














                                                                                                                                                  
                                                           
                                                                             



                                            
                                                                   

                                                                          



        
                                                            



                                 
                                                                   

                                            
                                                   



                                                
                                                                                                         
                                      
                                
                                                                             





                                                                             
                                       


                                                              

                      



                                                                                                                    



                                                                             
                                                                                                                           
                                          
                                                                                






                             















                                                                                                   




                                                                   
 
// To recursively copy containers and any addresses they contain, use
// 'deep-copy'.
//
// Invariant: After a deep-copy its ingredient and result will point to no
// common addresses.
// Implications: Refcounts of all data pointed to by the original ingredient
// will remain unchanged. Refcounts of all data pointed to by the (newly
// created) result will be 1, in the absence of cycles.

:(scenario deep_copy_number)
def main [
  local-scope
  x:number <- copy 34
  y:number <- deep-copy x
  10:boolean/raw <- equal x, y
]
# non-address primitives are identical
+mem: storing 1 in location 10

:(scenario deep_copy_container_without_address)
container foo [
  x:number
  y:number
]
def main [
  local-scope
  a:foo <- merge 34 35
  b:foo <- deep-copy a
  10:boolean/raw <- equal a, b
]
# containers are identical as long as they don't contain addresses
+mem: storing 1 in location 10

:(scenario deep_copy_address)
% Memory_allocated_until = 200;
def main [
  # avoid all memory allocations except the implicit ones inside deep-copy, so
  # that the result is deterministic
  1:address:number <- copy 100/unsafe  # pretend allocation
  *1:address:number <- copy 34
  2:address:number <- deep-copy 1:address:number
  10:boolean <- equal 1:address:number, 2:address:number
  11:boolean <- equal *1:address:number, *2:address:number
  2:address:number <- copy 0
]
# the result of deep-copy is a new address
+mem: storing 0 in location 10
# however, the contents are identical
+mem: storing 1 in location 11
# the result of deep-copy gets a refcount of 1
# (its address 202 = 200 base + 2 for temporary space inside deep-copy)
+run: {2: ("address" "number")} <- copy {0: "literal"}
+mem: decrementing refcount of 202: 1 -> 0
+abandon: saving 202 in free-list of size 2

:(scenario deep_copy_array)
% Memory_allocated_until = 200;
def main [
  # avoid all memory allocations except the implicit ones inside deep-copy, so
  # that the result is deterministic
  100:number <- copy 1  # pretend refcount
  101:number <- copy 3  # pretend array length
  1:address:array:number <- copy 100/unsafe  # pretend allocation
  put-index *1:address:array:number, 0, 34
  put-index *1:address:array:number, 1, 35
  put-index *1:address:array:number, 2, 36
  stash [old:], *1:address:array:number
  2:address:array:number <- deep-copy 1:address:array:number
  stash 2:address:array:number
  stash [new:], *2:address:array:number
  10:boolean <- equal 1:address:array:number, 2:address:array:number
  11:boolean <- equal *1:address:array:number, *2:address:array:number
]
+app: old: 3 34 35 36
+app: new: 3 34 35 36
# the result of deep-copy is a new address
+mem: storing 0 in location 10
# however, the contents are identical
+mem: storing 1 in location 11

:(before "End Primitive Recipe Declarations")
DEEP_COPY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "deep-copy", DEEP_COPY);
:(before "End Primitive Recipe Checks")
case DEEP_COPY: {
  if (SIZE(inst.ingredients) != 1) {
    raise << maybe(get(Recipe, r).name) << "'deep-copy' takes exactly one ingredient rather than '" << to_original_string(inst) << "'\n" << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case DEEP_COPY: {
  const reagent& input = current_instruction().ingredients.at(0);
  // allocate a tiny bit of temporary space for deep_copy()
  trace(9991, "run") << "deep-copy: allocating space for temporary" << end();
  reagent tmp("tmp:address:number");
  tmp.value = allocate(1);
  products.push_back(deep_copy(input, tmp));
  // reclaim Mu memory allocated for tmp
  trace(9991, "run") << "deep-copy: reclaiming temporary" << end();
  abandon(tmp.value, tmp.type->right, payload_size(tmp));
  // reclaim host memory allocated for tmp.type when tmp goes out of scope
  break;
}

:(code)
vector<double> deep_copy(reagent/*copy*/ in, reagent& tmp) {
  canonize(in);
  vector<double> result;
  map<int, int> addresses_copied;
  if (is_mu_address(in))
    result.push_back(deep_copy_address(in, addresses_copied, tmp));
  else
    deep_copy(in, addresses_copied, result);
  trace(9991, "run") << "deep-copy: done" << end();
  return result;
}

// deep-copy an address and return a new address
int deep_copy_address(const reagent& canonized_in, map<int, int>& addresses_copied, const reagent& tmp) {
  int in_address = canonized_in.value;
  if (in_address == 0) return 0;
  trace(9991, "run") << "deep-copy: copying address " << in_address << end();
  if (contains_key(addresses_copied, in_address))
    return get(addresses_copied, in_address);
  // TODO: what about address:address:___? Should deep-copy be doing multiple
  // lookups? If the goal is to eliminate all common addresses, yes.
  reagent/*copy*/ payload = canonized_in;
  payload.properties.push_back(pair<string, string_tree*>("lookup", NULL));
  int out = allocate(size_of(payload));
  reagent/*copy*/ payload_type = payload;
  canonize_type(payload_type);
  const type_info& info = get(Type, payload_type.type->value);
  switch (info.kind) {
    case PRIMITIVE: {
      trace(9991, "run") << "deep-copy: reading ingredient " << payload.value << ' ' << to_string(payload) << end();
      vector<double> data = read_memory(payload);
      trace(9991, "run") << "deep-copy: writing result " << out << end();
      reagent/*copy*/ out_payload = payload;
      // HACK: write_memory interface isn't ideal for this situation; we need
      // a temporary location to help copy the payload.
      put(Memory, tmp.value, out);
      out_payload.value = tmp.value;
      trace(9991, "run") << "deep-copy: really writing to " << out_payload.value << ' ' << to_string(out_payload) << end();
      write_memory(out_payload, data, -1);
      trace(9991, "run") << "deep-copy: output is " << to_string(data) << end();
      break;
    }
    case CONTAINER:
      break;
    case EXCLUSIVE_CONTAINER:
      break;
  }
  put(addresses_copied, in_address, out);
  return out;
}

// deep-copy a container and return a container

// deep-copy a container and return a vector of locations
void deep_copy(const reagent& canonized_in, map<int, int>& addresses_copied, vector<double>& out) {
  assert(!is_mu_address(canonized_in));
  if (!contains_key(Container_metadata, canonized_in.type)) {
    assert(get(Type, canonized_in.type->value).kind == PRIMITIVE);  // not a container
    vector<double> result = read_memory(canonized_in);
    assert(scalar(result));
    out.push_back(result.at(0));
    return;
  }
  if (get(Container_metadata, canonized_in.type).address.empty()) {
    vector<double> result = read_memory(canonized_in);
    out.insert(out.end(), result.begin(), result.end());
    return;
  }
}