# HG changeset patch # User Lukas Stadler # Date 1355762649 -3600 # Node ID c6696813003774f2f0a3831b71a6a49e8dcd3a31 # Parent 73139223837c7ba8785b9f6372363d6d9acd22b0 replicate c1 tlab refill behavior more closely, fixes problem with huge tlab sizes diff -r 73139223837c -r c66968130037 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Mon Dec 17 17:42:27 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Mon Dec 17 17:44:09 2012 +0100 @@ -83,13 +83,7 @@ // check that array length is small enough for fast path. if (!forceSlowPath() && length <= MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH) { - Word memory; - if (refillTLAB(intArrayHub, Word.fromLong(tlabIntArrayMarkWord()), tlabAlignmentReserveInHeapWords() * wordSize(), log)) { - memory = allocate(sizeInBytes); - } else { - log(log, "newArray: allocating directly in eden\n", 0L); - memory = edenAllocate(Word.fromInt(sizeInBytes), log); - } + Word memory = refillAllocate(intArrayHub, sizeInBytes, log); if (memory != Word.zero()) { log(log, "newArray: allocated new array at %p\n", memory.toLong()); formatArray(hub, sizeInBytes, length, headerSize, memory, Word.fromLong(arrayPrototypeMarkWord()), true); diff -r 73139223837c -r c66968130037 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Mon Dec 17 17:42:27 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Mon Dec 17 17:44:09 2012 +0100 @@ -71,12 +71,7 @@ int sizeInBytes = loadIntFromWord(hub, klassInstanceSizeOffset()); if (!forceSlowPath() && inlineContiguousAllocationSupported()) { if (loadIntFromWord(hub, klassStateOffset()) == klassStateFullyInitialized()) { - Word memory; - if (refillTLAB(intArrayHub, Word.fromLong(tlabIntArrayMarkWord()), tlabAlignmentReserveInHeapWords() * wordSize(), log)) { - memory = allocate(sizeInBytes); - } else { - memory = edenAllocate(Word.fromInt(sizeInBytes), log); - } + Word memory = refillAllocate(intArrayHub, sizeInBytes, log); if (memory != Word.zero()) { Word prototypeMarkWord = loadWordFromWord(hub, prototypeMarkWordOffset()); storeWord(memory, 0, markOffset(), prototypeMarkWord); @@ -92,15 +87,17 @@ } /** - * Attempts to refill the current thread's TLAB. + * Attempts to refill the current thread's TLAB and retries the allocation. * * @param intArrayHub the hub for {@code int[].class} - * @param intArrayMarkWord the mark word for the int array placed in the left over TLAB space - * @param alignmentReserveInBytes the amount of extra bytes to reserve in a new TLAB + * @param sizeInBytes the size of the allocation * @param log specifies if logging is enabled - * @return whether or not a new TLAB was allocated + * @return the newly allocated, uninitialized chunk of memory, or {@link Word#zero()} if the operation was unsuccessful */ - static boolean refillTLAB(Word intArrayHub, Word intArrayMarkWord, int alignmentReserveInBytes, boolean log) { + static Word refillAllocate(Word intArrayHub, int sizeInBytes, boolean log) { + + Word intArrayMarkWord = Word.fromLong(tlabIntArrayMarkWord()); + int alignmentReserveInBytes = tlabAlignmentReserveInHeapWords() * wordSize(); Word thread = thread(); Word top = loadWordFromWord(thread, threadTlabTopOffset()); @@ -156,9 +153,10 @@ end = top.plus(tlabRefillSizeInBytes.minus(alignmentReserveInBytes)); storeWord(thread, 0, threadTlabEndOffset(), end); - return true; + + return allocate(sizeInBytes); } else { - return false; + return Word.zero(); } } else { // Retain TLAB @@ -170,7 +168,7 @@ storeInt(thread, 0, tlabSlowAllocationsOffset(), loadIntFromWord(thread, tlabSlowAllocationsOffset()) + 1); } - return false; + return edenAllocate(Word.fromInt(sizeInBytes), log); } } diff -r 73139223837c -r c66968130037 graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/WordTypeRewriterPhase.java --- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/WordTypeRewriterPhase.java Mon Dec 17 17:42:27 2012 +0100 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/WordTypeRewriterPhase.java Mon Dec 17 17:44:09 2012 +0100 @@ -25,7 +25,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.ConvertNode.Op; import com.oracle.graal.nodes.extended.*;