mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
Region::clone() should share the zone if it's read-only.
This avoids copying the .text and .rodata segments in fork(). The next step is copy-on-write support for the writable regions.
This commit is contained in:
@@ -428,6 +428,10 @@ RetainPtr<Region> Region::clone()
|
||||
InterruptDisabler disabler;
|
||||
KernelPagingScope pagingScope;
|
||||
|
||||
if (is_readable && !is_writable) {
|
||||
// Create a new region backed by the same zone.
|
||||
return adopt(*new Region(linearAddress, size, zone.copyRef(), String(name), is_readable, is_writable));
|
||||
}
|
||||
// FIXME: Implement COW regions.
|
||||
auto clone_zone = MM.createZone(zone->size());
|
||||
auto clone_region = adopt(*new Region(linearAddress, size, move(clone_zone), String(name), is_readable, is_writable));
|
||||
|
||||
Reference in New Issue
Block a user