Mercurial > hg > graal-compiler
changeset 7544:5d9c23b8dbb8
factored out common code in NewObjectSnippets
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 23 Jan 2013 22:39:57 +0100 |
parents | be0d995ef51e |
children | b30b33d9da80 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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;