@@ -90,16 +90,11 @@ class List {
9090 * MAX_ALLOC (i.e. the whole address space).
9191 */
9292var BUCKET_START : usize = HEAP_BASE ;
93- var BUCKET_END : usize = BUCKET_START + BUCKET_COUNT * sizeof < usize > ( ) ;
93+ var BUCKET_END : usize = BUCKET_START + BUCKET_COUNT * List . SIZE ;
9494
9595function get_bucket ( index : usize ) : List {
9696 assert ( index < BUCKET_COUNT ) ;
97- return load < List > ( BUCKET_START + index * sizeof < usize > ( ) ) ;
98- }
99-
100- function set_bucket ( index : usize , list : List ) : void {
101- assert ( index < BUCKET_COUNT ) ;
102- store < List > ( BUCKET_START + index * sizeof < usize > ( ) , list ) ;
97+ return changetype < List > ( BUCKET_START + index * List . SIZE ) ;
10398}
10499
105100/*
@@ -330,6 +325,8 @@ function lower_bucket_limit(bucket: usize): u32 {
330325 return 1 ;
331326}
332327
328+ declare function logi ( i : i32 ) : void ;
329+
333330@global
334331function allocate_memory ( request : usize ) : usize {
335332 var original_bucket : usize , bucket : usize ;
@@ -349,7 +346,8 @@ function allocate_memory(request: usize): usize {
349346 * possible allocation size. More memory will be reserved later as needed.
350347 */
351348 if ( base_ptr == 0 ) {
352- base_ptr = max_ptr = SPLIT_END ;
349+ base_ptr = SPLIT_END ;
350+ max_ptr = < usize > current_memory ( ) << 16 ; // differs, must grow first
353351 bucket_limit = BUCKET_COUNT - 1 ;
354352 update_max_ptr ( base_ptr + List . SIZE ) ;
355353 list_init ( get_bucket ( BUCKET_COUNT - 1 ) ) ;
0 commit comments