Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2747:84f4c7dceb14
fixes for mergeOrClone move
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 20 May 2011 13:53:31 +0200 |
parents | 05c92e53a50d |
children | 36440e516e44 |
comparison
equal
deleted
inserted
replaced
2746:05c92e53a50d | 2747:84f4c7dceb14 |
---|---|
1046 throw new CiBailout("jsr/ret not supported"); | 1046 throw new CiBailout("jsr/ret not supported"); |
1047 } | 1047 } |
1048 | 1048 |
1049 private void genTableswitch() { | 1049 private void genTableswitch() { |
1050 int bci = bci(); | 1050 int bci = bci(); |
1051 Value value = frameState.ipop(); | |
1051 BytecodeTableSwitch ts = new BytecodeTableSwitch(stream(), bci); | 1052 BytecodeTableSwitch ts = new BytecodeTableSwitch(stream(), bci); |
1052 int max = ts.numberOfCases(); | 1053 int max = ts.numberOfCases(); |
1053 List<Instruction> list = new ArrayList<Instruction>(max + 1); | 1054 List<Instruction> list = new ArrayList<Instruction>(max + 1); |
1054 boolean isBackwards = false; | 1055 boolean isBackwards = false; |
1055 for (int i = 0; i < max; i++) { | 1056 for (int i = 0; i < max; i++) { |
1061 int offset = ts.defaultOffset(); | 1062 int offset = ts.defaultOffset(); |
1062 isBackwards |= offset < 0; // if the default successor is backwards | 1063 isBackwards |= offset < 0; // if the default successor is backwards |
1063 list.add(createTargetAt(bci + offset, frameState)); | 1064 list.add(createTargetAt(bci + offset, frameState)); |
1064 boolean isSafepoint = isBackwards && !noSafepoints(); | 1065 boolean isSafepoint = isBackwards && !noSafepoints(); |
1065 FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null; | 1066 FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null; |
1066 append(new TableSwitch(frameState.ipop(), (List) list, ts.lowKey(), stateAfter, graph)); | 1067 append(new TableSwitch(value, (List) list, ts.lowKey(), stateAfter, graph)); |
1067 } | 1068 } |
1068 | 1069 |
1069 private Instruction createTargetAt(int bci, FrameStateAccess stateAfter) { | 1070 private Instruction createTargetAt(int bci, FrameStateAccess stateAfter) { |
1070 return createTarget(blockList[bci], stateAfter); | 1071 return createTarget(blockList[bci], stateAfter); |
1071 } | 1072 } |
1076 return block.firstInstruction; | 1077 return block.firstInstruction; |
1077 } | 1078 } |
1078 | 1079 |
1079 private void genLookupswitch() { | 1080 private void genLookupswitch() { |
1080 int bci = bci(); | 1081 int bci = bci(); |
1082 Value value = frameState.ipop(); | |
1081 BytecodeLookupSwitch ls = new BytecodeLookupSwitch(stream(), bci); | 1083 BytecodeLookupSwitch ls = new BytecodeLookupSwitch(stream(), bci); |
1082 int max = ls.numberOfCases(); | 1084 int max = ls.numberOfCases(); |
1083 List<Instruction> list = new ArrayList<Instruction>(max + 1); | 1085 List<Instruction> list = new ArrayList<Instruction>(max + 1); |
1084 int[] keys = new int[max]; | 1086 int[] keys = new int[max]; |
1085 boolean isBackwards = false; | 1087 boolean isBackwards = false; |
1093 int offset = ls.defaultOffset(); | 1095 int offset = ls.defaultOffset(); |
1094 isBackwards |= offset < 0; // if the default successor is backwards | 1096 isBackwards |= offset < 0; // if the default successor is backwards |
1095 list.add(createTargetAt(bci + offset, frameState)); | 1097 list.add(createTargetAt(bci + offset, frameState)); |
1096 boolean isSafepoint = isBackwards && !noSafepoints(); | 1098 boolean isSafepoint = isBackwards && !noSafepoints(); |
1097 FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null; | 1099 FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null; |
1098 append(new LookupSwitch(frameState.ipop(), (List) list, keys, stateAfter, graph)); | 1100 append(new LookupSwitch(value, (List) list, keys, stateAfter, graph)); |
1099 } | 1101 } |
1100 | 1102 |
1101 private Value appendConstant(CiConstant constant) { | 1103 private Value appendConstant(CiConstant constant) { |
1102 return appendWithBCI(new Constant(constant, graph)); | 1104 return appendWithBCI(new Constant(constant, graph)); |
1103 } | 1105 } |
1211 int bci = block.startBci; | 1213 int bci = block.startBci; |
1212 while (bci < endBCI) { | 1214 while (bci < endBCI) { |
1213 Block nextBlock = blockList[bci]; | 1215 Block nextBlock = blockList[bci]; |
1214 if (nextBlock != null && nextBlock != block) { | 1216 if (nextBlock != null && nextBlock != block) { |
1215 // we fell through to the next block, add a goto and break | 1217 // we fell through to the next block, add a goto and break |
1216 end = new Goto((BlockBegin) nextBlock.firstInstruction, null, graph); | 1218 Instruction next = createTarget(nextBlock, frameState); |
1219 end = new Goto((BlockBegin) next, null, graph); | |
1217 lastInstr = lastInstr.appendNext(end); | 1220 lastInstr = lastInstr.appendNext(end); |
1218 break; | 1221 break; |
1219 } | 1222 } |
1220 // read the opcode | 1223 // read the opcode |
1221 int opcode = stream.currentBC(); | 1224 int opcode = stream.currentBC(); |