void vm_map_store_copy_insert( vm_map_t map, vm_map_entry_t after_where, vm_map_copy_t copy) { if (__improbable(vm_debug_events)) { vm_map_entry_t entry; for (entry = vm_map_copy_first_entry(copy); entry != vm_map_copy_to_entry(copy); entry = entry->vme_next) { DTRACE_VM4(map_entry_link_copy, vm_map_t, map, vm_map_entry_t, entry, vm_address_t, entry->links.start, vm_address_t, entry->links.end); } } if (map->holelistenabled) { vm_map_entry_t entry = NULL; entry = vm_map_copy_first_entry(copy); while (entry != vm_map_copy_to_entry(copy)) { vm_map_store_update_first_free(map, entry, TRUE); entry = entry->vme_next; } } vm_map_store_copy_insert_ll(map, after_where, copy); #ifdef VM_MAP_STORE_USE_RB if (vm_map_store_has_RB_support( &map->hdr )) { vm_map_store_copy_insert_rb(map, after_where, copy); } #endif }
void vm_map_store_copy_insert_rb( vm_map_t map, __unused vm_map_entry_t after_where, vm_map_copy_t copy) { struct vm_map_header *mapHdr = &(map->hdr); struct rb_head *rbh = &(mapHdr->rb_head_store); struct vm_map_store *store; vm_map_entry_t entry = vm_map_copy_first_entry(copy); int inserted=0, nentries = copy->cpy_hdr.nentries; while (entry != vm_map_copy_to_entry(copy) && nentries > 0) { vm_map_entry_t prev = entry; store = &(entry->store); if( RB_INSERT( rb_head, rbh, store ) != NULL){ panic("VMSCIR1: INSERT FAILED: %d: %p, %p, %p, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx",inserted, prev, entry, vm_map_copy_to_entry(copy), (uintptr_t)prev->vme_start, (uintptr_t)prev->vme_end, (uintptr_t)entry->vme_start, (uintptr_t)entry->vme_end, (uintptr_t)(VME_FOR_STORE(rbh->rbh_root))->vme_start, (uintptr_t)(VME_FOR_STORE(rbh->rbh_root))->vme_end); } else { #if MAP_ENTRY_INSERTION_DEBUG backtrace(&entry->vme_insertion_bt[0], (sizeof (entry->vme_insertion_bt) / sizeof (uintptr_t))); #endif entry = entry->vme_next; inserted++; nentries--; } } }
void vm_map_store_copy_reset_ll( vm_map_copy_t copy, __unused vm_map_entry_t entry, __unused int nentries) { copy->cpy_hdr.nentries = 0; vm_map_copy_first_entry(copy) = vm_map_copy_last_entry(copy) = vm_map_copy_to_entry(copy); }