# HG changeset patch # User Doug Simon # Date 1358977197 -3600 # Node ID 5d9c23b8dbb8f06b21035232feb9d3eac525830c # Parent be0d995ef51ef5417deee3d25dc5b5ff8a873b1d factored out common code in NewObjectSnippets diff -r be0d995ef51e -r 5d9c23b8dbb8 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java Wed Jan 23 22:37:22 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java Wed Jan 23 22:39:57 2013 +0100 @@ -259,9 +259,7 @@ StructuredGraph graph = (StructuredGraph) newInstanceNode.graph(); HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newInstanceNode.instanceClass(); ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph); - int size = type.instanceSize(); - assert (size % wordSize()) == 0; - assert size >= 0; + int size = instanceSize(type); ValueNode memory; if (!useTLAB) { @@ -333,9 +331,7 @@ HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) initializeNode.type(); assert !type.isArray(); ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph); - int size = type.instanceSize(); - assert (size % wordSize()) == 0; - assert size >= 0; + int size = instanceSize(type); Key key = new Key(initializeObject).add("size", size).add("fillContents", initializeNode.fillContents()).add("locked", initializeNode.locked()); ValueNode memory = initializeNode.memory(); Arguments arguments = arguments("memory", memory).add("hub", hub).add("prototypeMarkWord", type.prototypeMarkWord()); @@ -377,6 +373,13 @@ SnippetTemplate template = cache.get(key, assumptions); template.instantiate(runtime, newmultiarrayNode, DEFAULT_REPLACER, arguments); } + + private static int instanceSize(HotSpotResolvedObjectType type) { + int size = type.instanceSize(); + assert (size % wordSize()) == 0; + assert size >= 0; + return size; + } } private static final SnippetCounter.Group countersNew = GraalOptions.SnippetCounters ? new SnippetCounter.Group("NewInstance") : null;