@@ -25,7 +25,7 @@ use wasmtime_environ::{
2525} ;
2626
2727mod index_allocator;
28- use index_allocator:: PoolingAllocationState ;
28+ use index_allocator:: { PoolingAllocationState , SlotId } ;
2929
3030cfg_if:: cfg_if! {
3131 if #[ cfg( windows) ] {
@@ -404,7 +404,7 @@ impl InstancePool {
404404 if alloc. is_empty ( ) {
405405 return Err ( InstantiationError :: Limit ( self . max_instances as u32 ) ) ;
406406 }
407- alloc. alloc ( req. unique_id )
407+ alloc. alloc ( req. unique_id ) . index ( )
408408 } ;
409409
410410 unsafe {
@@ -430,7 +430,6 @@ impl InstancePool {
430430 debug_assert ! ( index < self . max_instances) ;
431431
432432 let instance = unsafe { & mut * handle. instance } ;
433- let unique_id = instance. unique_id ;
434433
435434 // Decommit any linear memories that were used
436435 for ( ( def_mem_idx, memory) , base) in
@@ -500,7 +499,7 @@ impl InstancePool {
500499 // touched again until we write a fresh Instance in-place with
501500 // std::ptr::write in allocate() above.
502501
503- self . index_allocator . lock ( ) . unwrap ( ) . free ( index, unique_id ) ;
502+ self . index_allocator . lock ( ) . unwrap ( ) . free ( SlotId ( index) ) ;
504503 }
505504
506505 fn set_instance_memories (
@@ -928,7 +927,7 @@ impl StackPool {
928927 if alloc. is_empty ( ) {
929928 return Err ( FiberStackError :: Limit ( self . max_instances as u32 ) ) ;
930929 }
931- alloc. alloc ( None )
930+ alloc. alloc ( None ) . index ( )
932931 } ;
933932
934933 debug_assert ! ( index < self . max_instances) ;
@@ -974,7 +973,7 @@ impl StackPool {
974973
975974 decommit_stack_pages ( bottom_of_stack as _ , stack_size) . unwrap ( ) ;
976975
977- self . index_allocator . lock ( ) . unwrap ( ) . free ( index, None ) ;
976+ self . index_allocator . lock ( ) . unwrap ( ) . free ( SlotId ( index) ) ;
978977 }
979978}
980979
@@ -1457,7 +1456,7 @@ mod test {
14571456
14581457 assert_eq ! (
14591458 instances. index_allocator. lock( ) . unwrap( ) . testing_freelist( ) ,
1460- & [ 0 , 1 , 2 ]
1459+ & [ SlotId ( 0 ) , SlotId ( 1 ) , SlotId ( 2 ) ]
14611460 ) ;
14621461
14631462 let mut handles = Vec :: new ( ) ;
@@ -1520,7 +1519,7 @@ mod test {
15201519
15211520 assert_eq ! (
15221521 instances. index_allocator. lock( ) . unwrap( ) . testing_freelist( ) ,
1523- & [ 2 , 1 , 0 ]
1522+ & [ SlotId ( 2 ) , SlotId ( 1 ) , SlotId ( 0 ) ]
15241523 ) ;
15251524
15261525 Ok ( ( ) )
@@ -1632,7 +1631,18 @@ mod test {
16321631
16331632 assert_eq ! (
16341633 pool. index_allocator. lock( ) . unwrap( ) . testing_freelist( ) ,
1635- & [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ,
1634+ & [
1635+ SlotId ( 0 ) ,
1636+ SlotId ( 1 ) ,
1637+ SlotId ( 2 ) ,
1638+ SlotId ( 3 ) ,
1639+ SlotId ( 4 ) ,
1640+ SlotId ( 5 ) ,
1641+ SlotId ( 6 ) ,
1642+ SlotId ( 7 ) ,
1643+ SlotId ( 8 ) ,
1644+ SlotId ( 9 )
1645+ ] ,
16361646 ) ;
16371647
16381648 let base = pool. mapping . as_ptr ( ) as usize ;
@@ -1660,7 +1670,18 @@ mod test {
16601670
16611671 assert_eq ! (
16621672 pool. index_allocator. lock( ) . unwrap( ) . testing_freelist( ) ,
1663- & [ 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 ] ,
1673+ & [
1674+ SlotId ( 9 ) ,
1675+ SlotId ( 8 ) ,
1676+ SlotId ( 7 ) ,
1677+ SlotId ( 6 ) ,
1678+ SlotId ( 5 ) ,
1679+ SlotId ( 4 ) ,
1680+ SlotId ( 3 ) ,
1681+ SlotId ( 2 ) ,
1682+ SlotId ( 1 ) ,
1683+ SlotId ( 0 )
1684+ ] ,
16641685 ) ;
16651686
16661687 Ok ( ( ) )
0 commit comments