Add a heap block map for objects of size granules to obj_map. */ Return FALSE on failure. */ A size of 0 granules is used for large objects. */
| 49 | /* Return FALSE on failure. */ |
| 50 | /* A size of 0 granules is used for large objects. */ |
| 51 | GC_bool GC_add_map_entry(size_t granules) |
| 52 | { |
| 53 | unsigned displ; |
| 54 | short * new_map; |
| 55 | |
| 56 | if (granules > BYTES_TO_GRANULES(MAXOBJBYTES)) granules = 0; |
| 57 | if (GC_obj_map[granules] != 0) { |
| 58 | return(TRUE); |
| 59 | } |
| 60 | new_map = (short *)GC_scratch_alloc(MAP_LEN * sizeof(short)); |
| 61 | if (new_map == 0) return(FALSE); |
| 62 | if (GC_print_stats) |
| 63 | GC_printf("Adding block map for size of %u granules (%u bytes)\n", |
| 64 | (unsigned)granules, (unsigned)(GRANULES_TO_BYTES(granules))); |
| 65 | if (granules == 0) { |
| 66 | for (displ = 0; displ < BYTES_TO_GRANULES(HBLKSIZE); displ++) { |
| 67 | new_map[displ] = 1; /* Nonzero to get us out of marker fast path. */ |
| 68 | } |
| 69 | } else { |
| 70 | for (displ = 0; displ < BYTES_TO_GRANULES(HBLKSIZE); displ++) { |
| 71 | new_map[displ] = (short)(displ % granules); |
| 72 | } |
| 73 | } |
| 74 | GC_obj_map[granules] = new_map; |
| 75 | return(TRUE); |
| 76 | } |
| 77 | #endif |
| 78 | |
| 79 | static GC_bool offsets_initialized = FALSE; |
no test coverage detected