# HG changeset patch # User Doug Simon # Date 1427385968 -3600 # Node ID f137f1974f60d8b72d388f3e460947dbef3f885f # Parent c38296febf23cedfe7390f431c79f377b8396394 removed uses of StringBuffer, Hashtable and Stack diff -r c38296febf23 -r f137f1974f60 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java Thu Mar 26 11:39:07 2015 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java Thu Mar 26 17:06:08 2015 +0100 @@ -51,7 +51,7 @@ */ public static long getMemorySizeRecursive(MetaAccessProvider access, ConstantReflectionProvider constantReflection, JavaConstant constant, PrintStream out, int printTopN) { Set marked = new HashSet<>(); - Stack stack = new Stack<>(); + Deque stack = new ArrayDeque<>(); if (constant.getKind() == Kind.Object && constant.isNonNull()) { marked.add(constant); } @@ -120,7 +120,7 @@ return sum; } - private static void pushConstant(Set marked, Stack stack, JavaConstant value) { + private static void pushConstant(Set marked, Deque stack, JavaConstant value) { if (value.isNonNull()) { if (!marked.contains(value)) { marked.add(value); diff -r c38296febf23 -r f137f1974f60 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/UnsafeAccess.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/UnsafeAccess.java Thu Mar 26 11:39:07 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/UnsafeAccess.java Thu Mar 26 17:06:08 2015 +0100 @@ -65,7 +65,7 @@ if (address == 0) { return null; } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0;; i++) { char c = (char) unsafe.getByte(address + i); if (c == 0) { diff -r c38296febf23 -r f137f1974f60 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java Thu Mar 26 11:39:07 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java Thu Mar 26 17:06:08 2015 +0100 @@ -300,7 +300,7 @@ @Test public void test14() throws Exception { HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBufferTest", Object.class, Object.class); - StringBuffer buffer = new StringBuffer("TestTestTestTestTestTestTest"); + StringBuilder buffer = new StringBuilder("TestTestTestTestTestTestTest"); Assert.assertTrue(buffer.length() == 28); String a = new String("TestTestTestTestTestTestTest"); installedBenchmarkCode.executeVarargs(buffer, a.toCharArray()); @@ -323,7 +323,7 @@ } public static void stringBufferTestIn() { - StringBuffer buffer = new StringBuffer("TestTestTestTestTestTestTest"); + StringBuilder buffer = new StringBuilder("TestTestTestTestTestTestTest"); Assert.assertTrue(buffer.length() == 28); String a = new String("TestTestTestTestTestTestTest"); char[] add = a.toCharArray(); @@ -341,7 +341,7 @@ } public static void stringBufferArrayCopy() { - StringBuffer buffer = new StringBuffer("TestTestTestTestTestTestTest"); + StringBuilder buffer = new StringBuilder("TestTestTestTestTestTestTest"); Assert.assertTrue(buffer.length() == 28); String a = new String("TestTestTestTestTestTestTest"); char[] dst = new char[buffer.length() * 2]; diff -r c38296febf23 -r f137f1974f60 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Mar 26 11:39:07 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Mar 26 17:06:08 2015 +0100 @@ -296,7 +296,7 @@ private final boolean explodeLoops; private final boolean mergeExplosions; private final Map mergeExplosionsMap; - private Stack explodeLoopsContext; + private Deque explodeLoopsContext; private int nextPeelIteration = 1; private boolean controlFlowSplit; private final InvocationPluginReceiver invocationPluginReceiver = new InvocationPluginReceiver(this); @@ -452,7 +452,7 @@ private void detectLoops(FixedNode startInstruction) { NodeBitMap visited = currentGraph.createNodeBitMap(); NodeBitMap active = currentGraph.createNodeBitMap(); - Stack stack = new Stack<>(); + Deque stack = new ArrayDeque<>(); stack.add(startInstruction); visited.mark(startInstruction); while (!stack.isEmpty()) { @@ -498,7 +498,7 @@ private void insertLoopEnds(FixedNode startInstruction) { NodeBitMap visited = currentGraph.createNodeBitMap(); - Stack stack = new Stack<>(); + Deque stack = new ArrayDeque<>(); stack.add(startInstruction); visited.mark(startInstruction); List loopBegins = new ArrayList<>(); @@ -538,7 +538,7 @@ private void insertLoopExits(LoopBeginNode loopBegin, IdentityHashMap> innerLoopsMap) { NodeBitMap visited = currentGraph.createNodeBitMap(); - Stack stack = new Stack<>(); + Deque stack = new ArrayDeque<>(); for (LoopEndNode loopEnd : loopBegin.loopEnds()) { stack.push(loopEnd); visited.mark(loopEnd); @@ -622,7 +622,7 @@ private int iterateExplodedLoopHeader(BciBlock[] blocks, BciBlock header) { if (explodeLoopsContext == null) { - explodeLoopsContext = new Stack<>(); + explodeLoopsContext = new ArrayDeque<>(); } ExplodedLoopContext context = new ExplodedLoopContext(); @@ -1870,9 +1870,7 @@ } private int findOperatingDimensionWithLoopExplosion(BciBlock block, HIRFrameStateBuilder state) { - int i; - for (i = explodeLoopsContext.size() - 1; i >= 0; --i) { - ExplodedLoopContext context = explodeLoopsContext.elementAt(i); + for (ExplodedLoopContext context : explodeLoopsContext) { if (context.header == block) { if (this.mergeExplosions) { diff -r c38296febf23 -r f137f1974f60 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java Thu Mar 26 11:39:07 2015 +0100 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java Thu Mar 26 17:06:08 2015 +0100 @@ -89,7 +89,7 @@ break; case (char) 0xFFFF - 21: result = 858112498 / val; - x = new Hashtable<>(); + x = new HashMap<>(); break; default: result = 34324341 / val; @@ -142,7 +142,7 @@ break; case (short) -0x7FFF + 21: result = 858112498 / val; - x = new Hashtable<>(); + x = new HashMap<>(); break; default: result = 34324341 / val; @@ -198,7 +198,7 @@ break; case (byte) -0x7F + 21: result = 858112498 / val; - x = new Hashtable<>(); + x = new HashMap<>(); break; default: result = 34324341 / val; diff -r c38296febf23 -r f137f1974f60 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Thu Mar 26 11:39:07 2015 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Thu Mar 26 17:06:08 2015 +0100 @@ -130,13 +130,13 @@ private static class Instance { private final NodeMap map; - private final Stack loopExits; + private final Deque loopExits; private final Function> blockToNodes; private final Function nodeToBlock; public Instance(StructuredGraph graph, Function> blockToNodes, Function nodeToBlock) { map = graph.createNodeMap(); - loopExits = new Stack<>(); + loopExits = new ArrayDeque<>(); this.blockToNodes = blockToNodes; this.nodeToBlock = nodeToBlock; } @@ -282,8 +282,8 @@ } Block guardBlock = nodeToBlock.apply(proxiedGuard); assert guardBlock != null; - for (int i = 0; i < loopExits.size(); ++i) { - LoopExitNode loopExitNode = loopExits.get(i); + for (Iterator iter = loopExits.descendingIterator(); iter.hasNext();) { + LoopExitNode loopExitNode = iter.next(); Block loopExitBlock = nodeToBlock.apply(loopExitNode); if (guardBlock != loopExitBlock && AbstractControlFlowGraph.dominates(guardBlock, loopExitBlock)) { Block loopBeginBlock = nodeToBlock.apply(loopExitNode.loopBegin()); diff -r c38296febf23 -r f137f1974f60 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Thu Mar 26 11:39:07 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Thu Mar 26 17:06:08 2015 +0100 @@ -268,6 +268,9 @@ if (targetMethod != null) { // TODO maybe cast arguments + if (!targetMethod.canBeInlined()) { + return null; + } if (targetMethod.canBeStaticallyBound()) { return new InlineInfo(targetMethod, false, false); }