MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / block_allocator

Function block_allocator

cranelift/entity/src/list.rs:669–692  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

667
668 #[test]
669 fn block_allocator() {
670 let mut pool = ListPool::<Inst>::new();
671 let b1 = pool.alloc(0);
672 let b2 = pool.alloc(1);
673 let b3 = pool.alloc(0);
674 assert_ne!(b1, b2);
675 assert_ne!(b1, b3);
676 assert_ne!(b2, b3);
677 pool.free(b2, 1);
678 let b2a = pool.alloc(1);
679 let b2b = pool.alloc(1);
680 assert_ne!(b2a, b2b);
681 // One of these should reuse the freed block.
682 assert!(b2a == b2 || b2b == b2);
683
684 // Check the free lists for a size class smaller than the largest seen so far.
685 pool.free(b1, 0);
686 pool.free(b3, 0);
687 let b1a = pool.alloc(0);
688 let b3a = pool.alloc(0);
689 assert_ne!(b1a, b3a);
690 assert!(b1a == b1 || b1a == b3);
691 assert!(b3a == b1 || b3a == b3);
692 }
693
694 #[test]
695 fn empty_list() {

Callers

nothing calls this directly

Calls 3

newFunction · 0.50
allocMethod · 0.45
freeMethod · 0.45

Tested by

no test coverage detected