1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

Implement COW pages! :^)

sys$fork() now clones all writable regions with per-page COW bits.
The pages are then mapped read-only and we handle a PF by COWing the pages.

This is quite delightful. Obviously there's lots of work to do still,
and it needs better data structures, but the general concept works.
This commit is contained in:
Andreas Kling 2018-11-05 13:48:07 +01:00
parent e85c22fe58
commit 2d045d2a64
Notes: sideshowbarker 2024-07-19 18:33:38 +09:00
11 changed files with 271 additions and 97 deletions

View file

@ -3,6 +3,7 @@
#include "StdLib.h"
#include "Types.h"
#include "kmalloc.h"
#include "Assertions.h"
namespace AK {
@ -14,9 +15,9 @@ public:
return Bitmap(data, size);
}
static Bitmap create(unsigned size)
static Bitmap create(unsigned size, bool default_value = 0)
{
return Bitmap(size);
return Bitmap(size, default_value);
}
~Bitmap()
@ -45,12 +46,14 @@ public:
const byte* data() const { return m_data; }
private:
explicit Bitmap(unsigned size)
explicit Bitmap(unsigned size, bool default_value)
: m_size(size)
, m_owned(true)
{
ASSERT(m_size != 0);
m_data = reinterpret_cast<byte*>(kmalloc(ceilDiv(size, 8u)));
size_t size_to_allocate = ceilDiv(size, 8u);
m_data = reinterpret_cast<byte*>(kmalloc(size_to_allocate));
memset(m_data, default_value ? 0xff : 0x00, size_to_allocate);
}
Bitmap(byte* data, unsigned size)