// locate an exiting record that contains specified address, or // the record, where the record with specified address, should // be inserted virtual MemPointer* locate(address addr) { VMMemRegion* cur = (VMMemRegion*)current(); VMMemRegion* next_p; while (cur != NULL) { if (cur->base() > addr) { return cur; } else { // find nearest existing range that has base address <= addr next_p = (VMMemRegion*)peek_next(); if (next_p != NULL && next_p->base() <= addr) { cur = (VMMemRegion*)next(); continue; } } if (cur->is_reserve_record() && cur->base() <= addr && (cur->base() + cur->size() > addr)) { return cur; } else if (cur->is_commit_record() && cur->base() <= addr && (cur->base() + cur->committed_size() > addr)) { return cur; } cur = (VMMemRegion*)next(); } return NULL; }
bool VMMemPointerIterator::insert_reserved_region(MemPointerRecord* rec) { // skip all 'commit' records associated with previous reserved region VMMemRegion* p = (VMMemRegion*)next(); while (p != NULL && p->is_committed_region() && p->base() + p->size() < rec->addr()) { p = (VMMemRegion*)next(); } return insert_record(rec); }
// locate an existing reserved memory region that contains specified address, // or the reserved region just above this address, where the incoming // reserved region should be inserted. virtual MemPointer* locate(address addr) { reset(); VMMemRegion* reg = (VMMemRegion*)current(); while (reg != NULL) { if (reg->is_reserved_region()) { if (reg->contains_address(addr) || addr < reg->base()) { return reg; } } reg = (VMMemRegion*)next(); } return NULL; }