Mercurial > hg > truffle
comparison graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java @ 13227:1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 03 Dec 2013 10:51:16 +0100 |
parents | 2d3d3d36ab3c |
children | b429ec5c46d6 |
comparison
equal
deleted
inserted
replaced
13226:0b4d38339708 | 13227:1a66453f73db |
---|---|
73 public DirectCallOp(ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) { | 73 public DirectCallOp(ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) { |
74 super(callTarget, result, parameters, temps, state); | 74 super(callTarget, result, parameters, temps, state); |
75 } | 75 } |
76 | 76 |
77 @Override | 77 @Override |
78 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { | 78 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
79 directCall(tasm, masm, callTarget, null, true, state); | 79 directCall(crb, masm, callTarget, null, true, state); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 @Opcode("CALL_INDIRECT") | 83 @Opcode("CALL_INDIRECT") |
84 public static class IndirectCallOp extends MethodCallOp { | 84 public static class IndirectCallOp extends MethodCallOp { |
89 super(callTarget, result, parameters, temps, state); | 89 super(callTarget, result, parameters, temps, state); |
90 this.targetAddress = targetAddress; | 90 this.targetAddress = targetAddress; |
91 } | 91 } |
92 | 92 |
93 @Override | 93 @Override |
94 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { | 94 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
95 indirectCall(tasm, masm, asRegister(targetAddress), callTarget, state); | 95 indirectCall(crb, masm, asRegister(targetAddress), callTarget, state); |
96 } | 96 } |
97 | 97 |
98 @Override | 98 @Override |
99 protected void verify() { | 99 protected void verify() { |
100 super.verify(); | 100 super.verify(); |
123 public DirectNearForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] parameters, Value[] temps, LIRFrameState state) { | 123 public DirectNearForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] parameters, Value[] temps, LIRFrameState state) { |
124 super(linkage, result, parameters, temps, state); | 124 super(linkage, result, parameters, temps, state); |
125 } | 125 } |
126 | 126 |
127 @Override | 127 @Override |
128 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { | 128 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
129 directCall(tasm, masm, callTarget, null, false, state); | 129 directCall(crb, masm, callTarget, null, false, state); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 @Opcode("FAR_FOREIGN_CALL") | 133 @Opcode("FAR_FOREIGN_CALL") |
134 public static class DirectFarForeignCallOp extends ForeignCallOp { | 134 public static class DirectFarForeignCallOp extends ForeignCallOp { |
139 super(callTarget, result, parameters, temps, state); | 139 super(callTarget, result, parameters, temps, state); |
140 callTemp = gen.newVariable(Kind.Long); | 140 callTemp = gen.newVariable(Kind.Long); |
141 } | 141 } |
142 | 142 |
143 @Override | 143 @Override |
144 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { | 144 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
145 directCall(tasm, masm, callTarget, ((RegisterValue) callTemp).getRegister(), false, state); | 145 directCall(crb, masm, callTarget, ((RegisterValue) callTemp).getRegister(), false, state); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 public static void directCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { | 149 public static void directCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { |
150 if (align) { | 150 if (align) { |
151 emitAlignmentForDirectCall(tasm, masm); | 151 emitAlignmentForDirectCall(crb, masm); |
152 } | 152 } |
153 int before = masm.codeBuffer.position(); | 153 int before = masm.codeBuffer.position(); |
154 if (scratch != null) { | 154 if (scratch != null) { |
155 // offset might not fit a 32-bit immediate, generate an | 155 // offset might not fit a 32-bit immediate, generate an |
156 // indirect call with a 64-bit immediate | 156 // indirect call with a 64-bit immediate |
158 masm.call(scratch); | 158 masm.call(scratch); |
159 } else { | 159 } else { |
160 masm.call(); | 160 masm.call(); |
161 } | 161 } |
162 int after = masm.codeBuffer.position(); | 162 int after = masm.codeBuffer.position(); |
163 tasm.recordDirectCall(before, after, callTarget, info); | 163 crb.recordDirectCall(before, after, callTarget, info); |
164 tasm.recordExceptionHandlers(after, info); | 164 crb.recordExceptionHandlers(after, info); |
165 masm.ensureUniquePC(); | 165 masm.ensureUniquePC(); |
166 } | 166 } |
167 | 167 |
168 protected static void emitAlignmentForDirectCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { | 168 protected static void emitAlignmentForDirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
169 // make sure that the displacement word of the call ends up word aligned | 169 // make sure that the displacement word of the call ends up word aligned |
170 int offset = masm.codeBuffer.position(); | 170 int offset = masm.codeBuffer.position(); |
171 offset += tasm.target.arch.getMachineCodeCallDisplacementOffset(); | 171 offset += crb.target.arch.getMachineCodeCallDisplacementOffset(); |
172 int modulus = tasm.target.wordSize; | 172 int modulus = crb.target.wordSize; |
173 if (offset % modulus != 0) { | 173 if (offset % modulus != 0) { |
174 masm.nop(modulus - offset % modulus); | 174 masm.nop(modulus - offset % modulus); |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 public static void directJmp(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget target) { | 178 public static void directJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target) { |
179 int before = masm.codeBuffer.position(); | 179 int before = masm.codeBuffer.position(); |
180 masm.jmp(0, true); | 180 masm.jmp(0, true); |
181 int after = masm.codeBuffer.position(); | 181 int after = masm.codeBuffer.position(); |
182 tasm.recordDirectCall(before, after, target, null); | 182 crb.recordDirectCall(before, after, target, null); |
183 masm.ensureUniquePC(); | 183 masm.ensureUniquePC(); |
184 } | 184 } |
185 | 185 |
186 public static void directConditionalJmp(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget target, ConditionFlag cond) { | 186 public static void directConditionalJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target, ConditionFlag cond) { |
187 int before = masm.codeBuffer.position(); | 187 int before = masm.codeBuffer.position(); |
188 masm.jcc(cond, 0, true); | 188 masm.jcc(cond, 0, true); |
189 int after = masm.codeBuffer.position(); | 189 int after = masm.codeBuffer.position(); |
190 tasm.recordDirectCall(before, after, target, null); | 190 crb.recordDirectCall(before, after, target, null); |
191 masm.ensureUniquePC(); | 191 masm.ensureUniquePC(); |
192 } | 192 } |
193 | 193 |
194 public static void indirectCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { | 194 public static void indirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { |
195 int before = masm.codeBuffer.position(); | 195 int before = masm.codeBuffer.position(); |
196 masm.call(dst); | 196 masm.call(dst); |
197 int after = masm.codeBuffer.position(); | 197 int after = masm.codeBuffer.position(); |
198 tasm.recordIndirectCall(before, after, callTarget, info); | 198 crb.recordIndirectCall(before, after, callTarget, info); |
199 tasm.recordExceptionHandlers(after, info); | 199 crb.recordExceptionHandlers(after, info); |
200 masm.ensureUniquePC(); | 200 masm.ensureUniquePC(); |
201 } | 201 } |
202 } | 202 } |