Mercurial > hg > truffle
comparison graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java @ 4524:dcc8f5c6f394
Refactorings to prepare for LIR project splitting
author | Christian Wimmer <Christian.Wimmer@Oracle.com> |
---|---|
date | Wed, 08 Feb 2012 18:19:09 -0800 |
parents | aa867c7c1d1e |
children |
comparison
equal
deleted
inserted
replaced
4523:ade4281b79c3 | 4524:dcc8f5c6f394 |
---|---|
27 import java.util.*; | 27 import java.util.*; |
28 | 28 |
29 import com.oracle.max.asm.*; | 29 import com.oracle.max.asm.*; |
30 import com.oracle.max.cri.ci.*; | 30 import com.oracle.max.cri.ci.*; |
31 import com.oracle.max.cri.ri.*; | 31 import com.oracle.max.cri.ri.*; |
32 import com.oracle.max.criutils.*; | |
33 import com.oracle.max.graal.compiler.*; | |
34 import com.oracle.max.graal.compiler.lir.*; | 32 import com.oracle.max.graal.compiler.lir.*; |
35 import com.oracle.max.graal.compiler.lir.LIR.SlowPath; | 33 import com.oracle.max.graal.compiler.lir.LIR.SlowPath; |
36 import com.oracle.max.graal.compiler.util.*; | |
37 import com.oracle.max.graal.debug.*; | 34 import com.oracle.max.graal.debug.*; |
35 import com.oracle.max.graal.graph.*; | |
38 | 36 |
39 public class TargetMethodAssembler { | 37 public class TargetMethodAssembler { |
38 | |
39 private static class ExceptionInfo { | |
40 public final int codeOffset; | |
41 public final LabelRef exceptionEdge; | |
42 | |
43 public ExceptionInfo(int pcOffset, LabelRef exceptionEdge) { | |
44 this.codeOffset = pcOffset; | |
45 this.exceptionEdge = exceptionEdge; | |
46 } | |
47 } | |
40 | 48 |
41 public final AbstractAssembler asm; | 49 public final AbstractAssembler asm; |
42 public final CiTargetMethod targetMethod; | 50 public final CiTargetMethod targetMethod; |
43 public final CiTarget target; | 51 public final CiTarget target; |
44 public final RiRuntime runtime; | 52 public final RiRuntime runtime; |
45 public final FrameMap frameMap; | 53 public final FrameMap frameMap; |
46 public final List<SlowPath> slowPaths; | 54 public final List<SlowPath> slowPaths; |
47 | 55 |
48 private List<ExceptionInfo> exceptionInfoList; | 56 private List<ExceptionInfo> exceptionInfoList; |
49 private int lastSafepointPos; | 57 private int lastSafepointPos; |
58 | |
50 public TargetMethodAssembler(CiTarget target, RiRuntime runtime, FrameMap frameMap, List<SlowPath> slowPaths, AbstractAssembler asm) { | 59 public TargetMethodAssembler(CiTarget target, RiRuntime runtime, FrameMap frameMap, List<SlowPath> slowPaths, AbstractAssembler asm) { |
51 this.target = target; | 60 this.target = target; |
52 this.runtime = runtime; | 61 this.runtime = runtime; |
53 this.frameMap = frameMap; | 62 this.frameMap = frameMap; |
54 this.slowPaths = slowPaths; | 63 this.slowPaths = slowPaths; |
86 Debug.metric("CodeBytesEmitted").add(targetMethod.targetCodeSize()); | 95 Debug.metric("CodeBytesEmitted").add(targetMethod.targetCodeSize()); |
87 Debug.metric("SafepointsEmitted").add(targetMethod.safepoints.size()); | 96 Debug.metric("SafepointsEmitted").add(targetMethod.safepoints.size()); |
88 Debug.metric("DataPatches").add(targetMethod.dataReferences.size()); | 97 Debug.metric("DataPatches").add(targetMethod.dataReferences.size()); |
89 Debug.metric("ExceptionHandlersEmitted").add(targetMethod.exceptionHandlers.size()); | 98 Debug.metric("ExceptionHandlersEmitted").add(targetMethod.exceptionHandlers.size()); |
90 | 99 |
100 Debug.log("Finished target method %s, isStub %d", name, isStub); | |
101 /* | |
91 if (GraalOptions.PrintAssembly && !TTY.isSuppressed() && !isStub) { | 102 if (GraalOptions.PrintAssembly && !TTY.isSuppressed() && !isStub) { |
92 Util.printSection("Target Method", Util.SECTION_CHARACTER); | 103 Util.printSection("Target Method", Util.SECTION_CHARACTER); |
93 TTY.println("Name: " + name); | 104 TTY.println("Name: " + name); |
94 TTY.println("Frame size: " + targetMethod.frameSize()); | 105 TTY.println("Frame size: " + targetMethod.frameSize()); |
95 TTY.println("Register size: " + asm.target.arch.registerReferenceMapBitCount); | 106 TTY.println("Register size: " + asm.target.arch.registerReferenceMapBitCount); |
126 Util.printSection("Exception Handlers", Util.SUB_SECTION_CHARACTER); | 137 Util.printSection("Exception Handlers", Util.SUB_SECTION_CHARACTER); |
127 for (CiTargetMethod.ExceptionHandler x : targetMethod.exceptionHandlers) { | 138 for (CiTargetMethod.ExceptionHandler x : targetMethod.exceptionHandlers) { |
128 TTY.println(x.toString()); | 139 TTY.println(x.toString()); |
129 } | 140 } |
130 } | 141 } |
142 */ | |
131 | 143 |
132 return targetMethod; | 144 return targetMethod; |
133 } | 145 } |
134 | 146 |
135 public void recordExceptionHandlers(int pcOffset, LIRDebugInfo info) { | 147 public void recordExceptionHandlers(int pcOffset, LIRDebugInfo info) { |
136 if (info != null) { | 148 if (info != null) { |
137 if (info.exceptionEdge != null) { | 149 if (info.exceptionEdge != null) { |
138 if (exceptionInfoList == null) { | 150 if (exceptionInfoList == null) { |
139 exceptionInfoList = new ArrayList<>(4); | 151 exceptionInfoList = new ArrayList<>(4); |
140 } | 152 } |
141 exceptionInfoList.add(new ExceptionInfo(pcOffset, info.exceptionEdge, info.topFrame.bci)); | 153 exceptionInfoList.add(new ExceptionInfo(pcOffset, info.exceptionEdge)); |
142 } | 154 } |
143 } | 155 } |
144 } | 156 } |
145 | 157 |
146 public void recordImplicitException(int pcOffset, LIRDebugInfo info) { | 158 public void recordImplicitException(int pcOffset, LIRDebugInfo info) { |
194 */ | 206 */ |
195 public int asIntConst(CiValue value) { | 207 public int asIntConst(CiValue value) { |
196 assert (value.kind.stackKind() == CiKind.Int || value.kind == CiKind.Jsr || value.kind == CiKind.Long) && isConstant(value); | 208 assert (value.kind.stackKind() == CiKind.Int || value.kind == CiKind.Jsr || value.kind == CiKind.Long) && isConstant(value); |
197 long c = ((CiConstant) value).asLong(); | 209 long c = ((CiConstant) value).asLong(); |
198 if (!(NumUtil.isInt(c))) { | 210 if (!(NumUtil.isInt(c))) { |
199 throw Util.shouldNotReachHere(); | 211 throw GraalInternalError.shouldNotReachHere(); |
200 } | 212 } |
201 return (int) c; | 213 return (int) c; |
202 } | 214 } |
203 | 215 |
204 /** | 216 /** |