1.1 --- a/jitcraft/Spaces.cpp Wed Jul 04 19:54:53 2012 -0400
1.2 +++ b/jitcraft/Spaces.cpp Fri Jul 06 09:45:21 2012 -0400
1.3 @@ -1,52 +1,54 @@
1.4 -/*
1.5 - * Copyright (C) 2012 David Anderson
1.6 - *
1.7 - * This file is part of JITCraft.
1.8 - *
1.9 - * JITCraft is free software: you can redistribute it and/or modify it under
1.10 - * the terms of the GNU General Public License as published by the Free
1.11 - * Software Foundation, either version 3 of the License, or (at your option)
1.12 - * any later version.
1.13 - *
1.14 - * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
1.15 - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.16 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1.17 - *
1.18 - * You should have received a copy of the GNU General Public License along with
1.19 - * JITCraft. If not, see http://www.gnu.org/licenses/.
1.20 - */
1.21 -#include "Spaces.h"
1.22 -#include "Platform.h"
1.23 -#include "Spaces-inl.h"
1.24 -
1.25 -using namespace jc;
1.26 -
1.27 -HeapStack::HeapStack()
1.28 - : buffer_(NULL),
1.29 - pos_(NULL),
1.30 - end_(NULL)
1.31 -{
1.32 -}
1.33 -
1.34 -HeapStack::~HeapStack()
1.35 -{
1.36 - if (buffer_)
1.37 - OS::UnmapAlignedMemory(map_.base(), map_.size());
1.38 -}
1.39 -
1.40 -bool
1.41 -HeapStack::initialize()
1.42 -{
1.43 - map_ = OS::MapAlignedMemory(kStackSize, kStackSize, OS::Map_Commit);
1.44 - if (!map_.base())
1.45 - return false;
1.46 -
1.47 - buffer_ = map_.aligned();
1.48 - pos_ = buffer_;
1.49 - end_ = buffer_ + kStackSize;
1.50 - return true;
1.51 -}
1.52 -
1.53 +/* vim: set ts=4 sw=4 tw=99 et:
1.54 + *
1.55 + * Copyright (C) 2012 David Anderson
1.56 + *
1.57 + * This file is part of JITCraft.
1.58 + *
1.59 + * JITCraft is free software: you can redistribute it and/or modify it under
1.60 + * the terms of the GNU General Public License as published by the Free
1.61 + * Software Foundation, either version 3 of the License, or (at your option)
1.62 + * any later version.
1.63 + *
1.64 + * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
1.65 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.66 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1.67 + *
1.68 + * You should have received a copy of the GNU General Public License along with
1.69 + * JITCraft. If not, see http://www.gnu.org/licenses/.
1.70 + */
1.71 +#include "Spaces.h"
1.72 +#include "Platform.h"
1.73 +#include "Spaces-inl.h"
1.74 +
1.75 +using namespace jc;
1.76 +
1.77 +HeapStack::HeapStack()
1.78 + : buffer_(NULL),
1.79 + pos_(NULL),
1.80 + end_(NULL)
1.81 +{
1.82 +}
1.83 +
1.84 +HeapStack::~HeapStack()
1.85 +{
1.86 + if (buffer_)
1.87 + OS::UnmapAlignedMemory(map_.base(), map_.size());
1.88 +}
1.89 +
1.90 +bool
1.91 +HeapStack::initialize()
1.92 +{
1.93 + map_ = OS::MapAlignedMemory(kStackSize, kStackSize, OS::Map_Commit);
1.94 + if (!map_.base())
1.95 + return false;
1.96 +
1.97 + buffer_ = map_.aligned();
1.98 + pos_ = buffer_;
1.99 + end_ = buffer_ + kStackSize;
1.100 + mask_ = kStackSize - 1;
1.101 + return true;
1.102 +}
1.103 +
1.104 HeapChunk *
1.105 HeapChunk::New(HeapChunk *prev, size_t size)
1.106 {
1.107 @@ -105,4 +107,18 @@
1.108 first_ = temp;
1.109 }
1.110 }
1.111 -
1.112 +
1.113 +
1.114 +Address
1.115 +LargeObjectSpace::allocate(size_t nbytes)
1.116 +{
1.117 + assert(IsAligned(nbytes, kObjectAlignment));
1.118 +
1.119 + if (last_) {
1.120 + if (Address addr = last_->allocate(nbytes))
1.121 + return addr;
1.122 + }
1.123 +
1.124 +
1.125 +}
1.126 +