Mercurial > hg > graal-compiler
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2641:d1c5a798b73c
Removed memory map.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 11 May 2011 14:12:24 +0200 |
parents | 9e30cf6dcf96 |
children | 8932f1027050 |
comparison
equal
deleted
inserted
replaced
2640:9e30cf6dcf96 | 2641:d1c5a798b73c |
---|---|
85 /** | 85 /** |
86 * Map used to implement local value numbering for the current block. | 86 * Map used to implement local value numbering for the current block. |
87 */ | 87 */ |
88 private final ValueMap localValueMap; | 88 private final ValueMap localValueMap; |
89 | 89 |
90 /** | |
91 * Map used for local load elimination (i.e. within the current block). | |
92 */ | |
93 private final MemoryMap memoryMap; | |
94 | |
95 private final BytecodeStream stream; // the bytecode stream | 90 private final BytecodeStream stream; // the bytecode stream |
96 // bci-to-block mapping | 91 // bci-to-block mapping |
97 private BlockMap blockMap; | 92 private BlockMap blockMap; |
98 | 93 |
99 // the constant pool | 94 // the constant pool |
131 */ | 126 */ |
132 public GraphBuilder(C1XCompilation compilation, IR ir, Graph graph) { | 127 public GraphBuilder(C1XCompilation compilation, IR ir, Graph graph) { |
133 this.compilation = compilation; | 128 this.compilation = compilation; |
134 this.ir = ir; | 129 this.ir = ir; |
135 this.stats = compilation.stats; | 130 this.stats = compilation.stats; |
136 this.memoryMap = C1XOptions.OptLocalLoadElimination ? new MemoryMap() : null; | |
137 this.localValueMap = C1XOptions.OptLocalValueNumbering ? new ValueMap() : null; | 131 this.localValueMap = C1XOptions.OptLocalValueNumbering ? new ValueMap() : null; |
138 log = C1XOptions.TraceBytecodeParserLevel > 0 ? new LogStream(TTY.out()) : null; | 132 log = C1XOptions.TraceBytecodeParserLevel > 0 ? new LogStream(TTY.out()) : null; |
139 stream = new BytecodeStream(compilation.method.code()); | 133 stream = new BytecodeStream(compilation.method.code()); |
140 constantPool = compilation.runtime.getConstantPool(compilation.method); | 134 constantPool = compilation.runtime.getConstantPool(compilation.method); |
141 this.graph = graph; | 135 this.graph = graph; |
376 if (cseArrayLength(array)) { | 370 if (cseArrayLength(array)) { |
377 length = append(new ArrayLength(array, graph)); | 371 length = append(new ArrayLength(array, graph)); |
378 } | 372 } |
379 StoreIndexed result = new StoreIndexed(array, index, length, kind, value, graph); | 373 StoreIndexed result = new StoreIndexed(array, index, length, kind, value, graph); |
380 append(result); | 374 append(result); |
381 if (memoryMap != null) { | |
382 memoryMap.storeValue(value); | |
383 } | |
384 } | 375 } |
385 | 376 |
386 void stackOp(int opcode) { | 377 void stackOp(int opcode) { |
387 switch (opcode) { | 378 switch (opcode) { |
388 case POP: { | 379 case POP: { |
591 FrameState stateBefore = null; | 582 FrameState stateBefore = null; |
592 if (!type.isResolved()) { | 583 if (!type.isResolved()) { |
593 stateBefore = frameState.create(bci()); | 584 stateBefore = frameState.create(bci()); |
594 } | 585 } |
595 NewInstance n = new NewInstance(type, cpi, constantPool(), graph); | 586 NewInstance n = new NewInstance(type, cpi, constantPool(), graph); |
596 if (memoryMap != null) { | |
597 memoryMap.newInstance(n); | |
598 } | |
599 n.setStateBefore(stateBefore); | 587 n.setStateBefore(stateBefore); |
600 frameState.apush(append(n)); | 588 frameState.apush(append(n)); |
601 } | 589 } |
602 | 590 |
603 void genNewTypeArray(int typeCode) { | 591 void genNewTypeArray(int typeCode) { |
700 } | 688 } |
701 return holderInstr; | 689 return holderInstr; |
702 } | 690 } |
703 | 691 |
704 private void appendOptimizedStoreField(StoreField store) { | 692 private void appendOptimizedStoreField(StoreField store) { |
705 if (memoryMap != null) { | |
706 StoreField previous = memoryMap.store(store); | |
707 if (previous == null) { | |
708 // the store is redundant, do not append | |
709 return; | |
710 } | |
711 } | |
712 append(store); | 693 append(store); |
713 } | 694 } |
714 | 695 |
715 private void appendOptimizedLoadField(CiKind kind, LoadField load) { | 696 private void appendOptimizedLoadField(CiKind kind, LoadField load) { |
716 if (memoryMap != null) { | |
717 Value replacement = memoryMap.load(load); | |
718 if (replacement != load) { | |
719 // the memory buffer found a replacement for this load (no need to append) | |
720 frameState.push(kind.stackKind(), replacement); | |
721 return; | |
722 } | |
723 } | |
724 // append the load to the instruction | 697 // append the load to the instruction |
725 Value optimized = append(load); | 698 Value optimized = append(load); |
726 if (memoryMap != null && optimized != load) { | |
727 // local optimization happened, replace its value in the memory map | |
728 memoryMap.setResult(load, optimized); | |
729 } | |
730 frameState.push(kind.stackKind(), optimized); | 699 frameState.push(kind.stackKind(), optimized); |
731 } | 700 } |
732 | 701 |
733 void genInvokeStatic(RiMethod target, int cpi, RiConstantPool constantPool) { | 702 void genInvokeStatic(RiMethod target, int cpi, RiConstantPool constantPool) { |
734 RiType holder = target.holder(); | 703 RiType holder = target.holder(); |
1127 lastInstr = lastInstr.appendNext(x, bci); | 1096 lastInstr = lastInstr.appendNext(x, bci); |
1128 } | 1097 } |
1129 if (++stats.nodeCount >= C1XOptions.MaximumInstructionCount) { | 1098 if (++stats.nodeCount >= C1XOptions.MaximumInstructionCount) { |
1130 // bailout if we've exceeded the maximum inlining size | 1099 // bailout if we've exceeded the maximum inlining size |
1131 throw new CiBailout("Method and/or inlining is too large"); | 1100 throw new CiBailout("Method and/or inlining is too large"); |
1132 } | |
1133 | |
1134 if (memoryMap != null && hasUncontrollableSideEffects(x)) { | |
1135 // conservatively kill all memory if there are unknown side effects | |
1136 memoryMap.kill(); | |
1137 } | 1101 } |
1138 | 1102 |
1139 if (x.canTrap()) { | 1103 if (x.canTrap()) { |
1140 // connect the instruction to any exception handlers | 1104 // connect the instruction to any exception handlers |
1141 x.setExceptionHandlers(handleException(x, bci)); | 1105 x.setExceptionHandlers(handleException(x, bci)); |
1553 | 1517 |
1554 void killMemoryMap() { | 1518 void killMemoryMap() { |
1555 if (localValueMap != null) { | 1519 if (localValueMap != null) { |
1556 localValueMap.killAll(); | 1520 localValueMap.killAll(); |
1557 } | 1521 } |
1558 if (memoryMap != null) { | |
1559 memoryMap.kill(); | |
1560 } | |
1561 } | 1522 } |
1562 | 1523 |
1563 boolean assumeLeafClass(RiType type) { | 1524 boolean assumeLeafClass(RiType type) { |
1564 if (type.isResolved()) { | 1525 if (type.isResolved()) { |
1565 if (isFinal(type.accessFlags())) { | 1526 if (isFinal(type.accessFlags())) { |