jitcraft/Spaces-inl.h
changeset 51 fb324242a675
parent 49 a92afa7484fd
child 53 13bd3a8df334
     1.1 --- a/jitcraft/Spaces-inl.h	Fri Jul 06 18:57:27 2012 -0400
     1.2 +++ b/jitcraft/Spaces-inl.h	Fri Jul 06 19:24:22 2012 -0400
     1.3 @@ -26,30 +26,19 @@
     1.4  {
     1.5      nbytes = Align(nbytes, kObjectAlignment);
     1.6  
     1.7 -    if (pos_ + nbytes > end_)
     1.8 +    if (cursor_ + nbytes > chunk_->end())
     1.9          return NULL;
    1.10  
    1.11 -    Address ptr = pos_;
    1.12 -    pos_ += nbytes;
    1.13 +    Address ptr = cursor_;
    1.14 +    cursor_ += nbytes;
    1.15      return ptr;
    1.16  }
    1.17  
    1.18  inline void
    1.19  HeapStack::unwind(Address to)
    1.20  {
    1.21 -    assert(to <= pos_ && to >= buffer_);
    1.22 -    pos_ = to;
    1.23 -}
    1.24 -
    1.25 -inline Address
    1.26 -HeapChunk::allocate(size_t nbytes)
    1.27 -{
    1.28 -    if (cursor_ + nbytes > end_)
    1.29 -        return NULL;
    1.30 -
    1.31 -    Address address = cursor_;
    1.32 -    cursor_ += nbytes;
    1.33 -    return address;
    1.34 +    assert(to <= cursor_ && to >= chunk_->first());
    1.35 +    cursor_ = to;
    1.36  }
    1.37  
    1.38  inline Address
    1.39 @@ -57,10 +46,12 @@
    1.40  {
    1.41      assert(IsAligned(nbytes, kObjectAlignment));
    1.42  
    1.43 -    if (Address addr = last_->allocate(nbytes))
    1.44 -        return addr;
    1.45 +    if (cursor_ + nbytes > last_->end())
    1.46 +        return allocateSlow(nbytes);
    1.47  
    1.48 -    return allocateSlow(nbytes);
    1.49 +    Address addr = cursor_ + nbytes;
    1.50 +    cursor_ += nbytes;
    1.51 +    return addr;
    1.52  }
    1.53  
    1.54  }