# HG changeset patch # User Doug Simon # Date 1340378856 -7200 # Node ID 5d06e32f10dfa05dd5fd281f03429ddcfa6ea126 # Parent 6cb39a47da14655d589884dcabb9ec5327106810 limited length of zeroing instructions for object initialization to object below a certain size diff -r 6cb39a47da14 -r 5d06e32f10df graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java Fri Jun 22 17:16:57 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java Fri Jun 22 17:27:36 2012 +0200 @@ -98,14 +98,27 @@ } /** + * Maximum size of an object whose body is initialized by a sequence of + * zero-stores to its fields. Larger objects have their bodies initialized + * in a loop. + */ + private static final int MAX_UNROLLED_OBJECT_INITIALIZATION_SIZE = 10 * wordSize(); + + /** * Formats some allocated memory with an object header zeroes out the rest. */ private static void formatObject(Object hub, int size, Word memory, Word headerPrototype) { store(memory, 0, 0, headerPrototype); store(memory, 0, hubOffset(), hub); - explodeLoop(); - for (int offset = 2 * wordSize(); offset < size; offset += wordSize()) { - store(memory, 0, offset, 0); + if (size <= MAX_UNROLLED_OBJECT_INITIALIZATION_SIZE) { + explodeLoop(); + for (int offset = 2 * wordSize(); offset < size; offset += wordSize()) { + store(memory, 0, offset, 0); + } + } else { + for (int offset = 2 * wordSize(); offset < size; offset += wordSize()) { + store(memory, 0, offset, 0); + } } }