equal
deleted
inserted
replaced
240 detach_memory(_pre_mapped.virtual_memory(), _pre_mapped.physical_memory()); |
240 detach_memory(_pre_mapped.virtual_memory(), _pre_mapped.physical_memory()); |
241 |
241 |
242 _pre_mapped.clear(); |
242 _pre_mapped.clear(); |
243 } |
243 } |
244 |
244 |
245 void ZPageAllocator::map_page(ZPage* page) { |
|
246 // Map physical memory |
|
247 _physical.map(page->physical_memory(), page->start()); |
|
248 } |
|
249 |
|
250 void ZPageAllocator::detach_page(ZPage* page) { |
245 void ZPageAllocator::detach_page(ZPage* page) { |
251 // Detach the memory mapping. |
246 // Detach the memory mapping. |
252 detach_memory(page->virtual_memory(), page->physical_memory()); |
247 detach_memory(page->virtual_memory(), page->physical_memory()); |
253 |
248 |
254 // Add to list of detached pages |
249 // Add to list of detached pages |
263 ZLocker<ZLock> locker(&_lock); |
258 ZLocker<ZLock> locker(&_lock); |
264 _virtual.free(page->virtual_memory()); |
259 _virtual.free(page->virtual_memory()); |
265 } |
260 } |
266 |
261 |
267 delete page; |
262 delete page; |
|
263 } |
|
264 |
|
265 void ZPageAllocator::map_page(ZPage* page) { |
|
266 // Map physical memory |
|
267 if (!page->is_mapped()) { |
|
268 _physical.map(page->physical_memory(), page->start()); |
|
269 } else if (ZVerifyViews) { |
|
270 _physical.debug_map(page->physical_memory(), page->start()); |
|
271 } |
|
272 } |
|
273 |
|
274 void ZPageAllocator::unmap_all_pages() { |
|
275 ZPhysicalMemory pmem(ZPhysicalMemorySegment(0 /* start */, ZAddressOffsetMax)); |
|
276 _physical.debug_unmap(pmem, 0 /* offset */); |
|
277 pmem.clear(); |
268 } |
278 } |
269 |
279 |
270 void ZPageAllocator::flush_detached_pages(ZList<ZPage>* list) { |
280 void ZPageAllocator::flush_detached_pages(ZList<ZPage>* list) { |
271 ZLocker<ZLock> locker(&_lock); |
281 ZLocker<ZLock> locker(&_lock); |
272 list->transfer(&_detached); |
282 list->transfer(&_detached); |
396 // Out of memory |
406 // Out of memory |
397 return NULL; |
407 return NULL; |
398 } |
408 } |
399 |
409 |
400 // Map page if needed |
410 // Map page if needed |
401 if (!page->is_mapped()) { |
411 map_page(page); |
402 map_page(page); |
|
403 } |
|
404 |
412 |
405 // Reset page. This updates the page's sequence number and must |
413 // Reset page. This updates the page's sequence number and must |
406 // be done after page allocation, which potentially blocked in |
414 // be done after page allocation, which potentially blocked in |
407 // a safepoint where the global sequence number was updated. |
415 // a safepoint where the global sequence number was updated. |
408 page->reset(); |
416 page->reset(); |
453 |
461 |
454 // Clear physical mapping |
462 // Clear physical mapping |
455 pmem.clear(); |
463 pmem.clear(); |
456 } |
464 } |
457 |
465 |
458 void ZPageAllocator::flip_page(ZPage* page) { |
|
459 const ZPhysicalMemory& pmem = page->physical_memory(); |
|
460 const uintptr_t addr = page->start(); |
|
461 |
|
462 // Flip physical mapping |
|
463 _physical.flip(pmem, addr); |
|
464 } |
|
465 |
|
466 void ZPageAllocator::flip_pre_mapped() { |
|
467 if (_pre_mapped.available() == 0) { |
|
468 // Nothing to flip |
|
469 return; |
|
470 } |
|
471 |
|
472 const ZPhysicalMemory& pmem = _pre_mapped.physical_memory(); |
|
473 const ZVirtualMemory& vmem = _pre_mapped.virtual_memory(); |
|
474 |
|
475 // Flip physical mapping |
|
476 _physical.flip(pmem, vmem.start()); |
|
477 } |
|
478 |
|
479 void ZPageAllocator::free_page(ZPage* page, bool reclaimed) { |
466 void ZPageAllocator::free_page(ZPage* page, bool reclaimed) { |
480 ZLocker<ZLock> locker(&_lock); |
467 ZLocker<ZLock> locker(&_lock); |
481 |
468 |
482 // Update used statistics |
469 // Update used statistics |
483 decrease_used(page->size(), reclaimed); |
470 decrease_used(page->size(), reclaimed); |