Mercurial > hg > graal-jvmci-8
annotate src/cpu/x86/vm/templateTable_x86_64.cpp @ 23696:54f09016769e
Make sure the client VM can build properly
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Fri, 17 Jun 2016 18:41:13 +0200 |
parents | b5f3a471e646 |
children | ca5c97226d1c |
rev | line source |
---|---|
0 | 1 /* |
23614 | 2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
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:
1506
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
7199
cd3d6a6b95d9
8003240: x86: move MacroAssembler into separate file
twisti
parents:
6840
diff
changeset
|
26 #include "asm/macroAssembler.hpp" |
1972 | 27 #include "interpreter/interpreter.hpp" |
28 #include "interpreter/interpreterRuntime.hpp" | |
29 #include "interpreter/templateTable.hpp" | |
30 #include "memory/universe.inline.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
31 #include "oops/methodData.hpp" |
1972 | 32 #include "oops/objArrayKlass.hpp" |
33 #include "oops/oop.inline.hpp" | |
34 #include "prims/methodHandles.hpp" | |
35 #include "runtime/sharedRuntime.hpp" | |
36 #include "runtime/stubRoutines.hpp" | |
37 #include "runtime/synchronizer.hpp" | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7199
diff
changeset
|
38 #include "utilities/macros.hpp" |
0 | 39 |
304 | 40 #ifndef CC_INTERP |
41 | |
0 | 42 #define __ _masm-> |
43 | |
44 // Platform-dependent initialization | |
45 | |
46 void TemplateTable::pd_initialize() { | |
47 // No amd64 specific initialization | |
48 } | |
49 | |
50 // Address computation: local variables | |
51 | |
52 static inline Address iaddress(int n) { | |
53 return Address(r14, Interpreter::local_offset_in_bytes(n)); | |
54 } | |
55 | |
56 static inline Address laddress(int n) { | |
57 return iaddress(n + 1); | |
58 } | |
59 | |
60 static inline Address faddress(int n) { | |
61 return iaddress(n); | |
62 } | |
63 | |
64 static inline Address daddress(int n) { | |
65 return laddress(n); | |
66 } | |
67 | |
68 static inline Address aaddress(int n) { | |
69 return iaddress(n); | |
70 } | |
71 | |
72 static inline Address iaddress(Register r) { | |
1506 | 73 return Address(r14, r, Address::times_8); |
0 | 74 } |
75 | |
76 static inline Address laddress(Register r) { | |
77 return Address(r14, r, Address::times_8, Interpreter::local_offset_in_bytes(1)); | |
78 } | |
79 | |
80 static inline Address faddress(Register r) { | |
81 return iaddress(r); | |
82 } | |
83 | |
84 static inline Address daddress(Register r) { | |
85 return laddress(r); | |
86 } | |
87 | |
88 static inline Address aaddress(Register r) { | |
89 return iaddress(r); | |
90 } | |
91 | |
92 static inline Address at_rsp() { | |
93 return Address(rsp, 0); | |
94 } | |
95 | |
96 // At top of Java expression stack which may be different than esp(). It | |
97 // isn't for category 1 objects. | |
98 static inline Address at_tos () { | |
99 return Address(rsp, Interpreter::expr_offset_in_bytes(0)); | |
100 } | |
101 | |
102 static inline Address at_tos_p1() { | |
103 return Address(rsp, Interpreter::expr_offset_in_bytes(1)); | |
104 } | |
105 | |
106 static inline Address at_tos_p2() { | |
107 return Address(rsp, Interpreter::expr_offset_in_bytes(2)); | |
108 } | |
109 | |
110 // Condition conversion | |
111 static Assembler::Condition j_not(TemplateTable::Condition cc) { | |
112 switch (cc) { | |
113 case TemplateTable::equal : return Assembler::notEqual; | |
114 case TemplateTable::not_equal : return Assembler::equal; | |
115 case TemplateTable::less : return Assembler::greaterEqual; | |
116 case TemplateTable::less_equal : return Assembler::greater; | |
117 case TemplateTable::greater : return Assembler::lessEqual; | |
118 case TemplateTable::greater_equal: return Assembler::less; | |
119 } | |
120 ShouldNotReachHere(); | |
121 return Assembler::zero; | |
122 } | |
123 | |
124 | |
125 // Miscelaneous helper routines | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
126 // Store an oop (or NULL) at the address described by obj. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
127 // If val == noreg this means store a NULL |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
128 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
129 static void do_oop_store(InterpreterMacroAssembler* _masm, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
130 Address obj, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
131 Register val, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
132 BarrierSet::Name barrier, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
133 bool precise) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
134 assert(val == noreg || val == rax, "parameter is just for looks"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
135 switch (barrier) { |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7199
diff
changeset
|
136 #if INCLUDE_ALL_GCS |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
137 case BarrierSet::G1SATBCT: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
138 case BarrierSet::G1SATBCTLogging: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
139 { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
140 // flatten object address if needed |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
141 if (obj.index() == noreg && obj.disp() == 0) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
142 if (obj.base() != rdx) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
143 __ movq(rdx, obj.base()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
144 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
145 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
146 __ leaq(rdx, obj); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
147 } |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
148 __ g1_write_barrier_pre(rdx /* obj */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
149 rbx /* pre_val */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
150 r15_thread /* thread */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
151 r8 /* tmp */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
152 val != noreg /* tosca_live */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
153 false /* expand_call */); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
154 if (val == noreg) { |
1047
beb8f45ee9f0
6889740: G1: OpenDS fails with "unhandled exception in compiled code"
johnc
parents:
844
diff
changeset
|
155 __ store_heap_oop_null(Address(rdx, 0)); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
156 } else { |
10102
f2e682ef3156
8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc.
johnc
parents:
8001
diff
changeset
|
157 // G1 barrier needs uncompressed oop for region cross check. |
f2e682ef3156
8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc.
johnc
parents:
8001
diff
changeset
|
158 Register new_val = val; |
f2e682ef3156
8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc.
johnc
parents:
8001
diff
changeset
|
159 if (UseCompressedOops) { |
f2e682ef3156
8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc.
johnc
parents:
8001
diff
changeset
|
160 new_val = rbx; |
f2e682ef3156
8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc.
johnc
parents:
8001
diff
changeset
|
161 __ movptr(new_val, val); |
f2e682ef3156
8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc.
johnc
parents:
8001
diff
changeset
|
162 } |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
163 __ store_heap_oop(Address(rdx, 0), val); |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
164 __ g1_write_barrier_post(rdx /* store_adr */, |
10102
f2e682ef3156
8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc.
johnc
parents:
8001
diff
changeset
|
165 new_val /* new_val */, |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
166 r15_thread /* thread */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
167 r8 /* tmp */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
168 rbx /* tmp2 */); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
169 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
170 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
171 break; |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7199
diff
changeset
|
172 #endif // INCLUDE_ALL_GCS |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
173 case BarrierSet::CardTableModRef: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
174 case BarrierSet::CardTableExtension: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
175 { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
176 if (val == noreg) { |
1047
beb8f45ee9f0
6889740: G1: OpenDS fails with "unhandled exception in compiled code"
johnc
parents:
844
diff
changeset
|
177 __ store_heap_oop_null(obj); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
178 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
179 __ store_heap_oop(obj, val); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
180 // flatten object address if needed |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
181 if (!precise || (obj.index() == noreg && obj.disp() == 0)) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
182 __ store_check(obj.base()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
183 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
184 __ leaq(rdx, obj); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
185 __ store_check(rdx); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
186 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
187 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
188 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
189 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
190 case BarrierSet::ModRef: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
191 case BarrierSet::Other: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
192 if (val == noreg) { |
1047
beb8f45ee9f0
6889740: G1: OpenDS fails with "unhandled exception in compiled code"
johnc
parents:
844
diff
changeset
|
193 __ store_heap_oop_null(obj); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
194 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
195 __ store_heap_oop(obj, val); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
196 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
197 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
198 default : |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
199 ShouldNotReachHere(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
200 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
201 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
202 } |
0 | 203 |
204 Address TemplateTable::at_bcp(int offset) { | |
205 assert(_desc->uses_bcp(), "inconsistent uses_bcp information"); | |
206 return Address(r13, offset); | |
207 } | |
208 | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
209 void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg, |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
210 Register temp_reg, bool load_bc_into_bc_reg/*=true*/, |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
211 int byte_no) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
212 if (!RewriteBytecodes) return; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
213 Label L_patch_done; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
214 |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
215 switch (bc) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
216 case Bytecodes::_fast_aputfield: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
217 case Bytecodes::_fast_bputfield: |
23614 | 218 case Bytecodes::_fast_zputfield: |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
219 case Bytecodes::_fast_cputfield: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
220 case Bytecodes::_fast_dputfield: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
221 case Bytecodes::_fast_fputfield: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
222 case Bytecodes::_fast_iputfield: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
223 case Bytecodes::_fast_lputfield: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
224 case Bytecodes::_fast_sputfield: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
225 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
226 // We skip bytecode quickening for putfield instructions when |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
227 // the put_code written to the constant pool cache is zero. |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
228 // This is required so that every execution of this instruction |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
229 // calls out to InterpreterRuntime::resolve_get_put to do |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
230 // additional, required work. |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
231 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
232 assert(load_bc_into_bc_reg, "we use bc_reg as temp"); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
233 __ get_cache_and_index_and_bytecode_at_bcp(temp_reg, bc_reg, temp_reg, byte_no, 1); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
234 __ movl(bc_reg, bc); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
235 __ cmpl(temp_reg, (int) 0); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
236 __ jcc(Assembler::zero, L_patch_done); // don't patch |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
237 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
238 break; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
239 default: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
240 assert(byte_no == -1, "sanity"); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
241 // the pair bytecodes have already done the load. |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
242 if (load_bc_into_bc_reg) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
243 __ movl(bc_reg, bc); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
244 } |
0 | 245 } |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
246 |
0 | 247 if (JvmtiExport::can_post_breakpoint()) { |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
248 Label L_fast_patch; |
0 | 249 // if a breakpoint is present we can't rewrite the stream directly |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
250 __ movzbl(temp_reg, at_bcp(0)); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
251 __ cmpl(temp_reg, Bytecodes::_breakpoint); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
252 __ jcc(Assembler::notEqual, L_fast_patch); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
253 __ get_method(temp_reg); |
0 | 254 // Let breakpoint table handling rewrite to quicker bytecode |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
255 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::set_original_bytecode_at), temp_reg, r13, bc_reg); |
0 | 256 #ifndef ASSERT |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
257 __ jmpb(L_patch_done); |
1108 | 258 #else |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
259 __ jmp(L_patch_done); |
1108 | 260 #endif |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
261 __ bind(L_fast_patch); |
0 | 262 } |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
263 |
1108 | 264 #ifdef ASSERT |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
265 Label L_okay; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
266 __ load_unsigned_byte(temp_reg, at_bcp(0)); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
267 __ cmpl(temp_reg, (int) Bytecodes::java_code(bc)); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
268 __ jcc(Assembler::equal, L_okay); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
269 __ cmpl(temp_reg, bc_reg); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
270 __ jcc(Assembler::equal, L_okay); |
0 | 271 __ stop("patching the wrong bytecode"); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
272 __ bind(L_okay); |
0 | 273 #endif |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
274 |
0 | 275 // patch bytecode |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
276 __ movb(at_bcp(0), bc_reg); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
277 __ bind(L_patch_done); |
0 | 278 } |
279 | |
280 | |
281 // Individual instructions | |
282 | |
283 void TemplateTable::nop() { | |
284 transition(vtos, vtos); | |
285 // nothing to do | |
286 } | |
287 | |
288 void TemplateTable::shouldnotreachhere() { | |
289 transition(vtos, vtos); | |
290 __ stop("shouldnotreachhere bytecode"); | |
291 } | |
292 | |
293 void TemplateTable::aconst_null() { | |
294 transition(vtos, atos); | |
295 __ xorl(rax, rax); | |
296 } | |
297 | |
298 void TemplateTable::iconst(int value) { | |
299 transition(vtos, itos); | |
300 if (value == 0) { | |
301 __ xorl(rax, rax); | |
302 } else { | |
303 __ movl(rax, value); | |
304 } | |
305 } | |
306 | |
307 void TemplateTable::lconst(int value) { | |
308 transition(vtos, ltos); | |
309 if (value == 0) { | |
310 __ xorl(rax, rax); | |
311 } else { | |
312 __ movl(rax, value); | |
313 } | |
314 } | |
315 | |
316 void TemplateTable::fconst(int value) { | |
317 transition(vtos, ftos); | |
318 static float one = 1.0f, two = 2.0f; | |
319 switch (value) { | |
320 case 0: | |
321 __ xorps(xmm0, xmm0); | |
322 break; | |
323 case 1: | |
324 __ movflt(xmm0, ExternalAddress((address) &one)); | |
325 break; | |
326 case 2: | |
327 __ movflt(xmm0, ExternalAddress((address) &two)); | |
328 break; | |
329 default: | |
330 ShouldNotReachHere(); | |
331 break; | |
332 } | |
333 } | |
334 | |
335 void TemplateTable::dconst(int value) { | |
336 transition(vtos, dtos); | |
337 static double one = 1.0; | |
338 switch (value) { | |
339 case 0: | |
340 __ xorpd(xmm0, xmm0); | |
341 break; | |
342 case 1: | |
343 __ movdbl(xmm0, ExternalAddress((address) &one)); | |
344 break; | |
345 default: | |
346 ShouldNotReachHere(); | |
347 break; | |
348 } | |
349 } | |
350 | |
351 void TemplateTable::bipush() { | |
352 transition(vtos, itos); | |
353 __ load_signed_byte(rax, at_bcp(1)); | |
354 } | |
355 | |
356 void TemplateTable::sipush() { | |
357 transition(vtos, itos); | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
358 __ load_unsigned_short(rax, at_bcp(1)); |
0 | 359 __ bswapl(rax); |
360 __ sarl(rax, 16); | |
361 } | |
362 | |
363 void TemplateTable::ldc(bool wide) { | |
364 transition(vtos, vtos); | |
365 Label call_ldc, notFloat, notClass, Done; | |
366 | |
367 if (wide) { | |
368 __ get_unsigned_2_byte_index_at_bcp(rbx, 1); | |
369 } else { | |
370 __ load_unsigned_byte(rbx, at_bcp(1)); | |
371 } | |
372 | |
373 __ get_cpool_and_tags(rcx, rax); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
374 const int base_offset = ConstantPool::header_size() * wordSize; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
375 const int tags_offset = Array<u1>::base_offset_in_bytes(); |
0 | 376 |
377 // get type | |
378 __ movzbl(rdx, Address(rax, rbx, Address::times_1, tags_offset)); | |
379 | |
380 // unresolved class - get the resolved class | |
381 __ cmpl(rdx, JVM_CONSTANT_UnresolvedClass); | |
382 __ jccb(Assembler::equal, call_ldc); | |
383 | |
384 // unresolved class in error state - call into runtime to throw the error | |
385 // from the first resolution attempt | |
386 __ cmpl(rdx, JVM_CONSTANT_UnresolvedClassInError); | |
387 __ jccb(Assembler::equal, call_ldc); | |
388 | |
389 // resolved class - need to call vm to get java mirror of the class | |
390 __ cmpl(rdx, JVM_CONSTANT_Class); | |
391 __ jcc(Assembler::notEqual, notClass); | |
392 | |
393 __ bind(call_ldc); | |
394 __ movl(c_rarg1, wide); | |
395 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), c_rarg1); | |
396 __ push_ptr(rax); | |
397 __ verify_oop(rax); | |
398 __ jmp(Done); | |
399 | |
400 __ bind(notClass); | |
401 __ cmpl(rdx, JVM_CONSTANT_Float); | |
402 __ jccb(Assembler::notEqual, notFloat); | |
403 // ftos | |
404 __ movflt(xmm0, Address(rcx, rbx, Address::times_8, base_offset)); | |
405 __ push_f(); | |
406 __ jmp(Done); | |
407 | |
408 __ bind(notFloat); | |
409 #ifdef ASSERT | |
410 { | |
411 Label L; | |
412 __ cmpl(rdx, JVM_CONSTANT_Integer); | |
413 __ jcc(Assembler::equal, L); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
414 // String and Object are rewritten to fast_aldc |
0 | 415 __ stop("unexpected tag type in ldc"); |
416 __ bind(L); | |
417 } | |
418 #endif | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
419 // itos JVM_CONSTANT_Integer only |
0 | 420 __ movl(rax, Address(rcx, rbx, Address::times_8, base_offset)); |
421 __ push_i(rax); | |
422 __ bind(Done); | |
423 } | |
424 | |
1602 | 425 // Fast path for caching oop constants. |
426 void TemplateTable::fast_aldc(bool wide) { | |
427 transition(vtos, atos); | |
428 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
429 Register result = rax; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
430 Register tmp = rdx; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
431 int index_size = wide ? sizeof(u2) : sizeof(u1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
432 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
433 Label resolved; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
434 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
435 // We are resolved if the resolved reference cache entry contains a |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
436 // non-null object (String, MethodType, etc.) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
437 assert_different_registers(result, tmp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
438 __ get_cache_index_at_bcp(tmp, 1, index_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
439 __ load_resolved_reference_at_index(result, tmp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
440 __ testl(result, result); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
441 __ jcc(Assembler::notZero, resolved); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
442 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
443 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
444 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
445 // first time invocation - must resolve first |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
446 __ movl(tmp, (int)bytecode()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
447 __ call_VM(result, entry, tmp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
448 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
449 __ bind(resolved); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
450 |
1602 | 451 if (VerifyOops) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
452 __ verify_oop(result); |
1602 | 453 } |
454 } | |
455 | |
0 | 456 void TemplateTable::ldc2_w() { |
457 transition(vtos, vtos); | |
458 Label Long, Done; | |
459 __ get_unsigned_2_byte_index_at_bcp(rbx, 1); | |
460 | |
461 __ get_cpool_and_tags(rcx, rax); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
462 const int base_offset = ConstantPool::header_size() * wordSize; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
463 const int tags_offset = Array<u1>::base_offset_in_bytes(); |
0 | 464 |
465 // get type | |
466 __ cmpb(Address(rax, rbx, Address::times_1, tags_offset), | |
467 JVM_CONSTANT_Double); | |
468 __ jccb(Assembler::notEqual, Long); | |
469 // dtos | |
470 __ movdbl(xmm0, Address(rcx, rbx, Address::times_8, base_offset)); | |
471 __ push_d(); | |
472 __ jmpb(Done); | |
473 | |
474 __ bind(Long); | |
475 // ltos | |
476 __ movq(rax, Address(rcx, rbx, Address::times_8, base_offset)); | |
477 __ push_l(); | |
478 | |
479 __ bind(Done); | |
480 } | |
481 | |
482 void TemplateTable::locals_index(Register reg, int offset) { | |
483 __ load_unsigned_byte(reg, at_bcp(offset)); | |
304 | 484 __ negptr(reg); |
0 | 485 } |
486 | |
487 void TemplateTable::iload() { | |
488 transition(vtos, itos); | |
489 if (RewriteFrequentPairs) { | |
490 Label rewrite, done; | |
491 const Register bc = c_rarg3; | |
492 assert(rbx != bc, "register damaged"); | |
493 | |
494 // get next byte | |
495 __ load_unsigned_byte(rbx, | |
496 at_bcp(Bytecodes::length_for(Bytecodes::_iload))); | |
497 // if _iload, wait to rewrite to iload2. We only want to rewrite the | |
498 // last two iloads in a pair. Comparing against fast_iload means that | |
499 // the next bytecode is neither an iload or a caload, and therefore | |
500 // an iload pair. | |
501 __ cmpl(rbx, Bytecodes::_iload); | |
502 __ jcc(Assembler::equal, done); | |
503 | |
504 __ cmpl(rbx, Bytecodes::_fast_iload); | |
505 __ movl(bc, Bytecodes::_fast_iload2); | |
506 __ jccb(Assembler::equal, rewrite); | |
507 | |
508 // if _caload, rewrite to fast_icaload | |
509 __ cmpl(rbx, Bytecodes::_caload); | |
510 __ movl(bc, Bytecodes::_fast_icaload); | |
511 __ jccb(Assembler::equal, rewrite); | |
512 | |
513 // rewrite so iload doesn't check again. | |
514 __ movl(bc, Bytecodes::_fast_iload); | |
515 | |
516 // rewrite | |
517 // bc: fast bytecode | |
518 __ bind(rewrite); | |
519 patch_bytecode(Bytecodes::_iload, bc, rbx, false); | |
520 __ bind(done); | |
521 } | |
522 | |
523 // Get the local value into tos | |
524 locals_index(rbx); | |
525 __ movl(rax, iaddress(rbx)); | |
526 } | |
527 | |
528 void TemplateTable::fast_iload2() { | |
529 transition(vtos, itos); | |
530 locals_index(rbx); | |
531 __ movl(rax, iaddress(rbx)); | |
532 __ push(itos); | |
533 locals_index(rbx, 3); | |
534 __ movl(rax, iaddress(rbx)); | |
535 } | |
536 | |
537 void TemplateTable::fast_iload() { | |
538 transition(vtos, itos); | |
539 locals_index(rbx); | |
540 __ movl(rax, iaddress(rbx)); | |
541 } | |
542 | |
543 void TemplateTable::lload() { | |
544 transition(vtos, ltos); | |
545 locals_index(rbx); | |
546 __ movq(rax, laddress(rbx)); | |
547 } | |
548 | |
549 void TemplateTable::fload() { | |
550 transition(vtos, ftos); | |
551 locals_index(rbx); | |
552 __ movflt(xmm0, faddress(rbx)); | |
553 } | |
554 | |
555 void TemplateTable::dload() { | |
556 transition(vtos, dtos); | |
557 locals_index(rbx); | |
558 __ movdbl(xmm0, daddress(rbx)); | |
559 } | |
560 | |
561 void TemplateTable::aload() { | |
562 transition(vtos, atos); | |
563 locals_index(rbx); | |
304 | 564 __ movptr(rax, aaddress(rbx)); |
0 | 565 } |
566 | |
567 void TemplateTable::locals_index_wide(Register reg) { | |
13034
ea79ab313e98
8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
mgerdin
parents:
12875
diff
changeset
|
568 __ load_unsigned_short(reg, at_bcp(2)); |
0 | 569 __ bswapl(reg); |
570 __ shrl(reg, 16); | |
304 | 571 __ negptr(reg); |
0 | 572 } |
573 | |
574 void TemplateTable::wide_iload() { | |
575 transition(vtos, itos); | |
576 locals_index_wide(rbx); | |
577 __ movl(rax, iaddress(rbx)); | |
578 } | |
579 | |
580 void TemplateTable::wide_lload() { | |
581 transition(vtos, ltos); | |
582 locals_index_wide(rbx); | |
583 __ movq(rax, laddress(rbx)); | |
584 } | |
585 | |
586 void TemplateTable::wide_fload() { | |
587 transition(vtos, ftos); | |
588 locals_index_wide(rbx); | |
589 __ movflt(xmm0, faddress(rbx)); | |
590 } | |
591 | |
592 void TemplateTable::wide_dload() { | |
593 transition(vtos, dtos); | |
594 locals_index_wide(rbx); | |
595 __ movdbl(xmm0, daddress(rbx)); | |
596 } | |
597 | |
598 void TemplateTable::wide_aload() { | |
599 transition(vtos, atos); | |
600 locals_index_wide(rbx); | |
304 | 601 __ movptr(rax, aaddress(rbx)); |
0 | 602 } |
603 | |
604 void TemplateTable::index_check(Register array, Register index) { | |
605 // destroys rbx | |
606 // check array | |
607 __ null_check(array, arrayOopDesc::length_offset_in_bytes()); | |
608 // sign extend index for use by indexed load | |
304 | 609 __ movl2ptr(index, index); |
0 | 610 // check index |
611 __ cmpl(index, Address(array, arrayOopDesc::length_offset_in_bytes())); | |
612 if (index != rbx) { | |
613 // ??? convention: move aberrant index into ebx for exception message | |
614 assert(rbx != array, "different registers"); | |
615 __ movl(rbx, index); | |
616 } | |
617 __ jump_cc(Assembler::aboveEqual, | |
618 ExternalAddress(Interpreter::_throw_ArrayIndexOutOfBoundsException_entry)); | |
619 } | |
620 | |
621 void TemplateTable::iaload() { | |
622 transition(itos, itos); | |
623 __ pop_ptr(rdx); | |
624 // eax: index | |
625 // rdx: array | |
626 index_check(rdx, rax); // kills rbx | |
627 __ movl(rax, Address(rdx, rax, | |
628 Address::times_4, | |
629 arrayOopDesc::base_offset_in_bytes(T_INT))); | |
630 } | |
631 | |
632 void TemplateTable::laload() { | |
633 transition(itos, ltos); | |
634 __ pop_ptr(rdx); | |
635 // eax: index | |
636 // rdx: array | |
637 index_check(rdx, rax); // kills rbx | |
638 __ movq(rax, Address(rdx, rbx, | |
639 Address::times_8, | |
640 arrayOopDesc::base_offset_in_bytes(T_LONG))); | |
641 } | |
642 | |
643 void TemplateTable::faload() { | |
644 transition(itos, ftos); | |
645 __ pop_ptr(rdx); | |
646 // eax: index | |
647 // rdx: array | |
648 index_check(rdx, rax); // kills rbx | |
649 __ movflt(xmm0, Address(rdx, rax, | |
650 Address::times_4, | |
651 arrayOopDesc::base_offset_in_bytes(T_FLOAT))); | |
652 } | |
653 | |
654 void TemplateTable::daload() { | |
655 transition(itos, dtos); | |
656 __ pop_ptr(rdx); | |
657 // eax: index | |
658 // rdx: array | |
659 index_check(rdx, rax); // kills rbx | |
660 __ movdbl(xmm0, Address(rdx, rax, | |
661 Address::times_8, | |
662 arrayOopDesc::base_offset_in_bytes(T_DOUBLE))); | |
663 } | |
664 | |
665 void TemplateTable::aaload() { | |
666 transition(itos, atos); | |
667 __ pop_ptr(rdx); | |
668 // eax: index | |
669 // rdx: array | |
670 index_check(rdx, rax); // kills rbx | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
671 __ load_heap_oop(rax, Address(rdx, rax, |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
672 UseCompressedOops ? Address::times_4 : Address::times_8, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
673 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
0 | 674 } |
675 | |
676 void TemplateTable::baload() { | |
677 transition(itos, itos); | |
678 __ pop_ptr(rdx); | |
679 // eax: index | |
680 // rdx: array | |
681 index_check(rdx, rax); // kills rbx | |
682 __ load_signed_byte(rax, | |
683 Address(rdx, rax, | |
684 Address::times_1, | |
685 arrayOopDesc::base_offset_in_bytes(T_BYTE))); | |
686 } | |
687 | |
688 void TemplateTable::caload() { | |
689 transition(itos, itos); | |
690 __ pop_ptr(rdx); | |
691 // eax: index | |
692 // rdx: array | |
693 index_check(rdx, rax); // kills rbx | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
694 __ load_unsigned_short(rax, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
695 Address(rdx, rax, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
696 Address::times_2, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
697 arrayOopDesc::base_offset_in_bytes(T_CHAR))); |
0 | 698 } |
699 | |
700 // iload followed by caload frequent pair | |
701 void TemplateTable::fast_icaload() { | |
702 transition(vtos, itos); | |
703 // load index out of locals | |
704 locals_index(rbx); | |
705 __ movl(rax, iaddress(rbx)); | |
706 | |
707 // eax: index | |
708 // rdx: array | |
709 __ pop_ptr(rdx); | |
710 index_check(rdx, rax); // kills rbx | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
711 __ load_unsigned_short(rax, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
712 Address(rdx, rax, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
713 Address::times_2, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
714 arrayOopDesc::base_offset_in_bytes(T_CHAR))); |
0 | 715 } |
716 | |
717 void TemplateTable::saload() { | |
718 transition(itos, itos); | |
719 __ pop_ptr(rdx); | |
720 // eax: index | |
721 // rdx: array | |
722 index_check(rdx, rax); // kills rbx | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
723 __ load_signed_short(rax, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
724 Address(rdx, rax, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
725 Address::times_2, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
726 arrayOopDesc::base_offset_in_bytes(T_SHORT))); |
0 | 727 } |
728 | |
729 void TemplateTable::iload(int n) { | |
730 transition(vtos, itos); | |
731 __ movl(rax, iaddress(n)); | |
732 } | |
733 | |
734 void TemplateTable::lload(int n) { | |
735 transition(vtos, ltos); | |
736 __ movq(rax, laddress(n)); | |
737 } | |
738 | |
739 void TemplateTable::fload(int n) { | |
740 transition(vtos, ftos); | |
741 __ movflt(xmm0, faddress(n)); | |
742 } | |
743 | |
744 void TemplateTable::dload(int n) { | |
745 transition(vtos, dtos); | |
746 __ movdbl(xmm0, daddress(n)); | |
747 } | |
748 | |
749 void TemplateTable::aload(int n) { | |
750 transition(vtos, atos); | |
304 | 751 __ movptr(rax, aaddress(n)); |
0 | 752 } |
753 | |
754 void TemplateTable::aload_0() { | |
755 transition(vtos, atos); | |
756 // According to bytecode histograms, the pairs: | |
757 // | |
758 // _aload_0, _fast_igetfield | |
759 // _aload_0, _fast_agetfield | |
760 // _aload_0, _fast_fgetfield | |
761 // | |
762 // occur frequently. If RewriteFrequentPairs is set, the (slow) | |
763 // _aload_0 bytecode checks if the next bytecode is either | |
764 // _fast_igetfield, _fast_agetfield or _fast_fgetfield and then | |
765 // rewrites the current bytecode into a pair bytecode; otherwise it | |
766 // rewrites the current bytecode into _fast_aload_0 that doesn't do | |
767 // the pair check anymore. | |
768 // | |
769 // Note: If the next bytecode is _getfield, the rewrite must be | |
770 // delayed, otherwise we may miss an opportunity for a pair. | |
771 // | |
772 // Also rewrite frequent pairs | |
773 // aload_0, aload_1 | |
774 // aload_0, iload_1 | |
775 // These bytecodes with a small amount of code are most profitable | |
776 // to rewrite | |
777 if (RewriteFrequentPairs) { | |
778 Label rewrite, done; | |
779 const Register bc = c_rarg3; | |
780 assert(rbx != bc, "register damaged"); | |
781 // get next byte | |
782 __ load_unsigned_byte(rbx, | |
783 at_bcp(Bytecodes::length_for(Bytecodes::_aload_0))); | |
784 | |
785 // do actual aload_0 | |
786 aload(0); | |
787 | |
788 // if _getfield then wait with rewrite | |
789 __ cmpl(rbx, Bytecodes::_getfield); | |
790 __ jcc(Assembler::equal, done); | |
791 | |
792 // if _igetfield then reqrite to _fast_iaccess_0 | |
793 assert(Bytecodes::java_code(Bytecodes::_fast_iaccess_0) == | |
794 Bytecodes::_aload_0, | |
795 "fix bytecode definition"); | |
796 __ cmpl(rbx, Bytecodes::_fast_igetfield); | |
797 __ movl(bc, Bytecodes::_fast_iaccess_0); | |
798 __ jccb(Assembler::equal, rewrite); | |
799 | |
800 // if _agetfield then reqrite to _fast_aaccess_0 | |
801 assert(Bytecodes::java_code(Bytecodes::_fast_aaccess_0) == | |
802 Bytecodes::_aload_0, | |
803 "fix bytecode definition"); | |
804 __ cmpl(rbx, Bytecodes::_fast_agetfield); | |
805 __ movl(bc, Bytecodes::_fast_aaccess_0); | |
806 __ jccb(Assembler::equal, rewrite); | |
807 | |
808 // if _fgetfield then reqrite to _fast_faccess_0 | |
809 assert(Bytecodes::java_code(Bytecodes::_fast_faccess_0) == | |
810 Bytecodes::_aload_0, | |
811 "fix bytecode definition"); | |
812 __ cmpl(rbx, Bytecodes::_fast_fgetfield); | |
813 __ movl(bc, Bytecodes::_fast_faccess_0); | |
814 __ jccb(Assembler::equal, rewrite); | |
815 | |
816 // else rewrite to _fast_aload0 | |
817 assert(Bytecodes::java_code(Bytecodes::_fast_aload_0) == | |
818 Bytecodes::_aload_0, | |
819 "fix bytecode definition"); | |
820 __ movl(bc, Bytecodes::_fast_aload_0); | |
821 | |
822 // rewrite | |
823 // bc: fast bytecode | |
824 __ bind(rewrite); | |
825 patch_bytecode(Bytecodes::_aload_0, bc, rbx, false); | |
826 | |
827 __ bind(done); | |
828 } else { | |
829 aload(0); | |
830 } | |
831 } | |
832 | |
833 void TemplateTable::istore() { | |
834 transition(itos, vtos); | |
835 locals_index(rbx); | |
836 __ movl(iaddress(rbx), rax); | |
837 } | |
838 | |
839 void TemplateTable::lstore() { | |
840 transition(ltos, vtos); | |
841 locals_index(rbx); | |
842 __ movq(laddress(rbx), rax); | |
843 } | |
844 | |
845 void TemplateTable::fstore() { | |
846 transition(ftos, vtos); | |
847 locals_index(rbx); | |
848 __ movflt(faddress(rbx), xmm0); | |
849 } | |
850 | |
851 void TemplateTable::dstore() { | |
852 transition(dtos, vtos); | |
853 locals_index(rbx); | |
854 __ movdbl(daddress(rbx), xmm0); | |
855 } | |
856 | |
857 void TemplateTable::astore() { | |
858 transition(vtos, vtos); | |
1506 | 859 __ pop_ptr(rax); |
0 | 860 locals_index(rbx); |
304 | 861 __ movptr(aaddress(rbx), rax); |
0 | 862 } |
863 | |
864 void TemplateTable::wide_istore() { | |
865 transition(vtos, vtos); | |
866 __ pop_i(); | |
867 locals_index_wide(rbx); | |
868 __ movl(iaddress(rbx), rax); | |
869 } | |
870 | |
871 void TemplateTable::wide_lstore() { | |
872 transition(vtos, vtos); | |
873 __ pop_l(); | |
874 locals_index_wide(rbx); | |
875 __ movq(laddress(rbx), rax); | |
876 } | |
877 | |
878 void TemplateTable::wide_fstore() { | |
879 transition(vtos, vtos); | |
880 __ pop_f(); | |
881 locals_index_wide(rbx); | |
882 __ movflt(faddress(rbx), xmm0); | |
883 } | |
884 | |
885 void TemplateTable::wide_dstore() { | |
886 transition(vtos, vtos); | |
887 __ pop_d(); | |
888 locals_index_wide(rbx); | |
889 __ movdbl(daddress(rbx), xmm0); | |
890 } | |
891 | |
892 void TemplateTable::wide_astore() { | |
893 transition(vtos, vtos); | |
1506 | 894 __ pop_ptr(rax); |
0 | 895 locals_index_wide(rbx); |
304 | 896 __ movptr(aaddress(rbx), rax); |
0 | 897 } |
898 | |
899 void TemplateTable::iastore() { | |
900 transition(itos, vtos); | |
901 __ pop_i(rbx); | |
902 __ pop_ptr(rdx); | |
903 // eax: value | |
904 // ebx: index | |
905 // rdx: array | |
906 index_check(rdx, rbx); // prefer index in ebx | |
907 __ movl(Address(rdx, rbx, | |
908 Address::times_4, | |
909 arrayOopDesc::base_offset_in_bytes(T_INT)), | |
910 rax); | |
911 } | |
912 | |
913 void TemplateTable::lastore() { | |
914 transition(ltos, vtos); | |
915 __ pop_i(rbx); | |
916 __ pop_ptr(rdx); | |
917 // rax: value | |
918 // ebx: index | |
919 // rdx: array | |
920 index_check(rdx, rbx); // prefer index in ebx | |
921 __ movq(Address(rdx, rbx, | |
922 Address::times_8, | |
923 arrayOopDesc::base_offset_in_bytes(T_LONG)), | |
924 rax); | |
925 } | |
926 | |
927 void TemplateTable::fastore() { | |
928 transition(ftos, vtos); | |
929 __ pop_i(rbx); | |
930 __ pop_ptr(rdx); | |
931 // xmm0: value | |
932 // ebx: index | |
933 // rdx: array | |
934 index_check(rdx, rbx); // prefer index in ebx | |
935 __ movflt(Address(rdx, rbx, | |
936 Address::times_4, | |
937 arrayOopDesc::base_offset_in_bytes(T_FLOAT)), | |
938 xmm0); | |
939 } | |
940 | |
941 void TemplateTable::dastore() { | |
942 transition(dtos, vtos); | |
943 __ pop_i(rbx); | |
944 __ pop_ptr(rdx); | |
945 // xmm0: value | |
946 // ebx: index | |
947 // rdx: array | |
948 index_check(rdx, rbx); // prefer index in ebx | |
949 __ movdbl(Address(rdx, rbx, | |
950 Address::times_8, | |
951 arrayOopDesc::base_offset_in_bytes(T_DOUBLE)), | |
952 xmm0); | |
953 } | |
954 | |
955 void TemplateTable::aastore() { | |
956 Label is_null, ok_is_subtype, done; | |
957 transition(vtos, vtos); | |
958 // stack: ..., array, index, value | |
304 | 959 __ movptr(rax, at_tos()); // value |
0 | 960 __ movl(rcx, at_tos_p1()); // index |
304 | 961 __ movptr(rdx, at_tos_p2()); // array |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
962 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
963 Address element_address(rdx, rcx, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
964 UseCompressedOops? Address::times_4 : Address::times_8, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
965 arrayOopDesc::base_offset_in_bytes(T_OBJECT)); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
966 |
0 | 967 index_check(rdx, rcx); // kills rbx |
968 // do array store check - check for NULL value first | |
304 | 969 __ testptr(rax, rax); |
0 | 970 __ jcc(Assembler::zero, is_null); |
971 | |
972 // Move subklass into rbx | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
973 __ load_klass(rbx, rax); |
0 | 974 // Move superklass into rax |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
975 __ load_klass(rax, rdx); |
304 | 976 __ movptr(rax, Address(rax, |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6740
diff
changeset
|
977 ObjArrayKlass::element_klass_offset())); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
978 // Compress array + index*oopSize + 12 into a single register. Frees rcx. |
362 | 979 __ lea(rdx, element_address); |
0 | 980 |
981 // Generate subtype check. Blows rcx, rdi | |
982 // Superklass in rax. Subklass in rbx. | |
983 __ gen_subtype_check(rbx, ok_is_subtype); | |
984 | |
985 // Come here on failure | |
986 // object is at TOS | |
987 __ jump(ExternalAddress(Interpreter::_throw_ArrayStoreException_entry)); | |
988 | |
989 // Come here on success | |
990 __ bind(ok_is_subtype); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
991 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
992 // Get the value we will store |
362 | 993 __ movptr(rax, at_tos()); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
994 // Now store using the appropriate barrier |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
995 do_oop_store(_masm, Address(rdx, 0), rax, _bs->kind(), true); |
0 | 996 __ jmp(done); |
997 | |
998 // Have a NULL in rax, rdx=array, ecx=index. Store NULL at ary[idx] | |
999 __ bind(is_null); | |
1000 __ profile_null_seen(rbx); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
1001 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
1002 // Store a NULL |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
1003 do_oop_store(_masm, element_address, noreg, _bs->kind(), true); |
0 | 1004 |
1005 // Pop stack arguments | |
1006 __ bind(done); | |
1506 | 1007 __ addptr(rsp, 3 * Interpreter::stackElementSize); |
0 | 1008 } |
1009 | |
1010 void TemplateTable::bastore() { | |
1011 transition(itos, vtos); | |
1012 __ pop_i(rbx); | |
1013 __ pop_ptr(rdx); | |
1014 // eax: value | |
1015 // ebx: index | |
1016 // rdx: array | |
1017 index_check(rdx, rbx); // prefer index in ebx | |
23614 | 1018 // Need to check whether array is boolean or byte |
1019 // since both types share the bastore bytecode. | |
1020 __ load_klass(rcx, rdx); | |
1021 __ movl(rcx, Address(rcx, Klass::layout_helper_offset())); | |
1022 int diffbit = Klass::layout_helper_boolean_diffbit(); | |
1023 __ testl(rcx, diffbit); | |
1024 Label L_skip; | |
1025 __ jccb(Assembler::zero, L_skip); | |
1026 __ andl(rax, 1); // if it is a T_BOOLEAN array, mask the stored value to 0/1 | |
1027 __ bind(L_skip); | |
0 | 1028 __ movb(Address(rdx, rbx, |
1029 Address::times_1, | |
1030 arrayOopDesc::base_offset_in_bytes(T_BYTE)), | |
1031 rax); | |
1032 } | |
1033 | |
1034 void TemplateTable::castore() { | |
1035 transition(itos, vtos); | |
1036 __ pop_i(rbx); | |
1037 __ pop_ptr(rdx); | |
1038 // eax: value | |
1039 // ebx: index | |
1040 // rdx: array | |
1041 index_check(rdx, rbx); // prefer index in ebx | |
1042 __ movw(Address(rdx, rbx, | |
1043 Address::times_2, | |
1044 arrayOopDesc::base_offset_in_bytes(T_CHAR)), | |
1045 rax); | |
1046 } | |
1047 | |
1048 void TemplateTable::sastore() { | |
1049 castore(); | |
1050 } | |
1051 | |
1052 void TemplateTable::istore(int n) { | |
1053 transition(itos, vtos); | |
1054 __ movl(iaddress(n), rax); | |
1055 } | |
1056 | |
1057 void TemplateTable::lstore(int n) { | |
1058 transition(ltos, vtos); | |
1059 __ movq(laddress(n), rax); | |
1060 } | |
1061 | |
1062 void TemplateTable::fstore(int n) { | |
1063 transition(ftos, vtos); | |
1064 __ movflt(faddress(n), xmm0); | |
1065 } | |
1066 | |
1067 void TemplateTable::dstore(int n) { | |
1068 transition(dtos, vtos); | |
1069 __ movdbl(daddress(n), xmm0); | |
1070 } | |
1071 | |
1072 void TemplateTable::astore(int n) { | |
1073 transition(vtos, vtos); | |
1506 | 1074 __ pop_ptr(rax); |
304 | 1075 __ movptr(aaddress(n), rax); |
0 | 1076 } |
1077 | |
1078 void TemplateTable::pop() { | |
1079 transition(vtos, vtos); | |
1506 | 1080 __ addptr(rsp, Interpreter::stackElementSize); |
0 | 1081 } |
1082 | |
1083 void TemplateTable::pop2() { | |
1084 transition(vtos, vtos); | |
1506 | 1085 __ addptr(rsp, 2 * Interpreter::stackElementSize); |
0 | 1086 } |
1087 | |
1088 void TemplateTable::dup() { | |
1089 transition(vtos, vtos); | |
1506 | 1090 __ load_ptr(0, rax); |
1091 __ push_ptr(rax); | |
0 | 1092 // stack: ..., a, a |
1093 } | |
1094 | |
1095 void TemplateTable::dup_x1() { | |
1096 transition(vtos, vtos); | |
1097 // stack: ..., a, b | |
1506 | 1098 __ load_ptr( 0, rax); // load b |
1099 __ load_ptr( 1, rcx); // load a | |
1100 __ store_ptr(1, rax); // store b | |
1101 __ store_ptr(0, rcx); // store a | |
1102 __ push_ptr(rax); // push b | |
0 | 1103 // stack: ..., b, a, b |
1104 } | |
1105 | |
1106 void TemplateTable::dup_x2() { | |
1107 transition(vtos, vtos); | |
1108 // stack: ..., a, b, c | |
1506 | 1109 __ load_ptr( 0, rax); // load c |
1110 __ load_ptr( 2, rcx); // load a | |
1111 __ store_ptr(2, rax); // store c in a | |
1112 __ push_ptr(rax); // push c | |
0 | 1113 // stack: ..., c, b, c, c |
1506 | 1114 __ load_ptr( 2, rax); // load b |
1115 __ store_ptr(2, rcx); // store a in b | |
0 | 1116 // stack: ..., c, a, c, c |
1506 | 1117 __ store_ptr(1, rax); // store b in c |
0 | 1118 // stack: ..., c, a, b, c |
1119 } | |
1120 | |
1121 void TemplateTable::dup2() { | |
1122 transition(vtos, vtos); | |
1123 // stack: ..., a, b | |
1506 | 1124 __ load_ptr(1, rax); // load a |
1125 __ push_ptr(rax); // push a | |
1126 __ load_ptr(1, rax); // load b | |
1127 __ push_ptr(rax); // push b | |
0 | 1128 // stack: ..., a, b, a, b |
1129 } | |
1130 | |
1131 void TemplateTable::dup2_x1() { | |
1132 transition(vtos, vtos); | |
1133 // stack: ..., a, b, c | |
1506 | 1134 __ load_ptr( 0, rcx); // load c |
1135 __ load_ptr( 1, rax); // load b | |
1136 __ push_ptr(rax); // push b | |
1137 __ push_ptr(rcx); // push c | |
0 | 1138 // stack: ..., a, b, c, b, c |
1506 | 1139 __ store_ptr(3, rcx); // store c in b |
0 | 1140 // stack: ..., a, c, c, b, c |
1506 | 1141 __ load_ptr( 4, rcx); // load a |
1142 __ store_ptr(2, rcx); // store a in 2nd c | |
0 | 1143 // stack: ..., a, c, a, b, c |
1506 | 1144 __ store_ptr(4, rax); // store b in a |
0 | 1145 // stack: ..., b, c, a, b, c |
1146 } | |
1147 | |
1148 void TemplateTable::dup2_x2() { | |
1149 transition(vtos, vtos); | |
1150 // stack: ..., a, b, c, d | |
1506 | 1151 __ load_ptr( 0, rcx); // load d |
1152 __ load_ptr( 1, rax); // load c | |
1153 __ push_ptr(rax); // push c | |
1154 __ push_ptr(rcx); // push d | |
0 | 1155 // stack: ..., a, b, c, d, c, d |
1506 | 1156 __ load_ptr( 4, rax); // load b |
1157 __ store_ptr(2, rax); // store b in d | |
1158 __ store_ptr(4, rcx); // store d in b | |
0 | 1159 // stack: ..., a, d, c, b, c, d |
1506 | 1160 __ load_ptr( 5, rcx); // load a |
1161 __ load_ptr( 3, rax); // load c | |
1162 __ store_ptr(3, rcx); // store a in c | |
1163 __ store_ptr(5, rax); // store c in a | |
0 | 1164 // stack: ..., c, d, a, b, c, d |
1165 } | |
1166 | |
1167 void TemplateTable::swap() { | |
1168 transition(vtos, vtos); | |
1169 // stack: ..., a, b | |
1506 | 1170 __ load_ptr( 1, rcx); // load a |
1171 __ load_ptr( 0, rax); // load b | |
1172 __ store_ptr(0, rcx); // store a in b | |
1173 __ store_ptr(1, rax); // store b in a | |
0 | 1174 // stack: ..., b, a |
1175 } | |
1176 | |
1177 void TemplateTable::iop2(Operation op) { | |
1178 transition(itos, itos); | |
1179 switch (op) { | |
1180 case add : __ pop_i(rdx); __ addl (rax, rdx); break; | |
1181 case sub : __ movl(rdx, rax); __ pop_i(rax); __ subl (rax, rdx); break; | |
1182 case mul : __ pop_i(rdx); __ imull(rax, rdx); break; | |
1183 case _and : __ pop_i(rdx); __ andl (rax, rdx); break; | |
1184 case _or : __ pop_i(rdx); __ orl (rax, rdx); break; | |
1185 case _xor : __ pop_i(rdx); __ xorl (rax, rdx); break; | |
1186 case shl : __ movl(rcx, rax); __ pop_i(rax); __ shll (rax); break; | |
1187 case shr : __ movl(rcx, rax); __ pop_i(rax); __ sarl (rax); break; | |
1188 case ushr : __ movl(rcx, rax); __ pop_i(rax); __ shrl (rax); break; | |
1189 default : ShouldNotReachHere(); | |
1190 } | |
1191 } | |
1192 | |
1193 void TemplateTable::lop2(Operation op) { | |
1194 transition(ltos, ltos); | |
1195 switch (op) { | |
1506 | 1196 case add : __ pop_l(rdx); __ addptr(rax, rdx); break; |
1197 case sub : __ mov(rdx, rax); __ pop_l(rax); __ subptr(rax, rdx); break; | |
1198 case _and : __ pop_l(rdx); __ andptr(rax, rdx); break; | |
1199 case _or : __ pop_l(rdx); __ orptr (rax, rdx); break; | |
1200 case _xor : __ pop_l(rdx); __ xorptr(rax, rdx); break; | |
1201 default : ShouldNotReachHere(); | |
0 | 1202 } |
1203 } | |
1204 | |
1205 void TemplateTable::idiv() { | |
1206 transition(itos, itos); | |
1207 __ movl(rcx, rax); | |
1208 __ pop_i(rax); | |
1209 // Note: could xor eax and ecx and compare with (-1 ^ min_int). If | |
1210 // they are not equal, one could do a normal division (no correction | |
1211 // needed), which may speed up this implementation for the common case. | |
1212 // (see also JVM spec., p.243 & p.271) | |
1213 __ corrected_idivl(rcx); | |
1214 } | |
1215 | |
1216 void TemplateTable::irem() { | |
1217 transition(itos, itos); | |
1218 __ movl(rcx, rax); | |
1219 __ pop_i(rax); | |
1220 // Note: could xor eax and ecx and compare with (-1 ^ min_int). If | |
1221 // they are not equal, one could do a normal division (no correction | |
1222 // needed), which may speed up this implementation for the common case. | |
1223 // (see also JVM spec., p.243 & p.271) | |
1224 __ corrected_idivl(rcx); | |
1225 __ movl(rax, rdx); | |
1226 } | |
1227 | |
1228 void TemplateTable::lmul() { | |
1229 transition(ltos, ltos); | |
1230 __ pop_l(rdx); | |
1231 __ imulq(rax, rdx); | |
1232 } | |
1233 | |
1234 void TemplateTable::ldiv() { | |
1235 transition(ltos, ltos); | |
304 | 1236 __ mov(rcx, rax); |
0 | 1237 __ pop_l(rax); |
1238 // generate explicit div0 check | |
1239 __ testq(rcx, rcx); | |
1240 __ jump_cc(Assembler::zero, | |
1241 ExternalAddress(Interpreter::_throw_ArithmeticException_entry)); | |
1242 // Note: could xor rax and rcx and compare with (-1 ^ min_int). If | |
1243 // they are not equal, one could do a normal division (no correction | |
1244 // needed), which may speed up this implementation for the common case. | |
1245 // (see also JVM spec., p.243 & p.271) | |
1246 __ corrected_idivq(rcx); // kills rbx | |
1247 } | |
1248 | |
1249 void TemplateTable::lrem() { | |
1250 transition(ltos, ltos); | |
304 | 1251 __ mov(rcx, rax); |
0 | 1252 __ pop_l(rax); |
1253 __ testq(rcx, rcx); | |
1254 __ jump_cc(Assembler::zero, | |
1255 ExternalAddress(Interpreter::_throw_ArithmeticException_entry)); | |
1256 // Note: could xor rax and rcx and compare with (-1 ^ min_int). If | |
1257 // they are not equal, one could do a normal division (no correction | |
1258 // needed), which may speed up this implementation for the common case. | |
1259 // (see also JVM spec., p.243 & p.271) | |
1260 __ corrected_idivq(rcx); // kills rbx | |
304 | 1261 __ mov(rax, rdx); |
0 | 1262 } |
1263 | |
1264 void TemplateTable::lshl() { | |
1265 transition(itos, ltos); | |
1266 __ movl(rcx, rax); // get shift count | |
1267 __ pop_l(rax); // get shift value | |
1268 __ shlq(rax); | |
1269 } | |
1270 | |
1271 void TemplateTable::lshr() { | |
1272 transition(itos, ltos); | |
1273 __ movl(rcx, rax); // get shift count | |
1274 __ pop_l(rax); // get shift value | |
1275 __ sarq(rax); | |
1276 } | |
1277 | |
1278 void TemplateTable::lushr() { | |
1279 transition(itos, ltos); | |
1280 __ movl(rcx, rax); // get shift count | |
1281 __ pop_l(rax); // get shift value | |
1282 __ shrq(rax); | |
1283 } | |
1284 | |
1285 void TemplateTable::fop2(Operation op) { | |
1286 transition(ftos, ftos); | |
1287 switch (op) { | |
1288 case add: | |
1289 __ addss(xmm0, at_rsp()); | |
1506 | 1290 __ addptr(rsp, Interpreter::stackElementSize); |
0 | 1291 break; |
1292 case sub: | |
1293 __ movflt(xmm1, xmm0); | |
1294 __ pop_f(xmm0); | |
1295 __ subss(xmm0, xmm1); | |
1296 break; | |
1297 case mul: | |
1298 __ mulss(xmm0, at_rsp()); | |
1506 | 1299 __ addptr(rsp, Interpreter::stackElementSize); |
0 | 1300 break; |
1301 case div: | |
1302 __ movflt(xmm1, xmm0); | |
1303 __ pop_f(xmm0); | |
1304 __ divss(xmm0, xmm1); | |
1305 break; | |
1306 case rem: | |
1307 __ movflt(xmm1, xmm0); | |
1308 __ pop_f(xmm0); | |
1309 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::frem), 2); | |
1310 break; | |
1311 default: | |
1312 ShouldNotReachHere(); | |
1313 break; | |
1314 } | |
1315 } | |
1316 | |
1317 void TemplateTable::dop2(Operation op) { | |
1318 transition(dtos, dtos); | |
1319 switch (op) { | |
1320 case add: | |
1321 __ addsd(xmm0, at_rsp()); | |
1506 | 1322 __ addptr(rsp, 2 * Interpreter::stackElementSize); |
0 | 1323 break; |
1324 case sub: | |
1325 __ movdbl(xmm1, xmm0); | |
1326 __ pop_d(xmm0); | |
1327 __ subsd(xmm0, xmm1); | |
1328 break; | |
1329 case mul: | |
1330 __ mulsd(xmm0, at_rsp()); | |
1506 | 1331 __ addptr(rsp, 2 * Interpreter::stackElementSize); |
0 | 1332 break; |
1333 case div: | |
1334 __ movdbl(xmm1, xmm0); | |
1335 __ pop_d(xmm0); | |
1336 __ divsd(xmm0, xmm1); | |
1337 break; | |
1338 case rem: | |
1339 __ movdbl(xmm1, xmm0); | |
1340 __ pop_d(xmm0); | |
1341 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::drem), 2); | |
1342 break; | |
1343 default: | |
1344 ShouldNotReachHere(); | |
1345 break; | |
1346 } | |
1347 } | |
1348 | |
1349 void TemplateTable::ineg() { | |
1350 transition(itos, itos); | |
1351 __ negl(rax); | |
1352 } | |
1353 | |
1354 void TemplateTable::lneg() { | |
1355 transition(ltos, ltos); | |
1356 __ negq(rax); | |
1357 } | |
1358 | |
1359 // Note: 'double' and 'long long' have 32-bits alignment on x86. | |
1360 static jlong* double_quadword(jlong *adr, jlong lo, jlong hi) { | |
1361 // Use the expression (adr)&(~0xF) to provide 128-bits aligned address | |
1362 // of 128-bits operands for SSE instructions. | |
1363 jlong *operand = (jlong*)(((intptr_t)adr)&((intptr_t)(~0xF))); | |
1364 // Store the value to a 128-bits operand. | |
1365 operand[0] = lo; | |
1366 operand[1] = hi; | |
1367 return operand; | |
1368 } | |
1369 | |
1370 // Buffer for 128-bits masks used by SSE instructions. | |
1371 static jlong float_signflip_pool[2*2]; | |
1372 static jlong double_signflip_pool[2*2]; | |
1373 | |
1374 void TemplateTable::fneg() { | |
1375 transition(ftos, ftos); | |
1376 static jlong *float_signflip = double_quadword(&float_signflip_pool[1], 0x8000000080000000, 0x8000000080000000); | |
1377 __ xorps(xmm0, ExternalAddress((address) float_signflip)); | |
1378 } | |
1379 | |
1380 void TemplateTable::dneg() { | |
1381 transition(dtos, dtos); | |
1382 static jlong *double_signflip = double_quadword(&double_signflip_pool[1], 0x8000000000000000, 0x8000000000000000); | |
1383 __ xorpd(xmm0, ExternalAddress((address) double_signflip)); | |
1384 } | |
1385 | |
1386 void TemplateTable::iinc() { | |
1387 transition(vtos, vtos); | |
1388 __ load_signed_byte(rdx, at_bcp(2)); // get constant | |
1389 locals_index(rbx); | |
1390 __ addl(iaddress(rbx), rdx); | |
1391 } | |
1392 | |
1393 void TemplateTable::wide_iinc() { | |
1394 transition(vtos, vtos); | |
1395 __ movl(rdx, at_bcp(4)); // get constant | |
1396 locals_index_wide(rbx); | |
1397 __ bswapl(rdx); // swap bytes & sign-extend constant | |
1398 __ sarl(rdx, 16); | |
1399 __ addl(iaddress(rbx), rdx); | |
1400 // Note: should probably use only one movl to get both | |
1401 // the index and the constant -> fix this | |
1402 } | |
1403 | |
1404 void TemplateTable::convert() { | |
1405 // Checking | |
1406 #ifdef ASSERT | |
1407 { | |
1408 TosState tos_in = ilgl; | |
1409 TosState tos_out = ilgl; | |
1410 switch (bytecode()) { | |
1411 case Bytecodes::_i2l: // fall through | |
1412 case Bytecodes::_i2f: // fall through | |
1413 case Bytecodes::_i2d: // fall through | |
1414 case Bytecodes::_i2b: // fall through | |
1415 case Bytecodes::_i2c: // fall through | |
1416 case Bytecodes::_i2s: tos_in = itos; break; | |
1417 case Bytecodes::_l2i: // fall through | |
1418 case Bytecodes::_l2f: // fall through | |
1419 case Bytecodes::_l2d: tos_in = ltos; break; | |
1420 case Bytecodes::_f2i: // fall through | |
1421 case Bytecodes::_f2l: // fall through | |
1422 case Bytecodes::_f2d: tos_in = ftos; break; | |
1423 case Bytecodes::_d2i: // fall through | |
1424 case Bytecodes::_d2l: // fall through | |
1425 case Bytecodes::_d2f: tos_in = dtos; break; | |
1426 default : ShouldNotReachHere(); | |
1427 } | |
1428 switch (bytecode()) { | |
1429 case Bytecodes::_l2i: // fall through | |
1430 case Bytecodes::_f2i: // fall through | |
1431 case Bytecodes::_d2i: // fall through | |
1432 case Bytecodes::_i2b: // fall through | |
1433 case Bytecodes::_i2c: // fall through | |
1434 case Bytecodes::_i2s: tos_out = itos; break; | |
1435 case Bytecodes::_i2l: // fall through | |
1436 case Bytecodes::_f2l: // fall through | |
1437 case Bytecodes::_d2l: tos_out = ltos; break; | |
1438 case Bytecodes::_i2f: // fall through | |
1439 case Bytecodes::_l2f: // fall through | |
1440 case Bytecodes::_d2f: tos_out = ftos; break; | |
1441 case Bytecodes::_i2d: // fall through | |
1442 case Bytecodes::_l2d: // fall through | |
1443 case Bytecodes::_f2d: tos_out = dtos; break; | |
1444 default : ShouldNotReachHere(); | |
1445 } | |
1446 transition(tos_in, tos_out); | |
1447 } | |
1448 #endif // ASSERT | |
1449 | |
1450 static const int64_t is_nan = 0x8000000000000000L; | |
1451 | |
1452 // Conversion | |
1453 switch (bytecode()) { | |
1454 case Bytecodes::_i2l: | |
1455 __ movslq(rax, rax); | |
1456 break; | |
1457 case Bytecodes::_i2f: | |
1458 __ cvtsi2ssl(xmm0, rax); | |
1459 break; | |
1460 case Bytecodes::_i2d: | |
1461 __ cvtsi2sdl(xmm0, rax); | |
1462 break; | |
1463 case Bytecodes::_i2b: | |
1464 __ movsbl(rax, rax); | |
1465 break; | |
1466 case Bytecodes::_i2c: | |
1467 __ movzwl(rax, rax); | |
1468 break; | |
1469 case Bytecodes::_i2s: | |
1470 __ movswl(rax, rax); | |
1471 break; | |
1472 case Bytecodes::_l2i: | |
1473 __ movl(rax, rax); | |
1474 break; | |
1475 case Bytecodes::_l2f: | |
1476 __ cvtsi2ssq(xmm0, rax); | |
1477 break; | |
1478 case Bytecodes::_l2d: | |
1479 __ cvtsi2sdq(xmm0, rax); | |
1480 break; | |
1481 case Bytecodes::_f2i: | |
1482 { | |
1483 Label L; | |
1484 __ cvttss2sil(rax, xmm0); | |
1485 __ cmpl(rax, 0x80000000); // NaN or overflow/underflow? | |
1486 __ jcc(Assembler::notEqual, L); | |
1487 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2i), 1); | |
1488 __ bind(L); | |
1489 } | |
1490 break; | |
1491 case Bytecodes::_f2l: | |
1492 { | |
1493 Label L; | |
1494 __ cvttss2siq(rax, xmm0); | |
1495 // NaN or overflow/underflow? | |
1496 __ cmp64(rax, ExternalAddress((address) &is_nan)); | |
1497 __ jcc(Assembler::notEqual, L); | |
1498 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2l), 1); | |
1499 __ bind(L); | |
1500 } | |
1501 break; | |
1502 case Bytecodes::_f2d: | |
1503 __ cvtss2sd(xmm0, xmm0); | |
1504 break; | |
1505 case Bytecodes::_d2i: | |
1506 { | |
1507 Label L; | |
1508 __ cvttsd2sil(rax, xmm0); | |
1509 __ cmpl(rax, 0x80000000); // NaN or overflow/underflow? | |
1510 __ jcc(Assembler::notEqual, L); | |
1511 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::d2i), 1); | |
1512 __ bind(L); | |
1513 } | |
1514 break; | |
1515 case Bytecodes::_d2l: | |
1516 { | |
1517 Label L; | |
1518 __ cvttsd2siq(rax, xmm0); | |
1519 // NaN or overflow/underflow? | |
1520 __ cmp64(rax, ExternalAddress((address) &is_nan)); | |
1521 __ jcc(Assembler::notEqual, L); | |
1522 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::d2l), 1); | |
1523 __ bind(L); | |
1524 } | |
1525 break; | |
1526 case Bytecodes::_d2f: | |
1527 __ cvtsd2ss(xmm0, xmm0); | |
1528 break; | |
1529 default: | |
1530 ShouldNotReachHere(); | |
1531 } | |
1532 } | |
1533 | |
1534 void TemplateTable::lcmp() { | |
1535 transition(ltos, itos); | |
1536 Label done; | |
1537 __ pop_l(rdx); | |
1538 __ cmpq(rdx, rax); | |
1539 __ movl(rax, -1); | |
1540 __ jccb(Assembler::less, done); | |
1541 __ setb(Assembler::notEqual, rax); | |
1542 __ movzbl(rax, rax); | |
1543 __ bind(done); | |
1544 } | |
1545 | |
1546 void TemplateTable::float_cmp(bool is_float, int unordered_result) { | |
1547 Label done; | |
1548 if (is_float) { | |
1549 // XXX get rid of pop here, use ... reg, mem32 | |
1550 __ pop_f(xmm1); | |
1551 __ ucomiss(xmm1, xmm0); | |
1552 } else { | |
1553 // XXX get rid of pop here, use ... reg, mem64 | |
1554 __ pop_d(xmm1); | |
1555 __ ucomisd(xmm1, xmm0); | |
1556 } | |
1557 if (unordered_result < 0) { | |
1558 __ movl(rax, -1); | |
1559 __ jccb(Assembler::parity, done); | |
1560 __ jccb(Assembler::below, done); | |
1561 __ setb(Assembler::notEqual, rdx); | |
1562 __ movzbl(rax, rdx); | |
1563 } else { | |
1564 __ movl(rax, 1); | |
1565 __ jccb(Assembler::parity, done); | |
1566 __ jccb(Assembler::above, done); | |
1567 __ movl(rax, 0); | |
1568 __ jccb(Assembler::equal, done); | |
1569 __ decrementl(rax); | |
1570 } | |
1571 __ bind(done); | |
1572 } | |
1573 | |
1574 void TemplateTable::branch(bool is_jsr, bool is_wide) { | |
1575 __ get_method(rcx); // rcx holds method | |
1576 __ profile_taken_branch(rax, rbx); // rax holds updated MDP, rbx | |
1577 // holds bumped taken count | |
1578 | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1579 const ByteSize be_offset = MethodCounters::backedge_counter_offset() + |
0 | 1580 InvocationCounter::counter_offset(); |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1581 const ByteSize inv_offset = MethodCounters::invocation_counter_offset() + |
0 | 1582 InvocationCounter::counter_offset(); |
1583 | |
1584 // Load up edx with the branch displacement | |
13034
ea79ab313e98
8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
mgerdin
parents:
12875
diff
changeset
|
1585 if (is_wide) { |
ea79ab313e98
8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
mgerdin
parents:
12875
diff
changeset
|
1586 __ movl(rdx, at_bcp(1)); |
ea79ab313e98
8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
mgerdin
parents:
12875
diff
changeset
|
1587 } else { |
ea79ab313e98
8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
mgerdin
parents:
12875
diff
changeset
|
1588 __ load_signed_short(rdx, at_bcp(1)); |
ea79ab313e98
8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
mgerdin
parents:
12875
diff
changeset
|
1589 } |
0 | 1590 __ bswapl(rdx); |
1591 | |
1592 if (!is_wide) { | |
1593 __ sarl(rdx, 16); | |
1594 } | |
304 | 1595 __ movl2ptr(rdx, rdx); |
0 | 1596 |
1597 // Handle all the JSR stuff here, then exit. | |
1598 // It's much shorter and cleaner than intermingling with the non-JSR | |
605 | 1599 // normal-branch stuff occurring below. |
0 | 1600 if (is_jsr) { |
1601 // Pre-load the next target bytecode into rbx | |
1602 __ load_unsigned_byte(rbx, Address(r13, rdx, Address::times_1, 0)); | |
1603 | |
1604 // compute return address as bci in rax | |
304 | 1605 __ lea(rax, at_bcp((is_wide ? 5 : 3) - |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1606 in_bytes(ConstMethod::codes_offset()))); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1607 __ subptr(rax, Address(rcx, Method::const_offset())); |
0 | 1608 // Adjust the bcp in r13 by the displacement in rdx |
304 | 1609 __ addptr(r13, rdx); |
0 | 1610 // jsr returns atos that is not an oop |
1611 __ push_i(rax); | |
1612 __ dispatch_only(vtos); | |
1613 return; | |
1614 } | |
1615 | |
1616 // Normal (non-jsr) branch handling | |
1617 | |
1618 // Adjust the bcp in r13 by the displacement in rdx | |
304 | 1619 __ addptr(r13, rdx); |
0 | 1620 |
1621 assert(UseLoopCounter || !UseOnStackReplacement, | |
1622 "on-stack-replacement requires loop counters"); | |
1623 Label backedge_counter_overflow; | |
1624 Label profile_method; | |
1625 Label dispatch; | |
1626 if (UseLoopCounter) { | |
1627 // increment backedge counter for backward branches | |
1628 // rax: MDO | |
1629 // ebx: MDO bumped taken-count | |
1630 // rcx: method | |
1631 // rdx: target offset | |
1632 // r13: target bcp | |
1633 // r14: locals pointer | |
1634 __ testl(rdx, rdx); // check if forward or backward branch | |
1635 __ jcc(Assembler::positive, dispatch); // count only if backward branch | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1636 |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1637 // check if MethodCounters exists |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1638 Label has_counters; |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1639 __ movptr(rax, Address(rcx, Method::method_counters_offset())); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1640 __ testptr(rax, rax); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1641 __ jcc(Assembler::notZero, has_counters); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1642 __ push(rdx); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1643 __ push(rcx); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1644 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters), |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1645 rcx); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1646 __ pop(rcx); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1647 __ pop(rdx); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1648 __ movptr(rax, Address(rcx, Method::method_counters_offset())); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1649 __ jcc(Assembler::zero, dispatch); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1650 __ bind(has_counters); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1651 |
1783 | 1652 if (TieredCompilation) { |
1653 Label no_mdo; | |
1654 int increment = InvocationCounter::count_increment; | |
1655 int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift; | |
1656 if (ProfileInterpreter) { | |
1657 // Are we profiling? | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1658 __ movptr(rbx, Address(rcx, in_bytes(Method::method_data_offset()))); |
1783 | 1659 __ testptr(rbx, rbx); |
1660 __ jccb(Assembler::zero, no_mdo); | |
1661 // Increment the MDO backedge counter | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1662 const Address mdo_backedge_counter(rbx, in_bytes(MethodData::backedge_counter_offset()) + |
1783 | 1663 in_bytes(InvocationCounter::counter_offset())); |
1664 __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, | |
1665 rax, false, Assembler::zero, &backedge_counter_overflow); | |
1666 __ jmp(dispatch); | |
0 | 1667 } |
1783 | 1668 __ bind(no_mdo); |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1669 // Increment backedge counter in MethodCounters* |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1670 __ movptr(rcx, Address(rcx, Method::method_counters_offset())); |
1783 | 1671 __ increment_mask_and_jump(Address(rcx, be_offset), increment, mask, |
1672 rax, false, Assembler::zero, &backedge_counter_overflow); | |
0 | 1673 } else { |
1783 | 1674 // increment counter |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1675 __ movptr(rcx, Address(rcx, Method::method_counters_offset())); |
1783 | 1676 __ movl(rax, Address(rcx, be_offset)); // load backedge counter |
1677 __ incrementl(rax, InvocationCounter::count_increment); // increment counter | |
1678 __ movl(Address(rcx, be_offset), rax); // store counter | |
1679 | |
1680 __ movl(rax, Address(rcx, inv_offset)); // load invocation counter | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8001
diff
changeset
|
1681 |
1783 | 1682 __ andl(rax, InvocationCounter::count_mask_value); // and the status bits |
1683 __ addl(rax, Address(rcx, be_offset)); // add both counters | |
1684 | |
1685 if (ProfileInterpreter) { | |
1686 // Test to see if we should create a method data oop | |
0 | 1687 __ cmp32(rax, |
1783 | 1688 ExternalAddress((address) &InvocationCounter::InterpreterProfileLimit)); |
1689 __ jcc(Assembler::less, dispatch); | |
1690 | |
1691 // if no method data exists, go to profile method | |
1692 __ test_method_data_pointer(rax, profile_method); | |
1693 | |
1694 if (UseOnStackReplacement) { | |
1695 // check for overflow against ebx which is the MDO taken count | |
1696 __ cmp32(rbx, | |
1697 ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit)); | |
1698 __ jcc(Assembler::below, dispatch); | |
1699 | |
1700 // When ProfileInterpreter is on, the backedge_count comes | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1701 // from the MethodData*, which value does not get reset on |
1783 | 1702 // the call to frequency_counter_overflow(). To avoid |
1703 // excessive calls to the overflow routine while the method is | |
1704 // being compiled, add a second test to make sure the overflow | |
1705 // function is called only once every overflow_frequency. | |
1706 const int overflow_frequency = 1024; | |
1707 __ andl(rbx, overflow_frequency - 1); | |
1708 __ jcc(Assembler::zero, backedge_counter_overflow); | |
1709 | |
1710 } | |
1711 } else { | |
1712 if (UseOnStackReplacement) { | |
1713 // check for overflow against eax, which is the sum of the | |
1714 // counters | |
1715 __ cmp32(rax, | |
1716 ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit)); | |
1717 __ jcc(Assembler::aboveEqual, backedge_counter_overflow); | |
1718 | |
1719 } | |
0 | 1720 } |
1721 } | |
1722 __ bind(dispatch); | |
1723 } | |
1724 | |
1725 // Pre-load the next target bytecode into rbx | |
1726 __ load_unsigned_byte(rbx, Address(r13, 0)); | |
1727 | |
1728 // continue with the bytecode @ target | |
1729 // eax: return bci for jsr's, unused otherwise | |
1730 // ebx: target bytecode | |
1731 // r13: target bcp | |
1732 __ dispatch_only(vtos); | |
1733 | |
1734 if (UseLoopCounter) { | |
1735 if (ProfileInterpreter) { | |
1736 // Out-of-line code to allocate method data oop. | |
1737 __ bind(profile_method); | |
2118
dd031b2226de
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
1976
diff
changeset
|
1738 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method)); |
0 | 1739 __ load_unsigned_byte(rbx, Address(r13, 0)); // restore target bytecode |
2118
dd031b2226de
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
1976
diff
changeset
|
1740 __ set_method_data_pointer_for_bcp(); |
0 | 1741 __ jmp(dispatch); |
1742 } | |
1743 | |
1744 if (UseOnStackReplacement) { | |
1745 // invocation counter overflow | |
1746 __ bind(backedge_counter_overflow); | |
304 | 1747 __ negptr(rdx); |
1748 __ addptr(rdx, r13); // branch bcp | |
0 | 1749 // IcoResult frequency_counter_overflow([JavaThread*], address branch_bcp) |
1750 __ call_VM(noreg, | |
1751 CAST_FROM_FN_PTR(address, | |
1752 InterpreterRuntime::frequency_counter_overflow), | |
1753 rdx); | |
1754 __ load_unsigned_byte(rbx, Address(r13, 0)); // restore target bytecode | |
1755 | |
1756 // rax: osr nmethod (osr ok) or NULL (osr not possible) | |
1757 // ebx: target bytecode | |
1758 // rdx: scratch | |
1759 // r14: locals pointer | |
1760 // r13: bcp | |
304 | 1761 __ testptr(rax, rax); // test result |
0 | 1762 __ jcc(Assembler::zero, dispatch); // no osr if null |
1763 // nmethod may have been invalidated (VM may block upon call_VM return) | |
1764 __ movl(rcx, Address(rax, nmethod::entry_bci_offset())); | |
1765 __ cmpl(rcx, InvalidOSREntryBci); | |
1766 __ jcc(Assembler::equal, dispatch); | |
1767 | |
1768 // We have the address of an on stack replacement routine in eax | |
1769 // We need to prepare to execute the OSR method. First we must | |
1770 // migrate the locals and monitors off of the stack. | |
1771 | |
304 | 1772 __ mov(r13, rax); // save the nmethod |
0 | 1773 |
1774 call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin)); | |
1775 | |
1776 // eax is OSR buffer, move it to expected parameter location | |
304 | 1777 __ mov(j_rarg0, rax); |
0 | 1778 |
1779 // We use j_rarg definitions here so that registers don't conflict as parameter | |
1780 // registers change across platforms as we are in the midst of a calling | |
1781 // sequence to the OSR nmethod and we don't want collision. These are NOT parameters. | |
1782 | |
1783 const Register retaddr = j_rarg2; | |
1784 const Register sender_sp = j_rarg1; | |
1785 | |
1786 // pop the interpreter frame | |
304 | 1787 __ movptr(sender_sp, Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize)); // get sender sp |
0 | 1788 __ leave(); // remove frame anchor |
304 | 1789 __ pop(retaddr); // get return address |
1790 __ mov(rsp, sender_sp); // set sp to sender sp | |
0 | 1791 // Ensure compiled code always sees stack at proper alignment |
304 | 1792 __ andptr(rsp, -(StackAlignmentInBytes)); |
0 | 1793 |
1794 // unlike x86 we need no specialized return from compiled code | |
1795 // to the interpreter or the call stub. | |
1796 | |
1797 // push the return address | |
304 | 1798 __ push(retaddr); |
0 | 1799 |
1800 // and begin the OSR nmethod | |
1801 __ jmp(Address(r13, nmethod::osr_entry_point_offset())); | |
1802 } | |
1803 } | |
1804 } | |
1805 | |
1806 | |
1807 void TemplateTable::if_0cmp(Condition cc) { | |
1808 transition(itos, vtos); | |
1809 // assume branch is more often taken than not (loops use backward branches) | |
1810 Label not_taken; | |
1811 __ testl(rax, rax); | |
1812 __ jcc(j_not(cc), not_taken); | |
1813 branch(false, false); | |
1814 __ bind(not_taken); | |
1815 __ profile_not_taken_branch(rax); | |
1816 } | |
1817 | |
1818 void TemplateTable::if_icmp(Condition cc) { | |
1819 transition(itos, vtos); | |
1820 // assume branch is more often taken than not (loops use backward branches) | |
1821 Label not_taken; | |
1822 __ pop_i(rdx); | |
1823 __ cmpl(rdx, rax); | |
1824 __ jcc(j_not(cc), not_taken); | |
1825 branch(false, false); | |
1826 __ bind(not_taken); | |
1827 __ profile_not_taken_branch(rax); | |
1828 } | |
1829 | |
1830 void TemplateTable::if_nullcmp(Condition cc) { | |
1831 transition(atos, vtos); | |
1832 // assume branch is more often taken than not (loops use backward branches) | |
1833 Label not_taken; | |
304 | 1834 __ testptr(rax, rax); |
0 | 1835 __ jcc(j_not(cc), not_taken); |
1836 branch(false, false); | |
1837 __ bind(not_taken); | |
1838 __ profile_not_taken_branch(rax); | |
1839 } | |
1840 | |
1841 void TemplateTable::if_acmp(Condition cc) { | |
1842 transition(atos, vtos); | |
1843 // assume branch is more often taken than not (loops use backward branches) | |
1844 Label not_taken; | |
1845 __ pop_ptr(rdx); | |
304 | 1846 __ cmpptr(rdx, rax); |
0 | 1847 __ jcc(j_not(cc), not_taken); |
1848 branch(false, false); | |
1849 __ bind(not_taken); | |
1850 __ profile_not_taken_branch(rax); | |
1851 } | |
1852 | |
1853 void TemplateTable::ret() { | |
1854 transition(vtos, vtos); | |
1855 locals_index(rbx); | |
304 | 1856 __ movslq(rbx, iaddress(rbx)); // get return bci, compute return bcp |
0 | 1857 __ profile_ret(rbx, rcx); |
1858 __ get_method(rax); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1859 __ movptr(r13, Address(rax, Method::const_offset())); |
304 | 1860 __ lea(r13, Address(r13, rbx, Address::times_1, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1861 ConstMethod::codes_offset())); |
0 | 1862 __ dispatch_next(vtos); |
1863 } | |
1864 | |
1865 void TemplateTable::wide_ret() { | |
1866 transition(vtos, vtos); | |
1867 locals_index_wide(rbx); | |
304 | 1868 __ movptr(rbx, aaddress(rbx)); // get return bci, compute return bcp |
0 | 1869 __ profile_ret(rbx, rcx); |
1870 __ get_method(rax); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1871 __ movptr(r13, Address(rax, Method::const_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1872 __ lea(r13, Address(r13, rbx, Address::times_1, ConstMethod::codes_offset())); |
0 | 1873 __ dispatch_next(vtos); |
1874 } | |
1875 | |
1876 void TemplateTable::tableswitch() { | |
1877 Label default_case, continue_execution; | |
1878 transition(itos, vtos); | |
1879 // align r13 | |
304 | 1880 __ lea(rbx, at_bcp(BytesPerInt)); |
1881 __ andptr(rbx, -BytesPerInt); | |
0 | 1882 // load lo & hi |
1883 __ movl(rcx, Address(rbx, BytesPerInt)); | |
1884 __ movl(rdx, Address(rbx, 2 * BytesPerInt)); | |
1885 __ bswapl(rcx); | |
1886 __ bswapl(rdx); | |
1887 // check against lo & hi | |
1888 __ cmpl(rax, rcx); | |
1889 __ jcc(Assembler::less, default_case); | |
1890 __ cmpl(rax, rdx); | |
1891 __ jcc(Assembler::greater, default_case); | |
1892 // lookup dispatch offset | |
1893 __ subl(rax, rcx); | |
1894 __ movl(rdx, Address(rbx, rax, Address::times_4, 3 * BytesPerInt)); | |
1895 __ profile_switch_case(rax, rbx, rcx); | |
1896 // continue execution | |
1897 __ bind(continue_execution); | |
1898 __ bswapl(rdx); | |
304 | 1899 __ movl2ptr(rdx, rdx); |
0 | 1900 __ load_unsigned_byte(rbx, Address(r13, rdx, Address::times_1)); |
304 | 1901 __ addptr(r13, rdx); |
0 | 1902 __ dispatch_only(vtos); |
1903 // handle default | |
1904 __ bind(default_case); | |
1905 __ profile_switch_default(rax); | |
1906 __ movl(rdx, Address(rbx, 0)); | |
1907 __ jmp(continue_execution); | |
1908 } | |
1909 | |
1910 void TemplateTable::lookupswitch() { | |
1911 transition(itos, itos); | |
1912 __ stop("lookupswitch bytecode should have been rewritten"); | |
1913 } | |
1914 | |
1915 void TemplateTable::fast_linearswitch() { | |
1916 transition(itos, vtos); | |
1917 Label loop_entry, loop, found, continue_execution; | |
1918 // bswap rax so we can avoid bswapping the table entries | |
1919 __ bswapl(rax); | |
1920 // align r13 | |
304 | 1921 __ lea(rbx, at_bcp(BytesPerInt)); // btw: should be able to get rid of |
1922 // this instruction (change offsets | |
1923 // below) | |
1924 __ andptr(rbx, -BytesPerInt); | |
0 | 1925 // set counter |
1926 __ movl(rcx, Address(rbx, BytesPerInt)); | |
1927 __ bswapl(rcx); | |
1928 __ jmpb(loop_entry); | |
1929 // table search | |
1930 __ bind(loop); | |
1931 __ cmpl(rax, Address(rbx, rcx, Address::times_8, 2 * BytesPerInt)); | |
1932 __ jcc(Assembler::equal, found); | |
1933 __ bind(loop_entry); | |
1934 __ decrementl(rcx); | |
1935 __ jcc(Assembler::greaterEqual, loop); | |
1936 // default case | |
1937 __ profile_switch_default(rax); | |
1938 __ movl(rdx, Address(rbx, 0)); | |
1939 __ jmp(continue_execution); | |
1940 // entry found -> get offset | |
1941 __ bind(found); | |
1942 __ movl(rdx, Address(rbx, rcx, Address::times_8, 3 * BytesPerInt)); | |
1943 __ profile_switch_case(rcx, rax, rbx); | |
1944 // continue execution | |
1945 __ bind(continue_execution); | |
1946 __ bswapl(rdx); | |
304 | 1947 __ movl2ptr(rdx, rdx); |
0 | 1948 __ load_unsigned_byte(rbx, Address(r13, rdx, Address::times_1)); |
304 | 1949 __ addptr(r13, rdx); |
0 | 1950 __ dispatch_only(vtos); |
1951 } | |
1952 | |
1953 void TemplateTable::fast_binaryswitch() { | |
1954 transition(itos, vtos); | |
1955 // Implementation using the following core algorithm: | |
1956 // | |
1957 // int binary_search(int key, LookupswitchPair* array, int n) { | |
1958 // // Binary search according to "Methodik des Programmierens" by | |
1959 // // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985. | |
1960 // int i = 0; | |
1961 // int j = n; | |
1962 // while (i+1 < j) { | |
1963 // // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q) | |
1964 // // with Q: for all i: 0 <= i < n: key < a[i] | |
1965 // // where a stands for the array and assuming that the (inexisting) | |
1966 // // element a[n] is infinitely big. | |
1967 // int h = (i + j) >> 1; | |
1968 // // i < h < j | |
1969 // if (key < array[h].fast_match()) { | |
1970 // j = h; | |
1971 // } else { | |
1972 // i = h; | |
1973 // } | |
1974 // } | |
1975 // // R: a[i] <= key < a[i+1] or Q | |
1976 // // (i.e., if key is within array, i is the correct index) | |
1977 // return i; | |
1978 // } | |
1979 | |
1980 // Register allocation | |
1981 const Register key = rax; // already set (tosca) | |
1982 const Register array = rbx; | |
1983 const Register i = rcx; | |
1984 const Register j = rdx; | |
1985 const Register h = rdi; | |
1986 const Register temp = rsi; | |
1987 | |
1988 // Find array start | |
304 | 1989 __ lea(array, at_bcp(3 * BytesPerInt)); // btw: should be able to |
1990 // get rid of this | |
1991 // instruction (change | |
1992 // offsets below) | |
1993 __ andptr(array, -BytesPerInt); | |
0 | 1994 |
1995 // Initialize i & j | |
1996 __ xorl(i, i); // i = 0; | |
1997 __ movl(j, Address(array, -BytesPerInt)); // j = length(array); | |
1998 | |
1999 // Convert j into native byteordering | |
2000 __ bswapl(j); | |
2001 | |
2002 // And start | |
2003 Label entry; | |
2004 __ jmp(entry); | |
2005 | |
2006 // binary search loop | |
2007 { | |
2008 Label loop; | |
2009 __ bind(loop); | |
2010 // int h = (i + j) >> 1; | |
2011 __ leal(h, Address(i, j, Address::times_1)); // h = i + j; | |
2012 __ sarl(h, 1); // h = (i + j) >> 1; | |
2013 // if (key < array[h].fast_match()) { | |
2014 // j = h; | |
2015 // } else { | |
2016 // i = h; | |
2017 // } | |
2018 // Convert array[h].match to native byte-ordering before compare | |
2019 __ movl(temp, Address(array, h, Address::times_8)); | |
2020 __ bswapl(temp); | |
2021 __ cmpl(key, temp); | |
2022 // j = h if (key < array[h].fast_match()) | |
2023 __ cmovl(Assembler::less, j, h); | |
2024 // i = h if (key >= array[h].fast_match()) | |
2025 __ cmovl(Assembler::greaterEqual, i, h); | |
2026 // while (i+1 < j) | |
2027 __ bind(entry); | |
2028 __ leal(h, Address(i, 1)); // i+1 | |
2029 __ cmpl(h, j); // i+1 < j | |
2030 __ jcc(Assembler::less, loop); | |
2031 } | |
2032 | |
2033 // end of binary search, result index is i (must check again!) | |
2034 Label default_case; | |
2035 // Convert array[i].match to native byte-ordering before compare | |
2036 __ movl(temp, Address(array, i, Address::times_8)); | |
2037 __ bswapl(temp); | |
2038 __ cmpl(key, temp); | |
2039 __ jcc(Assembler::notEqual, default_case); | |
2040 | |
2041 // entry found -> j = offset | |
2042 __ movl(j , Address(array, i, Address::times_8, BytesPerInt)); | |
2043 __ profile_switch_case(i, key, array); | |
2044 __ bswapl(j); | |
304 | 2045 __ movl2ptr(j, j); |
0 | 2046 __ load_unsigned_byte(rbx, Address(r13, j, Address::times_1)); |
304 | 2047 __ addptr(r13, j); |
0 | 2048 __ dispatch_only(vtos); |
2049 | |
2050 // default case -> j = default offset | |
2051 __ bind(default_case); | |
2052 __ profile_switch_default(i); | |
2053 __ movl(j, Address(array, -2 * BytesPerInt)); | |
2054 __ bswapl(j); | |
304 | 2055 __ movl2ptr(j, j); |
0 | 2056 __ load_unsigned_byte(rbx, Address(r13, j, Address::times_1)); |
304 | 2057 __ addptr(r13, j); |
0 | 2058 __ dispatch_only(vtos); |
2059 } | |
2060 | |
2061 | |
2062 void TemplateTable::_return(TosState state) { | |
2063 transition(state, state); | |
2064 assert(_desc->calls_vm(), | |
2065 "inconsistent calls_vm information"); // call in remove_activation | |
2066 | |
2067 if (_desc->bytecode() == Bytecodes::_return_register_finalizer) { | |
2068 assert(state == vtos, "only valid state"); | |
304 | 2069 __ movptr(c_rarg1, aaddress(0)); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2070 __ load_klass(rdi, c_rarg1); |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
3852
diff
changeset
|
2071 __ movl(rdi, Address(rdi, Klass::access_flags_offset())); |
0 | 2072 __ testl(rdi, JVM_ACC_HAS_FINALIZER); |
2073 Label skip_register_finalizer; | |
2074 __ jcc(Assembler::zero, skip_register_finalizer); | |
2075 | |
2076 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), c_rarg1); | |
2077 | |
2078 __ bind(skip_register_finalizer); | |
2079 } | |
2080 | |
23614 | 2081 // Narrow result if state is itos but result type is smaller. |
2082 // Need to narrow in the return bytecode rather than in generate_return_entry | |
2083 // since compiled code callers expect the result to already be narrowed. | |
2084 if (state == itos) { | |
2085 __ narrow(rax); | |
2086 } | |
0 | 2087 __ remove_activation(state, r13); |
23614 | 2088 |
0 | 2089 __ jmp(r13); |
2090 } | |
2091 | |
2092 // ---------------------------------------------------------------------------- | |
2093 // Volatile variables demand their effects be made known to all CPU's | |
2094 // in order. Store buffers on most chips allow reads & writes to | |
2095 // reorder; the JMM's ReadAfterWrite.java test fails in -Xint mode | |
2096 // without some kind of memory barrier (i.e., it's not sufficient that | |
2097 // the interpreter does not reorder volatile references, the hardware | |
2098 // also must not reorder them). | |
2099 // | |
2100 // According to the new Java Memory Model (JMM): | |
2101 // (1) All volatiles are serialized wrt to each other. ALSO reads & | |
2102 // writes act as aquire & release, so: | |
2103 // (2) A read cannot let unrelated NON-volatile memory refs that | |
2104 // happen after the read float up to before the read. It's OK for | |
2105 // non-volatile memory refs that happen before the volatile read to | |
2106 // float down below it. | |
2107 // (3) Similar a volatile write cannot let unrelated NON-volatile | |
2108 // memory refs that happen BEFORE the write float down to after the | |
2109 // write. It's OK for non-volatile memory refs that happen after the | |
2110 // volatile write to float up before it. | |
2111 // | |
2112 // We only put in barriers around volatile refs (they are expensive), | |
2113 // not _between_ memory refs (that would require us to track the | |
2114 // flavor of the previous memory refs). Requirements (2) and (3) | |
2115 // require some barriers before volatile stores and after volatile | |
2116 // loads. These nearly cover requirement (1) but miss the | |
2117 // volatile-store-volatile-load case. This final case is placed after | |
2118 // volatile-stores although it could just as well go before | |
2119 // volatile-loads. | |
2120 void TemplateTable::volatile_barrier(Assembler::Membar_mask_bits | |
2121 order_constraint) { | |
2122 // Helper function to insert a is-volatile test and memory barrier | |
2123 if (os::is_MP()) { // Not needed on single CPU | |
2124 __ membar(order_constraint); | |
2125 } | |
2126 } | |
2127 | |
1565 | 2128 void TemplateTable::resolve_cache_and_index(int byte_no, |
2129 Register Rcache, | |
2130 Register index, | |
2131 size_t index_size) { | |
0 | 2132 const Register temp = rbx; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2133 assert_different_registers(Rcache, index, temp); |
1565 | 2134 |
0 | 2135 Label resolved; |
1565 | 2136 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2137 __ get_cache_and_index_and_bytecode_at_bcp(Rcache, index, temp, byte_no, 1, index_size); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2138 __ cmpl(temp, (int) bytecode()); // have we resolved this bytecode? |
1108 | 2139 __ jcc(Assembler::equal, resolved); |
0 | 2140 |
2141 // resolve first time through | |
2142 address entry; | |
2143 switch (bytecode()) { | |
2144 case Bytecodes::_getstatic: | |
2145 case Bytecodes::_putstatic: | |
2146 case Bytecodes::_getfield: | |
2147 case Bytecodes::_putfield: | |
2148 entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_get_put); | |
2149 break; | |
2150 case Bytecodes::_invokevirtual: | |
2151 case Bytecodes::_invokespecial: | |
2152 case Bytecodes::_invokestatic: | |
2153 case Bytecodes::_invokeinterface: | |
2154 entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invoke); | |
2155 break; | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2156 case Bytecodes::_invokehandle: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2157 entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokehandle); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2158 break; |
1108 | 2159 case Bytecodes::_invokedynamic: |
2160 entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokedynamic); | |
2161 break; | |
0 | 2162 default: |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2163 fatal(err_msg("unexpected bytecode: %s", Bytecodes::name(bytecode()))); |
0 | 2164 break; |
2165 } | |
2166 __ movl(temp, (int) bytecode()); | |
2167 __ call_VM(noreg, entry, temp); | |
2168 | |
2169 // Update registers with resolved info | |
1565 | 2170 __ get_cache_and_index_at_bcp(Rcache, index, 1, index_size); |
0 | 2171 __ bind(resolved); |
2172 } | |
2173 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2174 // The cache and index registers must be set before call |
0 | 2175 void TemplateTable::load_field_cp_cache_entry(Register obj, |
2176 Register cache, | |
2177 Register index, | |
2178 Register off, | |
2179 Register flags, | |
2180 bool is_static = false) { | |
2181 assert_different_registers(cache, index, flags, off); | |
2182 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2183 ByteSize cp_base_offset = ConstantPoolCache::base_offset(); |
0 | 2184 // Field offset |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2185 __ movptr(off, Address(cache, index, Address::times_ptr, |
304 | 2186 in_bytes(cp_base_offset + |
2187 ConstantPoolCacheEntry::f2_offset()))); | |
0 | 2188 // Flags |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2189 __ movl(flags, Address(cache, index, Address::times_ptr, |
0 | 2190 in_bytes(cp_base_offset + |
2191 ConstantPoolCacheEntry::flags_offset()))); | |
2192 | |
2193 // klass overwrite register | |
2194 if (is_static) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2195 __ movptr(obj, Address(cache, index, Address::times_ptr, |
304 | 2196 in_bytes(cp_base_offset + |
2197 ConstantPoolCacheEntry::f1_offset()))); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2198 const int mirror_offset = in_bytes(Klass::java_mirror_offset()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2199 __ movptr(obj, Address(obj, mirror_offset)); |
0 | 2200 } |
2201 } | |
2202 | |
2203 void TemplateTable::load_invoke_cp_cache_entry(int byte_no, | |
2204 Register method, | |
2205 Register itable_index, | |
2206 Register flags, | |
2207 bool is_invokevirtual, | |
1565 | 2208 bool is_invokevfinal, /*unused*/ |
2209 bool is_invokedynamic) { | |
0 | 2210 // setup registers |
2211 const Register cache = rcx; | |
2212 const Register index = rdx; | |
2213 assert_different_registers(method, flags); | |
2214 assert_different_registers(method, cache, index); | |
2215 assert_different_registers(itable_index, flags); | |
2216 assert_different_registers(itable_index, cache, index); | |
2217 // determine constant pool cache field offsets | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2218 assert(is_invokevirtual == (byte_no == f2_byte), "is_invokevirtual flag redundant"); |
0 | 2219 const int method_offset = in_bytes( |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2220 ConstantPoolCache::base_offset() + |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2221 ((byte_no == f2_byte) |
0 | 2222 ? ConstantPoolCacheEntry::f2_offset() |
2223 : ConstantPoolCacheEntry::f1_offset())); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2224 const int flags_offset = in_bytes(ConstantPoolCache::base_offset() + |
0 | 2225 ConstantPoolCacheEntry::flags_offset()); |
2226 // access constant pool cache fields | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2227 const int index_offset = in_bytes(ConstantPoolCache::base_offset() + |
0 | 2228 ConstantPoolCacheEntry::f2_offset()); |
2229 | |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
2230 size_t index_size = (is_invokedynamic ? sizeof(u4) : sizeof(u2)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2231 resolve_cache_and_index(byte_no, cache, index, index_size); |
1565 | 2232 __ movptr(method, Address(cache, index, Address::times_ptr, method_offset)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2233 |
0 | 2234 if (itable_index != noreg) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2235 // pick up itable or appendix index from f2 also: |
1565 | 2236 __ movptr(itable_index, Address(cache, index, Address::times_ptr, index_offset)); |
0 | 2237 } |
1565 | 2238 __ movl(flags, Address(cache, index, Address::times_ptr, flags_offset)); |
0 | 2239 } |
2240 | |
2241 // Correct values of the cache and index registers are preserved. | |
2242 void TemplateTable::jvmti_post_field_access(Register cache, Register index, | |
2243 bool is_static, bool has_tos) { | |
2244 // do the JVMTI work here to avoid disturbing the register state below | |
2245 // We use c_rarg registers here because we want to use the register used in | |
2246 // the call to the VM | |
2247 if (JvmtiExport::can_post_field_access()) { | |
2248 // Check to see if a field access watch has been set before we | |
2249 // take the time to call into the VM. | |
2250 Label L1; | |
2251 assert_different_registers(cache, index, rax); | |
2252 __ mov32(rax, ExternalAddress((address) JvmtiExport::get_field_access_count_addr())); | |
2253 __ testl(rax, rax); | |
2254 __ jcc(Assembler::zero, L1); | |
2255 | |
2256 __ get_cache_and_index_at_bcp(c_rarg2, c_rarg3, 1); | |
2257 | |
2258 // cache entry pointer | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2259 __ addptr(c_rarg2, in_bytes(ConstantPoolCache::base_offset())); |
0 | 2260 __ shll(c_rarg3, LogBytesPerWord); |
304 | 2261 __ addptr(c_rarg2, c_rarg3); |
0 | 2262 if (is_static) { |
2263 __ xorl(c_rarg1, c_rarg1); // NULL object reference | |
2264 } else { | |
304 | 2265 __ movptr(c_rarg1, at_tos()); // get object pointer without popping it |
0 | 2266 __ verify_oop(c_rarg1); |
2267 } | |
2268 // c_rarg1: object pointer or NULL | |
2269 // c_rarg2: cache entry pointer | |
2270 // c_rarg3: jvalue object on the stack | |
2271 __ call_VM(noreg, CAST_FROM_FN_PTR(address, | |
2272 InterpreterRuntime::post_field_access), | |
2273 c_rarg1, c_rarg2, c_rarg3); | |
2274 __ get_cache_and_index_at_bcp(cache, index, 1); | |
2275 __ bind(L1); | |
2276 } | |
2277 } | |
2278 | |
2279 void TemplateTable::pop_and_check_object(Register r) { | |
2280 __ pop_ptr(r); | |
2281 __ null_check(r); // for field access must check obj. | |
2282 __ verify_oop(r); | |
2283 } | |
2284 | |
2285 void TemplateTable::getfield_or_static(int byte_no, bool is_static) { | |
2286 transition(vtos, vtos); | |
2287 | |
2288 const Register cache = rcx; | |
2289 const Register index = rdx; | |
2290 const Register obj = c_rarg3; | |
2291 const Register off = rbx; | |
2292 const Register flags = rax; | |
2293 const Register bc = c_rarg3; // uses same reg as obj, so don't mix them | |
2294 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2295 resolve_cache_and_index(byte_no, cache, index, sizeof(u2)); |
0 | 2296 jvmti_post_field_access(cache, index, is_static, false); |
2297 load_field_cp_cache_entry(obj, cache, index, off, flags, is_static); | |
2298 | |
2299 if (!is_static) { | |
2300 // obj is on the stack | |
2301 pop_and_check_object(obj); | |
2302 } | |
2303 | |
2304 const Address field(obj, off, Address::times_1); | |
2305 | |
23614 | 2306 Label Done, notByte, notBool, notInt, notShort, notChar, |
0 | 2307 notLong, notFloat, notObj, notDouble; |
2308 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2309 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2310 // Make sure we don't need to mask edx after the above shift |
0 | 2311 assert(btos == 0, "change code, btos != 0"); |
2312 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2313 __ andl(flags, ConstantPoolCacheEntry::tos_state_mask); |
0 | 2314 __ jcc(Assembler::notZero, notByte); |
2315 // btos | |
2316 __ load_signed_byte(rax, field); | |
2317 __ push(btos); | |
2318 // Rewrite bytecode to be faster | |
2319 if (!is_static) { | |
2320 patch_bytecode(Bytecodes::_fast_bgetfield, bc, rbx); | |
2321 } | |
2322 __ jmp(Done); | |
2323 | |
2324 __ bind(notByte); | |
23614 | 2325 __ cmpl(flags, ztos); |
2326 __ jcc(Assembler::notEqual, notBool); | |
2327 | |
2328 // ztos (same code as btos) | |
2329 __ load_signed_byte(rax, field); | |
2330 __ push(ztos); | |
2331 // Rewrite bytecode to be faster | |
2332 if (!is_static) { | |
2333 // use btos rewriting, no truncating to t/f bit is needed for getfield. | |
2334 patch_bytecode(Bytecodes::_fast_bgetfield, bc, rbx); | |
2335 } | |
2336 __ jmp(Done); | |
2337 | |
2338 __ bind(notBool); | |
0 | 2339 __ cmpl(flags, atos); |
2340 __ jcc(Assembler::notEqual, notObj); | |
2341 // atos | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2342 __ load_heap_oop(rax, field); |
0 | 2343 __ push(atos); |
2344 if (!is_static) { | |
2345 patch_bytecode(Bytecodes::_fast_agetfield, bc, rbx); | |
2346 } | |
2347 __ jmp(Done); | |
2348 | |
2349 __ bind(notObj); | |
2350 __ cmpl(flags, itos); | |
2351 __ jcc(Assembler::notEqual, notInt); | |
2352 // itos | |
2353 __ movl(rax, field); | |
2354 __ push(itos); | |
2355 // Rewrite bytecode to be faster | |
2356 if (!is_static) { | |
2357 patch_bytecode(Bytecodes::_fast_igetfield, bc, rbx); | |
2358 } | |
2359 __ jmp(Done); | |
2360 | |
2361 __ bind(notInt); | |
2362 __ cmpl(flags, ctos); | |
2363 __ jcc(Assembler::notEqual, notChar); | |
2364 // ctos | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
2365 __ load_unsigned_short(rax, field); |
0 | 2366 __ push(ctos); |
2367 // Rewrite bytecode to be faster | |
2368 if (!is_static) { | |
2369 patch_bytecode(Bytecodes::_fast_cgetfield, bc, rbx); | |
2370 } | |
2371 __ jmp(Done); | |
2372 | |
2373 __ bind(notChar); | |
2374 __ cmpl(flags, stos); | |
2375 __ jcc(Assembler::notEqual, notShort); | |
2376 // stos | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
2377 __ load_signed_short(rax, field); |
0 | 2378 __ push(stos); |
2379 // Rewrite bytecode to be faster | |
2380 if (!is_static) { | |
2381 patch_bytecode(Bytecodes::_fast_sgetfield, bc, rbx); | |
2382 } | |
2383 __ jmp(Done); | |
2384 | |
2385 __ bind(notShort); | |
2386 __ cmpl(flags, ltos); | |
2387 __ jcc(Assembler::notEqual, notLong); | |
2388 // ltos | |
2389 __ movq(rax, field); | |
2390 __ push(ltos); | |
2391 // Rewrite bytecode to be faster | |
2392 if (!is_static) { | |
2393 patch_bytecode(Bytecodes::_fast_lgetfield, bc, rbx); | |
2394 } | |
2395 __ jmp(Done); | |
2396 | |
2397 __ bind(notLong); | |
2398 __ cmpl(flags, ftos); | |
2399 __ jcc(Assembler::notEqual, notFloat); | |
2400 // ftos | |
2401 __ movflt(xmm0, field); | |
2402 __ push(ftos); | |
2403 // Rewrite bytecode to be faster | |
2404 if (!is_static) { | |
2405 patch_bytecode(Bytecodes::_fast_fgetfield, bc, rbx); | |
2406 } | |
2407 __ jmp(Done); | |
2408 | |
2409 __ bind(notFloat); | |
2410 #ifdef ASSERT | |
2411 __ cmpl(flags, dtos); | |
2412 __ jcc(Assembler::notEqual, notDouble); | |
2413 #endif | |
2414 // dtos | |
2415 __ movdbl(xmm0, field); | |
2416 __ push(dtos); | |
2417 // Rewrite bytecode to be faster | |
2418 if (!is_static) { | |
2419 patch_bytecode(Bytecodes::_fast_dgetfield, bc, rbx); | |
2420 } | |
2421 #ifdef ASSERT | |
2422 __ jmp(Done); | |
2423 | |
2424 __ bind(notDouble); | |
2425 __ stop("Bad state"); | |
2426 #endif | |
2427 | |
2428 __ bind(Done); | |
2429 // [jk] not needed currently | |
2430 // volatile_barrier(Assembler::Membar_mask_bits(Assembler::LoadLoad | | |
2431 // Assembler::LoadStore)); | |
2432 } | |
2433 | |
2434 | |
2435 void TemplateTable::getfield(int byte_no) { | |
2436 getfield_or_static(byte_no, false); | |
2437 } | |
2438 | |
2439 void TemplateTable::getstatic(int byte_no) { | |
2440 getfield_or_static(byte_no, true); | |
2441 } | |
2442 | |
2443 // The registers cache and index expected to be set before call. | |
2444 // The function may destroy various registers, just not the cache and index registers. | |
2445 void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is_static) { | |
2446 transition(vtos, vtos); | |
2447 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2448 ByteSize cp_base_offset = ConstantPoolCache::base_offset(); |
0 | 2449 |
2450 if (JvmtiExport::can_post_field_modification()) { | |
2451 // Check to see if a field modification watch has been set before | |
2452 // we take the time to call into the VM. | |
2453 Label L1; | |
2454 assert_different_registers(cache, index, rax); | |
2455 __ mov32(rax, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr())); | |
2456 __ testl(rax, rax); | |
2457 __ jcc(Assembler::zero, L1); | |
2458 | |
2459 __ get_cache_and_index_at_bcp(c_rarg2, rscratch1, 1); | |
2460 | |
2461 if (is_static) { | |
2462 // Life is simple. Null out the object pointer. | |
2463 __ xorl(c_rarg1, c_rarg1); | |
2464 } else { | |
2465 // Life is harder. The stack holds the value on top, followed by | |
2466 // the object. We don't know the size of the value, though; it | |
2467 // could be one or two words depending on its type. As a result, | |
2468 // we must find the type to determine where the object is. | |
2469 __ movl(c_rarg3, Address(c_rarg2, rscratch1, | |
2470 Address::times_8, | |
2471 in_bytes(cp_base_offset + | |
2472 ConstantPoolCacheEntry::flags_offset()))); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2473 __ shrl(c_rarg3, ConstantPoolCacheEntry::tos_state_shift); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2474 // Make sure we don't need to mask rcx after the above shift |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2475 ConstantPoolCacheEntry::verify_tos_state_shift(); |
304 | 2476 __ movptr(c_rarg1, at_tos_p1()); // initially assume a one word jvalue |
0 | 2477 __ cmpl(c_rarg3, ltos); |
304 | 2478 __ cmovptr(Assembler::equal, |
2479 c_rarg1, at_tos_p2()); // ltos (two word jvalue) | |
0 | 2480 __ cmpl(c_rarg3, dtos); |
304 | 2481 __ cmovptr(Assembler::equal, |
2482 c_rarg1, at_tos_p2()); // dtos (two word jvalue) | |
0 | 2483 } |
2484 // cache entry pointer | |
304 | 2485 __ addptr(c_rarg2, in_bytes(cp_base_offset)); |
0 | 2486 __ shll(rscratch1, LogBytesPerWord); |
304 | 2487 __ addptr(c_rarg2, rscratch1); |
0 | 2488 // object (tos) |
304 | 2489 __ mov(c_rarg3, rsp); |
0 | 2490 // c_rarg1: object pointer set up above (NULL if static) |
2491 // c_rarg2: cache entry pointer | |
2492 // c_rarg3: jvalue object on the stack | |
2493 __ call_VM(noreg, | |
2494 CAST_FROM_FN_PTR(address, | |
2495 InterpreterRuntime::post_field_modification), | |
2496 c_rarg1, c_rarg2, c_rarg3); | |
2497 __ get_cache_and_index_at_bcp(cache, index, 1); | |
2498 __ bind(L1); | |
2499 } | |
2500 } | |
2501 | |
2502 void TemplateTable::putfield_or_static(int byte_no, bool is_static) { | |
2503 transition(vtos, vtos); | |
2504 | |
2505 const Register cache = rcx; | |
2506 const Register index = rdx; | |
2507 const Register obj = rcx; | |
2508 const Register off = rbx; | |
2509 const Register flags = rax; | |
2510 const Register bc = c_rarg3; | |
2511 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2512 resolve_cache_and_index(byte_no, cache, index, sizeof(u2)); |
0 | 2513 jvmti_post_field_mod(cache, index, is_static); |
2514 load_field_cp_cache_entry(obj, cache, index, off, flags, is_static); | |
2515 | |
2516 // [jk] not needed currently | |
2517 // volatile_barrier(Assembler::Membar_mask_bits(Assembler::LoadStore | | |
2518 // Assembler::StoreStore)); | |
2519 | |
2520 Label notVolatile, Done; | |
2521 __ movl(rdx, flags); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2522 __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift); |
0 | 2523 __ andl(rdx, 0x1); |
2524 | |
2525 // field address | |
2526 const Address field(obj, off, Address::times_1); | |
2527 | |
23614 | 2528 Label notByte, notBool, notInt, notShort, notChar, |
0 | 2529 notLong, notFloat, notObj, notDouble; |
2530 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2531 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); |
0 | 2532 |
2533 assert(btos == 0, "change code, btos != 0"); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2534 __ andl(flags, ConstantPoolCacheEntry::tos_state_mask); |
0 | 2535 __ jcc(Assembler::notZero, notByte); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2536 |
0 | 2537 // btos |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2538 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2539 __ pop(btos); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2540 if (!is_static) pop_and_check_object(obj); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2541 __ movb(field, rax); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2542 if (!is_static) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2543 patch_bytecode(Bytecodes::_fast_bputfield, bc, rbx, true, byte_no); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2544 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2545 __ jmp(Done); |
0 | 2546 } |
2547 | |
2548 __ bind(notByte); | |
23614 | 2549 __ cmpl(flags, ztos); |
2550 __ jcc(Assembler::notEqual, notBool); | |
2551 | |
2552 // ztos | |
2553 { | |
2554 __ pop(ztos); | |
2555 if (!is_static) pop_and_check_object(obj); | |
2556 __ andl(rax, 0x1); | |
2557 __ movb(field, rax); | |
2558 if (!is_static) { | |
2559 patch_bytecode(Bytecodes::_fast_zputfield, bc, rbx, true, byte_no); | |
2560 } | |
2561 __ jmp(Done); | |
2562 } | |
2563 | |
2564 __ bind(notBool); | |
0 | 2565 __ cmpl(flags, atos); |
2566 __ jcc(Assembler::notEqual, notObj); | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2567 |
0 | 2568 // atos |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2569 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2570 __ pop(atos); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2571 if (!is_static) pop_and_check_object(obj); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2572 // Store into the field |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2573 do_oop_store(_masm, field, rax, _bs->kind(), false); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2574 if (!is_static) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2575 patch_bytecode(Bytecodes::_fast_aputfield, bc, rbx, true, byte_no); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2576 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2577 __ jmp(Done); |
0 | 2578 } |
2579 | |
2580 __ bind(notObj); | |
2581 __ cmpl(flags, itos); | |
2582 __ jcc(Assembler::notEqual, notInt); | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2583 |
0 | 2584 // itos |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2585 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2586 __ pop(itos); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2587 if (!is_static) pop_and_check_object(obj); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2588 __ movl(field, rax); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2589 if (!is_static) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2590 patch_bytecode(Bytecodes::_fast_iputfield, bc, rbx, true, byte_no); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2591 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2592 __ jmp(Done); |
0 | 2593 } |
2594 | |
2595 __ bind(notInt); | |
2596 __ cmpl(flags, ctos); | |
2597 __ jcc(Assembler::notEqual, notChar); | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2598 |
0 | 2599 // ctos |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2600 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2601 __ pop(ctos); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2602 if (!is_static) pop_and_check_object(obj); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2603 __ movw(field, rax); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2604 if (!is_static) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2605 patch_bytecode(Bytecodes::_fast_cputfield, bc, rbx, true, byte_no); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2606 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2607 __ jmp(Done); |
0 | 2608 } |
2609 | |
2610 __ bind(notChar); | |
2611 __ cmpl(flags, stos); | |
2612 __ jcc(Assembler::notEqual, notShort); | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2613 |
0 | 2614 // stos |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2615 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2616 __ pop(stos); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2617 if (!is_static) pop_and_check_object(obj); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2618 __ movw(field, rax); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2619 if (!is_static) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2620 patch_bytecode(Bytecodes::_fast_sputfield, bc, rbx, true, byte_no); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2621 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2622 __ jmp(Done); |
0 | 2623 } |
2624 | |
2625 __ bind(notShort); | |
2626 __ cmpl(flags, ltos); | |
2627 __ jcc(Assembler::notEqual, notLong); | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2628 |
0 | 2629 // ltos |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2630 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2631 __ pop(ltos); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2632 if (!is_static) pop_and_check_object(obj); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2633 __ movq(field, rax); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2634 if (!is_static) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2635 patch_bytecode(Bytecodes::_fast_lputfield, bc, rbx, true, byte_no); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2636 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2637 __ jmp(Done); |
0 | 2638 } |
2639 | |
2640 __ bind(notLong); | |
2641 __ cmpl(flags, ftos); | |
2642 __ jcc(Assembler::notEqual, notFloat); | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2643 |
0 | 2644 // ftos |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2645 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2646 __ pop(ftos); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2647 if (!is_static) pop_and_check_object(obj); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2648 __ movflt(field, xmm0); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2649 if (!is_static) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2650 patch_bytecode(Bytecodes::_fast_fputfield, bc, rbx, true, byte_no); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2651 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2652 __ jmp(Done); |
0 | 2653 } |
2654 | |
2655 __ bind(notFloat); | |
2656 #ifdef ASSERT | |
2657 __ cmpl(flags, dtos); | |
2658 __ jcc(Assembler::notEqual, notDouble); | |
2659 #endif | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2660 |
0 | 2661 // dtos |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2662 { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2663 __ pop(dtos); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2664 if (!is_static) pop_and_check_object(obj); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2665 __ movdbl(field, xmm0); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2666 if (!is_static) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2667 patch_bytecode(Bytecodes::_fast_dputfield, bc, rbx, true, byte_no); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2668 } |
0 | 2669 } |
2670 | |
2671 #ifdef ASSERT | |
2672 __ jmp(Done); | |
2673 | |
2674 __ bind(notDouble); | |
2675 __ stop("Bad state"); | |
2676 #endif | |
2677 | |
2678 __ bind(Done); | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
3461
diff
changeset
|
2679 |
0 | 2680 // Check for volatile store |
2681 __ testl(rdx, rdx); | |
2682 __ jcc(Assembler::zero, notVolatile); | |
2683 volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | | |
2684 Assembler::StoreStore)); | |
2685 __ bind(notVolatile); | |
2686 } | |
2687 | |
2688 void TemplateTable::putfield(int byte_no) { | |
2689 putfield_or_static(byte_no, false); | |
2690 } | |
2691 | |
2692 void TemplateTable::putstatic(int byte_no) { | |
2693 putfield_or_static(byte_no, true); | |
2694 } | |
2695 | |
2696 void TemplateTable::jvmti_post_fast_field_mod() { | |
2697 if (JvmtiExport::can_post_field_modification()) { | |
2698 // Check to see if a field modification watch has been set before | |
2699 // we take the time to call into the VM. | |
2700 Label L2; | |
2701 __ mov32(c_rarg3, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr())); | |
2702 __ testl(c_rarg3, c_rarg3); | |
2703 __ jcc(Assembler::zero, L2); | |
2704 __ pop_ptr(rbx); // copy the object pointer from tos | |
2705 __ verify_oop(rbx); | |
2706 __ push_ptr(rbx); // put the object pointer back on tos | |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2707 // Save tos values before call_VM() clobbers them. Since we have |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2708 // to do it for every data type, we use the saved values as the |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2709 // jvalue object. |
0 | 2710 switch (bytecode()) { // load values into the jvalue object |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2711 case Bytecodes::_fast_aputfield: __ push_ptr(rax); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2712 case Bytecodes::_fast_bputfield: // fall through |
23614 | 2713 case Bytecodes::_fast_zputfield: // fall through |
0 | 2714 case Bytecodes::_fast_sputfield: // fall through |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2715 case Bytecodes::_fast_cputfield: // fall through |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2716 case Bytecodes::_fast_iputfield: __ push_i(rax); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2717 case Bytecodes::_fast_dputfield: __ push_d(); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2718 case Bytecodes::_fast_fputfield: __ push_f(); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2719 case Bytecodes::_fast_lputfield: __ push_l(rax); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2720 |
0 | 2721 default: |
2722 ShouldNotReachHere(); | |
2723 } | |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2724 __ mov(c_rarg3, rsp); // points to jvalue on the stack |
0 | 2725 // access constant pool cache entry |
2726 __ get_cache_entry_pointer_at_bcp(c_rarg2, rax, 1); | |
2727 __ verify_oop(rbx); | |
2728 // rbx: object pointer copied above | |
2729 // c_rarg2: cache entry pointer | |
2730 // c_rarg3: jvalue object on the stack | |
2731 __ call_VM(noreg, | |
2732 CAST_FROM_FN_PTR(address, | |
2733 InterpreterRuntime::post_field_modification), | |
2734 rbx, c_rarg2, c_rarg3); | |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2735 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2736 switch (bytecode()) { // restore tos values |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2737 case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2738 case Bytecodes::_fast_bputfield: // fall through |
23614 | 2739 case Bytecodes::_fast_zputfield: // fall through |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2740 case Bytecodes::_fast_sputfield: // fall through |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2741 case Bytecodes::_fast_cputfield: // fall through |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2742 case Bytecodes::_fast_iputfield: __ pop_i(rax); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2743 case Bytecodes::_fast_dputfield: __ pop_d(); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2744 case Bytecodes::_fast_fputfield: __ pop_f(); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2745 case Bytecodes::_fast_lputfield: __ pop_l(rax); break; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
4771
diff
changeset
|
2746 } |
0 | 2747 __ bind(L2); |
2748 } | |
2749 } | |
2750 | |
2751 void TemplateTable::fast_storefield(TosState state) { | |
2752 transition(state, vtos); | |
2753 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2754 ByteSize base = ConstantPoolCache::base_offset(); |
0 | 2755 |
2756 jvmti_post_fast_field_mod(); | |
2757 | |
2758 // access constant pool cache | |
2759 __ get_cache_and_index_at_bcp(rcx, rbx, 1); | |
2760 | |
2761 // test for volatile with rdx | |
2762 __ movl(rdx, Address(rcx, rbx, Address::times_8, | |
2763 in_bytes(base + | |
2764 ConstantPoolCacheEntry::flags_offset()))); | |
2765 | |
2766 // replace index with field offset from cache entry | |
304 | 2767 __ movptr(rbx, Address(rcx, rbx, Address::times_8, |
2768 in_bytes(base + ConstantPoolCacheEntry::f2_offset()))); | |
0 | 2769 |
2770 // [jk] not needed currently | |
2771 // volatile_barrier(Assembler::Membar_mask_bits(Assembler::LoadStore | | |
2772 // Assembler::StoreStore)); | |
2773 | |
2774 Label notVolatile; | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2775 __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift); |
0 | 2776 __ andl(rdx, 0x1); |
2777 | |
2778 // Get object from stack | |
2779 pop_and_check_object(rcx); | |
2780 | |
2781 // field address | |
2782 const Address field(rcx, rbx, Address::times_1); | |
2783 | |
2784 // access field | |
2785 switch (bytecode()) { | |
2786 case Bytecodes::_fast_aputfield: | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
2787 do_oop_store(_masm, field, rax, _bs->kind(), false); |
0 | 2788 break; |
2789 case Bytecodes::_fast_lputfield: | |
2790 __ movq(field, rax); | |
2791 break; | |
2792 case Bytecodes::_fast_iputfield: | |
2793 __ movl(field, rax); | |
2794 break; | |
23614 | 2795 case Bytecodes::_fast_zputfield: |
2796 __ andl(rax, 0x1); // boolean is true if LSB is 1 | |
2797 // fall through to bputfield | |
0 | 2798 case Bytecodes::_fast_bputfield: |
2799 __ movb(field, rax); | |
2800 break; | |
2801 case Bytecodes::_fast_sputfield: | |
2802 // fall through | |
2803 case Bytecodes::_fast_cputfield: | |
2804 __ movw(field, rax); | |
2805 break; | |
2806 case Bytecodes::_fast_fputfield: | |
2807 __ movflt(field, xmm0); | |
2808 break; | |
2809 case Bytecodes::_fast_dputfield: | |
2810 __ movdbl(field, xmm0); | |
2811 break; | |
2812 default: | |
2813 ShouldNotReachHere(); | |
2814 } | |
2815 | |
2816 // Check for volatile store | |
2817 __ testl(rdx, rdx); | |
2818 __ jcc(Assembler::zero, notVolatile); | |
2819 volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | | |
2820 Assembler::StoreStore)); | |
2821 __ bind(notVolatile); | |
2822 } | |
2823 | |
2824 | |
2825 void TemplateTable::fast_accessfield(TosState state) { | |
2826 transition(atos, state); | |
2827 | |
2828 // Do the JVMTI work here to avoid disturbing the register state below | |
2829 if (JvmtiExport::can_post_field_access()) { | |
2830 // Check to see if a field access watch has been set before we | |
2831 // take the time to call into the VM. | |
2832 Label L1; | |
2833 __ mov32(rcx, ExternalAddress((address) JvmtiExport::get_field_access_count_addr())); | |
2834 __ testl(rcx, rcx); | |
2835 __ jcc(Assembler::zero, L1); | |
2836 // access constant pool cache entry | |
2837 __ get_cache_entry_pointer_at_bcp(c_rarg2, rcx, 1); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2838 __ verify_oop(rax); |
1976
0fc262af204f
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
1972
diff
changeset
|
2839 __ push_ptr(rax); // save object pointer before call_VM() clobbers it |
304 | 2840 __ mov(c_rarg1, rax); |
0 | 2841 // c_rarg1: object pointer copied above |
2842 // c_rarg2: cache entry pointer | |
2843 __ call_VM(noreg, | |
2844 CAST_FROM_FN_PTR(address, | |
2845 InterpreterRuntime::post_field_access), | |
2846 c_rarg1, c_rarg2); | |
1976
0fc262af204f
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
1972
diff
changeset
|
2847 __ pop_ptr(rax); // restore object pointer |
0 | 2848 __ bind(L1); |
2849 } | |
2850 | |
2851 // access constant pool cache | |
2852 __ get_cache_and_index_at_bcp(rcx, rbx, 1); | |
2853 // replace index with field offset from cache entry | |
2854 // [jk] not needed currently | |
2855 // if (os::is_MP()) { | |
2856 // __ movl(rdx, Address(rcx, rbx, Address::times_8, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2857 // in_bytes(ConstantPoolCache::base_offset() + |
0 | 2858 // ConstantPoolCacheEntry::flags_offset()))); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2859 // __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift); |
0 | 2860 // __ andl(rdx, 0x1); |
2861 // } | |
304 | 2862 __ movptr(rbx, Address(rcx, rbx, Address::times_8, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2863 in_bytes(ConstantPoolCache::base_offset() + |
304 | 2864 ConstantPoolCacheEntry::f2_offset()))); |
0 | 2865 |
2866 // rax: object | |
2867 __ verify_oop(rax); | |
2868 __ null_check(rax); | |
2869 Address field(rax, rbx, Address::times_1); | |
2870 | |
2871 // access field | |
2872 switch (bytecode()) { | |
2873 case Bytecodes::_fast_agetfield: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2874 __ load_heap_oop(rax, field); |
0 | 2875 __ verify_oop(rax); |
2876 break; | |
2877 case Bytecodes::_fast_lgetfield: | |
2878 __ movq(rax, field); | |
2879 break; | |
2880 case Bytecodes::_fast_igetfield: | |
2881 __ movl(rax, field); | |
2882 break; | |
2883 case Bytecodes::_fast_bgetfield: | |
2884 __ movsbl(rax, field); | |
2885 break; | |
2886 case Bytecodes::_fast_sgetfield: | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
2887 __ load_signed_short(rax, field); |
0 | 2888 break; |
2889 case Bytecodes::_fast_cgetfield: | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
2890 __ load_unsigned_short(rax, field); |
0 | 2891 break; |
2892 case Bytecodes::_fast_fgetfield: | |
2893 __ movflt(xmm0, field); | |
2894 break; | |
2895 case Bytecodes::_fast_dgetfield: | |
2896 __ movdbl(xmm0, field); | |
2897 break; | |
2898 default: | |
2899 ShouldNotReachHere(); | |
2900 } | |
2901 // [jk] not needed currently | |
2902 // if (os::is_MP()) { | |
2903 // Label notVolatile; | |
2904 // __ testl(rdx, rdx); | |
2905 // __ jcc(Assembler::zero, notVolatile); | |
2906 // __ membar(Assembler::LoadLoad); | |
2907 // __ bind(notVolatile); | |
2908 //}; | |
2909 } | |
2910 | |
2911 void TemplateTable::fast_xaccess(TosState state) { | |
2912 transition(vtos, state); | |
2913 | |
2914 // get receiver | |
304 | 2915 __ movptr(rax, aaddress(0)); |
0 | 2916 // access constant pool cache |
2917 __ get_cache_and_index_at_bcp(rcx, rdx, 2); | |
304 | 2918 __ movptr(rbx, |
2919 Address(rcx, rdx, Address::times_8, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2920 in_bytes(ConstantPoolCache::base_offset() + |
304 | 2921 ConstantPoolCacheEntry::f2_offset()))); |
0 | 2922 // make sure exception is reported in correct bcp range (getfield is |
2923 // next instruction) | |
304 | 2924 __ increment(r13); |
0 | 2925 __ null_check(rax); |
2926 switch (state) { | |
2927 case itos: | |
2928 __ movl(rax, Address(rax, rbx, Address::times_1)); | |
2929 break; | |
2930 case atos: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2931 __ load_heap_oop(rax, Address(rax, rbx, Address::times_1)); |
0 | 2932 __ verify_oop(rax); |
2933 break; | |
2934 case ftos: | |
2935 __ movflt(xmm0, Address(rax, rbx, Address::times_1)); | |
2936 break; | |
2937 default: | |
2938 ShouldNotReachHere(); | |
2939 } | |
2940 | |
2941 // [jk] not needed currently | |
2942 // if (os::is_MP()) { | |
2943 // Label notVolatile; | |
2944 // __ movl(rdx, Address(rcx, rdx, Address::times_8, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2945 // in_bytes(ConstantPoolCache::base_offset() + |
0 | 2946 // ConstantPoolCacheEntry::flags_offset()))); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2947 // __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift); |
0 | 2948 // __ testl(rdx, 0x1); |
2949 // __ jcc(Assembler::zero, notVolatile); | |
2950 // __ membar(Assembler::LoadLoad); | |
2951 // __ bind(notVolatile); | |
2952 // } | |
2953 | |
304 | 2954 __ decrement(r13); |
0 | 2955 } |
2956 | |
2957 | |
2958 | |
2959 //----------------------------------------------------------------------------- | |
2960 // Calls | |
2961 | |
2962 void TemplateTable::count_calls(Register method, Register temp) { | |
2963 // implemented elsewhere | |
2964 ShouldNotReachHere(); | |
2965 } | |
2966 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2967 void TemplateTable::prepare_invoke(int byte_no, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2968 Register method, // linked method (or i-klass) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2969 Register index, // itable index, MethodType, etc. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2970 Register recv, // if caller wants to see it |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2971 Register flags // if caller wants to test it |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2972 ) { |
0 | 2973 // determine flags |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2974 const Bytecodes::Code code = bytecode(); |
0 | 2975 const bool is_invokeinterface = code == Bytecodes::_invokeinterface; |
1108 | 2976 const bool is_invokedynamic = code == Bytecodes::_invokedynamic; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2977 const bool is_invokehandle = code == Bytecodes::_invokehandle; |
0 | 2978 const bool is_invokevirtual = code == Bytecodes::_invokevirtual; |
2979 const bool is_invokespecial = code == Bytecodes::_invokespecial; | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2980 const bool load_receiver = (recv != noreg); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2981 const bool save_flags = (flags != noreg); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2982 assert(load_receiver == (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic), ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2983 assert(save_flags == (is_invokeinterface || is_invokevirtual), "need flags for vfinal"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2984 assert(flags == noreg || flags == rdx, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2985 assert(recv == noreg || recv == rcx, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2986 |
0 | 2987 // setup registers & access constant pool cache |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2988 if (recv == noreg) recv = rcx; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2989 if (flags == noreg) flags = rdx; |
0 | 2990 assert_different_registers(method, index, recv, flags); |
2991 | |
2992 // save 'interpreter return address' | |
2993 __ save_bcp(); | |
2994 | |
1565 | 2995 load_invoke_cp_cache_entry(byte_no, method, index, flags, is_invokevirtual, false, is_invokedynamic); |
0 | 2996 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2997 // maybe push appendix to arguments (just before return address) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2998 if (is_invokedynamic || is_invokehandle) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
2999 Label L_no_push; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3000 __ testl(flags, (1 << ConstantPoolCacheEntry::has_appendix_shift)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3001 __ jcc(Assembler::zero, L_no_push); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3002 // Push the appendix as a trailing parameter. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3003 // This must be done before we get the receiver, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3004 // since the parameter_size includes it. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3005 __ push(rbx); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3006 __ mov(rbx, index); |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
3007 assert(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset == 0, "appendix expected at index+0"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3008 __ load_resolved_reference_at_index(index, rbx); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3009 __ pop(rbx); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3010 __ push(index); // push appendix (MethodType, CallSite, etc.) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3011 __ bind(L_no_push); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3012 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3013 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3014 // load receiver if needed (after appendix is pushed so parameter size is correct) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3015 // Note: no return address pushed yet |
0 | 3016 if (load_receiver) { |
3017 __ movl(recv, flags); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3018 __ andl(recv, ConstantPoolCacheEntry::parameter_size_mask); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3019 const int no_return_pc_pushed_yet = -1; // argument slot correction before we push return address |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3020 const int receiver_is_at_end = -1; // back off one slot to get receiver |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3021 Address recv_addr = __ argument_address(recv, no_return_pc_pushed_yet + receiver_is_at_end); |
1304 | 3022 __ movptr(recv, recv_addr); |
3023 __ verify_oop(recv); | |
0 | 3024 } |
3025 | |
3026 if (save_flags) { | |
3027 __ movl(r13, flags); | |
3028 } | |
3029 | |
3030 // compute return type | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3031 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3032 // Make sure we don't need to mask flags after the above shift |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3033 ConstantPoolCacheEntry::verify_tos_state_shift(); |
0 | 3034 // load return address |
3035 { | |
13010
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12875
diff
changeset
|
3036 const address table_addr = (address) Interpreter::invoke_return_entry_table_for(code); |
1108 | 3037 ExternalAddress table(table_addr); |
3038 __ lea(rscratch1, table); | |
3039 __ movptr(flags, Address(rscratch1, flags, Address::times_ptr)); | |
0 | 3040 } |
3041 | |
3042 // push return address | |
304 | 3043 __ push(flags); |
0 | 3044 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3045 // Restore flags value from the constant pool cache, and restore rsi |
0 | 3046 // for later null checks. r13 is the bytecode pointer |
3047 if (save_flags) { | |
3048 __ movl(flags, r13); | |
3049 __ restore_bcp(); | |
3050 } | |
3051 } | |
3052 | |
3053 | |
3054 void TemplateTable::invokevirtual_helper(Register index, | |
3055 Register recv, | |
3056 Register flags) { | |
1783 | 3057 // Uses temporary registers rax, rdx |
3058 assert_different_registers(index, recv, rax, rdx); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3059 assert(index == rbx, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3060 assert(recv == rcx, ""); |
0 | 3061 |
3062 // Test for an invoke of a final method | |
3063 Label notFinal; | |
3064 __ movl(rax, flags); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3065 __ andl(rax, (1 << ConstantPoolCacheEntry::is_vfinal_shift)); |
0 | 3066 __ jcc(Assembler::zero, notFinal); |
3067 | |
3068 const Register method = index; // method must be rbx | |
3069 assert(method == rbx, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3070 "Method* must be rbx for interpreter calling convention"); |
0 | 3071 |
3072 // do the call - the index is actually the method to call | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3073 // that is, f2 is a vtable index if !is_vfinal, else f2 is a Method* |
0 | 3074 |
3075 // It's final, need a null check here! | |
3076 __ null_check(recv); | |
3077 | |
3078 // profile this call | |
3079 __ profile_final_call(rax); | |
12875
d13d7aba8c12
8023657: New type profiling points: arguments to call
roland
parents:
10108
diff
changeset
|
3080 __ profile_arguments_type(rax, method, r13, true); |
0 | 3081 |
3082 __ jump_from_interpreted(method, rax); | |
3083 | |
3084 __ bind(notFinal); | |
3085 | |
3086 // get receiver klass | |
3087 __ null_check(recv, oopDesc::klass_offset_in_bytes()); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3088 __ load_klass(rax, recv); |
0 | 3089 |
3090 // profile this call | |
3091 __ profile_virtual_call(rax, r14, rdx); | |
3092 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3093 // get target Method* & entry point |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3094 __ lookup_virtual_method(rax, index, method); |
22298 | 3095 #if INCLUDE_JVMCI |
9760
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8001
diff
changeset
|
3096 // r14: MethodDataPointer (r14 is callee saved) |
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8001
diff
changeset
|
3097 __ profile_called_method(method, r14, r13); |
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8001
diff
changeset
|
3098 #endif |
12875
d13d7aba8c12
8023657: New type profiling points: arguments to call
roland
parents:
10108
diff
changeset
|
3099 __ profile_arguments_type(rdx, method, r13, true); |
13086
096c224171c4
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
3100 |
0 | 3101 __ jump_from_interpreted(method, rdx); |
3102 } | |
3103 | |
3104 | |
3105 void TemplateTable::invokevirtual(int byte_no) { | |
3106 transition(vtos, vtos); | |
1565 | 3107 assert(byte_no == f2_byte, "use this argument"); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3108 prepare_invoke(byte_no, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3109 rbx, // method or vtable index |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3110 noreg, // unused itable index |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3111 rcx, rdx); // recv, flags |
0 | 3112 |
3113 // rbx: index | |
3114 // rcx: receiver | |
3115 // rdx: flags | |
3116 | |
3117 invokevirtual_helper(rbx, rcx, rdx); | |
3118 } | |
3119 | |
3120 | |
3121 void TemplateTable::invokespecial(int byte_no) { | |
3122 transition(vtos, vtos); | |
1565 | 3123 assert(byte_no == f1_byte, "use this argument"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3124 prepare_invoke(byte_no, rbx, noreg, // get f1 Method* |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3125 rcx); // get receiver also for null check |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3126 __ verify_oop(rcx); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3127 __ null_check(rcx); |
0 | 3128 // do the call |
3129 __ profile_call(rax); | |
12875
d13d7aba8c12
8023657: New type profiling points: arguments to call
roland
parents:
10108
diff
changeset
|
3130 __ profile_arguments_type(rax, rbx, r13, false); |
0 | 3131 __ jump_from_interpreted(rbx, rax); |
3132 } | |
3133 | |
3134 | |
3135 void TemplateTable::invokestatic(int byte_no) { | |
3136 transition(vtos, vtos); | |
1565 | 3137 assert(byte_no == f1_byte, "use this argument"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3138 prepare_invoke(byte_no, rbx); // get f1 Method* |
0 | 3139 // do the call |
3140 __ profile_call(rax); | |
12875
d13d7aba8c12
8023657: New type profiling points: arguments to call
roland
parents:
10108
diff
changeset
|
3141 __ profile_arguments_type(rax, rbx, r13, false); |
0 | 3142 __ jump_from_interpreted(rbx, rax); |
3143 } | |
3144 | |
3145 void TemplateTable::fast_invokevfinal(int byte_no) { | |
3146 transition(vtos, vtos); | |
1565 | 3147 assert(byte_no == f2_byte, "use this argument"); |
0 | 3148 __ stop("fast_invokevfinal not used on amd64"); |
3149 } | |
3150 | |
3151 void TemplateTable::invokeinterface(int byte_no) { | |
3152 transition(vtos, vtos); | |
1565 | 3153 assert(byte_no == f1_byte, "use this argument"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3154 prepare_invoke(byte_no, rax, rbx, // get f1 Klass*, f2 itable index |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3155 rcx, rdx); // recv, flags |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3156 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3157 // rax: interface klass (from f1) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3158 // rbx: itable index (from f2) |
0 | 3159 // rcx: receiver |
3160 // rdx: flags | |
3161 | |
3162 // Special case of invokeinterface called for virtual method of | |
3163 // java.lang.Object. See cpCacheOop.cpp for details. | |
3164 // This code isn't produced by javac, but could be produced by | |
3165 // another compliant java compiler. | |
3166 Label notMethod; | |
3167 __ movl(r14, rdx); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3168 __ andl(r14, (1 << ConstantPoolCacheEntry::is_forced_virtual_shift)); |
0 | 3169 __ jcc(Assembler::zero, notMethod); |
3170 | |
3171 invokevirtual_helper(rbx, rcx, rdx); | |
3172 __ bind(notMethod); | |
3173 | |
3174 // Get receiver klass into rdx - also a null check | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3175 __ restore_locals(); // restore r14 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3176 __ null_check(rcx, oopDesc::klass_offset_in_bytes()); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3177 __ load_klass(rdx, rcx); |
0 | 3178 |
3179 // profile this call | |
3180 __ profile_virtual_call(rdx, r13, r14); | |
3181 | |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3182 Label no_such_interface, no_such_method; |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3183 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3184 __ lookup_interface_method(// inputs: rec. class, interface, itable index |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3185 rdx, rax, rbx, |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3186 // outputs: method, scan temp. reg |
9760
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8001
diff
changeset
|
3187 rbx, r14, |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3188 no_such_interface); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3189 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3190 // rbx: Method* to call |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3191 // rcx: receiver |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3192 // Check for abstract method error |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3193 // Note: This should be done more efficiently via a throw_abstract_method_error |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3194 // interpreter entry point and a conditional jump to it in case of a null |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3195 // method. |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3196 __ testptr(rbx, rbx); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3197 __ jcc(Assembler::zero, no_such_method); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3198 |
22298 | 3199 #if INCLUDE_JVMCI |
13109
58dfd753ada8
fixed regression from recent hsx merge that prevented TypeProfileLevel from being enabled
Doug Simon <doug.simon@oracle.com>
parents:
13086
diff
changeset
|
3200 // r13: MethodDataPointer (r13 is callee saved) |
58dfd753ada8
fixed regression from recent hsx merge that prevented TypeProfileLevel from being enabled
Doug Simon <doug.simon@oracle.com>
parents:
13086
diff
changeset
|
3201 __ profile_called_method(rbx, r13, r14); |
58dfd753ada8
fixed regression from recent hsx merge that prevented TypeProfileLevel from being enabled
Doug Simon <doug.simon@oracle.com>
parents:
13086
diff
changeset
|
3202 #endif |
12875
d13d7aba8c12
8023657: New type profiling points: arguments to call
roland
parents:
10108
diff
changeset
|
3203 __ profile_arguments_type(rdx, rbx, r13, true); |
d13d7aba8c12
8023657: New type profiling points: arguments to call
roland
parents:
10108
diff
changeset
|
3204 |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3205 // do the call |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3206 // rcx: receiver |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3207 // rbx,: Method* |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3208 __ jump_from_interpreted(rbx, rdx); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3209 __ should_not_reach_here(); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3210 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3211 // exception handling code follows... |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3212 // note: must restore interpreter registers to canonical |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3213 // state for exception handling to work correctly! |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3214 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3215 __ bind(no_such_method); |
0 | 3216 // throw exception |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3217 __ pop(rbx); // pop return address (pushed by prepare_invoke) |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3218 __ restore_bcp(); // r13 must be correct for exception handler (was destroyed) |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3219 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3220 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3221 // the call_VM checks for exception, so we should never return here. |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3222 __ should_not_reach_here(); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3223 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3224 __ bind(no_such_interface); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3225 // throw exception |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3226 __ pop(rbx); // pop return address (pushed by prepare_invoke) |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3227 __ restore_bcp(); // r13 must be correct for exception handler (was destroyed) |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3228 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) |
0 | 3229 __ call_VM(noreg, CAST_FROM_FN_PTR(address, |
3230 InterpreterRuntime::throw_IncompatibleClassChangeError)); | |
3231 // the call_VM checks for exception, so we should never return here. | |
3232 __ should_not_reach_here(); | |
3233 } | |
3234 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3235 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3236 void TemplateTable::invokehandle(int byte_no) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3237 transition(vtos, vtos); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3238 assert(byte_no == f1_byte, "use this argument"); |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
3239 const Register rbx_method = rbx; |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
3240 const Register rax_mtype = rax; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3241 const Register rcx_recv = rcx; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3242 const Register rdx_flags = rdx; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3243 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3244 if (!EnableInvokeDynamic) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3245 // rewriter does not generate this bytecode |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3246 __ should_not_reach_here(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3247 return; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3248 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3249 |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
3250 prepare_invoke(byte_no, rbx_method, rax_mtype, rcx_recv); |
6740
75f33eecc1b3
7196681: NPG: Some JSR 292 tests crash in Windows exception handler
coleenp
parents:
6725
diff
changeset
|
3251 __ verify_method_ptr(rbx_method); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3252 __ verify_oop(rcx_recv); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3253 __ null_check(rcx_recv); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3254 |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
3255 // rax: MethodType object (from cpool->resolved_references[f1], if necessary) |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
3256 // rbx: MH.invokeExact_MT method (from f2) |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
3257 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3258 // Note: rax_mtype is already pushed (if necessary) by prepare_invoke |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3259 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3260 // FIXME: profile the LambdaForm also |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3261 __ profile_final_call(rax); |
12875
d13d7aba8c12
8023657: New type profiling points: arguments to call
roland
parents:
10108
diff
changeset
|
3262 __ profile_arguments_type(rdx, rbx_method, r13, true); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3263 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3264 __ jump_from_interpreted(rbx_method, rdx); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3265 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3266 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3267 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3268 void TemplateTable::invokedynamic(int byte_no) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3269 transition(vtos, vtos); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3270 assert(byte_no == f1_byte, "use this argument"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3271 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3272 if (!EnableInvokeDynamic) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3273 // We should not encounter this bytecode if !EnableInvokeDynamic. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3274 // The verifier will stop it. However, if we get past the verifier, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3275 // this will stop the thread in a reasonable way, without crashing the JVM. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3276 __ call_VM(noreg, CAST_FROM_FN_PTR(address, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3277 InterpreterRuntime::throw_IncompatibleClassChangeError)); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3278 // the call_VM checks for exception, so we should never return here. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3279 __ should_not_reach_here(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3280 return; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3281 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3282 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3283 const Register rbx_method = rbx; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3284 const Register rax_callsite = rax; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3285 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3286 prepare_invoke(byte_no, rbx_method, rax_callsite); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3287 |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6740
diff
changeset
|
3288 // rax: CallSite object (from cpool->resolved_references[f1]) |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3289 // rbx: MH.linkToCallSite method (from f2) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3290 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3291 // Note: rax_callsite is already pushed by prepare_invoke |
1846 | 3292 |
3279
08ccee2c4dbf
6993078: JSR 292 too many pushes: Lesp points into register window
twisti
parents:
3275
diff
changeset
|
3293 // %%% should make a type profile for any invokedynamic that takes a ref argument |
08ccee2c4dbf
6993078: JSR 292 too many pushes: Lesp points into register window
twisti
parents:
3275
diff
changeset
|
3294 // profile this call |
08ccee2c4dbf
6993078: JSR 292 too many pushes: Lesp points into register window
twisti
parents:
3275
diff
changeset
|
3295 __ profile_call(r13); |
12875
d13d7aba8c12
8023657: New type profiling points: arguments to call
roland
parents:
10108
diff
changeset
|
3296 __ profile_arguments_type(rdx, rbx_method, r13, false); |
3279
08ccee2c4dbf
6993078: JSR 292 too many pushes: Lesp points into register window
twisti
parents:
3275
diff
changeset
|
3297 |
08ccee2c4dbf
6993078: JSR 292 too many pushes: Lesp points into register window
twisti
parents:
3275
diff
changeset
|
3298 __ verify_oop(rax_callsite); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3299 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
5995
diff
changeset
|
3300 __ jump_from_interpreted(rbx_method, rdx); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3301 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
623
diff
changeset
|
3302 |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3303 |
0 | 3304 //----------------------------------------------------------------------------- |
3305 // Allocation | |
3306 | |
3307 void TemplateTable::_new() { | |
3308 transition(vtos, atos); | |
3309 __ get_unsigned_2_byte_index_at_bcp(rdx, 1); | |
3310 Label slow_case; | |
3311 Label done; | |
3312 Label initialize_header; | |
3313 Label initialize_object; // including clearing the fields | |
3314 Label allocate_shared; | |
3315 | |
3316 __ get_cpool_and_tags(rsi, rax); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3317 // Make sure the class we're about to instantiate has been resolved. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3318 // This is done before loading InstanceKlass to be consistent with the order |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3319 // how Constant Pool is updated (see ConstantPool::klass_at_put) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3320 const int tags_offset = Array<u1>::base_offset_in_bytes(); |
0 | 3321 __ cmpb(Address(rax, rdx, Address::times_1, tags_offset), |
3322 JVM_CONSTANT_Class); | |
3323 __ jcc(Assembler::notEqual, slow_case); | |
3324 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3325 // get InstanceKlass |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3326 __ movptr(rsi, Address(rsi, rdx, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3327 Address::times_8, sizeof(ConstantPool))); |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3328 |
0 | 3329 // make sure klass is initialized & doesn't have finalizer |
3330 // make sure klass is fully initialized | |
4739
52b5d32fbfaf
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
3852
diff
changeset
|
3331 __ cmpb(Address(rsi, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3332 InstanceKlass::init_state_offset()), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3333 InstanceKlass::fully_initialized); |
0 | 3334 __ jcc(Assembler::notEqual, slow_case); |
3335 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3336 // get instance_size in InstanceKlass (scaled to a count of bytes) |
0 | 3337 __ movl(rdx, |
3338 Address(rsi, | |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
3852
diff
changeset
|
3339 Klass::layout_helper_offset())); |
0 | 3340 // test to see if it has a finalizer or is malformed in some way |
3341 __ testl(rdx, Klass::_lh_instance_slow_path_bit); | |
3342 __ jcc(Assembler::notZero, slow_case); | |
3343 | |
3344 // Allocate the instance | |
3345 // 1) Try to allocate in the TLAB | |
3346 // 2) if fail and the object is large allocate in the shared Eden | |
3347 // 3) if the above fails (or is not applicable), go to a slow case | |
3348 // (creates a new TLAB, etc.) | |
3349 | |
3350 const bool allow_shared_alloc = | |
3351 Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode; | |
3352 | |
3353 if (UseTLAB) { | |
304 | 3354 __ movptr(rax, Address(r15_thread, in_bytes(JavaThread::tlab_top_offset()))); |
3355 __ lea(rbx, Address(rax, rdx, Address::times_1)); | |
3356 __ cmpptr(rbx, Address(r15_thread, in_bytes(JavaThread::tlab_end_offset()))); | |
0 | 3357 __ jcc(Assembler::above, allow_shared_alloc ? allocate_shared : slow_case); |
304 | 3358 __ movptr(Address(r15_thread, in_bytes(JavaThread::tlab_top_offset())), rbx); |
0 | 3359 if (ZeroTLAB) { |
3360 // the fields have been already cleared | |
3361 __ jmp(initialize_header); | |
3362 } else { | |
3363 // initialize both the header and fields | |
3364 __ jmp(initialize_object); | |
3365 } | |
3366 } | |
3367 | |
3368 // Allocation in the shared Eden, if allowed. | |
3369 // | |
3370 // rdx: instance size in bytes | |
3371 if (allow_shared_alloc) { | |
3372 __ bind(allocate_shared); | |
3373 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
3374 ExternalAddress top((address)Universe::heap()->top_addr()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
3375 ExternalAddress end((address)Universe::heap()->end_addr()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
3376 |
0 | 3377 const Register RtopAddr = rscratch1; |
3378 const Register RendAddr = rscratch2; | |
3379 | |
3380 __ lea(RtopAddr, top); | |
3381 __ lea(RendAddr, end); | |
304 | 3382 __ movptr(rax, Address(RtopAddr, 0)); |
0 | 3383 |
3384 // For retries rax gets set by cmpxchgq | |
3385 Label retry; | |
3386 __ bind(retry); | |
304 | 3387 __ lea(rbx, Address(rax, rdx, Address::times_1)); |
3388 __ cmpptr(rbx, Address(RendAddr, 0)); | |
0 | 3389 __ jcc(Assembler::above, slow_case); |
3390 | |
3391 // Compare rax with the top addr, and if still equal, store the new | |
3392 // top addr in rbx at the address of the top addr pointer. Sets ZF if was | |
3393 // equal, and clears it otherwise. Use lock prefix for atomicity on MPs. | |
3394 // | |
3395 // rax: object begin | |
3396 // rbx: object end | |
3397 // rdx: instance size in bytes | |
3398 if (os::is_MP()) { | |
3399 __ lock(); | |
3400 } | |
304 | 3401 __ cmpxchgptr(rbx, Address(RtopAddr, 0)); |
0 | 3402 |
3403 // if someone beat us on the allocation, try again, otherwise continue | |
3404 __ jcc(Assembler::notEqual, retry); | |
2100
b1a2afa37ec4
7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents:
1976
diff
changeset
|
3405 |
b1a2afa37ec4
7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents:
1976
diff
changeset
|
3406 __ incr_allocated_bytes(r15_thread, rdx, 0); |
0 | 3407 } |
3408 | |
3409 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { | |
3410 // The object is initialized before the header. If the object size is | |
3411 // zero, go directly to the header initialization. | |
3412 __ bind(initialize_object); | |
3413 __ decrementl(rdx, sizeof(oopDesc)); | |
3414 __ jcc(Assembler::zero, initialize_header); | |
3415 | |
3416 // Initialize object fields | |
3417 __ xorl(rcx, rcx); // use zero reg to clear memory (shorter code) | |
3418 __ shrl(rdx, LogBytesPerLong); // divide by oopSize to simplify the loop | |
3419 { | |
3420 Label loop; | |
3421 __ bind(loop); | |
3422 __ movq(Address(rax, rdx, Address::times_8, | |
3423 sizeof(oopDesc) - oopSize), | |
3424 rcx); | |
3425 __ decrementl(rdx); | |
3426 __ jcc(Assembler::notZero, loop); | |
3427 } | |
3428 | |
3429 // initialize object header only. | |
3430 __ bind(initialize_header); | |
3431 if (UseBiasedLocking) { | |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
3852
diff
changeset
|
3432 __ movptr(rscratch1, Address(rsi, Klass::prototype_header_offset())); |
304 | 3433 __ movptr(Address(rax, oopDesc::mark_offset_in_bytes()), rscratch1); |
0 | 3434 } else { |
3435 __ movptr(Address(rax, oopDesc::mark_offset_in_bytes()), | |
3436 (intptr_t) markOopDesc::prototype()); // header (address 0x1) | |
3437 } | |
167
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
3438 __ xorl(rcx, rcx); // use zero reg to clear memory (shorter code) |
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
3439 __ store_klass_gap(rax, rcx); // zero klass gap for compressed oops |
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
3440 __ store_klass(rax, rsi); // store klass last |
1248
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3441 |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3442 { |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3443 SkipIfEqual skip(_masm, &DTraceAllocProbes, false); |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3444 // Trigger dtrace event for fastpath |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3445 __ push(atos); // save the return value |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3446 __ call_VM_leaf( |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3447 CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), rax); |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3448 __ pop(atos); // restore the return value |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3449 |
455df1b81409
6587322: dtrace probe object__alloc doesn't fire in some situations on amd64
kamg
parents:
1108
diff
changeset
|
3450 } |
0 | 3451 __ jmp(done); |
3452 } | |
3453 | |
3454 | |
3455 // slow case | |
3456 __ bind(slow_case); | |
3457 __ get_constant_pool(c_rarg1); | |
3458 __ get_unsigned_2_byte_index_at_bcp(c_rarg2, 1); | |
3459 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), c_rarg1, c_rarg2); | |
3460 __ verify_oop(rax); | |
3461 | |
3462 // continue | |
3463 __ bind(done); | |
3464 } | |
3465 | |
3466 void TemplateTable::newarray() { | |
3467 transition(itos, atos); | |
3468 __ load_unsigned_byte(c_rarg1, at_bcp(1)); | |
3469 __ movl(c_rarg2, rax); | |
3470 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::newarray), | |
3471 c_rarg1, c_rarg2); | |
3472 } | |
3473 | |
3474 void TemplateTable::anewarray() { | |
3475 transition(itos, atos); | |
3476 __ get_unsigned_2_byte_index_at_bcp(c_rarg2, 1); | |
3477 __ get_constant_pool(c_rarg1); | |
3478 __ movl(c_rarg3, rax); | |
3479 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::anewarray), | |
3480 c_rarg1, c_rarg2, c_rarg3); | |
3481 } | |
3482 | |
3483 void TemplateTable::arraylength() { | |
3484 transition(atos, itos); | |
3485 __ null_check(rax, arrayOopDesc::length_offset_in_bytes()); | |
3486 __ movl(rax, Address(rax, arrayOopDesc::length_offset_in_bytes())); | |
3487 } | |
3488 | |
3489 void TemplateTable::checkcast() { | |
3490 transition(atos, atos); | |
3491 Label done, is_null, ok_is_subtype, quicked, resolved; | |
304 | 3492 __ testptr(rax, rax); // object is in rax |
0 | 3493 __ jcc(Assembler::zero, is_null); |
3494 | |
3495 // Get cpool & tags index | |
3496 __ get_cpool_and_tags(rcx, rdx); // rcx=cpool, rdx=tags array | |
3497 __ get_unsigned_2_byte_index_at_bcp(rbx, 1); // rbx=index | |
3498 // See if bytecode has already been quicked | |
3499 __ cmpb(Address(rdx, rbx, | |
3500 Address::times_1, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3501 Array<u1>::base_offset_in_bytes()), |
0 | 3502 JVM_CONSTANT_Class); |
3503 __ jcc(Assembler::equal, quicked); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3504 __ push(atos); // save receiver for result, and for GC |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3505 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3506 // vm_result_2 has metadata result |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3507 __ get_vm_result_2(rax, r15_thread); |
0 | 3508 __ pop_ptr(rdx); // restore receiver |
3509 __ jmpb(resolved); | |
3510 | |
3511 // Get superklass in rax and subklass in rbx | |
3512 __ bind(quicked); | |
304 | 3513 __ mov(rdx, rax); // Save object in rdx; rax needed for subtype check |
3514 __ movptr(rax, Address(rcx, rbx, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3515 Address::times_8, sizeof(ConstantPool))); |
0 | 3516 |
3517 __ bind(resolved); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3518 __ load_klass(rbx, rdx); |
0 | 3519 |
3520 // Generate subtype check. Blows rcx, rdi. Object in rdx. | |
3521 // Superklass in rax. Subklass in rbx. | |
3522 __ gen_subtype_check(rbx, ok_is_subtype); | |
3523 | |
3524 // Come here on failure | |
3525 __ push_ptr(rdx); | |
3526 // object is at TOS | |
3527 __ jump(ExternalAddress(Interpreter::_throw_ClassCastException_entry)); | |
3528 | |
3529 // Come here on success | |
3530 __ bind(ok_is_subtype); | |
304 | 3531 __ mov(rax, rdx); // Restore object in rdx |
0 | 3532 |
3533 // Collect counts on whether this check-cast sees NULLs a lot or not. | |
3534 if (ProfileInterpreter) { | |
3535 __ jmp(done); | |
3536 __ bind(is_null); | |
3537 __ profile_null_seen(rcx); | |
3538 } else { | |
3539 __ bind(is_null); // same as 'done' | |
3540 } | |
3541 __ bind(done); | |
3542 } | |
3543 | |
3544 void TemplateTable::instanceof() { | |
3545 transition(atos, itos); | |
3546 Label done, is_null, ok_is_subtype, quicked, resolved; | |
304 | 3547 __ testptr(rax, rax); |
0 | 3548 __ jcc(Assembler::zero, is_null); |
3549 | |
3550 // Get cpool & tags index | |
3551 __ get_cpool_and_tags(rcx, rdx); // rcx=cpool, rdx=tags array | |
3552 __ get_unsigned_2_byte_index_at_bcp(rbx, 1); // rbx=index | |
3553 // See if bytecode has already been quicked | |
3554 __ cmpb(Address(rdx, rbx, | |
3555 Address::times_1, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3556 Array<u1>::base_offset_in_bytes()), |
0 | 3557 JVM_CONSTANT_Class); |
3558 __ jcc(Assembler::equal, quicked); | |
3559 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3560 __ push(atos); // save receiver for result, and for GC |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3561 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3562 // vm_result_2 has metadata result |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3563 __ get_vm_result_2(rax, r15_thread); |
0 | 3564 __ pop_ptr(rdx); // restore receiver |
1976
0fc262af204f
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
1972
diff
changeset
|
3565 __ verify_oop(rdx); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3566 __ load_klass(rdx, rdx); |
0 | 3567 __ jmpb(resolved); |
3568 | |
3569 // Get superklass in rax and subklass in rdx | |
3570 __ bind(quicked); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3571 __ load_klass(rdx, rax); |
304 | 3572 __ movptr(rax, Address(rcx, rbx, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
3573 Address::times_8, sizeof(ConstantPool))); |
0 | 3574 |
3575 __ bind(resolved); | |
3576 | |
3577 // Generate subtype check. Blows rcx, rdi | |
3578 // Superklass in rax. Subklass in rdx. | |
3579 __ gen_subtype_check(rdx, ok_is_subtype); | |
3580 | |
3581 // Come here on failure | |
3582 __ xorl(rax, rax); | |
3583 __ jmpb(done); | |
3584 // Come here on success | |
3585 __ bind(ok_is_subtype); | |
3586 __ movl(rax, 1); | |
3587 | |
3588 // Collect counts on whether this test sees NULLs a lot or not. | |
3589 if (ProfileInterpreter) { | |
3590 __ jmp(done); | |
3591 __ bind(is_null); | |
3592 __ profile_null_seen(rcx); | |
3593 } else { | |
3594 __ bind(is_null); // same as 'done' | |
3595 } | |
3596 __ bind(done); | |
3597 // rax = 0: obj == NULL or obj is not an instanceof the specified klass | |
3598 // rax = 1: obj != NULL and obj is an instanceof the specified klass | |
3599 } | |
3600 | |
3601 //----------------------------------------------------------------------------- | |
3602 // Breakpoints | |
3603 void TemplateTable::_breakpoint() { | |
3604 // Note: We get here even if we are single stepping.. | |
3605 // jbug inists on setting breakpoints at every bytecode | |
3606 // even if we are in single step mode. | |
3607 | |
3608 transition(vtos, vtos); | |
3609 | |
3610 // get the unpatched byte code | |
3611 __ get_method(c_rarg1); | |
3612 __ call_VM(noreg, | |
3613 CAST_FROM_FN_PTR(address, | |
3614 InterpreterRuntime::get_original_bytecode_at), | |
3615 c_rarg1, r13); | |
304 | 3616 __ mov(rbx, rax); |
0 | 3617 |
3618 // post the breakpoint event | |
3619 __ get_method(c_rarg1); | |
3620 __ call_VM(noreg, | |
3621 CAST_FROM_FN_PTR(address, InterpreterRuntime::_breakpoint), | |
3622 c_rarg1, r13); | |
3623 | |
3624 // complete the execution of original bytecode | |
3625 __ dispatch_only_normal(vtos); | |
3626 } | |
3627 | |
3628 //----------------------------------------------------------------------------- | |
3629 // Exceptions | |
3630 | |
3631 void TemplateTable::athrow() { | |
3632 transition(atos, vtos); | |
3633 __ null_check(rax); | |
3634 __ jump(ExternalAddress(Interpreter::throw_exception_entry())); | |
3635 } | |
3636 | |
3637 //----------------------------------------------------------------------------- | |
3638 // Synchronization | |
3639 // | |
3640 // Note: monitorenter & exit are symmetric routines; which is reflected | |
3641 // in the assembly code structure as well | |
3642 // | |
3643 // Stack layout: | |
3644 // | |
3645 // [expressions ] <--- rsp = expression stack top | |
3646 // .. | |
3647 // [expressions ] | |
3648 // [monitor entry] <--- monitor block top = expression stack bot | |
3649 // .. | |
3650 // [monitor entry] | |
3651 // [frame data ] <--- monitor block bot | |
3652 // ... | |
3653 // [saved rbp ] <--- rbp | |
3654 void TemplateTable::monitorenter() { | |
3655 transition(atos, vtos); | |
3656 | |
3657 // check for NULL object | |
3658 __ null_check(rax); | |
3659 | |
3660 const Address monitor_block_top( | |
3661 rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
3662 const Address monitor_block_bot( | |
3663 rbp, frame::interpreter_frame_initial_sp_offset * wordSize); | |
3664 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
3665 | |
3666 Label allocated; | |
3667 | |
3668 // initialize entry pointer | |
3669 __ xorl(c_rarg1, c_rarg1); // points to free slot or NULL | |
3670 | |
3671 // find a free slot in the monitor block (result in c_rarg1) | |
3672 { | |
3673 Label entry, loop, exit; | |
304 | 3674 __ movptr(c_rarg3, monitor_block_top); // points to current entry, |
0 | 3675 // starting with top-most entry |
304 | 3676 __ lea(c_rarg2, monitor_block_bot); // points to word before bottom |
0 | 3677 // of monitor block |
3678 __ jmpb(entry); | |
3679 | |
3680 __ bind(loop); | |
3681 // check if current entry is used | |
304 | 3682 __ cmpptr(Address(c_rarg3, BasicObjectLock::obj_offset_in_bytes()), (int32_t) NULL_WORD); |
0 | 3683 // if not used then remember entry in c_rarg1 |
304 | 3684 __ cmov(Assembler::equal, c_rarg1, c_rarg3); |
0 | 3685 // check if current entry is for same object |
304 | 3686 __ cmpptr(rax, Address(c_rarg3, BasicObjectLock::obj_offset_in_bytes())); |
0 | 3687 // if same object then stop searching |
3688 __ jccb(Assembler::equal, exit); | |
3689 // otherwise advance to next entry | |
304 | 3690 __ addptr(c_rarg3, entry_size); |
0 | 3691 __ bind(entry); |
3692 // check if bottom reached | |
304 | 3693 __ cmpptr(c_rarg3, c_rarg2); |
0 | 3694 // if not at bottom then check this entry |
3695 __ jcc(Assembler::notEqual, loop); | |
3696 __ bind(exit); | |
3697 } | |
3698 | |
304 | 3699 __ testptr(c_rarg1, c_rarg1); // check if a slot has been found |
0 | 3700 __ jcc(Assembler::notZero, allocated); // if found, continue with that one |
3701 | |
3702 // allocate one if there's no free slot | |
3703 { | |
3704 Label entry, loop; | |
304 | 3705 // 1. compute new pointers // rsp: old expression stack top |
3706 __ movptr(c_rarg1, monitor_block_bot); // c_rarg1: old expression stack bottom | |
3707 __ subptr(rsp, entry_size); // move expression stack top | |
3708 __ subptr(c_rarg1, entry_size); // move expression stack bottom | |
3709 __ mov(c_rarg3, rsp); // set start value for copy loop | |
3710 __ movptr(monitor_block_bot, c_rarg1); // set new monitor block bottom | |
0 | 3711 __ jmp(entry); |
3712 // 2. move expression stack contents | |
3713 __ bind(loop); | |
304 | 3714 __ movptr(c_rarg2, Address(c_rarg3, entry_size)); // load expression stack |
3715 // word from old location | |
3716 __ movptr(Address(c_rarg3, 0), c_rarg2); // and store it at new location | |
3717 __ addptr(c_rarg3, wordSize); // advance to next word | |
0 | 3718 __ bind(entry); |
304 | 3719 __ cmpptr(c_rarg3, c_rarg1); // check if bottom reached |
0 | 3720 __ jcc(Assembler::notEqual, loop); // if not at bottom then |
3721 // copy next word | |
3722 } | |
3723 | |
3724 // call run-time routine | |
3725 // c_rarg1: points to monitor entry | |
3726 __ bind(allocated); | |
3727 | |
3728 // Increment bcp to point to the next bytecode, so exception | |
3729 // handling for async. exceptions work correctly. | |
3730 // The object has already been poped from the stack, so the | |
3731 // expression stack looks correct. | |
304 | 3732 __ increment(r13); |
0 | 3733 |
3734 // store object | |
304 | 3735 __ movptr(Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes()), rax); |
0 | 3736 __ lock_object(c_rarg1); |
3737 | |
3738 // check to make sure this monitor doesn't cause stack overflow after locking | |
3739 __ save_bcp(); // in case of exception | |
3740 __ generate_stack_overflow_check(0); | |
3741 | |
3742 // The bcp has already been incremented. Just need to dispatch to | |
3743 // next instruction. | |
3744 __ dispatch_next(vtos); | |
3745 } | |
3746 | |
3747 | |
3748 void TemplateTable::monitorexit() { | |
3749 transition(atos, vtos); | |
3750 | |
3751 // check for NULL object | |
3752 __ null_check(rax); | |
3753 | |
3754 const Address monitor_block_top( | |
3755 rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
3756 const Address monitor_block_bot( | |
3757 rbp, frame::interpreter_frame_initial_sp_offset * wordSize); | |
3758 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
3759 | |
3760 Label found; | |
3761 | |
3762 // find matching slot | |
3763 { | |
3764 Label entry, loop; | |
304 | 3765 __ movptr(c_rarg1, monitor_block_top); // points to current entry, |
0 | 3766 // starting with top-most entry |
304 | 3767 __ lea(c_rarg2, monitor_block_bot); // points to word before bottom |
0 | 3768 // of monitor block |
3769 __ jmpb(entry); | |
3770 | |
3771 __ bind(loop); | |
3772 // check if current entry is for same object | |
304 | 3773 __ cmpptr(rax, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes())); |
0 | 3774 // if same object then stop searching |
3775 __ jcc(Assembler::equal, found); | |
3776 // otherwise advance to next entry | |
304 | 3777 __ addptr(c_rarg1, entry_size); |
0 | 3778 __ bind(entry); |
3779 // check if bottom reached | |
304 | 3780 __ cmpptr(c_rarg1, c_rarg2); |
0 | 3781 // if not at bottom then check this entry |
3782 __ jcc(Assembler::notEqual, loop); | |
3783 } | |
3784 | |
3785 // error handling. Unlocking was not block-structured | |
3786 __ call_VM(noreg, CAST_FROM_FN_PTR(address, | |
3787 InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
3788 __ should_not_reach_here(); | |
3789 | |
3790 // call run-time routine | |
3791 // rsi: points to monitor entry | |
3792 __ bind(found); | |
3793 __ push_ptr(rax); // make sure object is on stack (contract with oopMaps) | |
3794 __ unlock_object(c_rarg1); | |
3795 __ pop_ptr(rax); // discard object | |
3796 } | |
3797 | |
3798 | |
3799 // Wide instructions | |
3800 void TemplateTable::wide() { | |
3801 transition(vtos, vtos); | |
3802 __ load_unsigned_byte(rbx, at_bcp(1)); | |
3803 __ lea(rscratch1, ExternalAddress((address)Interpreter::_wentry_point)); | |
3804 __ jmp(Address(rscratch1, rbx, Address::times_8)); | |
3805 // Note: the r13 increment step is part of the individual wide | |
3806 // bytecode implementations | |
3807 } | |
3808 | |
3809 | |
3810 // Multi arrays | |
3811 void TemplateTable::multianewarray() { | |
3812 transition(vtos, atos); | |
3813 __ load_unsigned_byte(rax, at_bcp(3)); // get number of dimensions | |
3814 // last dim is on top of stack; we want address of first one: | |
3815 // first_addr = last_addr + (ndims - 1) * wordSize | |
304 | 3816 __ lea(c_rarg1, Address(rsp, rax, Address::times_8, -wordSize)); |
0 | 3817 call_VM(rax, |
3818 CAST_FROM_FN_PTR(address, InterpreterRuntime::multianewarray), | |
3819 c_rarg1); | |
3820 __ load_unsigned_byte(rbx, at_bcp(3)); | |
304 | 3821 __ lea(rsp, Address(rsp, rbx, Address::times_8)); |
0 | 3822 } |
304 | 3823 #endif // !CC_INTERP |