annotate src/cpu/x86/vm/interpreter_x86_64.cpp @ 2013:ec8c74742417

7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops Summary: Implementation of the CAS primitive for x64 compressed oops was incorrect. It kills rscratch2 register (r11), which is allocatable in C1. Also, we don't need to restore cmpval as it's never used after that, so we need only one temporary register, which can be scratch1. Reviewed-by: kvn, never
author iveresov
date Wed, 08 Dec 2010 02:36:36 -0800
parents f95d63e2154a
children 8033953d67ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1108
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1108
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1108
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "asm/assembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "interpreter/bytecodeHistogram.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "interpreter/interpreterGenerator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "interpreter/interpreterRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "interpreter/templateTable.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "oops/arrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "oops/methodDataOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "oops/methodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #include "prims/jvmtiExport.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #include "prims/jvmtiThreadState.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #include "prims/methodHandles.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 #include "runtime/arguments.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
40 #include "runtime/deoptimization.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
41 #include "runtime/frame.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
42 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
43 #include "runtime/stubRoutines.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
44 #include "runtime/synchronizer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
45 #include "runtime/timer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
46 #include "runtime/vframeArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
47 #include "utilities/debug.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
48 #ifdef COMPILER1
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
49 #include "c1/c1_Runtime1.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
50 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 #define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
56 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 address entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // rbx: method
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // r14: pointer to locals
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // c_rarg3: first stack arg - wordSize
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
62 __ mov(c_rarg3, rsp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // adjust rsp
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
64 __ subptr(rsp, 4 * wordSize);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65 __ call_VM(noreg,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 InterpreterRuntime::slow_signature_handler),
a61af66fc99e Initial load
duke
parents:
diff changeset
68 rbx, r14, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // rax: result handler
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Stack layout:
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // rsp: 3 integer or float args (if static first is unused)
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // 1 float/double identifiers
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // return address
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // stack args
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // garbage
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // expression stack bottom
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // bcp (NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Do FP first so we can use c_rarg3 as temp
a61af66fc99e Initial load
duke
parents:
diff changeset
83 __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 XMMRegister floatreg = as_XMMRegister(i+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 Label isfloatordouble, isdouble, next;
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 __ testl(c_rarg3, 1 << (i*2)); // Float or Double?
a61af66fc99e Initial load
duke
parents:
diff changeset
90 __ jcc(Assembler::notZero, isfloatordouble);
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Do Int register here
a61af66fc99e Initial load
duke
parents:
diff changeset
93 switch ( i ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
95 __ movl(rscratch1, Address(rbx, methodOopDesc::access_flags_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
96 __ testl(rscratch1, JVM_ACC_STATIC);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
97 __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 case 1:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
100 __ movptr(c_rarg2, Address(rsp, wordSize));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 case 2:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
103 __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
104 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
106 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 __ jmp (next);
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 __ bind(isfloatordouble);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 __ testl(c_rarg3, 1 << ((i*2)+1)); // Double?
a61af66fc99e Initial load
duke
parents:
diff changeset
113 __ jcc(Assembler::notZero, isdouble);
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Do Float Here
a61af66fc99e Initial load
duke
parents:
diff changeset
116 __ movflt(floatreg, Address(rsp, i * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
117 __ jmp(next);
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Do Double here
a61af66fc99e Initial load
duke
parents:
diff changeset
120 __ bind(isdouble);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 __ movdbl(floatreg, Address(rsp, i * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 __ bind(next);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // restore rsp
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
128 __ addptr(rsp, 4 * wordSize);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 return entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
135 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 address entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // rbx: method
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // r14: pointer to locals
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // c_rarg3: first stack arg - wordSize
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
141 __ mov(c_rarg3, rsp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // adjust rsp
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
143 __ subptr(rsp, 14 * wordSize);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 __ call_VM(noreg,
a61af66fc99e Initial load
duke
parents:
diff changeset
145 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
146 InterpreterRuntime::slow_signature_handler),
a61af66fc99e Initial load
duke
parents:
diff changeset
147 rbx, r14, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // rax: result handler
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Stack layout:
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // rsp: 5 integer args (if static first is unused)
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // 1 float/double identifiers
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // 8 double args
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // return address
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // stack args
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // garbage
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // expression stack bottom
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // bcp (NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Do FP first so we can use c_rarg3 as temp
a61af66fc99e Initial load
duke
parents:
diff changeset
163 __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 const XMMRegister r = as_XMMRegister(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 Label d, done;
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 __ testl(c_rarg3, 1 << i);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 __ jcc(Assembler::notZero, d);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 __ movflt(r, Address(rsp, (6 + i) * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
173 __ jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 __ bind(d);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 __ movdbl(r, Address(rsp, (6 + i) * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
176 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // Now handle integrals. Only do c_rarg1 if not static.
a61af66fc99e Initial load
duke
parents:
diff changeset
180 __ movl(c_rarg3, Address(rbx, methodOopDesc::access_flags_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
181 __ testl(c_rarg3, JVM_ACC_STATIC);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
182 __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
184 __ movptr(c_rarg2, Address(rsp, wordSize));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
185 __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
186 __ movptr(c_rarg4, Address(rsp, 3 * wordSize));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
187 __ movptr(c_rarg5, Address(rsp, 4 * wordSize));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // restore rsp
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
190 __ addptr(rsp, 14 * wordSize);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 return entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 //
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // Various method entries
a61af66fc99e Initial load
duke
parents:
diff changeset
201 //
a61af66fc99e Initial load
duke
parents:
diff changeset
202
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
203 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
204
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
205 // rbx,: methodOop
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
206 // rcx: scratrch
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
207 // r13: sender sp
0
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 address entry_point = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // These don't need a safepoint check because they aren't virtually
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // callable. We won't enter these intrinsics from compiled code.
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // If in the future we added an intrinsic which was virtually callable
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // we'd have to worry about how to safepoint so that this code is used.
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // mathematical functions inlined by compiler
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // (interpreter must provide identical implementation
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // in order to avoid monotonicity bugs when switching
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // from interpreter to compiler in the middle of some
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // computation)
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
223 //
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
224 // stack: [ ret adr ] <-- rsp
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
225 // [ lo(arg) ]
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
226 // [ hi(arg) ]
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
227 //
0
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // native methods. Interpreter::method_kind(...) does a check for
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // native methods first before checking for intrinsic methods and
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // thus will never select this entry point. Make sure it is not
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // called accidentally since the SharedRuntime entry points will
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // not work for JDK 1.2.
a61af66fc99e Initial load
duke
parents:
diff changeset
235 //
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // We no longer need to check for JDK 1.2 since it's EOL'ed.
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // The following check existed in pre 1.6 implementation,
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // if (Universe::is_jdk12x_version()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // Universe::is_jdk12x_version() always returns false since
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // the JDK version is not yet determined when this method is called.
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // This method is called during interpreter_init() whereas
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // JDK version is only determined when universe2_init() is called.
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // java methods. Interpreter::method_kind(...) will select
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // this entry point for the corresponding methods in JDK 1.3.
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
249 // get argument
0
a61af66fc99e Initial load
duke
parents:
diff changeset
250
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
251 if (kind == Interpreter::java_lang_math_sqrt) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
252 __ sqrtsd(xmm0, Address(rsp, wordSize));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
253 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
254 __ fld_d(Address(rsp, wordSize));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
255 switch (kind) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
256 case Interpreter::java_lang_math_sin :
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
257 __ trigfunc('s');
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
258 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
259 case Interpreter::java_lang_math_cos :
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
260 __ trigfunc('c');
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
261 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
262 case Interpreter::java_lang_math_tan :
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
263 __ trigfunc('t');
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
264 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
265 case Interpreter::java_lang_math_abs:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
266 __ fabs();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
267 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
268 case Interpreter::java_lang_math_log:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
269 __ flog();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
270 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
271 case Interpreter::java_lang_math_log10:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
272 __ flog10();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
273 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
274 default :
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
275 ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
276 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
277
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
278 // return double result in xmm0 for interpreter and compilers.
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
279 __ subptr(rsp, 2*wordSize);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
280 // Round to 64bit precision
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
281 __ fstp_d(Address(rsp, 0));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
282 __ movdbl(xmm0, Address(rsp, 0));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
283 __ addptr(rsp, 2*wordSize);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
284 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
285
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
286
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
287 __ pop(rax);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
288 __ mov(rsp, r13);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
289 __ jmp(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 return entry_point;
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // Abstract method entry
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // Attempt to execute abstract method. Throw exception
a61af66fc99e Initial load
duke
parents:
diff changeset
297 address InterpreterGenerator::generate_abstract_entry(void) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // rbx: methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // r13: sender SP
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 address entry_point = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // abstract method entry
a61af66fc99e Initial load
duke
parents:
diff changeset
304
1108
85f13cdfbc1d 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 710
diff changeset
305 // pop return address, reset last_sp to NULL
85f13cdfbc1d 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 710
diff changeset
306 __ empty_expression_stack();
85f13cdfbc1d 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 710
diff changeset
307 __ restore_bcp(); // rsi must be correct for exception handler (was destroyed)
85f13cdfbc1d 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 710
diff changeset
308 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 // throw exception
a61af66fc99e Initial load
duke
parents:
diff changeset
311 __ call_VM(noreg, CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
312 InterpreterRuntime::throw_AbstractMethodError));
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // the call_VM checks for exception, so we should never return here.
a61af66fc99e Initial load
duke
parents:
diff changeset
314 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return entry_point;
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
320 // Method handle invoker
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
321 // Dispatch a method of the form java.dyn.MethodHandles::invoke(...)
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
322 address InterpreterGenerator::generate_method_handle_entry(void) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
323 if (!EnableMethodHandles) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
324 return generate_abstract_entry();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
325 }
1108
85f13cdfbc1d 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 710
diff changeset
326
85f13cdfbc1d 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 710
diff changeset
327 address entry_point = MethodHandles::generate_method_handle_interpreter_entry(_masm);
85f13cdfbc1d 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 710
diff changeset
328
85f13cdfbc1d 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 710
diff changeset
329 return entry_point;
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
330 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
331
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 304
diff changeset
332
0
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // Empty method, generate a very fast return.
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 address InterpreterGenerator::generate_empty_entry(void) {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // rbx: methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // r13: sender sp must set sp to this value on return
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 if (!UseFastEmptyMethods) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 address entry_point = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // If we need a safepoint check, generate full interpreter entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
346 Label slow_path;
a61af66fc99e Initial load
duke
parents:
diff changeset
347 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
a61af66fc99e Initial load
duke
parents:
diff changeset
348 SafepointSynchronize::_not_synchronized);
a61af66fc99e Initial load
duke
parents:
diff changeset
349 __ jcc(Assembler::notEqual, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // do nothing for empty methods (do not even increment invocation counter)
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // Code: _return
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // _return
a61af66fc99e Initial load
duke
parents:
diff changeset
354 // return w/o popping parameters
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
355 __ pop(rax);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
356 __ mov(rsp, r13);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
357 __ jmp(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 __ bind(slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
360 (void) generate_normal_entry(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 return entry_point;
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // This method tells the deoptimizer how big an interpreted frame must be:
a61af66fc99e Initial load
duke
parents:
diff changeset
366 int AbstractInterpreter::size_activation(methodOop method,
a61af66fc99e Initial load
duke
parents:
diff changeset
367 int tempcount,
a61af66fc99e Initial load
duke
parents:
diff changeset
368 int popframe_extra_args,
a61af66fc99e Initial load
duke
parents:
diff changeset
369 int moncount,
a61af66fc99e Initial load
duke
parents:
diff changeset
370 int callee_param_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
371 int callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
372 bool is_top_frame) {
a61af66fc99e Initial load
duke
parents:
diff changeset
373 return layout_activation(method,
a61af66fc99e Initial load
duke
parents:
diff changeset
374 tempcount, popframe_extra_args, moncount,
a61af66fc99e Initial load
duke
parents:
diff changeset
375 callee_param_count, callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
376 (frame*) NULL, (frame*) NULL, is_top_frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
a61af66fc99e Initial load
duke
parents:
diff changeset
382 // the days we had adapter frames. When we deoptimize a situation where a
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // compiled caller calls a compiled caller will have registers it expects
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // to survive the call to the callee. If we deoptimize the callee the only
a61af66fc99e Initial load
duke
parents:
diff changeset
385 // way we can restore these registers is to have the oldest interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
386 // frame that we create restore these values. That is what this routine
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // will accomplish.
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // At the moment we have modified c2 to not have any callee save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // so this problem does not exist and this routine is just a place holder.
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 assert(f->is_interpreted_frame(), "must be interpreted");
a61af66fc99e Initial load
duke
parents:
diff changeset
393 }