diff -r 5e3c49013064 -r fb324242a675 jitcraft/Spaces.cpp --- a/jitcraft/Spaces.cpp Fri Jul 06 18:57:27 2012 -0400 +++ b/jitcraft/Spaces.cpp Fri Jul 06 19:24:22 2012 -0400 @@ -23,29 +23,22 @@ using namespace jc; HeapStack::HeapStack() - : buffer_(NULL), - pos_(NULL), - end_(NULL) + : chunk_(NULL), + cursor_(NULL) { } HeapStack::~HeapStack() { - if (buffer_) - OS::UnmapAlignedMemory(map_.base(), map_.size()); + if (chunk_) + HeapChunk::Destroy(chunk_); } bool HeapStack::initialize() { - map_ = OS::MapAlignedMemory(kStackSize, kStackSize, OS::Map_Commit); - if (!map_.base()) - return false; - - buffer_ = map_.aligned(); - pos_ = buffer_; - end_ = buffer_ + kStackSize; - mask_ = kStackSize - 1; + chunk_ = HeapChunk::New(NULL, kStackSize); + cursor_ = chunk_->first(); return true; } @@ -61,7 +54,6 @@ HeapChunk *chunk = reinterpret_cast(map.aligned()); chunk->base_ = map.base(); chunk->end_ = map.base() + map.size(); - chunk->cursor_ = chunk->first(); if (prev) prev->next_ = chunk; @@ -85,6 +77,7 @@ { first_ = HeapChunk::New(first_, HeapChunk::kDefaultSize); last_ = first_; + cursor_ = first_->first(); return !!first_; } @@ -96,7 +89,14 @@ if (!chunk) return NULL; - return chunk->allocate(nbytes); + last_ = chunk; + cursor_ = chunk->first(); + + assert(cursor_ + nbytes <= chunk->end()); + + Address address = cursor_; + cursor_ += nbytes; + return address; } OldSpace::~OldSpace() @@ -143,9 +143,6 @@ first_ = chunk; last_ = chunk; - Address address = chunk->allocate(nbytes); - assert(address); - - return address; + return chunk->first(); }