Mercurial > hg > graal-compiler
changeset 20040:f137f1974f60
removed uses of StringBuffer, Hashtable and Stack
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 26 Mar 2015 17:06:08 +0100 |
parents | c38296febf23 |
children | 01290be48def |
files | graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/UnsafeAccess.java graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java |
diffstat | 7 files changed, 22 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- 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<JavaConstant> marked = new HashSet<>(); - Stack<JavaConstant> stack = new Stack<>(); + Deque<JavaConstant> stack = new ArrayDeque<>(); if (constant.getKind() == Kind.Object && constant.isNonNull()) { marked.add(constant); } @@ -120,7 +120,7 @@ return sum; } - private static void pushConstant(Set<JavaConstant> marked, Stack<JavaConstant> stack, JavaConstant value) { + private static void pushConstant(Set<JavaConstant> marked, Deque<JavaConstant> stack, JavaConstant value) { if (value.isNonNull()) { if (!marked.contains(value)) { marked.add(value);
--- 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) {
--- 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];
--- 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<HIRFrameStateBuilder, Integer> mergeExplosionsMap; - private Stack<ExplodedLoopContext> explodeLoopsContext; + private Deque<ExplodedLoopContext> 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<Node> stack = new Stack<>(); + Deque<Node> 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<Node> stack = new Stack<>(); + Deque<Node> stack = new ArrayDeque<>(); stack.add(startInstruction); visited.mark(startInstruction); List<LoopBeginNode> loopBegins = new ArrayList<>(); @@ -538,7 +538,7 @@ private void insertLoopExits(LoopBeginNode loopBegin, IdentityHashMap<LoopBeginNode, List<LoopBeginNode>> innerLoopsMap) { NodeBitMap visited = currentGraph.createNodeBitMap(); - Stack<Node> stack = new Stack<>(); + Deque<Node> 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) {
--- 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;
--- 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<Info> map; - private final Stack<LoopExitNode> loopExits; + private final Deque<LoopExitNode> loopExits; private final Function<Block, Iterable<? extends Node>> blockToNodes; private final Function<Node, Block> nodeToBlock; public Instance(StructuredGraph graph, Function<Block, Iterable<? extends Node>> blockToNodes, Function<Node, Block> 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<LoopExitNode> 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());
--- 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); }