From 51a1081adc0744a4b04be7c7a5b2e9bcf23d5fc3 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 2 Feb 2011 08:46:20 -0700 Subject: [PATCH] remove unused Heap::Client::outOfMemory method The heap-dump-on-OOM feature has been moved to the collect function. --- src/heap.cpp | 7 ------- src/heap.h | 1 - src/machine.cpp | 30 +++++++++++++++--------------- src/machine.h | 1 + 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/heap.cpp b/src/heap.cpp index 7f923da02d..02e0e99a19 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -70,7 +70,6 @@ System* system(Context*); void* tryAllocate(Context* c, unsigned size); void* allocate(Context* c, unsigned size); void free(Context* c, const void* p, unsigned size); -void outOfMemory(Context*); #ifdef USE_ATOMIC_OPERATIONS inline void @@ -1780,12 +1779,6 @@ free_(Context* c, const void* p, unsigned size) free(c, p, size); } -void -outOfMemory(Context* c) -{ - c->client->outOfMemory(); -} - class MyHeap: public Heap { public: MyHeap(System* system, unsigned limit): diff --git a/src/heap.h b/src/heap.h index 3f454d6be0..ecb60d2637 100644 --- a/src/heap.h +++ b/src/heap.h @@ -49,7 +49,6 @@ class Heap: public Allocator { virtual unsigned copiedSizeInWords(void*) = 0; virtual void copy(void*, void*) = 0; virtual void walk(void*, Walker*) = 0; - virtual void outOfMemory() = 0; }; virtual void setClient(Client* client) = 0; diff --git a/src/machine.cpp b/src/machine.cpp index da705b5db6..31dad80726 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2156,21 +2156,6 @@ class HeapClient: public Heap::Client { ::walk(m->rootThread, w, o, 0); } - virtual void outOfMemory() { -#ifdef AVIAN_HEAPDUMP - const char* path = findProperty(m->rootThread, "avian.heap.dump"); - if (path) { - FILE* out = vm::fopen(path, "wb"); - if (out) { - dumpHeap(m->rootThread, out); - fclose(out); - } - } -#endif//AVIAN_HEAPDUMP - - abort(m->system); - } - void dispose() { m->heap->free(this, sizeof(*this)); } @@ -2282,6 +2267,7 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder, tenuredWeakReferences(0), unsafe(false), triedBuiltinOnLoad(false), + dumpedHeapOnOOM(false), heapPoolIndex(0) { heap->setClient(heapClient); @@ -3798,6 +3784,20 @@ collect(Thread* t, Heap::CollectionType type) // into the smallest possible space: doCollect(t, Heap::MajorCollection); } + +#ifdef AVIAN_HEAPDUMP + if ((not t->m->dumpedHeapOnOOM) and t->m->heap->limitExceeded()) { + t->m->dumpedHeapOnOOM = true; + const char* path = findProperty(t, "avian.heap.dump"); + if (path) { + FILE* out = vm::fopen(path, "wb"); + if (out) { + dumpHeap(t, out); + fclose(out); + } + } + } +#endif//AVIAN_HEAPDUMP } void diff --git a/src/machine.h b/src/machine.h index 100e6f1e04..3ab23cc2f4 100644 --- a/src/machine.h +++ b/src/machine.h @@ -1307,6 +1307,7 @@ class Machine { object tenuredWeakReferences; bool unsafe; bool triedBuiltinOnLoad; + bool dumpedHeapOnOOM; JavaVMVTable javaVMVTable; JNIEnvVTable jniEnvVTable; uintptr_t* heapPool[ThreadHeapPoolSize];