jitcraft/Spaces.cpp
changeset 50 5e3c49013064
parent 49 a92afa7484fd
child 51 fb324242a675
     1.1 --- a/jitcraft/Spaces.cpp	Fri Jul 06 09:45:21 2012 -0400
     1.2 +++ b/jitcraft/Spaces.cpp	Fri Jul 06 18:57:27 2012 -0400
     1.3 @@ -108,17 +108,44 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +LargeObjectSpace::LargeObjectSpace()
     1.8 +  : first_(NULL),
     1.9 +    last_(NULL)
    1.10 +{
    1.11 +}
    1.12 +
    1.13 +LargeObjectSpace::~LargeObjectSpace()
    1.14 +{
    1.15 +    while (first_) {
    1.16 +        HeapChunk *temp = first_->next();
    1.17 +        HeapChunk::Destroy(first_);
    1.18 +        first_ = temp;
    1.19 +    }
    1.20 +}
    1.21 +
    1.22 +bool
    1.23 +LargeObjectSpace::initialize()
    1.24 +{
    1.25 +    return true;
    1.26 +}
    1.27  
    1.28  Address
    1.29  LargeObjectSpace::allocate(size_t nbytes)
    1.30  {
    1.31      assert(IsAligned(nbytes, kObjectAlignment));
    1.32  
    1.33 -    if (last_) {
    1.34 -        if (Address addr = last_->allocate(nbytes))
    1.35 -            return addr;
    1.36 -    }
    1.37 +    // Always allocate a new chunk for large objects.
    1.38 +    HeapChunk *chunk = HeapChunk::New(last_, nbytes);
    1.39 +    if (!chunk)
    1.40 +        return NULL;
    1.41  
    1.42 +    if (!first_)
    1.43 +        first_ = chunk;
    1.44 +    last_ = chunk;
    1.45  
    1.46 +    Address address = chunk->allocate(nbytes);
    1.47 +    assert(address);
    1.48 +
    1.49 +    return address;
    1.50  }
    1.51