From ebb498587f16aed15bb77b9ad39990c8a37d0a01 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 5 May 2008 07:04:53 -0600 Subject: [PATCH] enter exclusive state in collect function instead of requiring caller to enter that state before calling --- src/builtin.cpp | 2 -- src/machine.cpp | 9 +++++---- src/machine.h | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 7a880b846c..df32700e42 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -575,8 +575,6 @@ Java_java_lang_Runtime_load(Thread* t, jclass, jstring name, jboolean mapName) extern "C" JNIEXPORT void JNICALL Java_java_lang_Runtime_gc(Thread* t, jobject) { - ENTER(t, Thread::ExclusiveState); - collect(t, Heap::MajorCollection); } diff --git a/src/machine.cpp b/src/machine.cpp index 7c596c9bf9..0e2e9ba3f1 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1447,6 +1447,8 @@ makeArrayClass(Thread* t, object spec) void removeMonitor(Thread* t, object o) { + expect(t, t->state == Thread::ExclusiveState); + unsigned hash; if (DebugMonitors) { hash = objectHash(t, o); @@ -1556,9 +1558,7 @@ class HeapClient: public Heap::Client { } virtual void collect(void* context, Heap::CollectionType type) { - Thread* t = static_cast(context); - ENTER(t, Thread::ExclusiveState); - collect(t, type); + collect(static_cast(context), type); } virtual bool isFixed(void* p) { @@ -2084,7 +2084,6 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type, } if (t->heap == 0) { - ENTER(t, Thread::ExclusiveState); // fprintf(stderr, "gc"); // vmPrintTrace(t); collect(t, Heap::MinorCollection); @@ -2735,6 +2734,8 @@ intern(Thread* t, object s) void collect(Thread* t, Heap::CollectionType type) { + ENTER(t, Thread::ExclusiveState); + #ifdef VM_STRESS bool stress = t->stress; if (not stress) t->stress = true; diff --git a/src/machine.h b/src/machine.h index cca8a3b564..fbf152d4ab 100644 --- a/src/machine.h +++ b/src/machine.h @@ -1348,14 +1348,12 @@ stress(Thread* t) and t->state != Thread::IdleState) { t->stress = true; - { ENTER(t, Thread::ExclusiveState); # ifdef VM_STRESS_MAJOR collect(t, Heap::MajorCollection); # else // not VM_STRESS_MAJOR collect(t, Heap::MinorCollection); # endif // not VM_STRESS_MAJOR - } t->stress = false; }