File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -426,16 +426,16 @@ function growMemory(root: Root, size: usize): void {
426
426
unreachable ( ) ;
427
427
return ;
428
428
}
429
+ // and additional BLOCK_OVERHEAD must be taken into account. If we are going
430
+ // to merge with the tail block, that's one time, otherwise it's two times.
431
+ let pagesBefore = memory . size ( ) ;
432
+ size += BLOCK_OVERHEAD << usize ( ( < usize > pagesBefore << 16 ) - BLOCK_OVERHEAD != changetype < usize > ( GETTAIL ( root ) ) ) ;
429
433
// Here, both rounding performed in searchBlock ...
430
434
const halfMaxSize = BLOCK_MAXSIZE >> 1 ;
431
435
if ( size < halfMaxSize ) { // don't round last fl
432
436
const invRound = ( sizeof < usize > ( ) * 8 - 1 ) - SL_BITS ;
433
- size += ( 1 << ( invRound - clz < usize > ( size ) ) ) - 1 ;
437
+ size += ( 1 << ( invRound - clz < usize > ( size ) ) ) - 1 ; // size should be larger than 15
434
438
}
435
- // and additional BLOCK_OVERHEAD must be taken into account. If we are going
436
- // to merge with the tail block, that's one time, otherwise it's two times.
437
- let pagesBefore = memory . size ( ) ;
438
- size += BLOCK_OVERHEAD << usize ( ( < usize > pagesBefore << 16 ) - BLOCK_OVERHEAD != changetype < usize > ( GETTAIL ( root ) ) ) ;
439
439
let pagesNeeded = < i32 > ( ( ( size + 0xffff ) & ~ 0xffff ) >>> 16 ) ;
440
440
let pagesWanted = max ( pagesBefore , pagesNeeded ) ; // double memory
441
441
if ( memory . grow ( pagesWanted ) < 0 ) {
You can’t perform that action at this time.
0 commit comments