From 850822ffbfd441d05161452be28b54f882b1b378 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 1 Nov 2017 03:41:16 -0700 Subject: 4102 --- html/034address.cc.html | 60 ++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'html/034address.cc.html') diff --git a/html/034address.cc.html b/html/034address.cc.html index ae716fa4..7d5c45c8 100644 --- a/html/034address.cc.html +++ b/html/034address.cc.html @@ -97,8 +97,8 @@ if ('onhashchange' in window) { 33 //: b) If you allow data to be reclaimed, you have to be careful not to 34 //: leave any stale addresses pointing at it. Otherwise your program might 35 //: try to lookup such an address and find something unexpected. Such - 36 //: problems can be very hard to track down, and they can also be exploited - 37 //: to break into your computer over the network, etc. + 36 //: "memory corruption" problems can be very hard to track down, and they + 37 //: can also be exploited to break into your computer over the network, etc. 38 //: 39 //: To avoid these problems, we introduce the notion of a *reference count* or 40 //: refcount. The life cycle of a bit of data accessed through addresses looks @@ -187,18 +187,18 @@ if ('onhashchange' in window) { 123 # call 'new' two times with identical types without modifying the results; you 124 # should get back different results 125 def main [ -126 1:address:num/raw <- new number:type -127 2:address:num/raw <- new number:type -128 3:bool/raw <- equal 1:address:num/raw, 2:address:num/raw +126 1:address:num/raw <- new number:type +127 2:address:num/raw <- new number:type +128 3:bool/raw <- equal 1:address:num/raw, 2:address:num/raw 129 ] 130 +mem: storing 0 in location 3 131 132 :(scenario new_array) 133 # call 'new' with a second ingredient to allocate an array of some type rather than a single copy 134 def main [ -135 1:address:array:num/raw <- new number:type, 5 -136 2:address:num/raw <- new number:type -137 3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw +135 1:address:array:num/raw <- new number:type, 5 +136 2:address:num/raw <- new number:type +137 3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw 138 ] 139 +run: {1: ("address" "array" "number"), "raw": ()} <- new {number: "type"}, {5: "literal"} 140 +mem: array length is 5 @@ -207,7 +207,7 @@ if ('onhashchange' in window) { 143 144 :(scenario dilated_reagent_with_new) 145 def main [ -146 1:address:address:num <- new {(address number): type} +146 1:address:address:num <- new {(address number): type} 147 ] 148 +new: size of '(address number)' is 1 149 @@ -271,7 +271,7 @@ if ('onhashchange' in window) { 207 void drop_from_type(reagent& r, string expected_type) { 208 assert(!r.type->atom); 209 if (r.type->left->name != expected_type) { -210 ¦ raise << "can't drop2 " << expected_type << " from '" << to_string(r) << "'\n" << end(); +210 ¦ raise << "can't drop2 " << expected_type << " from '" << to_string(r) << "'\n" << end(); 211 ¦ return; 212 } 213 // r.type = r.type->right @@ -298,19 +298,19 @@ if ('onhashchange' in window) { 234 :(scenario new_discerns_singleton_list_from_atom_container) 235 % Hide_errors = true; 236 def main [ -237 1:address:num/raw <- new {(num): type} # should be '{num: type}' +237 1:address:num/raw <- new {(num): type} # should be '{num: type}' 238 ] 239 +error: main: product of 'new' has incorrect type: '1:address:num/raw <- new {(num): type}' 240 241 :(scenario new_with_type_abbreviation) 242 def main [ -243 1:address:num/raw <- new num:type +243 1:address:num/raw <- new num:type 244 ] 245 $error: 0 246 247 :(scenario new_with_type_abbreviation_inside_compound) 248 def main [ -249 {1: (address address number), raw: ()} <- new {(& num): type} +249 {1: (address address number), raw: ()} <- new {(& num): type} 250 ] 251 $error: 0 252 @@ -382,7 +382,7 @@ if ('onhashchange' in window) { 318 ¦ size = /*space for length*/1 + size*ingredients.at(1).at(0); 319 } 320 int result = allocate(size); -321 if (SIZE(current_instruction().ingredients) > 1) { +321 if (SIZE(current_instruction().ingredients) > 1) { 322 ¦ // initialize array length 323 ¦ trace(9999, "mem") << "storing " << ingredients.at(1).at(0) << " in location " << result+/*skip refcount*/1 << end(); 324 ¦ put(Memory, result+/*skip refcount*/1, ingredients.at(1).at(0)); @@ -405,9 +405,9 @@ if ('onhashchange' in window) { 341 const int result = Current_routine->alloc; 342 trace(9999, "mem") << "new alloc: " << result << end(); 343 // initialize allocated space -344 for (int address = result; address < result+size; ++address) { -345 ¦ trace(9999, "mem") << "storing 0 in location " << address << end(); -346 ¦ put(Memory, address, 0); +344 for (int address = result; address < result+size; ++address) { +345 ¦ trace(9999, "mem") << "storing 0 in location " << address << end(); +346 ¦ put(Memory, address, 0); 347 } 348 Current_routine->alloc += size; 349 // no support yet for reclaiming memory between routines @@ -448,33 +448,33 @@ if ('onhashchange' in window) { 384 % Memory_allocated_until = 10; 385 % put(Memory, Memory_allocated_until, 1); 386 def main [ -387 1:address:num <- new number:type +387 1:address:num <- new number:type 388 ] 389 +mem: storing 0 in location 10 390 391 :(scenario new_size) 392 def main [ -393 11:address:num/raw <- new number:type -394 12:address:num/raw <- new number:type -395 13:num/raw <- subtract 12:address:num/raw, 11:address:num/raw +393 11:address:num/raw <- new number:type +394 12:address:num/raw <- new number:type +395 13:num/raw <- subtract 12:address:num/raw, 11:address:num/raw 396 ] 397 # size of number + refcount 398 +mem: storing 2 in location 13 399 400 :(scenario new_array_size) 401 def main [ -402 1:address:array:num/raw <- new number:type, 5 -403 2:address:num/raw <- new number:type -404 3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw +402 1:address:array:num/raw <- new number:type, 5 +403 2:address:num/raw <- new number:type +404 3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw 405 ] 406 # 5 locations for array contents + array length + refcount 407 +mem: storing 7 in location 3 408 409 :(scenario new_empty_array) 410 def main [ -411 1:address:array:num/raw <- new number:type, 0 -412 2:address:num/raw <- new number:type -413 3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw +411 1:address:array:num/raw <- new number:type, 0 +412 2:address:num/raw <- new number:type +413 3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw 414 ] 415 +run: {1: ("address" "array" "number"), "raw": ()} <- new {number: "type"}, {0: "literal"} 416 +mem: array length is 0 @@ -485,8 +485,8 @@ if ('onhashchange' in window) { 421 :(scenario new_overflow) 422 % Initial_memory_per_routine = 3; // barely enough room for point allocation below 423 def main [ -424 1:address:num/raw <- new number:type -425 2:address:point/raw <- new point:type # not enough room in initial page +424 1:address:num/raw <- new number:type +425 2:address:point/raw <- new point:type # not enough room in initial page 426 ] 427 +new: routine allocated memory from 1000 to 1003 428 +new: routine allocated memory from 1003 to 1006 @@ -494,7 +494,7 @@ if ('onhashchange' in window) { 430 :(scenario new_without_ingredient) 431 % Hide_errors = true; 432 def main [ -433 1:address:number <- new # missing ingredient +433 1:address:number <- new # missing ingredient 434 ] 435 +error: main: 'new' requires one or two ingredients, but got '1:address:number <- new' -- cgit 1.4.1-2-gfad0