# HG changeset patch # User Christos Kotselidis # Date 1363871473 -3600 # Node ID c3657d00e343c110c86990cd00ecc227355e763d # Parent dee7c8b578c7ffcd0bd4f33a1f17cd14f818b916# Parent 2bfb9644dcc23f4383afe0c123d9d02e1fbdef60 -Merge with tip diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Thu Mar 21 14:11:13 2013 +0100 @@ -37,6 +37,8 @@ import static com.oracle.graal.hotspot.nodes.ThreadIsInterruptedStubCall.*; import static com.oracle.graal.hotspot.nodes.VMErrorNode.*; import static com.oracle.graal.hotspot.nodes.VerifyOopStubCall.*; +import static com.oracle.graal.hotspot.nodes.WriteBarrierPreStubCall.*; +import static com.oracle.graal.hotspot.nodes.WriteBarrierPostStubCall.*; import static com.oracle.graal.hotspot.snippets.AESCryptSubstitutions.DecryptBlockStubCall.*; import static com.oracle.graal.hotspot.snippets.AESCryptSubstitutions.EncryptBlockStubCall.*; import static com.oracle.graal.hotspot.snippets.CipherBlockChainingSubstitutions.DecryptAESCryptStubCall.*; @@ -88,6 +90,16 @@ /* arg0: object */ javaCallingConvention(Kind.Object, /* arg1: lock */ word)); + addRuntimeCall(WBPRECALL, config.wbPreCallStub, + /* temps */ null, + /* ret */ ret(Kind.Void), + /* arg0: object */ javaCallingConvention(Kind.Object)); + + addRuntimeCall(WBPOSTCALL, config.wbPostCallStub, + /* temps */ null, + /* ret */ ret(Kind.Void), + /* arg0: object */ javaCallingConvention(Kind.Object, word)); + addRuntimeCall(MONITOREXIT, config.monitorExitStub, /* temps */ null, /* ret */ ret(Kind.Void), diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Mar 21 14:11:13 2013 +0100 @@ -22,7 +22,6 @@ */ package com.oracle.graal.hotspot; -import static com.oracle.graal.nodes.StructuredGraph.*; import static com.oracle.graal.phases.common.InliningUtil.*; import java.util.concurrent.*; @@ -36,6 +35,7 @@ import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; +import static com.oracle.graal.nodes.StructuredGraph.*; public final class CompilationTask implements Runnable, Comparable { diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Mar 21 14:11:13 2013 +0100 @@ -42,6 +42,7 @@ public boolean useBiasedLocking; public boolean usePopCountInstruction; public boolean useAESIntrinsics; + public boolean useG1GC; // offsets, ... public int stackShadowPages; @@ -216,6 +217,16 @@ public boolean isPollingPageFar; /** + * G1 Collector Related Values. + */ + public int g1CardQueueIndexOffset; + public int g1CardQueueBufferOffset; + public int logOfHRGrainBytes; + public int g1SATBQueueMarkingOffset; + public int g1SATBQueueIndexOffset; + public int g1SATBQueueBufferOffset; + + /** * The offset of the _java_mirror field (of type {@link Class}) in a Klass. */ public int classMirrorOffset; @@ -317,6 +328,9 @@ public long handleDeoptStub; public long monitorEnterStub; public long monitorExitStub; + public long wbPreCallStub; + public long wbPostCallStub; + public long verifyOopStub; public long vmErrorStub; public long deoptimizeStub; diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Mar 21 14:11:13 2013 +0100 @@ -87,6 +87,7 @@ private InstanceOfSnippets.Templates instanceofSnippets; private NewObjectSnippets.Templates newObjectSnippets; private MonitorSnippets.Templates monitorSnippets; + private WriteBarrierSnippets.Templates writeBarrierSnippets; private NewInstanceStub newInstanceStub; private NewArrayStub newArrayStub; @@ -265,7 +266,6 @@ /* ret */ ret(Kind.Void), /* arg0: object */ javaCallingConvention(Kind.Object, /* arg1: flags */ Kind.Int)); - // @formatter:on } @@ -353,11 +353,13 @@ installer.installSnippets(NewInstanceStub.class); installer.installSnippets(NewArrayStub.class); + installer.installSnippets(WriteBarrierSnippets.class); checkcastSnippets = new CheckCastSnippets.Templates(this, assumptions, graalRuntime.getTarget()); instanceofSnippets = new InstanceOfSnippets.Templates(this, assumptions, graalRuntime.getTarget()); newObjectSnippets = new NewObjectSnippets.Templates(this, assumptions, graalRuntime.getTarget(), config.useTLAB); monitorSnippets = new MonitorSnippets.Templates(this, assumptions, graalRuntime.getTarget(), config.useFastLocking); + writeBarrierSnippets = new WriteBarrierSnippets.Templates(this, assumptions, graalRuntime.getTarget()); newInstanceStub = new NewInstanceStub(this, assumptions, graalRuntime.getTarget()); newArrayStub = new NewArrayStub(this, assumptions, graalRuntime.getTarget()); @@ -580,10 +582,18 @@ LoadFieldNode loadField = (LoadFieldNode) n; HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) loadField.field(); ValueNode object = loadField.isStatic() ? ConstantNode.forObject(field.getDeclaringClass().mirror(), this, graph) : loadField.object(); + LocationNode location = LocationNode.create(field, field.getKind(), field.offset(), graph); assert loadField.kind() != Kind.Illegal; ReadNode memoryRead = graph.add(new ReadNode(object, LocationNode.create(field, field.getKind(), field.offset(), graph), loadField.stamp())); memoryRead.dependencies().add(tool.createNullCheckGuard(object)); + graph.replaceFixedWithFixed(loadField, memoryRead); + if (HotSpotSnippetUtils.useG1GC() && field.getKind() == Kind.Object && field.getDeclaringClass().getName().toString().equals("Ljava/lang/ref/Reference;") && + field.getName().equals("referent")) { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryRead.object(), memoryRead, location, false)); + graph.addAfterFixed(memoryRead, writeBarrierPre); + } + if (loadField.isVolatile()) { MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_READ)); graph.addBeforeFixed(memoryRead, preMembar); @@ -594,19 +604,31 @@ StoreFieldNode storeField = (StoreFieldNode) n; HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) storeField.field(); ValueNode object = storeField.isStatic() ? ConstantNode.forObject(field.getDeclaringClass().mirror(), this, graph) : storeField.object(); - WriteNode memoryWrite = graph.add(new WriteNode(object, storeField.value(), LocationNode.create(field, field.getKind(), field.offset(), graph))); + LocationNode location = LocationNode.create(field, field.getKind(), field.offset(), graph); + WriteNode memoryWrite = graph.add(new WriteNode(object, storeField.value(), location)); memoryWrite.dependencies().add(tool.createNullCheckGuard(object)); memoryWrite.setStateAfter(storeField.stateAfter()); graph.replaceFixedWithFixed(storeField, memoryWrite); FixedWithNextNode last = memoryWrite; + FixedWithNextNode first = memoryWrite; + if (field.getKind() == Kind.Object && !memoryWrite.value().objectStamp().alwaysNull()) { - FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(memoryWrite.object())); - graph.addAfterFixed(memoryWrite, writeBarrier); - last = writeBarrier; + if (!HotSpotSnippetUtils.useG1GC()) { + FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(memoryWrite.object())); + graph.addAfterFixed(memoryWrite, writeBarrier); + last = writeBarrier; + } else { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(memoryWrite.object(), null, memoryWrite.location(), true)); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(memoryWrite.object(), memoryWrite.value(), memoryWrite.location(), false)); + graph.addBeforeFixed(memoryWrite, writeBarrierPre); + graph.addAfterFixed(memoryWrite, writeBarrierPost); + first = writeBarrierPre; + last = writeBarrierPost; + } } if (storeField.isVolatile()) { MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_WRITE)); - graph.addBeforeFixed(memoryWrite, preMembar); + graph.addBeforeFixed(first, preMembar); MembarNode postMembar = graph.add(new MembarNode(JMM_POST_VOLATILE_WRITE)); graph.addAfterFixed(last, postMembar); } @@ -614,16 +636,29 @@ // Separate out GC barrier semantics CompareAndSwapNode cas = (CompareAndSwapNode) n; ValueNode expected = cas.expected(); + LocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, cas.expected().kind(), cas.displacement(), cas.offset(), graph, 1); if (expected.kind() == Kind.Object && !cas.newValue().objectStamp().alwaysNull()) { ResolvedJavaType type = cas.object().objectStamp().type(); if (type != null && !type.isArray() && !MetaUtil.isJavaLangObject(type)) { // Use a field write barrier since it's not an array store - FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(cas.object())); - graph.addAfterFixed(cas, writeBarrier); + if (!HotSpotSnippetUtils.useG1GC()) { + FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(cas.object())); + graph.addAfterFixed(cas, writeBarrier); + } else { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), null, location, true)); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location, false)); + graph.addBeforeFixed(cas, writeBarrierPre); + graph.addAfterFixed(cas, writeBarrierPost); + } } else { // This may be an array store so use an array write barrier - LocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, cas.expected().kind(), cas.displacement(), cas.offset(), graph, 1); - graph.addAfterFixed(cas, graph.add(new ArrayWriteBarrier(cas.object(), location))); + if (!HotSpotSnippetUtils.useG1GC()) { + graph.addAfterFixed(cas, graph.add(new ArrayWriteBarrier(cas.object(), (IndexedLocationNode) location))); + } else { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(cas.object(), null, location, true)); + graph.addBeforeFixed(cas, writeBarrierPre); + graph.addAfterFixed(cas, graph.add(new WriteBarrierPost(cas.object(), cas.newValue(), location, true))); + } } } } else if (n instanceof LoadIndexedNode) { @@ -665,11 +700,17 @@ WriteNode memoryWrite = graph.add(new WriteNode(array, value, arrayLocation)); memoryWrite.dependencies().add(boundsCheck); memoryWrite.setStateAfter(storeIndexed.stateAfter()); - graph.replaceFixedWithFixed(storeIndexed, memoryWrite); if (elementKind == Kind.Object && !value.objectStamp().alwaysNull()) { - graph.addAfterFixed(memoryWrite, graph.add(new ArrayWriteBarrier(array, arrayLocation))); + if (!HotSpotSnippetUtils.useG1GC()) { + graph.addAfterFixed(memoryWrite, graph.add(new ArrayWriteBarrier(array, (IndexedLocationNode) arrayLocation))); + } else { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(array, null, arrayLocation, true)); + graph.addBeforeFixed(memoryWrite, writeBarrierPre); + WriteBarrierPost writeBarrierPost = graph.add(new WriteBarrierPost(array, value, arrayLocation, true)); + graph.addAfterFixed(memoryWrite, writeBarrierPost); + } } } else if (n instanceof UnsafeLoadNode) { UnsafeLoadNode load = (UnsafeLoadNode) n; @@ -689,15 +730,28 @@ graph.replaceFixedWithFixed(store, write); if (write.value().kind() == Kind.Object && !write.value().objectStamp().alwaysNull()) { ResolvedJavaType type = object.objectStamp().type(); - WriteBarrier writeBarrier; + // WriteBarrier writeBarrier; if (type != null && !type.isArray() && !MetaUtil.isJavaLangObject(type)) { // Use a field write barrier since it's not an array store - writeBarrier = graph.add(new FieldWriteBarrier(object)); + if (!HotSpotSnippetUtils.useG1GC()) { + FieldWriteBarrier writeBarrier = graph.add(new FieldWriteBarrier(object)); + graph.addAfterFixed(write, writeBarrier); + } else { + WriteBarrierPre writeBarrierPre = new WriteBarrierPre(object, null, location, true); + graph.addBeforeFixed(write, graph.add(writeBarrierPre)); + graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location, false))); + } } else { // This may be an array store so use an array write barrier - writeBarrier = graph.add(new ArrayWriteBarrier(object, location)); + if (!HotSpotSnippetUtils.useG1GC()) { + ArrayWriteBarrier writeBarrier = graph.add(new ArrayWriteBarrier(object, location)); + graph.addAfterFixed(write, writeBarrier); + } else { + WriteBarrierPre writeBarrierPre = graph.add(new WriteBarrierPre(object, null, location, true)); + graph.addBeforeFixed(write, writeBarrierPre); + graph.addAfterFixed(write, graph.add(new WriteBarrierPost(object, write.value(), location, true))); + } } - graph.addAfterFixed(write, writeBarrier); } } else if (n instanceof LoadHubNode) { LoadHubNode loadHub = (LoadHubNode) n; @@ -729,6 +783,14 @@ monitorSnippets.lower((MonitorEnterNode) n, tool); } else if (n instanceof MonitorExitNode) { monitorSnippets.lower((MonitorExitNode) n, tool); + } else if (n instanceof FieldWriteBarrier) { + writeBarrierSnippets.lower((FieldWriteBarrier) n, tool); + } else if (n instanceof ArrayWriteBarrier) { + writeBarrierSnippets.lower((ArrayWriteBarrier) n, tool); + } else if (n instanceof WriteBarrierPre) { + writeBarrierSnippets.lower((WriteBarrierPre) n, tool); + } else if (n instanceof WriteBarrierPost) { + writeBarrierSnippets.lower((WriteBarrierPost) n, tool); } else if (n instanceof TLABAllocateNode) { newObjectSnippets.lower((TLABAllocateNode) n, tool); } else if (n instanceof InitializeObjectNode) { diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ArrayWriteBarrier.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ArrayWriteBarrier.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ArrayWriteBarrier.java Thu Mar 21 14:11:13 2013 +0100 @@ -22,32 +22,29 @@ */ package com.oracle.graal.hotspot.nodes; -import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; -public final class ArrayWriteBarrier extends WriteBarrier implements LIRLowerable { +public final class ArrayWriteBarrier extends WriteBarrier implements Lowerable { @Input private ValueNode object; - @Input private LocationNode location; + @Input private IndexedLocationNode location; public ValueNode object() { return object; } - public LocationNode location() { + public IndexedLocationNode location() { return location; } - public ArrayWriteBarrier(ValueNode object, LocationNode location) { + public ArrayWriteBarrier(ValueNode object, IndexedLocationNode location) { this.object = object; this.location = location; } - @Override - public void generate(LIRGeneratorTool gen) { - Value addr = location().generateLea(gen, object()); - generateBarrier(addr, gen); + public void lower(LoweringTool generator) { + generator.getRuntime().lower(this, generator); } } diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FieldWriteBarrier.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FieldWriteBarrier.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FieldWriteBarrier.java Thu Mar 21 14:11:13 2013 +0100 @@ -22,11 +22,10 @@ */ package com.oracle.graal.hotspot.nodes; -import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; -public final class FieldWriteBarrier extends WriteBarrier implements LIRLowerable { +public final class FieldWriteBarrier extends WriteBarrier implements Lowerable { @Input private ValueNode object; @@ -38,10 +37,7 @@ this.object = object; } - @Override - public void generate(LIRGeneratorTool generator) { - Value obj = generator.newVariable(generator.target().wordKind); - generator.emitMove(obj, generator.operand(object())); - generateBarrier(obj, generator); + public void lower(LoweringTool generator) { + generator.getRuntime().lower(this, generator); } } diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FixedValueAnchorNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/FixedValueAnchorNode.java Thu Mar 21 14:11:13 2013 +0100 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +public final class FixedValueAnchorNode extends FixedWithNextNode implements LIRLowerable { + + @Input private ValueNode object; + + public ValueNode object() { + return object; + } + + public FixedValueAnchorNode(ValueNode object) { + super(StampFactory.forNodeIntrinsic()); + this.object = object; + + } + + @Override + public boolean inferStamp() { + return updateStamp(object.stamp()); + } + + @NodeIntrinsic + public static native T getObject(Object object); + + @Override + public void generate(LIRGeneratorTool generator) { + generator.setResult(this, generator.operand(object)); + } + +} diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java Thu Mar 21 14:11:13 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot.nodes; import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.snippets.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -72,7 +73,7 @@ } public boolean fillContents() { - return fillContents; + return HotSpotSnippetUtils.useG1GC() ? true : fillContents; } public boolean locked() { diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeObjectNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeObjectNode.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeObjectNode.java Thu Mar 21 14:11:13 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot.nodes; import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.snippets.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -56,7 +57,7 @@ } public boolean fillContents() { - return fillContents; + return HotSpotSnippetUtils.useG1GC() ? true : fillContents; } public boolean locked() { diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPost.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPost.java Thu Mar 21 14:11:13 2013 +0100 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +public final class WriteBarrierPost extends FixedWithNextNode implements Lowerable { + + @Input private ValueNode object; + @Input private ValueNode value; + @Input private LocationNode location; + private boolean precise; + + public ValueNode object() { + return object; + } + + public ValueNode value() { + return value; + } + + public LocationNode location() { + return location; + } + + public boolean usePrecise() { + return precise; + } + + public WriteBarrierPost(ValueNode object, ValueNode value, LocationNode location, boolean precise) { + super(StampFactory.forVoid()); + this.object = object; + this.value = value; + this.location = location; + this.precise = precise; + } + + public void lower(LoweringTool generator) { + generator.getRuntime().lower(this, generator); + } +} diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPostStubCall.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPostStubCall.java Thu Mar 21 14:11:13 2013 +0100 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.compiler.gen.*; +import com.oracle.graal.compiler.target.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; +import com.oracle.graal.word.*; + +/** + * Node implementing a call to HotSpot's {@code graal_monitorenter} stub. + */ +public class WriteBarrierPostStubCall extends FixedWithNextNode implements LIRGenLowerable { + + @Input private final ValueNode object; + @Input private final ValueNode card; + public static final Descriptor WBPOSTCALL = new Descriptor("wbpostcall", true, void.class, Object.class, Word.class); + + public WriteBarrierPostStubCall(ValueNode object, ValueNode card) { + super(StampFactory.forVoid()); + this.object = object; + this.card = card; + } + + @Override + public void generate(LIRGenerator gen) { + RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(WriteBarrierPostStubCall.WBPOSTCALL); + gen.emitCall(stub, stub.getCallingConvention(), false, gen.operand(object), gen.operand(card)); + } + + @NodeIntrinsic + public static native void call(Object hub, Word card); +} diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPre.java Thu Mar 21 14:11:13 2013 +0100 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +public final class WriteBarrierPre extends FixedWithNextNode implements Lowerable { + + @Input private ValueNode object; + @Input private LocationNode location; + @Input private ValueNode expectedObject; + private boolean doLoad; + + public ValueNode object() { + return object; + } + + public ValueNode expectedObject() { + return expectedObject; + } + + public boolean doLoad() { + return doLoad; + } + + public LocationNode location() { + return location; + } + + public WriteBarrierPre(ValueNode object, ValueNode expectedObject, LocationNode location, boolean doLoad) { + super(StampFactory.forVoid()); + this.object = object; + this.doLoad = doLoad; + this.location = location; + this.expectedObject = expectedObject; + } + + public void lower(LoweringTool generator) { + generator.getRuntime().lower(this, generator); + } + +} diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPreStubCall.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierPreStubCall.java Thu Mar 21 14:11:13 2013 +0100 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.compiler.gen.*; +import com.oracle.graal.compiler.target.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; + +/** + * Node implementing a call to HotSpot's {@code graal_monitorenter} stub. + */ +public class WriteBarrierPreStubCall extends FixedWithNextNode implements LIRGenLowerable { + + @Input private final ValueNode object; + public static final Descriptor WBPRECALL = new Descriptor("wbprecall", true, void.class, Object.class); + + public WriteBarrierPreStubCall(ValueNode object) { + super(StampFactory.forVoid()); + this.object = object; + } + + @Override + public void generate(LIRGenerator gen) { + RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(WriteBarrierPreStubCall.WBPRECALL); + gen.emitCall(stub, stub.getCallingConvention(), false, gen.operand(object)); + } + + @NodeIntrinsic + public static native void call(Object hub); +} diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierStubCall.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrierStubCall.java Thu Mar 21 14:11:13 2013 +0100 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.compiler.gen.*; +import com.oracle.graal.compiler.target.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; + +/** + * Node implementing a call to HotSpot's {@code graal_monitorenter} stub. + */ +public class WriteBarrierStubCall extends FixedWithNextNode implements LIRGenLowerable { + + @Input private final ValueNode object; + public static final Descriptor G1_WB_SLOW = new Descriptor("g1_wb_slow", true, void.class, Object.class); + + public WriteBarrierStubCall(ValueNode object) { + super(StampFactory.forVoid()); + this.object = object; + } + + @Override + public void generate(LIRGenerator gen) { + RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(WriteBarrierStubCall.G1_WB_SLOW); + gen.emitCall(stub, stub.getCallingConvention(), true, gen.operand(object)); + } + + @NodeIntrinsic + public static native void call(Object hub); +} diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/HotSpotSnippetUtils.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/HotSpotSnippetUtils.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/HotSpotSnippetUtils.java Thu Mar 21 14:11:13 2013 +0100 @@ -53,6 +53,11 @@ } @Fold + public static boolean useTLAB() { + return config().useTLAB; + } + + @Fold public static boolean verifyOops() { return config().verifyOops; } @@ -281,6 +286,36 @@ } @Fold + public static int g1CardQueueIndexOffset() { + return config().g1CardQueueIndexOffset; + } + + @Fold + public static int g1CardQueueBufferOffset() { + return config().g1CardQueueBufferOffset; + } + + @Fold + public static int logOfHRGrainBytes() { + return config().logOfHRGrainBytes; + } + + @Fold + public static int g1SATBQueueMarkingOffset() { + return config().g1SATBQueueMarkingOffset; + } + + @Fold + public static int g1SATBQueueIndexOffset() { + return config().g1SATBQueueIndexOffset; + } + + @Fold + public static int g1SATBQueueBufferOffset() { + return config().g1SATBQueueBufferOffset; + } + + @Fold public static int superCheckOffsetOffset() { return config().superCheckOffsetOffset; } @@ -312,6 +347,11 @@ } @Fold + public static boolean useG1GC() { + return config().useG1GC; + } + + @Fold static int uninitializedIdentityHashCodeValue() { return config().uninitializedIdentityHashCodeValue; } diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/SystemSubstitutions.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Thu Mar 21 14:11:13 2013 +0100 @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.snippets; + +import static com.oracle.graal.hotspot.snippets.HotSpotSnippetUtils.*; +import static com.oracle.graal.snippets.SnippetTemplate.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.snippets.*; +import com.oracle.graal.snippets.Snippet.ConstantParameter; +import com.oracle.graal.snippets.Snippet.Parameter; +import com.oracle.graal.snippets.SnippetTemplate.AbstractTemplates; +import com.oracle.graal.snippets.SnippetTemplate.Arguments; +import com.oracle.graal.snippets.SnippetTemplate.Key; +import com.oracle.graal.word.*; + +public class WriteBarrierSnippets implements SnippetsInterface { + + @Snippet + public static void g1PreWriteBarrier(@Parameter("object") Object obj, @Parameter("expectedObject") Object expobj, @Parameter("location") Object location, + @ConstantParameter("doLoad") boolean doLoad) { + Word thread = thread(); + Object object = FixedValueAnchorNode.getObject(obj); + Object expectedObject = FixedValueAnchorNode.getObject(expobj); + Pointer field = Word.fromArray(object, location); + Pointer previousOop = Word.fromObject(expectedObject); + byte markingValue = thread.readByte(HotSpotSnippetUtils.g1SATBQueueMarkingOffset()); + + Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1SATBQueueBufferOffset()); + Word indexAddress = thread.add(HotSpotSnippetUtils.g1SATBQueueIndexOffset()); + Word indexValue = indexAddress.readWord(0); + + if (markingValue != (byte) 0) { + if (doLoad) { + previousOop = field.readWord(0); + } + if (previousOop.notEqual(Word.zero())) { + if (indexValue.notEqual(Word.zero())) { + Word nextIndex = indexValue.subtract(HotSpotSnippetUtils.wordSize()); + Word logAddress = bufferAddress.add(nextIndex); + logAddress.writeWord(0, previousOop); + indexAddress.writeWord(0, nextIndex); + } else { + WriteBarrierPreStubCall.call(previousOop); + + } + } + } + } + + @Snippet + public static void g1PostWriteBarrier(@Parameter("object") Object obj, @Parameter("value") Object value, @Parameter("location") Object location, @ConstantParameter("usePrecise") boolean usePrecise) { + Word thread = thread(); + Object object = FixedValueAnchorNode.getObject(obj); + Object wrObject = FixedValueAnchorNode.getObject(value); + Pointer oop = Word.fromObject(object); + Pointer field; + if (usePrecise) { + field = Word.fromArray(object, location); + } else { + field = oop; + } + Pointer writtenValue = Word.fromObject(wrObject); + Word bufferAddress = thread.readWord(HotSpotSnippetUtils.g1CardQueueBufferOffset()); + Word indexAddress = thread.add(HotSpotSnippetUtils.g1CardQueueIndexOffset()); + Word indexValue = thread.readWord(HotSpotSnippetUtils.g1CardQueueIndexOffset()); + Word xorResult = ((Word) field.xor(writtenValue)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes()); + + // Card Table + Word cardBase = (Word) field.unsignedShiftRight(cardTableShift()); + long startAddress = cardTableStart(); + int displacement = 0; + if (((int) startAddress) == startAddress) { + displacement = (int) startAddress; + } else { + cardBase = cardBase.add(Word.unsigned(cardTableStart())); + } + Word cardAddress = cardBase.add(displacement); + + if (xorResult.notEqual(Word.zero())) { + if (writtenValue.notEqual(Word.zero())) { + byte cardByte = cardAddress.readByte(0); + if (cardByte != (byte) 0) { + cardAddress.writeByte(0, (byte) 0); // smash zero into card + if (indexValue.notEqual(Word.zero())) { + Word nextIndex = indexValue.subtract(HotSpotSnippetUtils.wordSize()); + Word logAddress = bufferAddress.add(nextIndex); + logAddress.writeWord(0, cardAddress); + indexAddress.writeWord(0, nextIndex); + } else { + WriteBarrierPostStubCall.call(object, cardAddress); + } + } + } + } + } + + @Snippet + public static void serialFieldWriteBarrier(@Parameter("object") Object object) { + Pointer oop = Word.fromObject(object); + Word base = (Word) oop.unsignedShiftRight(cardTableShift()); + long startAddress = cardTableStart(); + int displacement = 0; + if (((int) startAddress) == startAddress) { + displacement = (int) startAddress; + } else { + base = base.add(Word.unsigned(cardTableStart())); + } + base.writeWord(displacement, Word.zero()); + } + + @Snippet + public static void serialArrayWriteBarrier(@Parameter("object") Object object, @Parameter("location") Object location) { + Pointer oop = Word.fromArray(object, location); + Word base = (Word) oop.unsignedShiftRight(cardTableShift()); + long startAddress = cardTableStart(); + int displacement = 0; + if (((int) startAddress) == startAddress) { + displacement = (int) startAddress; + } else { + base = base.add(Word.unsigned(cardTableStart())); + } + base.writeWord(displacement, Word.zero()); + } + + public static class Templates extends AbstractTemplates { + + private final ResolvedJavaMethod serialFieldWriteBarrier; + private final ResolvedJavaMethod serialArrayWriteBarrier; + private final ResolvedJavaMethod g1PreWriteBarrier; + private final ResolvedJavaMethod g1PostWriteBarrier; + + public Templates(CodeCacheProvider runtime, Assumptions assumptions, TargetDescription target) { + super(runtime, assumptions, target, WriteBarrierSnippets.class); + serialFieldWriteBarrier = snippet("serialFieldWriteBarrier", Object.class); + serialArrayWriteBarrier = snippet("serialArrayWriteBarrier", Object.class, Object.class); + g1PreWriteBarrier = snippet("g1PreWriteBarrier", Object.class, Object.class, Object.class, boolean.class); + g1PostWriteBarrier = snippet("g1PostWriteBarrier", Object.class, Object.class, Object.class, boolean.class); + } + + public void lower(ArrayWriteBarrier arrayWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { + ResolvedJavaMethod method = serialArrayWriteBarrier; + Key key = new Key(method); + Arguments arguments = new Arguments(); + arguments.add("object", arrayWriteBarrier.object()); + arguments.add("location", arrayWriteBarrier.location()); + SnippetTemplate template = cache.get(key, assumptions); + template.instantiate(runtime, arrayWriteBarrier, DEFAULT_REPLACER, arguments); + } + + public void lower(FieldWriteBarrier fieldWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { + ResolvedJavaMethod method = serialFieldWriteBarrier; + Key key = new Key(method); + Arguments arguments = new Arguments(); + arguments.add("object", fieldWriteBarrier.object()); + SnippetTemplate template = cache.get(key, assumptions); + template.instantiate(runtime, fieldWriteBarrier, DEFAULT_REPLACER, arguments); + } + + public void lower(WriteBarrierPre writeBarrierPre, @SuppressWarnings("unused") LoweringTool tool) { + ResolvedJavaMethod method = g1PreWriteBarrier; + Key key = new Key(method); + key.add("doLoad", writeBarrierPre.doLoad()); + Arguments arguments = new Arguments(); + arguments.add("object", writeBarrierPre.object()); + arguments.add("expectedObject", writeBarrierPre.expectedObject()); + arguments.add("location", writeBarrierPre.location()); + SnippetTemplate template = cache.get(key, assumptions); + template.instantiate(runtime, writeBarrierPre, DEFAULT_REPLACER, arguments); + } + + public void lower(WriteBarrierPost writeBarrierPost, @SuppressWarnings("unused") LoweringTool tool) { + ResolvedJavaMethod method = g1PostWriteBarrier; + Key key = new Key(method); + key.add("usePrecise", writeBarrierPost.usePrecise()); + Arguments arguments = new Arguments(); + arguments.add("object", writeBarrierPost.object()); + arguments.add("location", writeBarrierPost.location()); + arguments.add("value", writeBarrierPost.value()); + SnippetTemplate template = cache.get(key, assumptions); + template.instantiate(runtime, writeBarrierPost, DEFAULT_REPLACER, arguments); + } + + } +} diff -r 2bfb9644dcc2 -r c3657d00e343 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 Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Thu Mar 21 14:11:13 2013 +0100 @@ -94,7 +94,12 @@ * operation was unsuccessful */ static Word refillAllocate(Word intArrayHub, int sizeInBytes, boolean log) { - + if (useG1GC()) { + return Word.zero(); + } + if (!useTLAB()) { + return edenAllocate(Word.unsigned(sizeInBytes), log); + } Word intArrayMarkWord = Word.unsigned(tlabIntArrayMarkWord()); int alignmentReserveInBytes = tlabAlignmentReserveInHeapWords() * wordSize(); diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/GenerateLEANode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/GenerateLEANode.java Thu Mar 21 14:11:13 2013 +0100 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes.extended; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +/** + * The {@code UnsafeCastNode} produces the same value as its input, but with a different type. + */ +public class GenerateLEANode extends FloatingNode implements Canonicalizable, LIRLowerable { + + @Input private ValueNode object; + @Input private ValueNode location; + + public ValueNode object() { + return object; + } + + public LocationNode location() { + return (LocationNode) location; + } + + public GenerateLEANode(ValueNode object, ValueNode location, Stamp stamp) { + super(stamp); + this.object = object; + this.location = location; + } + + @Override + public ValueNode canonical(CanonicalizerTool tool) { + return this; + } + + @Override + public void generate(LIRGeneratorTool gen) { + Value addr = location().generateLea(gen, object()); + gen.setResult(this, addr); + } +} diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/GraalIntrinsics.java diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java Thu Mar 21 14:11:13 2013 +0100 @@ -63,6 +63,7 @@ FROM_UNSIGNED, FROM_SIGNED, FROM_OBJECT, + FROM_ARRAY, TO_OBJECT, TO_RAW_VALUE, } @@ -146,6 +147,9 @@ @Operation(opcode = Opcode.FROM_OBJECT) public static native Pointer fromObject(Object val); + @Operation(opcode = Opcode.FROM_ARRAY) + public static native Pointer fromArray(Object oop, Object location); + @Override @Operation(opcode = Opcode.TO_OBJECT) public native Object toObject(); diff -r 2bfb9644dcc2 -r c3657d00e343 graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Mon Mar 18 19:18:42 2013 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Thu Mar 21 14:11:13 2013 +0100 @@ -176,6 +176,11 @@ replace(invoke, graph.unique(new UnsafeCastNode(arguments.get(0), StampFactory.forKind(wordKind)))); break; + case FROM_ARRAY: + assert arguments.size() == 2; + replace(invoke, graph.unique(new GenerateLEANode(arguments.get(0), arguments.get(1), StampFactory.forKind(wordKind)))); + break; + case TO_OBJECT: assert arguments.size() == 1; replace(invoke, graph.unique(new UnsafeCastNode(arguments.get(0), invoke.node().stamp()))); diff -r 2bfb9644dcc2 -r c3657d00e343 mx/commands.py --- a/mx/commands.py Mon Mar 18 19:18:42 2013 +0100 +++ b/mx/commands.py Thu Mar 21 14:11:13 2013 +0100 @@ -1120,6 +1120,15 @@ vm = _vm; sanitycheck.getSPECjbb2013(benchArgs).bench(vm, opts=vmArgs) +def specjbb2005(args): + """runs the composite SPECjbb2005 benchmark + + All options begining with - will be passed to the vm""" + benchArgs = [a for a in args if a[0] != '-'] + vmArgs = [a for a in args if a[0] == '-'] + vm = _vm; + sanitycheck.getSPECjbb2005(benchArgs).bench(vm, opts=vmArgs) + def hsdis(args, copyToDir=None): """download the hsdis library @@ -1225,6 +1234,7 @@ 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], 'specjvm2008': [specjvm2008, '[VM options|specjvm2008 options (-v, -ikv, -ict, -wt, -it)]'], 'specjbb2013': [specjbb2013, '[VM options]'], + 'specjbb2005': [specjbb2005, '[VM options]'], #'example': [example, '[-v] example names...'], 'gate' : [gate, '[-options]'], 'gv' : [gv, ''], diff -r 2bfb9644dcc2 -r c3657d00e343 mx/sanitycheck.py --- a/mx/sanitycheck.py Mon Mar 18 19:18:42 2013 +0100 +++ b/mx/sanitycheck.py Thu Mar 21 14:11:13 2013 +0100 @@ -27,6 +27,8 @@ import re, mx, commands, os, sys, StringIO, subprocess from os.path import isfile, join, exists +gc='UseSerialGC' + dacapoSanityWarmup = { 'avrora': [0, 0, 3, 6, 13], 'batik': [0, 0, 5, 5, 20], @@ -107,7 +109,7 @@ success = re.compile(r"^Valid run, Score is [0-9]+$", re.MULTILINE) matcher = ValuesMatcher(score, {'group' : 'SPECjbb2005', 'name' : 'score', 'score' : ''}) classpath = ['jbb.jar', 'check.jar'] - return Test("SPECjbb2005", ['spec.jbb.JBBmain', '-propfile', 'SPECjbb.props'] + benchArgs, [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+UseSerialGC', '-XX:-UseCompressedOops', '-cp', os.pathsep.join(classpath)], defaultCwd=specjbb2005) + return Test("SPECjbb2005", ['spec.jbb.JBBmain', '-propfile', 'SPECjbb.props'] + benchArgs, [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+'+gc, '-XX:-UseCompressedOops', '-cp', os.pathsep.join(classpath)], defaultCwd=specjbb2005) def getSPECjbb2013(benchArgs = []): @@ -144,7 +146,7 @@ if skipCheck: opts += ['-ict'] - return Test("SPECjvm2008", ['-jar', 'SPECjvm2008.jar'] + opts + benchArgs, [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+UseSerialGC', '-XX:-UseCompressedOops'], defaultCwd=specjvm2008) + return Test("SPECjvm2008", ['-jar', 'SPECjvm2008.jar'] + opts + benchArgs, [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+'+gc, '-XX:-UseCompressedOops'], defaultCwd=specjvm2008) def getDacapos(level=SanityCheckLevel.Normal, gateBuildLevel=None, dacapoArgs=[]): checks = [] @@ -176,7 +178,7 @@ dacapoMatcher = ValuesMatcher(dacapoTime, {'group' : 'DaCapo', 'name' : '', 'score' : '