From 5a07e04d56df634e8abaf2ce1bb25fbbe7ad3fda Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 5 Feb 2013 09:48:20 -0700 Subject: [PATCH] assert that there are no outstanding Get*Critical requests during allocation When GetStringCritical or GetPrimitiveArrayCritical are called, the VM cannot risk new Java heap allocations until the corresponding release method is called because allocations may result in GC, which cannot happen while a string or array is pinned in memory. We already have a check for this latter in the footprint function used during GC, but it's best to catch the problem as early as possible. --- src/machine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/machine.cpp b/src/machine.cpp index c06d8c8159..5e08655898 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -3458,6 +3458,8 @@ object allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type, unsigned sizeInBytes, bool objectMask) { + expect(t, t->criticalLevel == 0); + if (UNLIKELY(t->flags & Thread::UseBackupHeapFlag)) { expect(t, t->backupHeapIndex + ceiling(sizeInBytes, BytesPerWord) <= ThreadBackupHeapSizeInWords);