author | coleenp |
Tue, 22 Dec 2015 11:11:29 -0500 | |
changeset 35214 | d86005e0b4c2 |
parent 34651 | 07b1cc0f6040 |
child 35232 | 76aed99c0ddd |
permissions | -rw-r--r-- |
1 | 1 |
/* |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33465
diff
changeset
|
2 |
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5419
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5419
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5419
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
13728
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
7397 | 27 |
#include "interpreter/bytecodeHistogram.hpp" |
28 |
#include "interpreter/interpreter.hpp" |
|
29 |
#include "interpreter/interpreterRuntime.hpp" |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
23203
diff
changeset
|
30 |
#include "interpreter/interp_masm.hpp" |
35214 | 31 |
#include "interpreter/templateInterpreterGenerator.hpp" |
7397 | 32 |
#include "interpreter/templateTable.hpp" |
33 |
#include "oops/arrayOop.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
34 |
#include "oops/methodData.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
35 |
#include "oops/method.hpp" |
7397 | 36 |
#include "oops/oop.inline.hpp" |
37 |
#include "prims/jvmtiExport.hpp" |
|
38 |
#include "prims/jvmtiThreadState.hpp" |
|
39 |
#include "prims/methodHandles.hpp" |
|
40 |
#include "runtime/arguments.hpp" |
|
41 |
#include "runtime/frame.inline.hpp" |
|
42 |
#include "runtime/sharedRuntime.hpp" |
|
43 |
#include "runtime/stubRoutines.hpp" |
|
44 |
#include "runtime/synchronizer.hpp" |
|
45 |
#include "runtime/timer.hpp" |
|
46 |
#include "runtime/vframeArray.hpp" |
|
47 |
#include "utilities/debug.hpp" |
|
48 |
#ifdef COMPILER1 |
|
49 |
#include "c1/c1_Runtime1.hpp" |
|
50 |
#endif |
|
1 | 51 |
|
52 |
#define __ _masm-> |
|
53 |
||
54 |
//------------------------------------------------------------------------------------------------------------------------ |
|
55 |
||
56 |
address AbstractInterpreterGenerator::generate_slow_signature_handler() { |
|
57 |
address entry = __ pc(); |
|
58 |
// rbx,: method |
|
59 |
// rcx: temporary |
|
60 |
// rdi: pointer to locals |
|
61 |
// rsp: end of copied parameters area |
|
1066 | 62 |
__ mov(rcx, rsp); |
1 | 63 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx); |
64 |
__ ret(0); |
|
65 |
return entry; |
|
66 |
} |
|
67 |
||
68 |
||
35214 | 69 |
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) { |
1 | 70 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
71 |
// rbx,: Method* |
1 | 72 |
// rcx: scratrch |
73 |
// rsi: sender sp |
|
74 |
||
75 |
if (!InlineIntrinsics) return NULL; // Generate a vanilla entry |
|
76 |
||
77 |
address entry_point = __ pc(); |
|
78 |
||
79 |
// These don't need a safepoint check because they aren't virtually |
|
80 |
// callable. We won't enter these intrinsics from compiled code. |
|
81 |
// If in the future we added an intrinsic which was virtually callable |
|
82 |
// we'd have to worry about how to safepoint so that this code is used. |
|
83 |
||
84 |
// mathematical functions inlined by compiler |
|
85 |
// (interpreter must provide identical implementation |
|
86 |
// in order to avoid monotonicity bugs when switching |
|
87 |
// from interpreter to compiler in the middle of some |
|
88 |
// computation) |
|
89 |
// |
|
90 |
// stack: [ ret adr ] <-- rsp |
|
91 |
// [ lo(arg) ] |
|
92 |
// [ hi(arg) ] |
|
93 |
// |
|
94 |
||
95 |
// Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are |
|
96 |
// native methods. Interpreter::method_kind(...) does a check for |
|
97 |
// native methods first before checking for intrinsic methods and |
|
98 |
// thus will never select this entry point. Make sure it is not |
|
99 |
// called accidentally since the SharedRuntime entry points will |
|
100 |
// not work for JDK 1.2. |
|
101 |
// |
|
102 |
// We no longer need to check for JDK 1.2 since it's EOL'ed. |
|
103 |
// The following check existed in pre 1.6 implementation, |
|
104 |
// if (Universe::is_jdk12x_version()) { |
|
105 |
// __ should_not_reach_here(); |
|
106 |
// } |
|
107 |
// Universe::is_jdk12x_version() always returns false since |
|
108 |
// the JDK version is not yet determined when this method is called. |
|
109 |
// This method is called during interpreter_init() whereas |
|
110 |
// JDK version is only determined when universe2_init() is called. |
|
111 |
||
112 |
// Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are |
|
113 |
// java methods. Interpreter::method_kind(...) will select |
|
114 |
// this entry point for the corresponding methods in JDK 1.3. |
|
115 |
// get argument |
|
5419 | 116 |
__ fld_d(Address(rsp, 1*wordSize)); |
1 | 117 |
switch (kind) { |
118 |
case Interpreter::java_lang_math_sin : |
|
119 |
__ trigfunc('s'); |
|
120 |
break; |
|
121 |
case Interpreter::java_lang_math_cos : |
|
122 |
__ trigfunc('c'); |
|
123 |
break; |
|
124 |
case Interpreter::java_lang_math_tan : |
|
125 |
__ trigfunc('t'); |
|
126 |
break; |
|
127 |
case Interpreter::java_lang_math_sqrt: |
|
128 |
__ fsqrt(); |
|
129 |
break; |
|
130 |
case Interpreter::java_lang_math_abs: |
|
131 |
__ fabs(); |
|
132 |
break; |
|
133 |
case Interpreter::java_lang_math_log: |
|
33465 | 134 |
__ subptr(rsp, 2 * wordSize); |
135 |
__ fstp_d(Address(rsp, 0)); |
|
136 |
if (VM_Version::supports_sse2()) { |
|
137 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog()))); |
|
138 |
} |
|
139 |
else { |
|
140 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog))); |
|
141 |
} |
|
142 |
__ addptr(rsp, 2 * wordSize); |
|
1 | 143 |
break; |
144 |
case Interpreter::java_lang_math_log10: |
|
145 |
__ flog10(); |
|
146 |
// Store to stack to convert 80bit precision back to 64bits |
|
147 |
__ push_fTOS(); |
|
148 |
__ pop_fTOS(); |
|
149 |
break; |
|
12739
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
150 |
case Interpreter::java_lang_math_pow: |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
151 |
__ fld_d(Address(rsp, 3*wordSize)); // second argument |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
152 |
__ pow_with_fallback(0); |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
153 |
// Store to stack to convert 80bit precision back to 64bits |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
154 |
__ push_fTOS(); |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
155 |
__ pop_fTOS(); |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
156 |
break; |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
157 |
case Interpreter::java_lang_math_exp: |
33089 | 158 |
__ subptr(rsp, 2*wordSize); |
159 |
__ fstp_d(Address(rsp, 0)); |
|
160 |
if (VM_Version::supports_sse2()) { |
|
161 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp()))); |
|
162 |
} else { |
|
163 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp))); |
|
164 |
} |
|
165 |
__ addptr(rsp, 2*wordSize); |
|
166 |
break; |
|
1 | 167 |
default : |
168 |
ShouldNotReachHere(); |
|
169 |
} |
|
170 |
||
171 |
// return double result in xmm0 for interpreter and compilers. |
|
172 |
if (UseSSE >= 2) { |
|
1066 | 173 |
__ subptr(rsp, 2*wordSize); |
1 | 174 |
__ fstp_d(Address(rsp, 0)); |
175 |
__ movdbl(xmm0, Address(rsp, 0)); |
|
1066 | 176 |
__ addptr(rsp, 2*wordSize); |
1 | 177 |
} |
178 |
||
179 |
// done, result in FPU ST(0) or XMM0 |
|
1066 | 180 |
__ pop(rdi); // get return address |
181 |
__ mov(rsp, rsi); // set sp to sender sp |
|
1 | 182 |
__ jmp(rdi); |
183 |
||
184 |
return entry_point; |
|
185 |
} |