VmAbstractHeap heap = currentHeap; Object result = null; int oomCount = 0;
final int alignedSize = ObjectLayout.objectAlign(size);
	protected Object allocObject(VmClassType vmClass, int size) {		// Make sure the class is initialized		vmClass.initialize();				final int alignedSize = ObjectLayout.objectAlign(size);		//final Monitor mon = heapMonitor;		VmAbstractHeap heap = currentHeap;		Object result = null;		int oomCount = 0;		if (gcActive) {		    Unsafe.debug("Using GC Heap sz"); Unsafe.debug(alignedSize);		    result = gcHeap.alloc(vmClass, alignedSize);		    if (result == null) {		        helper.die("Out of GC heap memory.");		    }		} else {		    final Monitor m = heapMonitor;		    //final Monitor m = null;		    if (m != null) {		        m.enter();		    }		    try {		        while (result == null) {		            // The current heap is full		            if (heap == null) {		                //Unsafe.debug("allocHeap in allocObject("); Unsafe.debug(alignedSize);		                //Unsafe.debug(") ");		                int newHeapSize = DEFAULT_HEAP_SIZE;  		                if (size > newHeapSize) {		                    // this is a BIG object, try to allocate a new heap 		                    // only for it		                    newHeapSize = size;		                }		                if ((heap = allocHeap(newHeapSize, true)) == null) {		                    lowOnMemory = true;		                    // It was not possible to allocate another heap.		                    // First try to GC, if we've done that before		                    // in this allocation, then we're in real panic.		                    if (oomCount == 0) {		                        oomCount++;		                        Unsafe.debug("<oom/>");		                        gcThread.trigger(true);		                        heap = firstHeap;		                        currentHeap = firstHeap;		                    } else {		                        Unsafe.debug("Out of memory in allocObject(");		                        Unsafe.debug(size);		                        Unsafe.debug(")");		                        throw OOME;		                        //Unsafe.die();		                    }		                } else {		                    //Unsafe.debug("AO.G");		                    // We successfully allocated a new heap, set it		                    // to current, so we'll use it for the following		                    // allocations.		                    currentHeap = heap;		                }		            }		            		            result = heap.alloc(vmClass, alignedSize);		            		            if (result == null) {		                heap = heap.getNext();		            }		        }		        vmClass.incInstanceCount();		        lowOnMemory = false;		        // Allocated objects are initially black.		        helper.unsafeSetObjectFlags(result, ObjectFlags.GC_DEFAULT_COLOR);		        		        allocatedSinceGcTrigger += alignedSize;		        if ((allocatedSinceGcTrigger > triggerSize) && (gcThread != null)) {		            Unsafe.debug("<alloc:GC trigger/>");		            allocatedSinceGcTrigger = 0;		            gcThread.trigger(false);		        }		    } finally {		        if (m != null) {		            m.exit();		        }		    }		}				return result;	}