Permalink
Browse files

Keep default heap size at 2 blocks for unit tests.

The default heap size for the `lcvm` binary remains at 1 MB.
  • Loading branch information...
1 parent f811798 commit 6ce6557c2347d0ed14ac02c928617b06a22f5c3b @nominolo committed Sep 20, 2012
Showing with 9 additions and 5 deletions.
  1. +1 −0 vm/main.cc
  2. +2 −5 vm/memorymanager.cc
  3. +6 −0 vm/memorymanager.hh
View
@@ -32,6 +32,7 @@ int main(int argc, char *argv[]) {
initializeTimer();
Time startup_time = getProcessElapsedTime();
MemoryManager mm;
+ mm.setMinHeapSize(1UL * 1024 * 1024);
Loader loader(&mm, opts->basePath().c_str());
if (!loader.loadWiredInModules())
View
@@ -127,7 +127,7 @@ Time gc_time = 0;
MemoryManager::MemoryManager()
: free_(NULL), old_heap_(NULL), topOfStackMask_(kNoMask),
- nextGC_(idivCeil(LC_DEFAULT_HEAP_SIZE, Block::kBlockSize)),
+ minHeapSize_(2), nextGC_(minHeapSize_),
allocated_(0), num_gcs_(0) {
region_ = Region::newRegion(Region::kSmallObjectRegion);
info_tables_ = grabFreeBlock(Block::kInfoTables);
@@ -318,11 +318,8 @@ void MemoryManager::performGC(Capability *cap) {
// TODO: Add sanity check. Everything reachable from the roots must
// be in a k[Static]Closures block now.
-
-
// TODO: Is this correct?
- uint32_t minHeapBlocks = idivCeil(LC_DEFAULT_HEAP_SIZE, Block::kBlockSize);
- nextGC_ = (fullBlocks > minHeapBlocks ? fullBlocks : minHeapBlocks) + 1;
+ nextGC_ = (fullBlocks > minHeapSize_ ? fullBlocks : minHeapSize_) + 1;
gc_time += getProcessElapsedTime() - gc_start;
}
View
@@ -225,6 +225,11 @@ public:
nextGC_ = blocks;
}
+ inline void setMinHeapSize(size_t bytes) {
+ minHeapSize_ = idivCeil(bytes, Block::kBlockSize);
+ if (minHeapSize_ < 2) minHeapSize_ = 2;
+ }
+
private:
inline void *allocInto(Block **block, size_t bytes) {
char *ptr = (*block)->alloc(bytes);
@@ -281,6 +286,7 @@ private:
Block *old_heap_; // Only non-NULL during GC
u4 topOfStackMask_;
+ uint64_t minHeapSize_; // in blocks
u4 nextGC_; // if zero, a GC gets triggered.
// Assuming an allocation rate of 16GB/s (pretty high), this counter

0 comments on commit 6ce6557

Please sign in to comment.