AllocatedMemoryIO allocate(Ruby runtime, int size, boolean clear) { MemoryAllocation allocation; Object sentinel; int idx = bucketIndex(roundUpToPowerOf2(Math.max(8, size))); AllocationGroup group = allocationGroups[idx]; if (group == null || (sentinel = group.get()) == null || (allocation = group.allocate(clear)) == null) { // no existing group, or it is all used up. allocationGroups[idx] = group = new AllocationGroup(buckets[idx].getMagazine(), sentinel = new Object()); referenceSet.put(group, Boolean.TRUE); allocation = group.allocate(clear); } return new AllocatedMemoryIO(runtime, sentinel, allocation, size); } }
AllocatedMemoryIO allocate(Ruby runtime, int size, boolean clear) { MemoryAllocation allocation; Object sentinel; int idx = bucketIndex(roundUpToPowerOf2(Math.max(8, size))); AllocationGroup group = allocationGroups[idx]; if (group == null || (sentinel = group.get()) == null || (allocation = group.allocate(clear)) == null) { // no existing group, or it is all used up. allocationGroups[idx] = group = new AllocationGroup(buckets[idx].getMagazine(), sentinel = new Object()); referenceSet.put(group, Boolean.TRUE); allocation = group.allocate(clear); } return new AllocatedMemoryIO(runtime, sentinel, allocation, size); } }
AllocatedMemoryIO allocate(Ruby runtime, int size, boolean clear) { MemoryAllocation allocation; Object sentinel; int idx = bucketIndex(roundUpToPowerOf2(Math.max(8, size))); AllocationGroup group = allocationGroups[idx]; if (group == null || (sentinel = group.get()) == null || (allocation = group.allocate(clear)) == null) { // no existing group, or it is all used up. allocationGroups[idx] = group = new AllocationGroup(buckets[idx].getMagazine(), sentinel = new Object()); referenceSet.put(group, Boolean.TRUE); allocation = group.allocate(clear); } return new AllocatedMemoryIO(runtime, sentinel, allocation, size); } }
AllocatedMemoryIO allocate(Ruby runtime, int size, boolean clear) { MemoryAllocation allocation; Object sentinel; int idx = bucketIndex(roundUpToPowerOf2(Math.max(8, size))); AllocationGroup group = allocationGroups[idx]; if (group == null || (sentinel = group.get()) == null || (allocation = group.allocate(clear)) == null) { // no existing group, or it is all used up. allocationGroups[idx] = group = new AllocationGroup(buckets[idx].getMagazine(), sentinel = new Object()); referenceSet.put(group, Boolean.TRUE); allocation = group.allocate(clear); } return new AllocatedMemoryIO(runtime, sentinel, allocation, size); } }
public void free() { if (allocation.isReleased()) { throw getRuntime().newRuntimeError("memory already freed"); } allocation.free(); sentinel = null; }
public void free() { if (allocation.isReleased()) { throw getRuntime().newRuntimeError("memory already freed"); } allocation.free(); sentinel = null; }
public void free() { if (allocation.isReleased()) { throw getRuntime().newRuntimeError("memory already freed"); } allocation.free(); sentinel = null; }
public void free() { if (allocation.isReleased()) { throw getRuntime().newRuntimeError("memory already freed"); } allocation.free(); sentinel = null; }