Mercurial > hg > graal-compiler
annotate graal/GraalCompiler/src/com/sun/c1x/asm/TargetMethodAssembler.java @ 2677:0ea5f12e873a
use com.oracle.max.asm project for assembler
author | Christian.Wimmer@Oracle.com |
---|---|
date | Fri, 13 May 2011 17:09:20 -0700 |
parents | |
children | 7ed72769d51a |
rev | line source |
---|---|
2677
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
1 /* |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
2 * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
4 * |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
8 * |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
13 * accompanied this code). |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
14 * |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
18 * |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
21 * questions. |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
22 */ |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
23 package com.sun.c1x.asm; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
24 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
25 import java.util.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
26 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
27 import com.oracle.max.asm.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
28 import com.sun.c1x.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
29 import com.sun.c1x.debug.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
30 import com.sun.c1x.ir.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
31 import com.sun.c1x.lir.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
32 import com.sun.c1x.util.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
33 import com.sun.cri.ci.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
34 import com.sun.cri.ri.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
35 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
36 public class TargetMethodAssembler { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
37 public final AbstractAssembler asm; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
38 public final CiTargetMethod targetMethod; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
39 public List<ExceptionInfo> exceptionInfoList; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
40 protected int lastSafepointPos; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
41 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
42 public TargetMethodAssembler(AbstractAssembler asm) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
43 this.asm = asm; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
44 this.targetMethod = new CiTargetMethod(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
45 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
46 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
47 public void setFrameSize(int frameSize) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
48 targetMethod.setFrameSize(frameSize); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
49 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
50 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
51 public CiTargetMethod.Mark recordMark(Object id, CiTargetMethod.Mark[] references) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
52 return targetMethod.recordMark(asm.codeBuffer.position(), id, references); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
53 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
54 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
55 public void blockComment(String s) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
56 targetMethod.addAnnotation(new CiTargetMethod.CodeComment(asm.codeBuffer.position(), s)); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
57 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
58 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
59 public CiTargetMethod finishTargetMethod(Object name, RiRuntime runtime, int registerRestoreEpilogueOffset, boolean isStub) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
60 // Install code, data and frame size |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
61 targetMethod.setTargetCode(asm.codeBuffer.close(false), asm.codeBuffer.position()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
62 targetMethod.setRegisterRestoreEpilogueOffset(registerRestoreEpilogueOffset); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
63 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
64 // Record exception handlers if they exist |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
65 if (exceptionInfoList != null) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
66 for (ExceptionInfo ei : exceptionInfoList) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
67 int codeOffset = ei.codeOffset; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
68 for (ExceptionHandler handler : ei.exceptionHandlers) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
69 int entryOffset = handler.entryCodeOffset(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
70 RiType caughtType = handler.handler.catchType(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
71 targetMethod.recordExceptionHandler(codeOffset, ei.bci, 0, entryOffset, handler.handlerBCI(), caughtType); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
72 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
73 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
74 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
75 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
76 if (C1XOptions.PrintMetrics) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
77 C1XMetrics.TargetMethods++; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
78 C1XMetrics.CodeBytesEmitted += targetMethod.targetCodeSize(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
79 C1XMetrics.SafepointsEmitted += targetMethod.safepoints.size(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
80 C1XMetrics.DirectCallSitesEmitted += targetMethod.directCalls.size(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
81 C1XMetrics.IndirectCallSitesEmitted += targetMethod.indirectCalls.size(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
82 C1XMetrics.DataPatches += targetMethod.dataReferences.size(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
83 C1XMetrics.ExceptionHandlersEmitted += targetMethod.exceptionHandlers.size(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
84 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
85 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
86 if (C1XOptions.PrintAssembly && !TTY.isSuppressed() && !isStub) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
87 Util.printSection("Target Method", Util.SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
88 TTY.println("Name: " + name); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
89 TTY.println("Frame size: " + targetMethod.frameSize()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
90 TTY.println("Register size: " + asm.target.arch.registerReferenceMapBitCount); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
91 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
92 if (C1XOptions.PrintCodeBytes) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
93 Util.printSection("Code", Util.SUB_SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
94 TTY.println("Code: %d bytes", targetMethod.targetCodeSize()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
95 Util.printBytes(0L, targetMethod.targetCode(), 0, targetMethod.targetCodeSize(), C1XOptions.PrintAssemblyBytesPerLine); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
96 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
97 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
98 Util.printSection("Disassembly", Util.SUB_SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
99 String disassembly = runtime.disassemble(targetMethod); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
100 TTY.println(disassembly); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
101 boolean noDis = disassembly == null || disassembly.length() == 0; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
102 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
103 Util.printSection("Safepoints", Util.SUB_SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
104 for (CiTargetMethod.Safepoint x : targetMethod.safepoints) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
105 TTY.println(x.toString()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
106 if (noDis && x.debugInfo != null) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
107 TTY.println(CiUtil.indent(x.debugInfo.toString(), " ")); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
108 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
109 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
110 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
111 Util.printSection("Direct Call Sites", Util.SUB_SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
112 for (CiTargetMethod.Call x : targetMethod.directCalls) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
113 TTY.println(x.toString()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
114 if (noDis && x.debugInfo != null) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
115 TTY.println(CiUtil.indent(x.debugInfo.toString(), " ")); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
116 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
117 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
118 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
119 Util.printSection("Indirect Call Sites", Util.SUB_SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
120 for (CiTargetMethod.Call x : targetMethod.indirectCalls) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
121 TTY.println(x.toString()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
122 if (noDis && x.debugInfo != null) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
123 TTY.println(CiUtil.indent(x.debugInfo.toString(), " ")); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
124 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
125 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
126 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
127 Util.printSection("Data Patches", Util.SUB_SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
128 for (CiTargetMethod.DataPatch x : targetMethod.dataReferences) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
129 TTY.println(x.toString()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
130 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
131 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
132 Util.printSection("Marks", Util.SUB_SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
133 for (CiTargetMethod.Mark x : targetMethod.marks) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
134 TTY.println(x.toString()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
135 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
136 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
137 Util.printSection("Exception Handlers", Util.SUB_SECTION_CHARACTER); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
138 for (CiTargetMethod.ExceptionHandler x : targetMethod.exceptionHandlers) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
139 TTY.println(x.toString()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
140 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
141 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
142 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
143 return targetMethod; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
144 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
145 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
146 public void recordExceptionHandlers(int pcOffset, LIRDebugInfo info) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
147 if (info != null) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
148 if (info.exceptionHandlers != null) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
149 if (exceptionInfoList == null) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
150 exceptionInfoList = new ArrayList<ExceptionInfo>(4); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
151 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
152 exceptionInfoList.add(new ExceptionInfo(pcOffset, info.exceptionHandlers, info.state.bci)); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
153 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
154 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
155 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
156 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
157 public void recordImplicitException(int pcOffset, LIRDebugInfo info) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
158 // record an implicit exception point |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
159 if (info != null) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
160 assert lastSafepointPos < pcOffset; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
161 lastSafepointPos = pcOffset; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
162 targetMethod.recordSafepoint(pcOffset, info.debugInfo()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
163 recordExceptionHandlers(pcOffset, info); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
164 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
165 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
166 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
167 public void recordDirectCall(int posBefore, int posAfter, Object target, LIRDebugInfo info) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
168 CiDebugInfo debugInfo = info != null ? info.debugInfo() : null; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
169 assert lastSafepointPos < posAfter; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
170 lastSafepointPos = posAfter; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
171 targetMethod.recordCall(posBefore, target, debugInfo, true); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
172 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
173 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
174 public void recordIndirectCall(int posBefore, int posAfter, Object target, LIRDebugInfo info) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
175 CiDebugInfo debugInfo = info != null ? info.debugInfo() : null; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
176 assert lastSafepointPos < posAfter; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
177 lastSafepointPos = posAfter; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
178 targetMethod.recordCall(posBefore, target, debugInfo, false); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
179 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
180 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
181 public void recordSafepoint(int pos, LIRDebugInfo info) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
182 // safepoints always need debug info |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
183 CiDebugInfo debugInfo = info.debugInfo(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
184 assert lastSafepointPos < pos; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
185 lastSafepointPos = pos; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
186 targetMethod.recordSafepoint(pos, debugInfo); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
187 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
188 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
189 public CiAddress recordDataReferenceInCode(CiConstant data) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
190 assert data != null; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
191 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
192 int pos = asm.codeBuffer.position(); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
193 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
194 if (C1XOptions.TraceRelocation) { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
195 TTY.print("Data reference in code: pos = %d, data = %s", pos, data.toString()); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
196 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
197 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
198 targetMethod.recordDataReference(pos, data); |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
199 return CiAddress.Placeholder; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
200 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
201 |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
202 public int lastSafepointPos() { |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
203 return lastSafepointPos; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
204 } |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
diff
changeset
|
205 } |