@@ -20,33 +20,26 @@ jl_gc_pagemeta_t *jl_gc_page_metadata(void *data)
20
20
return page_metadata (data );
21
21
}
22
22
23
- region_t * jl_gc_find_region (void * ptr )
24
- {
25
- return find_region (ptr );
26
- }
27
-
28
23
// Find the memory block in the pool that owns the byte pointed to by p.
29
24
// For end of object pointer (which is always the case for pointer to a
30
25
// singleton object), this usually returns the same pointer which points to
31
26
// the next object but it can also return NULL if the pointer is pointing to
32
27
// the end of the page.
33
28
JL_DLLEXPORT jl_taggedvalue_t * jl_gc_find_taggedvalue_pool (char * p , size_t * osize_p )
34
29
{
35
- region_t * r = find_region (p );
36
- // Not in the pool
37
- if (!r )
30
+ if (!page_metadata (p ))
31
+ // Not in the pool
38
32
return NULL ;
33
+ struct jl_gc_metadata_ext info = page_metadata_ext (p );
39
34
char * page_begin = gc_page_data (p ) + GC_PAGE_OFFSET ;
40
35
// In the page header
41
36
if (p < page_begin )
42
37
return NULL ;
43
38
size_t ofs = p - page_begin ;
44
- int pg_idx = page_index (r , page_begin );
45
39
// Check if this is a free page
46
- if (!(r -> allocmap [pg_idx / 32 ] & (uint32_t )(1 << ( pg_idx % 32 ) )))
40
+ if (!(info . region0 -> allocmap [info . region0_i32 / 32 ] & (uint32_t )(1 << info . region0_i )))
47
41
return NULL ;
48
- jl_gc_pagemeta_t * pagemeta = & r -> meta [pg_idx ];
49
- int osize = pagemeta -> osize ;
42
+ int osize = info .meta -> osize ;
50
43
// Shouldn't be needed, just in case
51
44
if (osize == 0 )
52
45
return NULL ;
@@ -1016,14 +1009,42 @@ static void gc_count_pool_page(jl_gc_pagemeta_t *pg)
1016
1009
}
1017
1010
}
1018
1011
1019
- static void gc_count_pool_region (region_t * region )
1012
+ static void gc_count_pool_region0 (region0_t * region0 )
1013
+ {
1014
+ for (int pg_i = 0 ; pg_i < REGION0_PG_COUNT / 32 ; pg_i ++ ) {
1015
+ uint32_t line = region0 -> allocmap [pg_i ];
1016
+ if (line ) {
1017
+ for (int j = 0 ; j < 32 ; j ++ ) {
1018
+ if ((line >> j ) & 1 ) {
1019
+ gc_count_pool_page (region0 -> meta [pg_i * 32 + j ]);
1020
+ }
1021
+ }
1022
+ }
1023
+ }
1024
+ }
1025
+
1026
+ static void gc_count_pool_region1 (region1_t * region1 )
1020
1027
{
1021
- for (int pg_i = 0 ; pg_i < region -> pg_cnt / 32 ; pg_i ++ ) {
1022
- uint32_t line = region -> allocmap [pg_i ];
1028
+ for (int pg_i = 0 ; pg_i < REGION1_PG_COUNT / 32 ; pg_i ++ ) {
1029
+ uint32_t line = region1 -> allocmap0 [pg_i ];
1023
1030
if (line ) {
1024
1031
for (int j = 0 ; j < 32 ; j ++ ) {
1025
1032
if ((line >> j ) & 1 ) {
1026
- gc_count_pool_page (& region -> meta [pg_i * 32 + j ]);
1033
+ gc_count_pool_region0 (region1 -> meta0 [pg_i * 32 + j ]);
1034
+ }
1035
+ }
1036
+ }
1037
+ }
1038
+ }
1039
+
1040
+ static void gc_count_pool_regions (void )
1041
+ {
1042
+ for (int pg_i = 0 ; pg_i < (REGION2_PG_COUNT + 31 ) / 32 ; pg_i ++ ) {
1043
+ uint32_t line = memory_map .allocmap1 [pg_i ];
1044
+ if (line ) {
1045
+ for (int j = 0 ; j < 32 ; j ++ ) {
1046
+ if ((line >> j ) & 1 ) {
1047
+ gc_count_pool_region1 (memory_map .meta1 [pg_i * 32 + j ]);
1027
1048
}
1028
1049
}
1029
1050
}
@@ -1034,11 +1055,7 @@ void gc_count_pool(void)
1034
1055
{
1035
1056
memset (& poolobj_sizes , 0 , sizeof (poolobj_sizes ));
1036
1057
empty_pages = 0 ;
1037
- for (int i = 0 ; i < REGION_COUNT ; i ++ ) {
1038
- if (!regions [i ].pages )
1039
- break ;
1040
- gc_count_pool_region (& regions [i ]);
1041
- }
1058
+ gc_count_pool_regions ();
1042
1059
jl_safe_printf ("****** Pool stat: ******\n" );
1043
1060
for (int i = 0 ;i < 4 ;i ++ )
1044
1061
jl_safe_printf ("bits(%d): %" PRId64 "\n" , i , poolobj_sizes [i ]);
0 commit comments