annotate graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java @ 8969:1fa6536416db

Runtime calls that do not destroy the caller's registers need no spilling at the call site.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 09 Apr 2013 19:29:12 +0200
parents 29d44e82b8f7
children da39fb4f9b2e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.lir.amd64;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
25 import static com.oracle.graal.api.code.ValueUtil.*;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
27
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
28 import com.oracle.graal.api.code.*;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
29 import com.oracle.graal.api.meta.*;
6531
4afe23aa0a00 renamed packages: com.oracle.max.asm... -> com.oracle.graal.asm...
Doug Simon <doug.simon@oracle.com>
parents: 6521
diff changeset
30 import com.oracle.graal.asm.amd64.*;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
31 import com.oracle.graal.lir.*;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
32 import com.oracle.graal.lir.LIRInstruction.Opcode;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
33 import com.oracle.graal.lir.asm.*;
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
34 import com.oracle.graal.nodes.spi.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
36 public class AMD64Call {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
37
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
38 @Opcode("CALL_DIRECT")
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
39 public static class DirectCallOp extends AMD64LIRInstruction {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
40
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
41 @Def({REG, ILLEGAL}) protected Value result;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
42 @Use({REG, STACK}) protected Value[] parameters;
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
43 @Temp protected Value[] temps;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
44 @State protected LIRFrameState state;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
45
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
46 protected final ResolvedJavaMethod callTarget;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
47
8356
29d44e82b8f7 Allow instantiation without creating a subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8333
diff changeset
48 public DirectCallOp(ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6582
diff changeset
49 this.callTarget = callTarget;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
50 this.result = result;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
51 this.parameters = parameters;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
52 this.state = state;
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
53 this.temps = temps;
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
54 assert temps != null;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
55 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
57 @Override
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
58 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
59 directCall(tasm, masm, callTarget, null, true, state);
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
60 }
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
61
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
62 @Override
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
63 public boolean hasCall() {
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
64 return true;
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
65 }
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
66 }
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
67
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
68 @Opcode("CALL_NEAR_RUNTIME")
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
69 public static class DirectNearRuntimeCallOp extends AMD64LIRInstruction {
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
70
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
71 @Def({REG, ILLEGAL}) protected Value result;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
72 @Use({REG, STACK}) protected Value[] parameters;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
73 @Temp protected Value[] temps;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
74 @State protected LIRFrameState state;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
75
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
76 protected final RuntimeCallTarget callTarget;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
77
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
78 public DirectNearRuntimeCallOp(RuntimeCallTarget callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
79 this.callTarget = callTarget;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
80 this.result = result;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
81 this.parameters = parameters;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
82 this.state = state;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
83 this.temps = temps;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
84 assert temps != null;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
85 }
5844
a432e6d43aa1 fixed bugs related to -G:+InlineVTableStubs and re-enabled it by default
Doug Simon <doug.simon@oracle.com>
parents: 5827
diff changeset
86
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
87 @Override
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
88 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
89 directCall(tasm, masm, callTarget, null, false, state);
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
90 }
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
91
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
92 @Override
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
93 public boolean hasCall() {
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
94 return !callTarget.preservesRegisters();
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
95 }
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
96 }
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
97
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
98 @Opcode("CALL_FAR_RUNTIME")
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
99 public static class DirectFarRuntimeCallOp extends AMD64LIRInstruction {
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
100
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
101 @Def({REG, ILLEGAL}) protected Value result;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
102 @Use({REG, STACK}) protected Value[] parameters;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
103 @Temp protected Value[] temps;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
104 @State protected LIRFrameState state;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
105 @Temp({REG}) protected AllocatableValue callTemp;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
106
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
107 protected final RuntimeCallTarget callTarget;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
108
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
109 public DirectFarRuntimeCallOp(LIRGeneratorTool gen, RuntimeCallTarget callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
110 this.callTarget = callTarget;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
111 this.result = result;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
112 this.parameters = parameters;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
113 this.state = state;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
114 this.temps = temps;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
115 assert temps != null;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
116 callTemp = gen.newVariable(Kind.Long);
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
117 }
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
118
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
119 @Override
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
120 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
121 directCall(tasm, masm, callTarget, ((RegisterValue) callTemp).getRegister(), false, state);
5844
a432e6d43aa1 fixed bugs related to -G:+InlineVTableStubs and re-enabled it by default
Doug Simon <doug.simon@oracle.com>
parents: 5827
diff changeset
122 }
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
123
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
124 @Override
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
125 public boolean hasCall() {
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
126 return !callTarget.preservesRegisters();
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
127 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
130 @Opcode("CALL_INDIRECT")
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
131 public static class IndirectCallOp extends AMD64LIRInstruction {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
132
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
133 @Def({REG, ILLEGAL}) protected Value result;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
134 @Use({REG, STACK}) protected Value[] parameters;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
135 @Use({REG}) protected Value targetAddress;
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
136 @Temp protected Value[] temps;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
137 @State protected LIRFrameState state;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
138
7814
bab2a51f8dbe Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7649
diff changeset
139 protected final InvokeTarget callTarget;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
140
8356
29d44e82b8f7 Allow instantiation without creating a subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8333
diff changeset
141 public IndirectCallOp(InvokeTarget callTarget, Value result, Value[] parameters, Value[] temps, Value targetAddress, LIRFrameState state) {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6582
diff changeset
142 this.callTarget = callTarget;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
143 this.result = result;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
144 this.parameters = parameters;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
145 this.targetAddress = targetAddress;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5547
diff changeset
146 this.state = state;
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
147 this.temps = temps;
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
148 assert temps != null;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
149 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
150
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
151 @Override
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4263
diff changeset
152 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6582
diff changeset
153 indirectCall(tasm, masm, asRegister(targetAddress), callTarget, state);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 }
5880
afd2508528f5 The targetAdress should be moved to a fixed register for indirect call. Fix from Christian Wimmer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5844
diff changeset
155
afd2508528f5 The targetAdress should be moved to a fixed register for indirect call. Fix from Christian Wimmer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5844
diff changeset
156 @Override
afd2508528f5 The targetAdress should be moved to a fixed register for indirect call. Fix from Christian Wimmer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5844
diff changeset
157 protected void verify() {
afd2508528f5 The targetAdress should be moved to a fixed register for indirect call. Fix from Christian Wimmer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5844
diff changeset
158 super.verify();
afd2508528f5 The targetAdress should be moved to a fixed register for indirect call. Fix from Christian Wimmer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5844
diff changeset
159 assert isRegister(targetAddress) : "The current register allocator cannot handle variables to be used at call sites, it must be in a fixed register for now";
afd2508528f5 The targetAdress should be moved to a fixed register for indirect call. Fix from Christian Wimmer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5844
diff changeset
160 }
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
161
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
162 @Override
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
163 public boolean hasCall() {
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
164 return true;
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8356
diff changeset
165 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
168 public static void directCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
169 if (align) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
170 emitAlignmentForDirectCall(tasm, masm);
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
171 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 int before = masm.codeBuffer.position();
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
173 if (scratch != null) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
174 // offset might not fit a 32-bit immediate, generate an
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
175 // indirect call with a 64-bit immediate
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
176 masm.movq(scratch, 0L);
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
177 masm.call(scratch);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 masm.call();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 int after = masm.codeBuffer.position();
7814
bab2a51f8dbe Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7649
diff changeset
182 tasm.recordDirectCall(before, after, callTarget, info);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 tasm.recordExceptionHandlers(after, info);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 masm.ensureUniquePC();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186
8333
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
187 protected static void emitAlignmentForDirectCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
188 // make sure that the displacement word of the call ends up word aligned
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
189 int offset = masm.codeBuffer.position();
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
190 offset += tasm.target.arch.getMachineCodeCallDisplacementOffset();
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
191 int modulus = tasm.target.wordSize;
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
192 if (offset % modulus != 0) {
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
193 masm.nop(modulus - offset % modulus);
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
194 }
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
195 }
e9c6fc513719 Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8196
diff changeset
196
7814
bab2a51f8dbe Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7649
diff changeset
197 public static void directJmp(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget target) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 int before = masm.codeBuffer.position();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 masm.jmp(0, true);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 int after = masm.codeBuffer.position();
7814
bab2a51f8dbe Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7649
diff changeset
201 tasm.recordDirectCall(before, after, target, null);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 masm.ensureUniquePC();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
204
7814
bab2a51f8dbe Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7649
diff changeset
205 public static void indirectCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 int before = masm.codeBuffer.position();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 masm.call(dst);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 int after = masm.codeBuffer.position();
7814
bab2a51f8dbe Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7649
diff changeset
209 tasm.recordIndirectCall(before, after, callTarget, info);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 tasm.recordExceptionHandlers(after, info);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 masm.ensureUniquePC();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 }