Mercurial > hg > truffle
changeset 10495:0fe1b0886dbf
Augment WriteBarrierAddition phase to insert G1 Barriers
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Fri, 21 Jun 2013 15:03:26 +0200 |
parents | 6f331db530f6 |
children | d18fbe96ba76 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java |
diffstat | 1 files changed, 42 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Fri Jun 21 11:59:34 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Fri Jun 21 15:03:26 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.phases; +import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.replacements.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.HeapAccess.WriteBarrierType; import com.oracle.graal.nodes.extended.*; @@ -35,6 +37,11 @@ @Override protected void run(StructuredGraph graph) { + for (ReadNode node : graph.getNodes(ReadNode.class)) { + if (node.getWriteBarrierType() == WriteBarrierType.PRECISE) { + addReadNodeBarriers(node, graph); + } + } for (WriteNode node : graph.getNodes(WriteNode.class)) { addWriteNodeBarriers(node, graph); } @@ -48,12 +55,27 @@ } } + private static void addReadNodeBarriers(ReadNode node, StructuredGraph graph) { + assert HotSpotReplacementsUtil.useG1GC(); + graph.addAfterFixed(node, graph.add(new G1PreWriteBarrier(node.object(), node, node.location(), false))); + } + private static void addWriteNodeBarriers(WriteNode node, StructuredGraph graph) { WriteBarrierType barrierType = node.getWriteBarrierType(); if (barrierType == WriteBarrierType.PRECISE) { - graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.location(), true))); + if (HotSpotReplacementsUtil.useG1GC()) { + graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), null, node.location(), true))); + graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.value(), node.location(), true))); + } else { + graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.location(), true))); + } } else if (barrierType == WriteBarrierType.IMPRECISE) { - graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.location(), false))); + if (HotSpotReplacementsUtil.useG1GC()) { + graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), null, node.location(), true))); + graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.value(), node.location(), false))); + } else { + graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.location(), false))); + } } else { assert barrierType == WriteBarrierType.NONE; } @@ -63,17 +85,31 @@ private static void addCASBarriers(CompareAndSwapNode node, StructuredGraph graph) { WriteBarrierType barrierType = node.getWriteBarrierType(); if (barrierType == WriteBarrierType.PRECISE) { - graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getLocation(), true))); + if (HotSpotReplacementsUtil.useG1GC()) { + graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), node.expected(), node.getLocation(), false))); + graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.newValue(), node.getLocation(), true))); + } else { + graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getLocation(), true))); + } } else if (barrierType == WriteBarrierType.IMPRECISE) { - graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getLocation(), false))); + if (HotSpotReplacementsUtil.useG1GC()) { + graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), node.expected(), node.getLocation(), false))); + graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.newValue(), node.getLocation(), false))); + } else { + graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getLocation(), false))); + } } else { assert barrierType == WriteBarrierType.NONE; } } private static void addArrayRangeBarriers(ArrayRangeWriteNode node, StructuredGraph graph) { - SerialArrayRangeWriteBarrier serialArrayRangeWriteBarrier = graph.add(new SerialArrayRangeWriteBarrier(node.getArray(), node.getIndex(), node.getLength())); - graph.addAfterFixed(node, serialArrayRangeWriteBarrier); + if (HotSpotReplacementsUtil.useG1GC()) { + throw new GraalInternalError("G1 does not yet suppot barriers for ArrayCopy Intrinsics. Run with -G:-IntrinsifyArrayCopy"); + } else { + SerialArrayRangeWriteBarrier serialArrayRangeWriteBarrier = graph.add(new SerialArrayRangeWriteBarrier(node.getArray(), node.getIndex(), node.getLength())); + graph.addAfterFixed(node, serialArrayRangeWriteBarrier); + } } }