Mercurial > hg > truffle
annotate src/cpu/sparc/vm/templateTable_sparc.cpp @ 1932:e6500c6c5e24
Removed launch configuration.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 21 Dec 2010 17:09:37 +0100 |
parents | 3b2dea75431e |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
2 * Copyright (c) 1997, 2010, 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 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_templateTable_sparc.cpp.incl" | |
27 | |
28 #ifndef CC_INTERP | |
29 #define __ _masm-> | |
30 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
31 // Misc helpers |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
32 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
33 // Do an oop store like *(base + index + offset) = val |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
34 // index can be noreg, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
35 static void do_oop_store(InterpreterMacroAssembler* _masm, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
36 Register base, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
37 Register index, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
38 int offset, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
39 Register val, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
40 Register tmp, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
41 BarrierSet::Name barrier, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
42 bool precise) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
43 assert(tmp != val && tmp != base && tmp != index, "register collision"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
44 assert(index == noreg || offset == 0, "only one offset"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
45 switch (barrier) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
46 #ifndef SERIALGC |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
47 case BarrierSet::G1SATBCT: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
48 case BarrierSet::G1SATBCTLogging: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
49 { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
50 __ g1_write_barrier_pre( base, index, offset, tmp, /*preserve_o_regs*/true); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
51 if (index == noreg ) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
52 assert(Assembler::is_simm13(offset), "fix this code"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
53 __ store_heap_oop(val, base, offset); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
54 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
55 __ store_heap_oop(val, base, index); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
56 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
57 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
58 // No need for post barrier if storing NULL |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
59 if (val != G0) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
60 if (precise) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
61 if (index == noreg) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
62 __ add(base, offset, base); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
63 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
64 __ add(base, index, base); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
65 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
66 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
67 __ g1_write_barrier_post(base, val, tmp); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
68 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
69 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
70 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
71 #endif // SERIALGC |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
72 case BarrierSet::CardTableModRef: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
73 case BarrierSet::CardTableExtension: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
74 { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
75 if (index == noreg ) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
76 assert(Assembler::is_simm13(offset), "fix this code"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
77 __ store_heap_oop(val, base, offset); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
78 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
79 __ store_heap_oop(val, base, index); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
80 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
81 // No need for post barrier if storing NULL |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
82 if (val != G0) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
83 if (precise) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
84 if (index == noreg) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
85 __ add(base, offset, base); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
86 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
87 __ add(base, index, base); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
88 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
89 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
90 __ card_write_barrier_post(base, val, tmp); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
91 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
92 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
93 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
94 case BarrierSet::ModRef: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
95 case BarrierSet::Other: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
96 ShouldNotReachHere(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
97 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
98 default : |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
99 ShouldNotReachHere(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
100 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
101 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
102 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
103 |
0 | 104 |
105 //---------------------------------------------------------------------------------------------------- | |
106 // Platform-dependent initialization | |
107 | |
108 void TemplateTable::pd_initialize() { | |
109 // (none) | |
110 } | |
111 | |
112 | |
113 //---------------------------------------------------------------------------------------------------- | |
114 // Condition conversion | |
115 Assembler::Condition ccNot(TemplateTable::Condition cc) { | |
116 switch (cc) { | |
117 case TemplateTable::equal : return Assembler::notEqual; | |
118 case TemplateTable::not_equal : return Assembler::equal; | |
119 case TemplateTable::less : return Assembler::greaterEqual; | |
120 case TemplateTable::less_equal : return Assembler::greater; | |
121 case TemplateTable::greater : return Assembler::lessEqual; | |
122 case TemplateTable::greater_equal: return Assembler::less; | |
123 } | |
124 ShouldNotReachHere(); | |
125 return Assembler::zero; | |
126 } | |
127 | |
128 //---------------------------------------------------------------------------------------------------- | |
129 // Miscelaneous helper routines | |
130 | |
131 | |
132 Address TemplateTable::at_bcp(int offset) { | |
133 assert(_desc->uses_bcp(), "inconsistent uses_bcp information"); | |
727 | 134 return Address(Lbcp, offset); |
0 | 135 } |
136 | |
137 | |
138 void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register Rbyte_code, | |
139 Register Rscratch, | |
140 bool load_bc_into_scratch /*=true*/) { | |
141 // With sharing on, may need to test methodOop flag. | |
142 if (!RewriteBytecodes) return; | |
143 if (load_bc_into_scratch) __ set(bc, Rbyte_code); | |
144 Label patch_done; | |
145 if (JvmtiExport::can_post_breakpoint()) { | |
146 Label fast_patch; | |
147 __ ldub(at_bcp(0), Rscratch); | |
148 __ cmp(Rscratch, Bytecodes::_breakpoint); | |
149 __ br(Assembler::notEqual, false, Assembler::pt, fast_patch); | |
150 __ delayed()->nop(); // don't bother to hoist the stb here | |
151 // perform the quickening, slowly, in the bowels of the breakpoint table | |
152 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::set_original_bytecode_at), Lmethod, Lbcp, Rbyte_code); | |
153 __ ba(false, patch_done); | |
154 __ delayed()->nop(); | |
155 __ bind(fast_patch); | |
156 } | |
157 #ifdef ASSERT | |
158 Bytecodes::Code orig_bytecode = Bytecodes::java_code(bc); | |
159 Label okay; | |
160 __ ldub(at_bcp(0), Rscratch); | |
161 __ cmp(Rscratch, orig_bytecode); | |
162 __ br(Assembler::equal, false, Assembler::pt, okay); | |
163 __ delayed() ->cmp(Rscratch, Rbyte_code); | |
164 __ br(Assembler::equal, false, Assembler::pt, okay); | |
165 __ delayed()->nop(); | |
166 __ stop("Rewriting wrong bytecode location"); | |
167 __ bind(okay); | |
168 #endif | |
169 __ stb(Rbyte_code, at_bcp(0)); | |
170 __ bind(patch_done); | |
171 } | |
172 | |
173 //---------------------------------------------------------------------------------------------------- | |
174 // Individual instructions | |
175 | |
176 void TemplateTable::nop() { | |
177 transition(vtos, vtos); | |
178 // nothing to do | |
179 } | |
180 | |
181 void TemplateTable::shouldnotreachhere() { | |
182 transition(vtos, vtos); | |
183 __ stop("shouldnotreachhere bytecode"); | |
184 } | |
185 | |
186 void TemplateTable::aconst_null() { | |
187 transition(vtos, atos); | |
188 __ clr(Otos_i); | |
189 } | |
190 | |
191 | |
192 void TemplateTable::iconst(int value) { | |
193 transition(vtos, itos); | |
194 __ set(value, Otos_i); | |
195 } | |
196 | |
197 | |
198 void TemplateTable::lconst(int value) { | |
199 transition(vtos, ltos); | |
200 assert(value >= 0, "check this code"); | |
201 #ifdef _LP64 | |
202 __ set(value, Otos_l); | |
203 #else | |
204 __ set(value, Otos_l2); | |
205 __ clr( Otos_l1); | |
206 #endif | |
207 } | |
208 | |
209 | |
210 void TemplateTable::fconst(int value) { | |
211 transition(vtos, ftos); | |
212 static float zero = 0.0, one = 1.0, two = 2.0; | |
213 float* p; | |
214 switch( value ) { | |
215 default: ShouldNotReachHere(); | |
216 case 0: p = &zero; break; | |
217 case 1: p = &one; break; | |
218 case 2: p = &two; break; | |
219 } | |
727 | 220 AddressLiteral a(p); |
221 __ sethi(a, G3_scratch); | |
222 __ ldf(FloatRegisterImpl::S, G3_scratch, a.low10(), Ftos_f); | |
0 | 223 } |
224 | |
225 | |
226 void TemplateTable::dconst(int value) { | |
227 transition(vtos, dtos); | |
228 static double zero = 0.0, one = 1.0; | |
229 double* p; | |
230 switch( value ) { | |
231 default: ShouldNotReachHere(); | |
232 case 0: p = &zero; break; | |
233 case 1: p = &one; break; | |
234 } | |
727 | 235 AddressLiteral a(p); |
236 __ sethi(a, G3_scratch); | |
237 __ ldf(FloatRegisterImpl::D, G3_scratch, a.low10(), Ftos_d); | |
0 | 238 } |
239 | |
240 | |
241 // %%%%% Should factore most snippet templates across platforms | |
242 | |
243 void TemplateTable::bipush() { | |
244 transition(vtos, itos); | |
245 __ ldsb( at_bcp(1), Otos_i ); | |
246 } | |
247 | |
248 void TemplateTable::sipush() { | |
249 transition(vtos, itos); | |
250 __ get_2_byte_integer_at_bcp(1, G3_scratch, Otos_i, InterpreterMacroAssembler::Signed); | |
251 } | |
252 | |
253 void TemplateTable::ldc(bool wide) { | |
254 transition(vtos, vtos); | |
255 Label call_ldc, notInt, notString, notClass, exit; | |
256 | |
257 if (wide) { | |
258 __ get_2_byte_integer_at_bcp(1, G3_scratch, O1, InterpreterMacroAssembler::Unsigned); | |
259 } else { | |
260 __ ldub(Lbcp, 1, O1); | |
261 } | |
262 __ get_cpool_and_tags(O0, O2); | |
263 | |
264 const int base_offset = constantPoolOopDesc::header_size() * wordSize; | |
265 const int tags_offset = typeArrayOopDesc::header_size(T_BYTE) * wordSize; | |
266 | |
267 // get type from tags | |
268 __ add(O2, tags_offset, O2); | |
269 __ ldub(O2, O1, O2); | |
270 __ cmp(O2, JVM_CONSTANT_UnresolvedString); // unresolved string? If so, must resolve | |
271 __ brx(Assembler::equal, true, Assembler::pt, call_ldc); | |
272 __ delayed()->nop(); | |
273 | |
274 __ cmp(O2, JVM_CONSTANT_UnresolvedClass); // unresolved class? If so, must resolve | |
275 __ brx(Assembler::equal, true, Assembler::pt, call_ldc); | |
276 __ delayed()->nop(); | |
277 | |
278 __ cmp(O2, JVM_CONSTANT_UnresolvedClassInError); // unresolved class in error state | |
279 __ brx(Assembler::equal, true, Assembler::pn, call_ldc); | |
280 __ delayed()->nop(); | |
281 | |
282 __ cmp(O2, JVM_CONSTANT_Class); // need to call vm to get java mirror of the class | |
283 __ brx(Assembler::notEqual, true, Assembler::pt, notClass); | |
284 __ delayed()->add(O0, base_offset, O0); | |
285 | |
286 __ bind(call_ldc); | |
287 __ set(wide, O1); | |
288 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), O1); | |
289 __ push(atos); | |
290 __ ba(false, exit); | |
291 __ delayed()->nop(); | |
292 | |
293 __ bind(notClass); | |
294 // __ add(O0, base_offset, O0); | |
295 __ sll(O1, LogBytesPerWord, O1); | |
296 __ cmp(O2, JVM_CONSTANT_Integer); | |
297 __ brx(Assembler::notEqual, true, Assembler::pt, notInt); | |
298 __ delayed()->cmp(O2, JVM_CONSTANT_String); | |
299 __ ld(O0, O1, Otos_i); | |
300 __ push(itos); | |
301 __ ba(false, exit); | |
302 __ delayed()->nop(); | |
303 | |
304 __ bind(notInt); | |
305 // __ cmp(O2, JVM_CONSTANT_String); | |
306 __ brx(Assembler::notEqual, true, Assembler::pt, notString); | |
307 __ delayed()->ldf(FloatRegisterImpl::S, O0, O1, Ftos_f); | |
308 __ ld_ptr(O0, O1, Otos_i); | |
309 __ verify_oop(Otos_i); | |
310 __ push(atos); | |
311 __ ba(false, exit); | |
312 __ delayed()->nop(); | |
313 | |
314 __ bind(notString); | |
315 // __ ldf(FloatRegisterImpl::S, O0, O1, Ftos_f); | |
316 __ push(ftos); | |
317 | |
318 __ bind(exit); | |
319 } | |
320 | |
1602 | 321 // Fast path for caching oop constants. |
322 // %%% We should use this to handle Class and String constants also. | |
323 // %%% It will simplify the ldc/primitive path considerably. | |
324 void TemplateTable::fast_aldc(bool wide) { | |
325 transition(vtos, atos); | |
326 | |
327 if (!EnableMethodHandles) { | |
328 // We should not encounter this bytecode if !EnableMethodHandles. | |
329 // The verifier will stop it. However, if we get past the verifier, | |
330 // this will stop the thread in a reasonable way, without crashing the JVM. | |
331 __ call_VM(noreg, CAST_FROM_FN_PTR(address, | |
332 InterpreterRuntime::throw_IncompatibleClassChangeError)); | |
333 // the call_VM checks for exception, so we should never return here. | |
334 __ should_not_reach_here(); | |
335 return; | |
336 } | |
337 | |
338 Register Rcache = G3_scratch; | |
339 Register Rscratch = G4_scratch; | |
340 | |
341 resolve_cache_and_index(f1_oop, Otos_i, Rcache, Rscratch, wide ? sizeof(u2) : sizeof(u1)); | |
342 | |
343 __ verify_oop(Otos_i); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
344 |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
345 Label L_done; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
346 const Register Rcon_klass = G3_scratch; // same as Rcache |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
347 const Register Rarray_klass = G4_scratch; // same as Rscratch |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
348 __ load_klass(Otos_i, Rcon_klass); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
349 AddressLiteral array_klass_addr((address)Universe::systemObjArrayKlassObj_addr()); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
350 __ load_contents(array_klass_addr, Rarray_klass); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
351 __ cmp(Rarray_klass, Rcon_klass); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
352 __ brx(Assembler::notEqual, false, Assembler::pt, L_done); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
353 __ delayed()->nop(); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
354 __ ld(Address(Otos_i, arrayOopDesc::length_offset_in_bytes()), Rcon_klass); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
355 __ tst(Rcon_klass); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
356 __ brx(Assembler::zero, true, Assembler::pt, L_done); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
357 __ delayed()->clr(Otos_i); // executed only if branch is taken |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
358 |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
359 // Load the exception from the system-array which wraps it: |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
360 __ load_heap_oop(Otos_i, arrayOopDesc::base_offset_in_bytes(T_OBJECT), Otos_i); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
361 __ throw_if_not_x(Assembler::never, Interpreter::throw_exception_entry(), G3_scratch); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
362 |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
363 __ bind(L_done); |
1602 | 364 } |
365 | |
0 | 366 void TemplateTable::ldc2_w() { |
367 transition(vtos, vtos); | |
368 Label retry, resolved, Long, exit; | |
369 | |
370 __ bind(retry); | |
371 __ get_2_byte_integer_at_bcp(1, G3_scratch, O1, InterpreterMacroAssembler::Unsigned); | |
372 __ get_cpool_and_tags(O0, O2); | |
373 | |
374 const int base_offset = constantPoolOopDesc::header_size() * wordSize; | |
375 const int tags_offset = typeArrayOopDesc::header_size(T_BYTE) * wordSize; | |
376 // get type from tags | |
377 __ add(O2, tags_offset, O2); | |
378 __ ldub(O2, O1, O2); | |
379 | |
380 __ sll(O1, LogBytesPerWord, O1); | |
381 __ add(O0, O1, G3_scratch); | |
382 | |
383 __ cmp(O2, JVM_CONSTANT_Double); | |
384 __ brx(Assembler::notEqual, false, Assembler::pt, Long); | |
385 __ delayed()->nop(); | |
386 // A double can be placed at word-aligned locations in the constant pool. | |
387 // Check out Conversions.java for an example. | |
388 // Also constantPoolOopDesc::header_size() is 20, which makes it very difficult | |
389 // to double-align double on the constant pool. SG, 11/7/97 | |
390 #ifdef _LP64 | |
391 __ ldf(FloatRegisterImpl::D, G3_scratch, base_offset, Ftos_d); | |
392 #else | |
393 FloatRegister f = Ftos_d; | |
394 __ ldf(FloatRegisterImpl::S, G3_scratch, base_offset, f); | |
395 __ ldf(FloatRegisterImpl::S, G3_scratch, base_offset + sizeof(jdouble)/2, | |
396 f->successor()); | |
397 #endif | |
398 __ push(dtos); | |
399 __ ba(false, exit); | |
400 __ delayed()->nop(); | |
401 | |
402 __ bind(Long); | |
403 #ifdef _LP64 | |
404 __ ldx(G3_scratch, base_offset, Otos_l); | |
405 #else | |
406 __ ld(G3_scratch, base_offset, Otos_l); | |
407 __ ld(G3_scratch, base_offset + sizeof(jlong)/2, Otos_l->successor()); | |
408 #endif | |
409 __ push(ltos); | |
410 | |
411 __ bind(exit); | |
412 } | |
413 | |
414 | |
415 void TemplateTable::locals_index(Register reg, int offset) { | |
416 __ ldub( at_bcp(offset), reg ); | |
417 } | |
418 | |
419 | |
420 void TemplateTable::locals_index_wide(Register reg) { | |
421 // offset is 2, not 1, because Lbcp points to wide prefix code | |
422 __ get_2_byte_integer_at_bcp(2, G4_scratch, reg, InterpreterMacroAssembler::Unsigned); | |
423 } | |
424 | |
425 void TemplateTable::iload() { | |
426 transition(vtos, itos); | |
427 // Rewrite iload,iload pair into fast_iload2 | |
428 // iload,caload pair into fast_icaload | |
429 if (RewriteFrequentPairs) { | |
430 Label rewrite, done; | |
431 | |
432 // get next byte | |
433 __ ldub(at_bcp(Bytecodes::length_for(Bytecodes::_iload)), G3_scratch); | |
434 | |
435 // if _iload, wait to rewrite to iload2. We only want to rewrite the | |
436 // last two iloads in a pair. Comparing against fast_iload means that | |
437 // the next bytecode is neither an iload or a caload, and therefore | |
438 // an iload pair. | |
439 __ cmp(G3_scratch, (int)Bytecodes::_iload); | |
440 __ br(Assembler::equal, false, Assembler::pn, done); | |
441 __ delayed()->nop(); | |
442 | |
443 __ cmp(G3_scratch, (int)Bytecodes::_fast_iload); | |
444 __ br(Assembler::equal, false, Assembler::pn, rewrite); | |
445 __ delayed()->set(Bytecodes::_fast_iload2, G4_scratch); | |
446 | |
447 __ cmp(G3_scratch, (int)Bytecodes::_caload); | |
448 __ br(Assembler::equal, false, Assembler::pn, rewrite); | |
449 __ delayed()->set(Bytecodes::_fast_icaload, G4_scratch); | |
450 | |
451 __ set(Bytecodes::_fast_iload, G4_scratch); // don't check again | |
452 // rewrite | |
453 // G4_scratch: fast bytecode | |
454 __ bind(rewrite); | |
455 patch_bytecode(Bytecodes::_iload, G4_scratch, G3_scratch, false); | |
456 __ bind(done); | |
457 } | |
458 | |
459 // Get the local value into tos | |
460 locals_index(G3_scratch); | |
461 __ access_local_int( G3_scratch, Otos_i ); | |
462 } | |
463 | |
464 void TemplateTable::fast_iload2() { | |
465 transition(vtos, itos); | |
466 locals_index(G3_scratch); | |
467 __ access_local_int( G3_scratch, Otos_i ); | |
468 __ push_i(); | |
469 locals_index(G3_scratch, 3); // get next bytecode's local index. | |
470 __ access_local_int( G3_scratch, Otos_i ); | |
471 } | |
472 | |
473 void TemplateTable::fast_iload() { | |
474 transition(vtos, itos); | |
475 locals_index(G3_scratch); | |
476 __ access_local_int( G3_scratch, Otos_i ); | |
477 } | |
478 | |
479 void TemplateTable::lload() { | |
480 transition(vtos, ltos); | |
481 locals_index(G3_scratch); | |
482 __ access_local_long( G3_scratch, Otos_l ); | |
483 } | |
484 | |
485 | |
486 void TemplateTable::fload() { | |
487 transition(vtos, ftos); | |
488 locals_index(G3_scratch); | |
489 __ access_local_float( G3_scratch, Ftos_f ); | |
490 } | |
491 | |
492 | |
493 void TemplateTable::dload() { | |
494 transition(vtos, dtos); | |
495 locals_index(G3_scratch); | |
496 __ access_local_double( G3_scratch, Ftos_d ); | |
497 } | |
498 | |
499 | |
500 void TemplateTable::aload() { | |
501 transition(vtos, atos); | |
502 locals_index(G3_scratch); | |
503 __ access_local_ptr( G3_scratch, Otos_i); | |
504 } | |
505 | |
506 | |
507 void TemplateTable::wide_iload() { | |
508 transition(vtos, itos); | |
509 locals_index_wide(G3_scratch); | |
510 __ access_local_int( G3_scratch, Otos_i ); | |
511 } | |
512 | |
513 | |
514 void TemplateTable::wide_lload() { | |
515 transition(vtos, ltos); | |
516 locals_index_wide(G3_scratch); | |
517 __ access_local_long( G3_scratch, Otos_l ); | |
518 } | |
519 | |
520 | |
521 void TemplateTable::wide_fload() { | |
522 transition(vtos, ftos); | |
523 locals_index_wide(G3_scratch); | |
524 __ access_local_float( G3_scratch, Ftos_f ); | |
525 } | |
526 | |
527 | |
528 void TemplateTable::wide_dload() { | |
529 transition(vtos, dtos); | |
530 locals_index_wide(G3_scratch); | |
531 __ access_local_double( G3_scratch, Ftos_d ); | |
532 } | |
533 | |
534 | |
535 void TemplateTable::wide_aload() { | |
536 transition(vtos, atos); | |
537 locals_index_wide(G3_scratch); | |
538 __ access_local_ptr( G3_scratch, Otos_i ); | |
539 __ verify_oop(Otos_i); | |
540 } | |
541 | |
542 | |
543 void TemplateTable::iaload() { | |
544 transition(itos, itos); | |
545 // Otos_i: index | |
546 // tos: array | |
547 __ index_check(O2, Otos_i, LogBytesPerInt, G3_scratch, O3); | |
548 __ ld(O3, arrayOopDesc::base_offset_in_bytes(T_INT), Otos_i); | |
549 } | |
550 | |
551 | |
552 void TemplateTable::laload() { | |
553 transition(itos, ltos); | |
554 // Otos_i: index | |
555 // O2: array | |
556 __ index_check(O2, Otos_i, LogBytesPerLong, G3_scratch, O3); | |
557 __ ld_long(O3, arrayOopDesc::base_offset_in_bytes(T_LONG), Otos_l); | |
558 } | |
559 | |
560 | |
561 void TemplateTable::faload() { | |
562 transition(itos, ftos); | |
563 // Otos_i: index | |
564 // O2: array | |
565 __ index_check(O2, Otos_i, LogBytesPerInt, G3_scratch, O3); | |
566 __ ldf(FloatRegisterImpl::S, O3, arrayOopDesc::base_offset_in_bytes(T_FLOAT), Ftos_f); | |
567 } | |
568 | |
569 | |
570 void TemplateTable::daload() { | |
571 transition(itos, dtos); | |
572 // Otos_i: index | |
573 // O2: array | |
574 __ index_check(O2, Otos_i, LogBytesPerLong, G3_scratch, O3); | |
575 __ ldf(FloatRegisterImpl::D, O3, arrayOopDesc::base_offset_in_bytes(T_DOUBLE), Ftos_d); | |
576 } | |
577 | |
578 | |
579 void TemplateTable::aaload() { | |
580 transition(itos, atos); | |
581 // Otos_i: index | |
582 // tos: array | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
583 __ index_check(O2, Otos_i, UseCompressedOops ? 2 : LogBytesPerWord, G3_scratch, O3); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
584 __ load_heap_oop(O3, arrayOopDesc::base_offset_in_bytes(T_OBJECT), Otos_i); |
0 | 585 __ verify_oop(Otos_i); |
586 } | |
587 | |
588 | |
589 void TemplateTable::baload() { | |
590 transition(itos, itos); | |
591 // Otos_i: index | |
592 // tos: array | |
593 __ index_check(O2, Otos_i, 0, G3_scratch, O3); | |
594 __ ldsb(O3, arrayOopDesc::base_offset_in_bytes(T_BYTE), Otos_i); | |
595 } | |
596 | |
597 | |
598 void TemplateTable::caload() { | |
599 transition(itos, itos); | |
600 // Otos_i: index | |
601 // tos: array | |
602 __ index_check(O2, Otos_i, LogBytesPerShort, G3_scratch, O3); | |
603 __ lduh(O3, arrayOopDesc::base_offset_in_bytes(T_CHAR), Otos_i); | |
604 } | |
605 | |
606 void TemplateTable::fast_icaload() { | |
607 transition(vtos, itos); | |
608 // Otos_i: index | |
609 // tos: array | |
610 locals_index(G3_scratch); | |
611 __ access_local_int( G3_scratch, Otos_i ); | |
612 __ index_check(O2, Otos_i, LogBytesPerShort, G3_scratch, O3); | |
613 __ lduh(O3, arrayOopDesc::base_offset_in_bytes(T_CHAR), Otos_i); | |
614 } | |
615 | |
616 | |
617 void TemplateTable::saload() { | |
618 transition(itos, itos); | |
619 // Otos_i: index | |
620 // tos: array | |
621 __ index_check(O2, Otos_i, LogBytesPerShort, G3_scratch, O3); | |
622 __ ldsh(O3, arrayOopDesc::base_offset_in_bytes(T_SHORT), Otos_i); | |
623 } | |
624 | |
625 | |
626 void TemplateTable::iload(int n) { | |
627 transition(vtos, itos); | |
628 __ ld( Llocals, Interpreter::local_offset_in_bytes(n), Otos_i ); | |
629 } | |
630 | |
631 | |
632 void TemplateTable::lload(int n) { | |
633 transition(vtos, ltos); | |
634 assert(n+1 < Argument::n_register_parameters, "would need more code"); | |
635 __ load_unaligned_long(Llocals, Interpreter::local_offset_in_bytes(n+1), Otos_l); | |
636 } | |
637 | |
638 | |
639 void TemplateTable::fload(int n) { | |
640 transition(vtos, ftos); | |
641 assert(n < Argument::n_register_parameters, "would need more code"); | |
642 __ ldf( FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(n), Ftos_f ); | |
643 } | |
644 | |
645 | |
646 void TemplateTable::dload(int n) { | |
647 transition(vtos, dtos); | |
648 FloatRegister dst = Ftos_d; | |
649 __ load_unaligned_double(Llocals, Interpreter::local_offset_in_bytes(n+1), dst); | |
650 } | |
651 | |
652 | |
653 void TemplateTable::aload(int n) { | |
654 transition(vtos, atos); | |
655 __ ld_ptr( Llocals, Interpreter::local_offset_in_bytes(n), Otos_i ); | |
656 } | |
657 | |
658 | |
659 void TemplateTable::aload_0() { | |
660 transition(vtos, atos); | |
661 | |
662 // According to bytecode histograms, the pairs: | |
663 // | |
664 // _aload_0, _fast_igetfield (itos) | |
665 // _aload_0, _fast_agetfield (atos) | |
666 // _aload_0, _fast_fgetfield (ftos) | |
667 // | |
668 // occur frequently. If RewriteFrequentPairs is set, the (slow) _aload_0 | |
669 // bytecode checks the next bytecode and then rewrites the current | |
670 // bytecode into a pair bytecode; otherwise it rewrites the current | |
671 // bytecode into _fast_aload_0 that doesn't do the pair check anymore. | |
672 // | |
673 if (RewriteFrequentPairs) { | |
674 Label rewrite, done; | |
675 | |
676 // get next byte | |
677 __ ldub(at_bcp(Bytecodes::length_for(Bytecodes::_aload_0)), G3_scratch); | |
678 | |
679 // do actual aload_0 | |
680 aload(0); | |
681 | |
682 // if _getfield then wait with rewrite | |
683 __ cmp(G3_scratch, (int)Bytecodes::_getfield); | |
684 __ br(Assembler::equal, false, Assembler::pn, done); | |
685 __ delayed()->nop(); | |
686 | |
687 // if _igetfield then rewrite to _fast_iaccess_0 | |
688 assert(Bytecodes::java_code(Bytecodes::_fast_iaccess_0) == Bytecodes::_aload_0, "adjust fast bytecode def"); | |
689 __ cmp(G3_scratch, (int)Bytecodes::_fast_igetfield); | |
690 __ br(Assembler::equal, false, Assembler::pn, rewrite); | |
691 __ delayed()->set(Bytecodes::_fast_iaccess_0, G4_scratch); | |
692 | |
693 // if _agetfield then rewrite to _fast_aaccess_0 | |
694 assert(Bytecodes::java_code(Bytecodes::_fast_aaccess_0) == Bytecodes::_aload_0, "adjust fast bytecode def"); | |
695 __ cmp(G3_scratch, (int)Bytecodes::_fast_agetfield); | |
696 __ br(Assembler::equal, false, Assembler::pn, rewrite); | |
697 __ delayed()->set(Bytecodes::_fast_aaccess_0, G4_scratch); | |
698 | |
699 // if _fgetfield then rewrite to _fast_faccess_0 | |
700 assert(Bytecodes::java_code(Bytecodes::_fast_faccess_0) == Bytecodes::_aload_0, "adjust fast bytecode def"); | |
701 __ cmp(G3_scratch, (int)Bytecodes::_fast_fgetfield); | |
702 __ br(Assembler::equal, false, Assembler::pn, rewrite); | |
703 __ delayed()->set(Bytecodes::_fast_faccess_0, G4_scratch); | |
704 | |
705 // else rewrite to _fast_aload0 | |
706 assert(Bytecodes::java_code(Bytecodes::_fast_aload_0) == Bytecodes::_aload_0, "adjust fast bytecode def"); | |
707 __ set(Bytecodes::_fast_aload_0, G4_scratch); | |
708 | |
709 // rewrite | |
710 // G4_scratch: fast bytecode | |
711 __ bind(rewrite); | |
712 patch_bytecode(Bytecodes::_aload_0, G4_scratch, G3_scratch, false); | |
713 __ bind(done); | |
714 } else { | |
715 aload(0); | |
716 } | |
717 } | |
718 | |
719 | |
720 void TemplateTable::istore() { | |
721 transition(itos, vtos); | |
722 locals_index(G3_scratch); | |
723 __ store_local_int( G3_scratch, Otos_i ); | |
724 } | |
725 | |
726 | |
727 void TemplateTable::lstore() { | |
728 transition(ltos, vtos); | |
729 locals_index(G3_scratch); | |
730 __ store_local_long( G3_scratch, Otos_l ); | |
731 } | |
732 | |
733 | |
734 void TemplateTable::fstore() { | |
735 transition(ftos, vtos); | |
736 locals_index(G3_scratch); | |
737 __ store_local_float( G3_scratch, Ftos_f ); | |
738 } | |
739 | |
740 | |
741 void TemplateTable::dstore() { | |
742 transition(dtos, vtos); | |
743 locals_index(G3_scratch); | |
744 __ store_local_double( G3_scratch, Ftos_d ); | |
745 } | |
746 | |
747 | |
748 void TemplateTable::astore() { | |
749 transition(vtos, vtos); | |
1506 | 750 __ load_ptr(0, Otos_i); |
751 __ inc(Lesp, Interpreter::stackElementSize); | |
0 | 752 __ verify_oop_or_return_address(Otos_i, G3_scratch); |
753 locals_index(G3_scratch); | |
1506 | 754 __ store_local_ptr(G3_scratch, Otos_i); |
0 | 755 } |
756 | |
757 | |
758 void TemplateTable::wide_istore() { | |
759 transition(vtos, vtos); | |
760 __ pop_i(); | |
761 locals_index_wide(G3_scratch); | |
762 __ store_local_int( G3_scratch, Otos_i ); | |
763 } | |
764 | |
765 | |
766 void TemplateTable::wide_lstore() { | |
767 transition(vtos, vtos); | |
768 __ pop_l(); | |
769 locals_index_wide(G3_scratch); | |
770 __ store_local_long( G3_scratch, Otos_l ); | |
771 } | |
772 | |
773 | |
774 void TemplateTable::wide_fstore() { | |
775 transition(vtos, vtos); | |
776 __ pop_f(); | |
777 locals_index_wide(G3_scratch); | |
778 __ store_local_float( G3_scratch, Ftos_f ); | |
779 } | |
780 | |
781 | |
782 void TemplateTable::wide_dstore() { | |
783 transition(vtos, vtos); | |
784 __ pop_d(); | |
785 locals_index_wide(G3_scratch); | |
786 __ store_local_double( G3_scratch, Ftos_d ); | |
787 } | |
788 | |
789 | |
790 void TemplateTable::wide_astore() { | |
791 transition(vtos, vtos); | |
1506 | 792 __ load_ptr(0, Otos_i); |
793 __ inc(Lesp, Interpreter::stackElementSize); | |
0 | 794 __ verify_oop_or_return_address(Otos_i, G3_scratch); |
795 locals_index_wide(G3_scratch); | |
1506 | 796 __ store_local_ptr(G3_scratch, Otos_i); |
0 | 797 } |
798 | |
799 | |
800 void TemplateTable::iastore() { | |
801 transition(itos, vtos); | |
802 __ pop_i(O2); // index | |
803 // Otos_i: val | |
804 // O3: array | |
805 __ index_check(O3, O2, LogBytesPerInt, G3_scratch, O2); | |
806 __ st(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_INT)); | |
807 } | |
808 | |
809 | |
810 void TemplateTable::lastore() { | |
811 transition(ltos, vtos); | |
812 __ pop_i(O2); // index | |
813 // Otos_l: val | |
814 // O3: array | |
815 __ index_check(O3, O2, LogBytesPerLong, G3_scratch, O2); | |
816 __ st_long(Otos_l, O2, arrayOopDesc::base_offset_in_bytes(T_LONG)); | |
817 } | |
818 | |
819 | |
820 void TemplateTable::fastore() { | |
821 transition(ftos, vtos); | |
822 __ pop_i(O2); // index | |
823 // Ftos_f: val | |
824 // O3: array | |
825 __ index_check(O3, O2, LogBytesPerInt, G3_scratch, O2); | |
826 __ stf(FloatRegisterImpl::S, Ftos_f, O2, arrayOopDesc::base_offset_in_bytes(T_FLOAT)); | |
827 } | |
828 | |
829 | |
830 void TemplateTable::dastore() { | |
831 transition(dtos, vtos); | |
832 __ pop_i(O2); // index | |
833 // Fos_d: val | |
834 // O3: array | |
835 __ index_check(O3, O2, LogBytesPerLong, G3_scratch, O2); | |
836 __ stf(FloatRegisterImpl::D, Ftos_d, O2, arrayOopDesc::base_offset_in_bytes(T_DOUBLE)); | |
837 } | |
838 | |
839 | |
840 void TemplateTable::aastore() { | |
841 Label store_ok, is_null, done; | |
842 transition(vtos, vtos); | |
843 __ ld_ptr(Lesp, Interpreter::expr_offset_in_bytes(0), Otos_i); | |
844 __ ld(Lesp, Interpreter::expr_offset_in_bytes(1), O2); // get index | |
845 __ ld_ptr(Lesp, Interpreter::expr_offset_in_bytes(2), O3); // get array | |
846 // Otos_i: val | |
847 // O2: index | |
848 // O3: array | |
849 __ verify_oop(Otos_i); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
850 __ index_check_without_pop(O3, O2, UseCompressedOops ? 2 : LogBytesPerWord, G3_scratch, O1); |
0 | 851 |
852 // do array store check - check for NULL value first | |
853 __ br_null( Otos_i, false, Assembler::pn, is_null ); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
854 __ delayed()->nop(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
855 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
856 __ load_klass(O3, O4); // get array klass |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
857 __ load_klass(Otos_i, O5); // get value klass |
0 | 858 |
859 // do fast instanceof cache test | |
860 | |
861 __ ld_ptr(O4, sizeof(oopDesc) + objArrayKlass::element_klass_offset_in_bytes(), O4); | |
862 | |
863 assert(Otos_i == O0, "just checking"); | |
864 | |
865 // Otos_i: value | |
866 // O1: addr - offset | |
867 // O2: index | |
868 // O3: array | |
869 // O4: array element klass | |
870 // O5: value klass | |
871 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
872 // Address element(O1, 0, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
873 |
0 | 874 // Generate a fast subtype check. Branch to store_ok if no |
875 // failure. Throw if failure. | |
876 __ gen_subtype_check( O5, O4, G3_scratch, G4_scratch, G1_scratch, store_ok ); | |
877 | |
878 // Not a subtype; so must throw exception | |
879 __ throw_if_not_x( Assembler::never, Interpreter::_throw_ArrayStoreException_entry, G3_scratch ); | |
880 | |
881 // Store is OK. | |
882 __ bind(store_ok); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
883 do_oop_store(_masm, O1, noreg, arrayOopDesc::base_offset_in_bytes(T_OBJECT), Otos_i, G3_scratch, _bs->kind(), true); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
884 |
0 | 885 __ ba(false,done); |
1506 | 886 __ delayed()->inc(Lesp, 3* Interpreter::stackElementSize); // adj sp (pops array, index and value) |
0 | 887 |
888 __ bind(is_null); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
889 do_oop_store(_masm, O1, noreg, arrayOopDesc::base_offset_in_bytes(T_OBJECT), G0, G4_scratch, _bs->kind(), true); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
890 |
0 | 891 __ profile_null_seen(G3_scratch); |
1506 | 892 __ inc(Lesp, 3* Interpreter::stackElementSize); // adj sp (pops array, index and value) |
0 | 893 __ bind(done); |
894 } | |
895 | |
896 | |
897 void TemplateTable::bastore() { | |
898 transition(itos, vtos); | |
899 __ pop_i(O2); // index | |
900 // Otos_i: val | |
901 // O3: array | |
902 __ index_check(O3, O2, 0, G3_scratch, O2); | |
903 __ stb(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_BYTE)); | |
904 } | |
905 | |
906 | |
907 void TemplateTable::castore() { | |
908 transition(itos, vtos); | |
909 __ pop_i(O2); // index | |
910 // Otos_i: val | |
911 // O3: array | |
912 __ index_check(O3, O2, LogBytesPerShort, G3_scratch, O2); | |
913 __ sth(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_CHAR)); | |
914 } | |
915 | |
916 | |
917 void TemplateTable::sastore() { | |
918 // %%%%% Factor across platform | |
919 castore(); | |
920 } | |
921 | |
922 | |
923 void TemplateTable::istore(int n) { | |
924 transition(itos, vtos); | |
925 __ st(Otos_i, Llocals, Interpreter::local_offset_in_bytes(n)); | |
926 } | |
927 | |
928 | |
929 void TemplateTable::lstore(int n) { | |
930 transition(ltos, vtos); | |
931 assert(n+1 < Argument::n_register_parameters, "only handle register cases"); | |
932 __ store_unaligned_long(Otos_l, Llocals, Interpreter::local_offset_in_bytes(n+1)); | |
933 | |
934 } | |
935 | |
936 | |
937 void TemplateTable::fstore(int n) { | |
938 transition(ftos, vtos); | |
939 assert(n < Argument::n_register_parameters, "only handle register cases"); | |
940 __ stf(FloatRegisterImpl::S, Ftos_f, Llocals, Interpreter::local_offset_in_bytes(n)); | |
941 } | |
942 | |
943 | |
944 void TemplateTable::dstore(int n) { | |
945 transition(dtos, vtos); | |
946 FloatRegister src = Ftos_d; | |
947 __ store_unaligned_double(src, Llocals, Interpreter::local_offset_in_bytes(n+1)); | |
948 } | |
949 | |
950 | |
951 void TemplateTable::astore(int n) { | |
952 transition(vtos, vtos); | |
1506 | 953 __ load_ptr(0, Otos_i); |
954 __ inc(Lesp, Interpreter::stackElementSize); | |
0 | 955 __ verify_oop_or_return_address(Otos_i, G3_scratch); |
1506 | 956 __ store_local_ptr(n, Otos_i); |
0 | 957 } |
958 | |
959 | |
960 void TemplateTable::pop() { | |
961 transition(vtos, vtos); | |
1506 | 962 __ inc(Lesp, Interpreter::stackElementSize); |
0 | 963 } |
964 | |
965 | |
966 void TemplateTable::pop2() { | |
967 transition(vtos, vtos); | |
1506 | 968 __ inc(Lesp, 2 * Interpreter::stackElementSize); |
0 | 969 } |
970 | |
971 | |
972 void TemplateTable::dup() { | |
973 transition(vtos, vtos); | |
974 // stack: ..., a | |
975 // load a and tag | |
1506 | 976 __ load_ptr(0, Otos_i); |
977 __ push_ptr(Otos_i); | |
0 | 978 // stack: ..., a, a |
979 } | |
980 | |
981 | |
982 void TemplateTable::dup_x1() { | |
983 transition(vtos, vtos); | |
984 // stack: ..., a, b | |
1506 | 985 __ load_ptr( 1, G3_scratch); // get a |
986 __ load_ptr( 0, Otos_l1); // get b | |
987 __ store_ptr(1, Otos_l1); // put b | |
988 __ store_ptr(0, G3_scratch); // put a - like swap | |
989 __ push_ptr(Otos_l1); // push b | |
0 | 990 // stack: ..., b, a, b |
991 } | |
992 | |
993 | |
994 void TemplateTable::dup_x2() { | |
995 transition(vtos, vtos); | |
996 // stack: ..., a, b, c | |
997 // get c and push on stack, reuse registers | |
1506 | 998 __ load_ptr( 0, G3_scratch); // get c |
999 __ push_ptr(G3_scratch); // push c with tag | |
0 | 1000 // stack: ..., a, b, c, c (c in reg) (Lesp - 4) |
1001 // (stack offsets n+1 now) | |
1506 | 1002 __ load_ptr( 3, Otos_l1); // get a |
1003 __ store_ptr(3, G3_scratch); // put c at 3 | |
0 | 1004 // stack: ..., c, b, c, c (a in reg) |
1506 | 1005 __ load_ptr( 2, G3_scratch); // get b |
1006 __ store_ptr(2, Otos_l1); // put a at 2 | |
0 | 1007 // stack: ..., c, a, c, c (b in reg) |
1506 | 1008 __ store_ptr(1, G3_scratch); // put b at 1 |
0 | 1009 // stack: ..., c, a, b, c |
1010 } | |
1011 | |
1012 | |
1013 void TemplateTable::dup2() { | |
1014 transition(vtos, vtos); | |
1506 | 1015 __ load_ptr(1, G3_scratch); // get a |
1016 __ load_ptr(0, Otos_l1); // get b | |
1017 __ push_ptr(G3_scratch); // push a | |
1018 __ push_ptr(Otos_l1); // push b | |
0 | 1019 // stack: ..., a, b, a, b |
1020 } | |
1021 | |
1022 | |
1023 void TemplateTable::dup2_x1() { | |
1024 transition(vtos, vtos); | |
1025 // stack: ..., a, b, c | |
1506 | 1026 __ load_ptr( 1, Lscratch); // get b |
1027 __ load_ptr( 2, Otos_l1); // get a | |
1028 __ store_ptr(2, Lscratch); // put b at a | |
0 | 1029 // stack: ..., b, b, c |
1506 | 1030 __ load_ptr( 0, G3_scratch); // get c |
1031 __ store_ptr(1, G3_scratch); // put c at b | |
0 | 1032 // stack: ..., b, c, c |
1506 | 1033 __ store_ptr(0, Otos_l1); // put a at c |
0 | 1034 // stack: ..., b, c, a |
1506 | 1035 __ push_ptr(Lscratch); // push b |
1036 __ push_ptr(G3_scratch); // push c | |
0 | 1037 // stack: ..., b, c, a, b, c |
1038 } | |
1039 | |
1040 | |
1041 // The spec says that these types can be a mixture of category 1 (1 word) | |
1042 // types and/or category 2 types (long and doubles) | |
1043 void TemplateTable::dup2_x2() { | |
1044 transition(vtos, vtos); | |
1045 // stack: ..., a, b, c, d | |
1506 | 1046 __ load_ptr( 1, Lscratch); // get c |
1047 __ load_ptr( 3, Otos_l1); // get a | |
1048 __ store_ptr(3, Lscratch); // put c at 3 | |
1049 __ store_ptr(1, Otos_l1); // put a at 1 | |
0 | 1050 // stack: ..., c, b, a, d |
1506 | 1051 __ load_ptr( 2, G3_scratch); // get b |
1052 __ load_ptr( 0, Otos_l1); // get d | |
1053 __ store_ptr(0, G3_scratch); // put b at 0 | |
1054 __ store_ptr(2, Otos_l1); // put d at 2 | |
0 | 1055 // stack: ..., c, d, a, b |
1506 | 1056 __ push_ptr(Lscratch); // push c |
1057 __ push_ptr(Otos_l1); // push d | |
0 | 1058 // stack: ..., c, d, a, b, c, d |
1059 } | |
1060 | |
1061 | |
1062 void TemplateTable::swap() { | |
1063 transition(vtos, vtos); | |
1064 // stack: ..., a, b | |
1506 | 1065 __ load_ptr( 1, G3_scratch); // get a |
1066 __ load_ptr( 0, Otos_l1); // get b | |
1067 __ store_ptr(0, G3_scratch); // put b | |
1068 __ store_ptr(1, Otos_l1); // put a | |
0 | 1069 // stack: ..., b, a |
1070 } | |
1071 | |
1072 | |
1073 void TemplateTable::iop2(Operation op) { | |
1074 transition(itos, itos); | |
1075 __ pop_i(O1); | |
1076 switch (op) { | |
1077 case add: __ add(O1, Otos_i, Otos_i); break; | |
1078 case sub: __ sub(O1, Otos_i, Otos_i); break; | |
1079 // %%%%% Mul may not exist: better to call .mul? | |
1080 case mul: __ smul(O1, Otos_i, Otos_i); break; | |
1506 | 1081 case _and: __ and3(O1, Otos_i, Otos_i); break; |
1082 case _or: __ or3(O1, Otos_i, Otos_i); break; | |
1083 case _xor: __ xor3(O1, Otos_i, Otos_i); break; | |
0 | 1084 case shl: __ sll(O1, Otos_i, Otos_i); break; |
1085 case shr: __ sra(O1, Otos_i, Otos_i); break; | |
1086 case ushr: __ srl(O1, Otos_i, Otos_i); break; | |
1087 default: ShouldNotReachHere(); | |
1088 } | |
1089 } | |
1090 | |
1091 | |
1092 void TemplateTable::lop2(Operation op) { | |
1093 transition(ltos, ltos); | |
1094 __ pop_l(O2); | |
1095 switch (op) { | |
1096 #ifdef _LP64 | |
1506 | 1097 case add: __ add(O2, Otos_l, Otos_l); break; |
1098 case sub: __ sub(O2, Otos_l, Otos_l); break; | |
1099 case _and: __ and3(O2, Otos_l, Otos_l); break; | |
1100 case _or: __ or3(O2, Otos_l, Otos_l); break; | |
1101 case _xor: __ xor3(O2, Otos_l, Otos_l); break; | |
0 | 1102 #else |
1103 case add: __ addcc(O3, Otos_l2, Otos_l2); __ addc(O2, Otos_l1, Otos_l1); break; | |
1104 case sub: __ subcc(O3, Otos_l2, Otos_l2); __ subc(O2, Otos_l1, Otos_l1); break; | |
1506 | 1105 case _and: __ and3(O3, Otos_l2, Otos_l2); __ and3(O2, Otos_l1, Otos_l1); break; |
1106 case _or: __ or3(O3, Otos_l2, Otos_l2); __ or3(O2, Otos_l1, Otos_l1); break; | |
1107 case _xor: __ xor3(O3, Otos_l2, Otos_l2); __ xor3(O2, Otos_l1, Otos_l1); break; | |
0 | 1108 #endif |
1109 default: ShouldNotReachHere(); | |
1110 } | |
1111 } | |
1112 | |
1113 | |
1114 void TemplateTable::idiv() { | |
1115 // %%%%% Later: ForSPARC/V7 call .sdiv library routine, | |
1116 // %%%%% Use ldsw...sdivx on pure V9 ABI. 64 bit safe. | |
1117 | |
1118 transition(itos, itos); | |
1119 __ pop_i(O1); // get 1st op | |
1120 | |
1121 // Y contains upper 32 bits of result, set it to 0 or all ones | |
1122 __ wry(G0); | |
1123 __ mov(~0, G3_scratch); | |
1124 | |
1125 __ tst(O1); | |
1126 Label neg; | |
1127 __ br(Assembler::negative, true, Assembler::pn, neg); | |
1128 __ delayed()->wry(G3_scratch); | |
1129 __ bind(neg); | |
1130 | |
1131 Label ok; | |
1132 __ tst(Otos_i); | |
1133 __ throw_if_not_icc( Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch ); | |
1134 | |
1135 const int min_int = 0x80000000; | |
1136 Label regular; | |
1137 __ cmp(Otos_i, -1); | |
1138 __ br(Assembler::notEqual, false, Assembler::pt, regular); | |
1139 #ifdef _LP64 | |
1140 // Don't put set in delay slot | |
1141 // Set will turn into multiple instructions in 64 bit mode | |
1142 __ delayed()->nop(); | |
1143 __ set(min_int, G4_scratch); | |
1144 #else | |
1145 __ delayed()->set(min_int, G4_scratch); | |
1146 #endif | |
1147 Label done; | |
1148 __ cmp(O1, G4_scratch); | |
1149 __ br(Assembler::equal, true, Assembler::pt, done); | |
1150 __ delayed()->mov(O1, Otos_i); // (mov only executed if branch taken) | |
1151 | |
1152 __ bind(regular); | |
1153 __ sdiv(O1, Otos_i, Otos_i); // note: irem uses O1 after this instruction! | |
1154 __ bind(done); | |
1155 } | |
1156 | |
1157 | |
1158 void TemplateTable::irem() { | |
1159 transition(itos, itos); | |
1160 __ mov(Otos_i, O2); // save divisor | |
1161 idiv(); // %%%% Hack: exploits fact that idiv leaves dividend in O1 | |
1162 __ smul(Otos_i, O2, Otos_i); | |
1163 __ sub(O1, Otos_i, Otos_i); | |
1164 } | |
1165 | |
1166 | |
1167 void TemplateTable::lmul() { | |
1168 transition(ltos, ltos); | |
1169 __ pop_l(O2); | |
1170 #ifdef _LP64 | |
1171 __ mulx(Otos_l, O2, Otos_l); | |
1172 #else | |
1173 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::lmul)); | |
1174 #endif | |
1175 | |
1176 } | |
1177 | |
1178 | |
1179 void TemplateTable::ldiv() { | |
1180 transition(ltos, ltos); | |
1181 | |
1182 // check for zero | |
1183 __ pop_l(O2); | |
1184 #ifdef _LP64 | |
1185 __ tst(Otos_l); | |
1186 __ throw_if_not_xcc( Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch); | |
1187 __ sdivx(O2, Otos_l, Otos_l); | |
1188 #else | |
1189 __ orcc(Otos_l1, Otos_l2, G0); | |
1190 __ throw_if_not_icc( Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch); | |
1191 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::ldiv)); | |
1192 #endif | |
1193 } | |
1194 | |
1195 | |
1196 void TemplateTable::lrem() { | |
1197 transition(ltos, ltos); | |
1198 | |
1199 // check for zero | |
1200 __ pop_l(O2); | |
1201 #ifdef _LP64 | |
1202 __ tst(Otos_l); | |
1203 __ throw_if_not_xcc( Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch); | |
1204 __ sdivx(O2, Otos_l, Otos_l2); | |
1205 __ mulx (Otos_l2, Otos_l, Otos_l2); | |
1206 __ sub (O2, Otos_l2, Otos_l); | |
1207 #else | |
1208 __ orcc(Otos_l1, Otos_l2, G0); | |
1209 __ throw_if_not_icc(Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch); | |
1210 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::lrem)); | |
1211 #endif | |
1212 } | |
1213 | |
1214 | |
1215 void TemplateTable::lshl() { | |
1216 transition(itos, ltos); // %%%% could optimize, fill delay slot or opt for ultra | |
1217 | |
1218 __ pop_l(O2); // shift value in O2, O3 | |
1219 #ifdef _LP64 | |
1220 __ sllx(O2, Otos_i, Otos_l); | |
1221 #else | |
1222 __ lshl(O2, O3, Otos_i, Otos_l1, Otos_l2, O4); | |
1223 #endif | |
1224 } | |
1225 | |
1226 | |
1227 void TemplateTable::lshr() { | |
1228 transition(itos, ltos); // %%%% see lshl comment | |
1229 | |
1230 __ pop_l(O2); // shift value in O2, O3 | |
1231 #ifdef _LP64 | |
1232 __ srax(O2, Otos_i, Otos_l); | |
1233 #else | |
1234 __ lshr(O2, O3, Otos_i, Otos_l1, Otos_l2, O4); | |
1235 #endif | |
1236 } | |
1237 | |
1238 | |
1239 | |
1240 void TemplateTable::lushr() { | |
1241 transition(itos, ltos); // %%%% see lshl comment | |
1242 | |
1243 __ pop_l(O2); // shift value in O2, O3 | |
1244 #ifdef _LP64 | |
1245 __ srlx(O2, Otos_i, Otos_l); | |
1246 #else | |
1247 __ lushr(O2, O3, Otos_i, Otos_l1, Otos_l2, O4); | |
1248 #endif | |
1249 } | |
1250 | |
1251 | |
1252 void TemplateTable::fop2(Operation op) { | |
1253 transition(ftos, ftos); | |
1254 switch (op) { | |
1255 case add: __ pop_f(F4); __ fadd(FloatRegisterImpl::S, F4, Ftos_f, Ftos_f); break; | |
1256 case sub: __ pop_f(F4); __ fsub(FloatRegisterImpl::S, F4, Ftos_f, Ftos_f); break; | |
1257 case mul: __ pop_f(F4); __ fmul(FloatRegisterImpl::S, F4, Ftos_f, Ftos_f); break; | |
1258 case div: __ pop_f(F4); __ fdiv(FloatRegisterImpl::S, F4, Ftos_f, Ftos_f); break; | |
1259 case rem: | |
1260 assert(Ftos_f == F0, "just checking"); | |
1261 #ifdef _LP64 | |
1262 // LP64 calling conventions use F1, F3 for passing 2 floats | |
1263 __ pop_f(F1); | |
1264 __ fmov(FloatRegisterImpl::S, Ftos_f, F3); | |
1265 #else | |
1266 __ pop_i(O0); | |
1267 __ stf(FloatRegisterImpl::S, Ftos_f, __ d_tmp); | |
1268 __ ld( __ d_tmp, O1 ); | |
1269 #endif | |
1270 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::frem)); | |
1271 assert( Ftos_f == F0, "fix this code" ); | |
1272 break; | |
1273 | |
1274 default: ShouldNotReachHere(); | |
1275 } | |
1276 } | |
1277 | |
1278 | |
1279 void TemplateTable::dop2(Operation op) { | |
1280 transition(dtos, dtos); | |
1281 switch (op) { | |
1282 case add: __ pop_d(F4); __ fadd(FloatRegisterImpl::D, F4, Ftos_d, Ftos_d); break; | |
1283 case sub: __ pop_d(F4); __ fsub(FloatRegisterImpl::D, F4, Ftos_d, Ftos_d); break; | |
1284 case mul: __ pop_d(F4); __ fmul(FloatRegisterImpl::D, F4, Ftos_d, Ftos_d); break; | |
1285 case div: __ pop_d(F4); __ fdiv(FloatRegisterImpl::D, F4, Ftos_d, Ftos_d); break; | |
1286 case rem: | |
1287 #ifdef _LP64 | |
1288 // Pass arguments in D0, D2 | |
1289 __ fmov(FloatRegisterImpl::D, Ftos_f, F2 ); | |
1290 __ pop_d( F0 ); | |
1291 #else | |
1292 // Pass arguments in O0O1, O2O3 | |
1293 __ stf(FloatRegisterImpl::D, Ftos_f, __ d_tmp); | |
1294 __ ldd( __ d_tmp, O2 ); | |
1295 __ pop_d(Ftos_f); | |
1296 __ stf(FloatRegisterImpl::D, Ftos_f, __ d_tmp); | |
1297 __ ldd( __ d_tmp, O0 ); | |
1298 #endif | |
1299 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::drem)); | |
1300 assert( Ftos_d == F0, "fix this code" ); | |
1301 break; | |
1302 | |
1303 default: ShouldNotReachHere(); | |
1304 } | |
1305 } | |
1306 | |
1307 | |
1308 void TemplateTable::ineg() { | |
1309 transition(itos, itos); | |
1310 __ neg(Otos_i); | |
1311 } | |
1312 | |
1313 | |
1314 void TemplateTable::lneg() { | |
1315 transition(ltos, ltos); | |
1316 #ifdef _LP64 | |
1317 __ sub(G0, Otos_l, Otos_l); | |
1318 #else | |
1319 __ lneg(Otos_l1, Otos_l2); | |
1320 #endif | |
1321 } | |
1322 | |
1323 | |
1324 void TemplateTable::fneg() { | |
1325 transition(ftos, ftos); | |
1326 __ fneg(FloatRegisterImpl::S, Ftos_f); | |
1327 } | |
1328 | |
1329 | |
1330 void TemplateTable::dneg() { | |
1331 transition(dtos, dtos); | |
1332 // v8 has fnegd if source and dest are the same | |
1333 __ fneg(FloatRegisterImpl::D, Ftos_f); | |
1334 } | |
1335 | |
1336 | |
1337 void TemplateTable::iinc() { | |
1338 transition(vtos, vtos); | |
1339 locals_index(G3_scratch); | |
1340 __ ldsb(Lbcp, 2, O2); // load constant | |
1341 __ access_local_int(G3_scratch, Otos_i); | |
1342 __ add(Otos_i, O2, Otos_i); | |
1506 | 1343 __ st(Otos_i, G3_scratch, 0); // access_local_int puts E.A. in G3_scratch |
0 | 1344 } |
1345 | |
1346 | |
1347 void TemplateTable::wide_iinc() { | |
1348 transition(vtos, vtos); | |
1349 locals_index_wide(G3_scratch); | |
1350 __ get_2_byte_integer_at_bcp( 4, O2, O3, InterpreterMacroAssembler::Signed); | |
1351 __ access_local_int(G3_scratch, Otos_i); | |
1352 __ add(Otos_i, O3, Otos_i); | |
1506 | 1353 __ st(Otos_i, G3_scratch, 0); // access_local_int puts E.A. in G3_scratch |
0 | 1354 } |
1355 | |
1356 | |
1357 void TemplateTable::convert() { | |
1358 // %%%%% Factor this first part accross platforms | |
1359 #ifdef ASSERT | |
1360 TosState tos_in = ilgl; | |
1361 TosState tos_out = ilgl; | |
1362 switch (bytecode()) { | |
1363 case Bytecodes::_i2l: // fall through | |
1364 case Bytecodes::_i2f: // fall through | |
1365 case Bytecodes::_i2d: // fall through | |
1366 case Bytecodes::_i2b: // fall through | |
1367 case Bytecodes::_i2c: // fall through | |
1368 case Bytecodes::_i2s: tos_in = itos; break; | |
1369 case Bytecodes::_l2i: // fall through | |
1370 case Bytecodes::_l2f: // fall through | |
1371 case Bytecodes::_l2d: tos_in = ltos; break; | |
1372 case Bytecodes::_f2i: // fall through | |
1373 case Bytecodes::_f2l: // fall through | |
1374 case Bytecodes::_f2d: tos_in = ftos; break; | |
1375 case Bytecodes::_d2i: // fall through | |
1376 case Bytecodes::_d2l: // fall through | |
1377 case Bytecodes::_d2f: tos_in = dtos; break; | |
1378 default : ShouldNotReachHere(); | |
1379 } | |
1380 switch (bytecode()) { | |
1381 case Bytecodes::_l2i: // fall through | |
1382 case Bytecodes::_f2i: // fall through | |
1383 case Bytecodes::_d2i: // fall through | |
1384 case Bytecodes::_i2b: // fall through | |
1385 case Bytecodes::_i2c: // fall through | |
1386 case Bytecodes::_i2s: tos_out = itos; break; | |
1387 case Bytecodes::_i2l: // fall through | |
1388 case Bytecodes::_f2l: // fall through | |
1389 case Bytecodes::_d2l: tos_out = ltos; break; | |
1390 case Bytecodes::_i2f: // fall through | |
1391 case Bytecodes::_l2f: // fall through | |
1392 case Bytecodes::_d2f: tos_out = ftos; break; | |
1393 case Bytecodes::_i2d: // fall through | |
1394 case Bytecodes::_l2d: // fall through | |
1395 case Bytecodes::_f2d: tos_out = dtos; break; | |
1396 default : ShouldNotReachHere(); | |
1397 } | |
1398 transition(tos_in, tos_out); | |
1399 #endif | |
1400 | |
1401 | |
1402 // Conversion | |
1403 Label done; | |
1404 switch (bytecode()) { | |
1405 case Bytecodes::_i2l: | |
1406 #ifdef _LP64 | |
1407 // Sign extend the 32 bits | |
1408 __ sra ( Otos_i, 0, Otos_l ); | |
1409 #else | |
1410 __ addcc(Otos_i, 0, Otos_l2); | |
1411 __ br(Assembler::greaterEqual, true, Assembler::pt, done); | |
1412 __ delayed()->clr(Otos_l1); | |
1413 __ set(~0, Otos_l1); | |
1414 #endif | |
1415 break; | |
1416 | |
1417 case Bytecodes::_i2f: | |
1418 __ st(Otos_i, __ d_tmp ); | |
1419 __ ldf(FloatRegisterImpl::S, __ d_tmp, F0); | |
1420 __ fitof(FloatRegisterImpl::S, F0, Ftos_f); | |
1421 break; | |
1422 | |
1423 case Bytecodes::_i2d: | |
1424 __ st(Otos_i, __ d_tmp); | |
1425 __ ldf(FloatRegisterImpl::S, __ d_tmp, F0); | |
1426 __ fitof(FloatRegisterImpl::D, F0, Ftos_f); | |
1427 break; | |
1428 | |
1429 case Bytecodes::_i2b: | |
1430 __ sll(Otos_i, 24, Otos_i); | |
1431 __ sra(Otos_i, 24, Otos_i); | |
1432 break; | |
1433 | |
1434 case Bytecodes::_i2c: | |
1435 __ sll(Otos_i, 16, Otos_i); | |
1436 __ srl(Otos_i, 16, Otos_i); | |
1437 break; | |
1438 | |
1439 case Bytecodes::_i2s: | |
1440 __ sll(Otos_i, 16, Otos_i); | |
1441 __ sra(Otos_i, 16, Otos_i); | |
1442 break; | |
1443 | |
1444 case Bytecodes::_l2i: | |
1445 #ifndef _LP64 | |
1446 __ mov(Otos_l2, Otos_i); | |
1447 #else | |
1448 // Sign-extend into the high 32 bits | |
1449 __ sra(Otos_l, 0, Otos_i); | |
1450 #endif | |
1451 break; | |
1452 | |
1453 case Bytecodes::_l2f: | |
1454 case Bytecodes::_l2d: | |
1455 __ st_long(Otos_l, __ d_tmp); | |
1456 __ ldf(FloatRegisterImpl::D, __ d_tmp, Ftos_d); | |
1457 | |
1458 if (VM_Version::v9_instructions_work()) { | |
1459 if (bytecode() == Bytecodes::_l2f) { | |
1460 __ fxtof(FloatRegisterImpl::S, Ftos_d, Ftos_f); | |
1461 } else { | |
1462 __ fxtof(FloatRegisterImpl::D, Ftos_d, Ftos_d); | |
1463 } | |
1464 } else { | |
1465 __ call_VM_leaf( | |
1466 Lscratch, | |
1467 bytecode() == Bytecodes::_l2f | |
1468 ? CAST_FROM_FN_PTR(address, SharedRuntime::l2f) | |
1469 : CAST_FROM_FN_PTR(address, SharedRuntime::l2d) | |
1470 ); | |
1471 } | |
1472 break; | |
1473 | |
1474 case Bytecodes::_f2i: { | |
1475 Label isNaN; | |
1476 // result must be 0 if value is NaN; test by comparing value to itself | |
1477 __ fcmp(FloatRegisterImpl::S, Assembler::fcc0, Ftos_f, Ftos_f); | |
1478 // According to the v8 manual, you have to have a non-fp instruction | |
1479 // between fcmp and fb. | |
1480 if (!VM_Version::v9_instructions_work()) { | |
1481 __ nop(); | |
1482 } | |
1483 __ fb(Assembler::f_unordered, true, Assembler::pn, isNaN); | |
1484 __ delayed()->clr(Otos_i); // NaN | |
1485 __ ftoi(FloatRegisterImpl::S, Ftos_f, F30); | |
1486 __ stf(FloatRegisterImpl::S, F30, __ d_tmp); | |
1487 __ ld(__ d_tmp, Otos_i); | |
1488 __ bind(isNaN); | |
1489 } | |
1490 break; | |
1491 | |
1492 case Bytecodes::_f2l: | |
1493 // must uncache tos | |
1494 __ push_f(); | |
1495 #ifdef _LP64 | |
1496 __ pop_f(F1); | |
1497 #else | |
1498 __ pop_i(O0); | |
1499 #endif | |
1500 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::f2l)); | |
1501 break; | |
1502 | |
1503 case Bytecodes::_f2d: | |
1504 __ ftof( FloatRegisterImpl::S, FloatRegisterImpl::D, Ftos_f, Ftos_f); | |
1505 break; | |
1506 | |
1507 case Bytecodes::_d2i: | |
1508 case Bytecodes::_d2l: | |
1509 // must uncache tos | |
1510 __ push_d(); | |
1511 #ifdef _LP64 | |
1512 // LP64 calling conventions pass first double arg in D0 | |
1513 __ pop_d( Ftos_d ); | |
1514 #else | |
1515 __ pop_i( O0 ); | |
1516 __ pop_i( O1 ); | |
1517 #endif | |
1518 __ call_VM_leaf(Lscratch, | |
1519 bytecode() == Bytecodes::_d2i | |
1520 ? CAST_FROM_FN_PTR(address, SharedRuntime::d2i) | |
1521 : CAST_FROM_FN_PTR(address, SharedRuntime::d2l)); | |
1522 break; | |
1523 | |
1524 case Bytecodes::_d2f: | |
1525 if (VM_Version::v9_instructions_work()) { | |
1526 __ ftof( FloatRegisterImpl::D, FloatRegisterImpl::S, Ftos_d, Ftos_f); | |
1527 } | |
1528 else { | |
1529 // must uncache tos | |
1530 __ push_d(); | |
1531 __ pop_i(O0); | |
1532 __ pop_i(O1); | |
1533 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::d2f)); | |
1534 } | |
1535 break; | |
1536 | |
1537 default: ShouldNotReachHere(); | |
1538 } | |
1539 __ bind(done); | |
1540 } | |
1541 | |
1542 | |
1543 void TemplateTable::lcmp() { | |
1544 transition(ltos, itos); | |
1545 | |
1546 #ifdef _LP64 | |
1547 __ pop_l(O1); // pop off value 1, value 2 is in O0 | |
1548 __ lcmp( O1, Otos_l, Otos_i ); | |
1549 #else | |
1550 __ pop_l(O2); // cmp O2,3 to O0,1 | |
1551 __ lcmp( O2, O3, Otos_l1, Otos_l2, Otos_i ); | |
1552 #endif | |
1553 } | |
1554 | |
1555 | |
1556 void TemplateTable::float_cmp(bool is_float, int unordered_result) { | |
1557 | |
1558 if (is_float) __ pop_f(F2); | |
1559 else __ pop_d(F2); | |
1560 | |
1561 assert(Ftos_f == F0 && Ftos_d == F0, "alias checking:"); | |
1562 | |
1563 __ float_cmp( is_float, unordered_result, F2, F0, Otos_i ); | |
1564 } | |
1565 | |
1566 void TemplateTable::branch(bool is_jsr, bool is_wide) { | |
1567 // Note: on SPARC, we use InterpreterMacroAssembler::if_cmp also. | |
1568 __ verify_oop(Lmethod); | |
1569 __ verify_thread(); | |
1570 | |
1571 const Register O2_bumped_count = O2; | |
1572 __ profile_taken_branch(G3_scratch, O2_bumped_count); | |
1573 | |
1574 // get (wide) offset to O1_disp | |
1575 const Register O1_disp = O1; | |
1576 if (is_wide) __ get_4_byte_integer_at_bcp( 1, G4_scratch, O1_disp, InterpreterMacroAssembler::set_CC); | |
1577 else __ get_2_byte_integer_at_bcp( 1, G4_scratch, O1_disp, InterpreterMacroAssembler::Signed, InterpreterMacroAssembler::set_CC); | |
1578 | |
1579 // Handle all the JSR stuff here, then exit. | |
1580 // It's much shorter and cleaner than intermingling with the | |
605 | 1581 // non-JSR normal-branch stuff occurring below. |
0 | 1582 if( is_jsr ) { |
1583 // compute return address as bci in Otos_i | |
727 | 1584 __ ld_ptr(Lmethod, methodOopDesc::const_offset(), G3_scratch); |
0 | 1585 __ sub(Lbcp, G3_scratch, G3_scratch); |
1586 __ sub(G3_scratch, in_bytes(constMethodOopDesc::codes_offset()) - (is_wide ? 5 : 3), Otos_i); | |
1587 | |
1588 // Bump Lbcp to target of JSR | |
1589 __ add(Lbcp, O1_disp, Lbcp); | |
1590 // Push returnAddress for "ret" on stack | |
1506 | 1591 __ push_ptr(Otos_i); |
0 | 1592 // And away we go! |
1593 __ dispatch_next(vtos); | |
1594 return; | |
1595 } | |
1596 | |
1597 // Normal (non-jsr) branch handling | |
1598 | |
1599 // Save the current Lbcp | |
1600 const Register O0_cur_bcp = O0; | |
1601 __ mov( Lbcp, O0_cur_bcp ); | |
1602 | |
1783 | 1603 |
0 | 1604 bool increment_invocation_counter_for_backward_branches = UseCompiler && UseLoopCounter; |
1605 if ( increment_invocation_counter_for_backward_branches ) { | |
1606 Label Lforward; | |
1607 // check branch direction | |
1608 __ br( Assembler::positive, false, Assembler::pn, Lforward ); | |
1609 // Bump bytecode pointer by displacement (take the branch) | |
1610 __ delayed()->add( O1_disp, Lbcp, Lbcp ); // add to bc addr | |
1611 | |
1783 | 1612 if (TieredCompilation) { |
1613 Label Lno_mdo, Loverflow; | |
1614 int increment = InvocationCounter::count_increment; | |
1615 int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift; | |
1616 if (ProfileInterpreter) { | |
1617 // If no method data exists, go to profile_continue. | |
1618 __ ld_ptr(Lmethod, methodOopDesc::method_data_offset(), G4_scratch); | |
1619 __ br_null(G4_scratch, false, Assembler::pn, Lno_mdo); | |
1620 __ delayed()->nop(); | |
1621 | |
1622 // Increment backedge counter in the MDO | |
1623 Address mdo_backedge_counter(G4_scratch, in_bytes(methodDataOopDesc::backedge_counter_offset()) + | |
1624 in_bytes(InvocationCounter::counter_offset())); | |
1625 __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, G3_scratch, Lscratch, | |
1626 Assembler::notZero, &Lforward); | |
1627 __ ba(false, Loverflow); | |
1628 __ delayed()->nop(); | |
0 | 1629 } |
1783 | 1630 |
1631 // If there's no MDO, increment counter in methodOop | |
1632 __ bind(Lno_mdo); | |
1633 Address backedge_counter(Lmethod, in_bytes(methodOopDesc::backedge_counter_offset()) + | |
1634 in_bytes(InvocationCounter::counter_offset())); | |
1635 __ increment_mask_and_jump(backedge_counter, increment, mask, G3_scratch, Lscratch, | |
1636 Assembler::notZero, &Lforward); | |
1637 __ bind(Loverflow); | |
1638 | |
1639 // notify point for loop, pass branch bytecode | |
1640 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), O0_cur_bcp); | |
1641 | |
1642 // Was an OSR adapter generated? | |
1643 // O0 = osr nmethod | |
1644 __ br_null(O0, false, Assembler::pn, Lforward); | |
1645 __ delayed()->nop(); | |
1646 | |
1647 // Has the nmethod been invalidated already? | |
1648 __ ld(O0, nmethod::entry_bci_offset(), O2); | |
1649 __ cmp(O2, InvalidOSREntryBci); | |
1650 __ br(Assembler::equal, false, Assembler::pn, Lforward); | |
1651 __ delayed()->nop(); | |
1652 | |
1653 // migrate the interpreter frame off of the stack | |
1654 | |
1655 __ mov(G2_thread, L7); | |
1656 // save nmethod | |
1657 __ mov(O0, L6); | |
1658 __ set_last_Java_frame(SP, noreg); | |
1659 __ call_VM_leaf(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin), L7); | |
1660 __ reset_last_Java_frame(); | |
1661 __ mov(L7, G2_thread); | |
1662 | |
1663 // move OSR nmethod to I1 | |
1664 __ mov(L6, I1); | |
1665 | |
1666 // OSR buffer to I0 | |
1667 __ mov(O0, I0); | |
1668 | |
1669 // remove the interpreter frame | |
1670 __ restore(I5_savedSP, 0, SP); | |
1671 | |
1672 // Jump to the osr code. | |
1673 __ ld_ptr(O1, nmethod::osr_entry_point_offset(), O2); | |
1674 __ jmp(O2, G0); | |
1675 __ delayed()->nop(); | |
1676 | |
0 | 1677 } else { |
1783 | 1678 // Update Backedge branch separately from invocations |
1679 const Register G4_invoke_ctr = G4; | |
1680 __ increment_backedge_counter(G4_invoke_ctr, G1_scratch); | |
1681 if (ProfileInterpreter) { | |
1682 __ test_invocation_counter_for_mdp(G4_invoke_ctr, Lbcp, G3_scratch, Lforward); | |
1683 if (UseOnStackReplacement) { | |
1684 __ test_backedge_count_for_osr(O2_bumped_count, O0_cur_bcp, G3_scratch); | |
1685 } | |
1686 } else { | |
1687 if (UseOnStackReplacement) { | |
1688 __ test_backedge_count_for_osr(G4_invoke_ctr, O0_cur_bcp, G3_scratch); | |
1689 } | |
0 | 1690 } |
1691 } | |
1692 | |
1693 __ bind(Lforward); | |
1694 } else | |
1695 // Bump bytecode pointer by displacement (take the branch) | |
1696 __ add( O1_disp, Lbcp, Lbcp );// add to bc addr | |
1697 | |
1698 // continue with bytecode @ target | |
1699 // %%%%% Like Intel, could speed things up by moving bytecode fetch to code above, | |
1700 // %%%%% and changing dispatch_next to dispatch_only | |
1701 __ dispatch_next(vtos); | |
1702 } | |
1703 | |
1704 | |
1705 // Note Condition in argument is TemplateTable::Condition | |
1706 // arg scope is within class scope | |
1707 | |
1708 void TemplateTable::if_0cmp(Condition cc) { | |
1709 // no pointers, integer only! | |
1710 transition(itos, vtos); | |
1711 // assume branch is more often taken than not (loops use backward branches) | |
1712 __ cmp( Otos_i, 0); | |
1713 __ if_cmp(ccNot(cc), false); | |
1714 } | |
1715 | |
1716 | |
1717 void TemplateTable::if_icmp(Condition cc) { | |
1718 transition(itos, vtos); | |
1719 __ pop_i(O1); | |
1720 __ cmp(O1, Otos_i); | |
1721 __ if_cmp(ccNot(cc), false); | |
1722 } | |
1723 | |
1724 | |
1725 void TemplateTable::if_nullcmp(Condition cc) { | |
1726 transition(atos, vtos); | |
1727 __ tst(Otos_i); | |
1728 __ if_cmp(ccNot(cc), true); | |
1729 } | |
1730 | |
1731 | |
1732 void TemplateTable::if_acmp(Condition cc) { | |
1733 transition(atos, vtos); | |
1734 __ pop_ptr(O1); | |
1735 __ verify_oop(O1); | |
1736 __ verify_oop(Otos_i); | |
1737 __ cmp(O1, Otos_i); | |
1738 __ if_cmp(ccNot(cc), true); | |
1739 } | |
1740 | |
1741 | |
1742 | |
1743 void TemplateTable::ret() { | |
1744 transition(vtos, vtos); | |
1745 locals_index(G3_scratch); | |
1746 __ access_local_returnAddress(G3_scratch, Otos_i); | |
1747 // Otos_i contains the bci, compute the bcp from that | |
1748 | |
1749 #ifdef _LP64 | |
1750 #ifdef ASSERT | |
1751 // jsr result was labeled as an 'itos' not an 'atos' because we cannot GC | |
1752 // the result. The return address (really a BCI) was stored with an | |
1753 // 'astore' because JVM specs claim it's a pointer-sized thing. Hence in | |
1754 // the 64-bit build the 32-bit BCI is actually in the low bits of a 64-bit | |
1755 // loaded value. | |
1756 { Label zzz ; | |
1757 __ set (65536, G3_scratch) ; | |
1758 __ cmp (Otos_i, G3_scratch) ; | |
1759 __ bp( Assembler::lessEqualUnsigned, false, Assembler::xcc, Assembler::pn, zzz); | |
1760 __ delayed()->nop(); | |
1761 __ stop("BCI is in the wrong register half?"); | |
1762 __ bind (zzz) ; | |
1763 } | |
1764 #endif | |
1765 #endif | |
1766 | |
1767 __ profile_ret(vtos, Otos_i, G4_scratch); | |
1768 | |
727 | 1769 __ ld_ptr(Lmethod, methodOopDesc::const_offset(), G3_scratch); |
0 | 1770 __ add(G3_scratch, Otos_i, G3_scratch); |
1771 __ add(G3_scratch, in_bytes(constMethodOopDesc::codes_offset()), Lbcp); | |
1772 __ dispatch_next(vtos); | |
1773 } | |
1774 | |
1775 | |
1776 void TemplateTable::wide_ret() { | |
1777 transition(vtos, vtos); | |
1778 locals_index_wide(G3_scratch); | |
1779 __ access_local_returnAddress(G3_scratch, Otos_i); | |
1780 // Otos_i contains the bci, compute the bcp from that | |
1781 | |
1782 __ profile_ret(vtos, Otos_i, G4_scratch); | |
1783 | |
727 | 1784 __ ld_ptr(Lmethod, methodOopDesc::const_offset(), G3_scratch); |
0 | 1785 __ add(G3_scratch, Otos_i, G3_scratch); |
1786 __ add(G3_scratch, in_bytes(constMethodOopDesc::codes_offset()), Lbcp); | |
1787 __ dispatch_next(vtos); | |
1788 } | |
1789 | |
1790 | |
1791 void TemplateTable::tableswitch() { | |
1792 transition(itos, vtos); | |
1793 Label default_case, continue_execution; | |
1794 | |
1795 // align bcp | |
1796 __ add(Lbcp, BytesPerInt, O1); | |
1797 __ and3(O1, -BytesPerInt, O1); | |
1798 // load lo, hi | |
1799 __ ld(O1, 1 * BytesPerInt, O2); // Low Byte | |
1800 __ ld(O1, 2 * BytesPerInt, O3); // High Byte | |
1801 #ifdef _LP64 | |
1802 // Sign extend the 32 bits | |
1803 __ sra ( Otos_i, 0, Otos_i ); | |
1804 #endif /* _LP64 */ | |
1805 | |
1806 // check against lo & hi | |
1807 __ cmp( Otos_i, O2); | |
1808 __ br( Assembler::less, false, Assembler::pn, default_case); | |
1809 __ delayed()->cmp( Otos_i, O3 ); | |
1810 __ br( Assembler::greater, false, Assembler::pn, default_case); | |
1811 // lookup dispatch offset | |
1812 __ delayed()->sub(Otos_i, O2, O2); | |
1813 __ profile_switch_case(O2, O3, G3_scratch, G4_scratch); | |
1814 __ sll(O2, LogBytesPerInt, O2); | |
1815 __ add(O2, 3 * BytesPerInt, O2); | |
1816 __ ba(false, continue_execution); | |
1817 __ delayed()->ld(O1, O2, O2); | |
1818 // handle default | |
1819 __ bind(default_case); | |
1820 __ profile_switch_default(O3); | |
1821 __ ld(O1, 0, O2); // get default offset | |
1822 // continue execution | |
1823 __ bind(continue_execution); | |
1824 __ add(Lbcp, O2, Lbcp); | |
1825 __ dispatch_next(vtos); | |
1826 } | |
1827 | |
1828 | |
1829 void TemplateTable::lookupswitch() { | |
1830 transition(itos, itos); | |
1831 __ stop("lookupswitch bytecode should have been rewritten"); | |
1832 } | |
1833 | |
1834 void TemplateTable::fast_linearswitch() { | |
1835 transition(itos, vtos); | |
1836 Label loop_entry, loop, found, continue_execution; | |
1837 // align bcp | |
1838 __ add(Lbcp, BytesPerInt, O1); | |
1839 __ and3(O1, -BytesPerInt, O1); | |
1840 // set counter | |
1841 __ ld(O1, BytesPerInt, O2); | |
1842 __ sll(O2, LogBytesPerInt + 1, O2); // in word-pairs | |
1843 __ add(O1, 2 * BytesPerInt, O3); // set first pair addr | |
1844 __ ba(false, loop_entry); | |
1845 __ delayed()->add(O3, O2, O2); // counter now points past last pair | |
1846 | |
1847 // table search | |
1848 __ bind(loop); | |
1849 __ cmp(O4, Otos_i); | |
1850 __ br(Assembler::equal, true, Assembler::pn, found); | |
1851 __ delayed()->ld(O3, BytesPerInt, O4); // offset -> O4 | |
1852 __ inc(O3, 2 * BytesPerInt); | |
1853 | |
1854 __ bind(loop_entry); | |
1855 __ cmp(O2, O3); | |
1856 __ brx(Assembler::greaterUnsigned, true, Assembler::pt, loop); | |
1857 __ delayed()->ld(O3, 0, O4); | |
1858 | |
1859 // default case | |
1860 __ ld(O1, 0, O4); // get default offset | |
1861 if (ProfileInterpreter) { | |
1862 __ profile_switch_default(O3); | |
1863 __ ba(false, continue_execution); | |
1864 __ delayed()->nop(); | |
1865 } | |
1866 | |
1867 // entry found -> get offset | |
1868 __ bind(found); | |
1869 if (ProfileInterpreter) { | |
1870 __ sub(O3, O1, O3); | |
1871 __ sub(O3, 2*BytesPerInt, O3); | |
1872 __ srl(O3, LogBytesPerInt + 1, O3); // in word-pairs | |
1873 __ profile_switch_case(O3, O1, O2, G3_scratch); | |
1874 | |
1875 __ bind(continue_execution); | |
1876 } | |
1877 __ add(Lbcp, O4, Lbcp); | |
1878 __ dispatch_next(vtos); | |
1879 } | |
1880 | |
1881 | |
1882 void TemplateTable::fast_binaryswitch() { | |
1883 transition(itos, vtos); | |
1884 // Implementation using the following core algorithm: (copied from Intel) | |
1885 // | |
1886 // int binary_search(int key, LookupswitchPair* array, int n) { | |
1887 // // Binary search according to "Methodik des Programmierens" by | |
1888 // // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985. | |
1889 // int i = 0; | |
1890 // int j = n; | |
1891 // while (i+1 < j) { | |
1892 // // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q) | |
1893 // // with Q: for all i: 0 <= i < n: key < a[i] | |
1894 // // where a stands for the array and assuming that the (inexisting) | |
1895 // // element a[n] is infinitely big. | |
1896 // int h = (i + j) >> 1; | |
1897 // // i < h < j | |
1898 // if (key < array[h].fast_match()) { | |
1899 // j = h; | |
1900 // } else { | |
1901 // i = h; | |
1902 // } | |
1903 // } | |
1904 // // R: a[i] <= key < a[i+1] or Q | |
1905 // // (i.e., if key is within array, i is the correct index) | |
1906 // return i; | |
1907 // } | |
1908 | |
1909 // register allocation | |
1910 assert(Otos_i == O0, "alias checking"); | |
1911 const Register Rkey = Otos_i; // already set (tosca) | |
1912 const Register Rarray = O1; | |
1913 const Register Ri = O2; | |
1914 const Register Rj = O3; | |
1915 const Register Rh = O4; | |
1916 const Register Rscratch = O5; | |
1917 | |
1918 const int log_entry_size = 3; | |
1919 const int entry_size = 1 << log_entry_size; | |
1920 | |
1921 Label found; | |
1922 // Find Array start | |
1923 __ add(Lbcp, 3 * BytesPerInt, Rarray); | |
1924 __ and3(Rarray, -BytesPerInt, Rarray); | |
1925 // initialize i & j (in delay slot) | |
1926 __ clr( Ri ); | |
1927 | |
1928 // and start | |
1929 Label entry; | |
1930 __ ba(false, entry); | |
1931 __ delayed()->ld( Rarray, -BytesPerInt, Rj); | |
1932 // (Rj is already in the native byte-ordering.) | |
1933 | |
1934 // binary search loop | |
1935 { Label loop; | |
1936 __ bind( loop ); | |
1937 // int h = (i + j) >> 1; | |
1938 __ sra( Rh, 1, Rh ); | |
1939 // if (key < array[h].fast_match()) { | |
1940 // j = h; | |
1941 // } else { | |
1942 // i = h; | |
1943 // } | |
1944 __ sll( Rh, log_entry_size, Rscratch ); | |
1945 __ ld( Rarray, Rscratch, Rscratch ); | |
1946 // (Rscratch is already in the native byte-ordering.) | |
1947 __ cmp( Rkey, Rscratch ); | |
1948 if ( VM_Version::v9_instructions_work() ) { | |
1949 __ movcc( Assembler::less, false, Assembler::icc, Rh, Rj ); // j = h if (key < array[h].fast_match()) | |
1950 __ movcc( Assembler::greaterEqual, false, Assembler::icc, Rh, Ri ); // i = h if (key >= array[h].fast_match()) | |
1951 } | |
1952 else { | |
1953 Label end_of_if; | |
1954 __ br( Assembler::less, true, Assembler::pt, end_of_if ); | |
1955 __ delayed()->mov( Rh, Rj ); // if (<) Rj = Rh | |
1956 __ mov( Rh, Ri ); // else i = h | |
1957 __ bind(end_of_if); // } | |
1958 } | |
1959 | |
1960 // while (i+1 < j) | |
1961 __ bind( entry ); | |
1962 __ add( Ri, 1, Rscratch ); | |
1963 __ cmp(Rscratch, Rj); | |
1964 __ br( Assembler::less, true, Assembler::pt, loop ); | |
1965 __ delayed()->add( Ri, Rj, Rh ); // start h = i + j >> 1; | |
1966 } | |
1967 | |
1968 // end of binary search, result index is i (must check again!) | |
1969 Label default_case; | |
1970 Label continue_execution; | |
1971 if (ProfileInterpreter) { | |
1972 __ mov( Ri, Rh ); // Save index in i for profiling | |
1973 } | |
1974 __ sll( Ri, log_entry_size, Ri ); | |
1975 __ ld( Rarray, Ri, Rscratch ); | |
1976 // (Rscratch is already in the native byte-ordering.) | |
1977 __ cmp( Rkey, Rscratch ); | |
1978 __ br( Assembler::notEqual, true, Assembler::pn, default_case ); | |
1979 __ delayed()->ld( Rarray, -2 * BytesPerInt, Rj ); // load default offset -> j | |
1980 | |
1981 // entry found -> j = offset | |
1982 __ inc( Ri, BytesPerInt ); | |
1983 __ profile_switch_case(Rh, Rj, Rscratch, Rkey); | |
1984 __ ld( Rarray, Ri, Rj ); | |
1985 // (Rj is already in the native byte-ordering.) | |
1986 | |
1987 if (ProfileInterpreter) { | |
1988 __ ba(false, continue_execution); | |
1989 __ delayed()->nop(); | |
1990 } | |
1991 | |
1992 __ bind(default_case); // fall through (if not profiling) | |
1993 __ profile_switch_default(Ri); | |
1994 | |
1995 __ bind(continue_execution); | |
1996 __ add( Lbcp, Rj, Lbcp ); | |
1997 __ dispatch_next( vtos ); | |
1998 } | |
1999 | |
2000 | |
2001 void TemplateTable::_return(TosState state) { | |
2002 transition(state, state); | |
2003 assert(_desc->calls_vm(), "inconsistent calls_vm information"); | |
2004 | |
2005 if (_desc->bytecode() == Bytecodes::_return_register_finalizer) { | |
2006 assert(state == vtos, "only valid state"); | |
2007 __ mov(G0, G3_scratch); | |
2008 __ access_local_ptr(G3_scratch, Otos_i); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2009 __ load_klass(Otos_i, O2); |
0 | 2010 __ set(JVM_ACC_HAS_FINALIZER, G3); |
2011 __ ld(O2, Klass::access_flags_offset_in_bytes() + sizeof(oopDesc), O2); | |
2012 __ andcc(G3, O2, G0); | |
2013 Label skip_register_finalizer; | |
2014 __ br(Assembler::zero, false, Assembler::pn, skip_register_finalizer); | |
2015 __ delayed()->nop(); | |
2016 | |
2017 // Call out to do finalizer registration | |
2018 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), Otos_i); | |
2019 | |
2020 __ bind(skip_register_finalizer); | |
2021 } | |
2022 | |
2023 __ remove_activation(state, /* throw_monitor_exception */ true); | |
2024 | |
2025 // The caller's SP was adjusted upon method entry to accomodate | |
2026 // the callee's non-argument locals. Undo that adjustment. | |
2027 __ ret(); // return to caller | |
2028 __ delayed()->restore(I5_savedSP, G0, SP); | |
2029 } | |
2030 | |
2031 | |
2032 // ---------------------------------------------------------------------------- | |
2033 // Volatile variables demand their effects be made known to all CPU's in | |
2034 // order. Store buffers on most chips allow reads & writes to reorder; the | |
2035 // JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of | |
2036 // memory barrier (i.e., it's not sufficient that the interpreter does not | |
2037 // reorder volatile references, the hardware also must not reorder them). | |
2038 // | |
2039 // According to the new Java Memory Model (JMM): | |
2040 // (1) All volatiles are serialized wrt to each other. | |
2041 // ALSO reads & writes act as aquire & release, so: | |
2042 // (2) A read cannot let unrelated NON-volatile memory refs that happen after | |
2043 // the read float up to before the read. It's OK for non-volatile memory refs | |
2044 // that happen before the volatile read to float down below it. | |
2045 // (3) Similar a volatile write cannot let unrelated NON-volatile memory refs | |
2046 // that happen BEFORE the write float down to after the write. It's OK for | |
2047 // non-volatile memory refs that happen after the volatile write to float up | |
2048 // before it. | |
2049 // | |
2050 // We only put in barriers around volatile refs (they are expensive), not | |
2051 // _between_ memory refs (that would require us to track the flavor of the | |
2052 // previous memory refs). Requirements (2) and (3) require some barriers | |
2053 // before volatile stores and after volatile loads. These nearly cover | |
2054 // requirement (1) but miss the volatile-store-volatile-load case. This final | |
2055 // case is placed after volatile-stores although it could just as well go | |
2056 // before volatile-loads. | |
2057 void TemplateTable::volatile_barrier(Assembler::Membar_mask_bits order_constraint) { | |
2058 // Helper function to insert a is-volatile test and memory barrier | |
2059 // All current sparc implementations run in TSO, needing only StoreLoad | |
2060 if ((order_constraint & Assembler::StoreLoad) == 0) return; | |
2061 __ membar( order_constraint ); | |
2062 } | |
2063 | |
2064 // ---------------------------------------------------------------------------- | |
1565 | 2065 void TemplateTable::resolve_cache_and_index(int byte_no, |
2066 Register result, | |
2067 Register Rcache, | |
2068 Register index, | |
2069 size_t index_size) { | |
0 | 2070 // Depends on cpCacheOop layout! |
2071 Label resolved; | |
2072 | |
1565 | 2073 __ get_cache_and_index_at_bcp(Rcache, index, 1, index_size); |
2074 if (byte_no == f1_oop) { | |
2075 // We are resolved if the f1 field contains a non-null object (CallSite, etc.) | |
2076 // This kind of CP cache entry does not need to match the flags byte, because | |
2077 // there is a 1-1 relation between bytecode type and CP entry type. | |
2078 assert_different_registers(result, Rcache); | |
1503 | 2079 __ ld_ptr(Rcache, constantPoolCacheOopDesc::base_offset() + |
1565 | 2080 ConstantPoolCacheEntry::f1_offset(), result); |
2081 __ tst(result); | |
1503 | 2082 __ br(Assembler::notEqual, false, Assembler::pt, resolved); |
2083 __ delayed()->set((int)bytecode(), O1); | |
2084 } else { | |
1565 | 2085 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); |
2086 assert(result == noreg, ""); //else change code for setting result | |
2087 const int shift_count = (1 + byte_no)*BitsPerByte; | |
2088 | |
1503 | 2089 __ ld_ptr(Rcache, constantPoolCacheOopDesc::base_offset() + |
2090 ConstantPoolCacheEntry::indices_offset(), Lbyte_code); | |
2091 | |
2092 __ srl( Lbyte_code, shift_count, Lbyte_code ); | |
2093 __ and3( Lbyte_code, 0xFF, Lbyte_code ); | |
2094 __ cmp( Lbyte_code, (int)bytecode()); | |
2095 __ br( Assembler::equal, false, Assembler::pt, resolved); | |
2096 __ delayed()->set((int)bytecode(), O1); | |
2097 } | |
0 | 2098 |
2099 address entry; | |
2100 switch (bytecode()) { | |
2101 case Bytecodes::_getstatic : // fall through | |
2102 case Bytecodes::_putstatic : // fall through | |
2103 case Bytecodes::_getfield : // fall through | |
2104 case Bytecodes::_putfield : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_get_put); break; | |
2105 case Bytecodes::_invokevirtual : // fall through | |
2106 case Bytecodes::_invokespecial : // fall through | |
2107 case Bytecodes::_invokestatic : // fall through | |
2108 case Bytecodes::_invokeinterface: entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invoke); break; | |
1503 | 2109 case Bytecodes::_invokedynamic : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokedynamic); break; |
1602 | 2110 case Bytecodes::_fast_aldc : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc); break; |
2111 case Bytecodes::_fast_aldc_w : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc); break; | |
0 | 2112 default : ShouldNotReachHere(); break; |
2113 } | |
2114 // first time invocation - must resolve first | |
2115 __ call_VM(noreg, entry, O1); | |
2116 // Update registers with resolved info | |
1565 | 2117 __ get_cache_and_index_at_bcp(Rcache, index, 1, index_size); |
2118 if (result != noreg) | |
2119 __ ld_ptr(Rcache, constantPoolCacheOopDesc::base_offset() + | |
2120 ConstantPoolCacheEntry::f1_offset(), result); | |
0 | 2121 __ bind(resolved); |
2122 } | |
2123 | |
2124 void TemplateTable::load_invoke_cp_cache_entry(int byte_no, | |
2125 Register Rmethod, | |
2126 Register Ritable_index, | |
2127 Register Rflags, | |
2128 bool is_invokevirtual, | |
1565 | 2129 bool is_invokevfinal, |
2130 bool is_invokedynamic) { | |
0 | 2131 // Uses both G3_scratch and G4_scratch |
2132 Register Rcache = G3_scratch; | |
2133 Register Rscratch = G4_scratch; | |
2134 assert_different_registers(Rcache, Rmethod, Ritable_index); | |
2135 | |
2136 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2137 | |
2138 // determine constant pool cache field offsets | |
2139 const int method_offset = in_bytes( | |
2140 cp_base_offset + | |
2141 (is_invokevirtual | |
2142 ? ConstantPoolCacheEntry::f2_offset() | |
2143 : ConstantPoolCacheEntry::f1_offset() | |
2144 ) | |
2145 ); | |
2146 const int flags_offset = in_bytes(cp_base_offset + | |
2147 ConstantPoolCacheEntry::flags_offset()); | |
2148 // access constant pool cache fields | |
2149 const int index_offset = in_bytes(cp_base_offset + | |
2150 ConstantPoolCacheEntry::f2_offset()); | |
2151 | |
2152 if (is_invokevfinal) { | |
2153 __ get_cache_and_index_at_bcp(Rcache, Rscratch, 1); | |
1565 | 2154 __ ld_ptr(Rcache, method_offset, Rmethod); |
2155 } else if (byte_no == f1_oop) { | |
2156 // Resolved f1_oop goes directly into 'method' register. | |
2157 resolve_cache_and_index(byte_no, Rmethod, Rcache, Rscratch, sizeof(u4)); | |
0 | 2158 } else { |
1565 | 2159 resolve_cache_and_index(byte_no, noreg, Rcache, Rscratch, sizeof(u2)); |
2160 __ ld_ptr(Rcache, method_offset, Rmethod); | |
0 | 2161 } |
2162 | |
2163 if (Ritable_index != noreg) { | |
727 | 2164 __ ld_ptr(Rcache, index_offset, Ritable_index); |
0 | 2165 } |
727 | 2166 __ ld_ptr(Rcache, flags_offset, Rflags); |
0 | 2167 } |
2168 | |
2169 // The Rcache register must be set before call | |
2170 void TemplateTable::load_field_cp_cache_entry(Register Robj, | |
2171 Register Rcache, | |
2172 Register index, | |
2173 Register Roffset, | |
2174 Register Rflags, | |
2175 bool is_static) { | |
2176 assert_different_registers(Rcache, Rflags, Roffset); | |
2177 | |
2178 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2179 | |
727 | 2180 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::flags_offset(), Rflags); |
2181 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Roffset); | |
0 | 2182 if (is_static) { |
727 | 2183 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f1_offset(), Robj); |
0 | 2184 } |
2185 } | |
2186 | |
2187 // The registers Rcache and index expected to be set before call. | |
2188 // Correct values of the Rcache and index registers are preserved. | |
2189 void TemplateTable::jvmti_post_field_access(Register Rcache, | |
2190 Register index, | |
2191 bool is_static, | |
2192 bool has_tos) { | |
2193 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2194 | |
2195 if (JvmtiExport::can_post_field_access()) { | |
2196 // Check to see if a field access watch has been set before we take | |
2197 // the time to call into the VM. | |
2198 Label Label1; | |
2199 assert_different_registers(Rcache, index, G1_scratch); | |
727 | 2200 AddressLiteral get_field_access_count_addr(JvmtiExport::get_field_access_count_addr()); |
0 | 2201 __ load_contents(get_field_access_count_addr, G1_scratch); |
2202 __ tst(G1_scratch); | |
2203 __ br(Assembler::zero, false, Assembler::pt, Label1); | |
2204 __ delayed()->nop(); | |
2205 | |
2206 __ add(Rcache, in_bytes(cp_base_offset), Rcache); | |
2207 | |
2208 if (is_static) { | |
2209 __ clr(Otos_i); | |
2210 } else { | |
2211 if (has_tos) { | |
2212 // save object pointer before call_VM() clobbers it | |
450
b22701a8b88f
6474243: suspicious jvmti code that uses oop unsafely across GC point
coleenp
parents:
356
diff
changeset
|
2213 __ push_ptr(Otos_i); // put object on tos where GC wants it. |
0 | 2214 } else { |
2215 // Load top of stack (do not pop the value off the stack); | |
2216 __ ld_ptr(Lesp, Interpreter::expr_offset_in_bytes(0), Otos_i); | |
2217 } | |
2218 __ verify_oop(Otos_i); | |
2219 } | |
2220 // Otos_i: object pointer or NULL if static | |
2221 // Rcache: cache entry pointer | |
2222 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_access), | |
2223 Otos_i, Rcache); | |
2224 if (!is_static && has_tos) { | |
450
b22701a8b88f
6474243: suspicious jvmti code that uses oop unsafely across GC point
coleenp
parents:
356
diff
changeset
|
2225 __ pop_ptr(Otos_i); // restore object pointer |
0 | 2226 __ verify_oop(Otos_i); |
2227 } | |
2228 __ get_cache_and_index_at_bcp(Rcache, index, 1); | |
2229 __ bind(Label1); | |
2230 } | |
2231 } | |
2232 | |
2233 void TemplateTable::getfield_or_static(int byte_no, bool is_static) { | |
2234 transition(vtos, vtos); | |
2235 | |
2236 Register Rcache = G3_scratch; | |
2237 Register index = G4_scratch; | |
2238 Register Rclass = Rcache; | |
2239 Register Roffset= G4_scratch; | |
2240 Register Rflags = G1_scratch; | |
2241 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2242 | |
1565 | 2243 resolve_cache_and_index(byte_no, noreg, Rcache, index, sizeof(u2)); |
0 | 2244 jvmti_post_field_access(Rcache, index, is_static, false); |
2245 load_field_cp_cache_entry(Rclass, Rcache, index, Roffset, Rflags, is_static); | |
2246 | |
2247 if (!is_static) { | |
2248 pop_and_check_object(Rclass); | |
2249 } else { | |
2250 __ verify_oop(Rclass); | |
2251 } | |
2252 | |
2253 Label exit; | |
2254 | |
2255 Assembler::Membar_mask_bits membar_bits = | |
2256 Assembler::Membar_mask_bits(Assembler::LoadLoad | Assembler::LoadStore); | |
2257 | |
2258 if (__ membar_has_effect(membar_bits)) { | |
2259 // Get volatile flag | |
2260 __ set((1 << ConstantPoolCacheEntry::volatileField), Lscratch); | |
2261 __ and3(Rflags, Lscratch, Lscratch); | |
2262 } | |
2263 | |
2264 Label checkVolatile; | |
2265 | |
2266 // compute field type | |
2267 Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj; | |
2268 __ srl(Rflags, ConstantPoolCacheEntry::tosBits, Rflags); | |
2269 // Make sure we don't need to mask Rflags for tosBits after the above shift | |
2270 ConstantPoolCacheEntry::verify_tosBits(); | |
2271 | |
2272 // Check atos before itos for getstatic, more likely (in Queens at least) | |
2273 __ cmp(Rflags, atos); | |
2274 __ br(Assembler::notEqual, false, Assembler::pt, notObj); | |
2275 __ delayed() ->cmp(Rflags, itos); | |
2276 | |
2277 // atos | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2278 __ load_heap_oop(Rclass, Roffset, Otos_i); |
0 | 2279 __ verify_oop(Otos_i); |
2280 __ push(atos); | |
2281 if (!is_static) { | |
2282 patch_bytecode(Bytecodes::_fast_agetfield, G3_scratch, G4_scratch); | |
2283 } | |
2284 __ ba(false, checkVolatile); | |
2285 __ delayed()->tst(Lscratch); | |
2286 | |
2287 __ bind(notObj); | |
2288 | |
2289 // cmp(Rflags, itos); | |
2290 __ br(Assembler::notEqual, false, Assembler::pt, notInt); | |
2291 __ delayed() ->cmp(Rflags, ltos); | |
2292 | |
2293 // itos | |
2294 __ ld(Rclass, Roffset, Otos_i); | |
2295 __ push(itos); | |
2296 if (!is_static) { | |
2297 patch_bytecode(Bytecodes::_fast_igetfield, G3_scratch, G4_scratch); | |
2298 } | |
2299 __ ba(false, checkVolatile); | |
2300 __ delayed()->tst(Lscratch); | |
2301 | |
2302 __ bind(notInt); | |
2303 | |
2304 // cmp(Rflags, ltos); | |
2305 __ br(Assembler::notEqual, false, Assembler::pt, notLong); | |
2306 __ delayed() ->cmp(Rflags, btos); | |
2307 | |
2308 // ltos | |
2309 // load must be atomic | |
2310 __ ld_long(Rclass, Roffset, Otos_l); | |
2311 __ push(ltos); | |
2312 if (!is_static) { | |
2313 patch_bytecode(Bytecodes::_fast_lgetfield, G3_scratch, G4_scratch); | |
2314 } | |
2315 __ ba(false, checkVolatile); | |
2316 __ delayed()->tst(Lscratch); | |
2317 | |
2318 __ bind(notLong); | |
2319 | |
2320 // cmp(Rflags, btos); | |
2321 __ br(Assembler::notEqual, false, Assembler::pt, notByte); | |
2322 __ delayed() ->cmp(Rflags, ctos); | |
2323 | |
2324 // btos | |
2325 __ ldsb(Rclass, Roffset, Otos_i); | |
2326 __ push(itos); | |
2327 if (!is_static) { | |
2328 patch_bytecode(Bytecodes::_fast_bgetfield, G3_scratch, G4_scratch); | |
2329 } | |
2330 __ ba(false, checkVolatile); | |
2331 __ delayed()->tst(Lscratch); | |
2332 | |
2333 __ bind(notByte); | |
2334 | |
2335 // cmp(Rflags, ctos); | |
2336 __ br(Assembler::notEqual, false, Assembler::pt, notChar); | |
2337 __ delayed() ->cmp(Rflags, stos); | |
2338 | |
2339 // ctos | |
2340 __ lduh(Rclass, Roffset, Otos_i); | |
2341 __ push(itos); | |
2342 if (!is_static) { | |
2343 patch_bytecode(Bytecodes::_fast_cgetfield, G3_scratch, G4_scratch); | |
2344 } | |
2345 __ ba(false, checkVolatile); | |
2346 __ delayed()->tst(Lscratch); | |
2347 | |
2348 __ bind(notChar); | |
2349 | |
2350 // cmp(Rflags, stos); | |
2351 __ br(Assembler::notEqual, false, Assembler::pt, notShort); | |
2352 __ delayed() ->cmp(Rflags, ftos); | |
2353 | |
2354 // stos | |
2355 __ ldsh(Rclass, Roffset, Otos_i); | |
2356 __ push(itos); | |
2357 if (!is_static) { | |
2358 patch_bytecode(Bytecodes::_fast_sgetfield, G3_scratch, G4_scratch); | |
2359 } | |
2360 __ ba(false, checkVolatile); | |
2361 __ delayed()->tst(Lscratch); | |
2362 | |
2363 __ bind(notShort); | |
2364 | |
2365 | |
2366 // cmp(Rflags, ftos); | |
2367 __ br(Assembler::notEqual, false, Assembler::pt, notFloat); | |
2368 __ delayed() ->tst(Lscratch); | |
2369 | |
2370 // ftos | |
2371 __ ldf(FloatRegisterImpl::S, Rclass, Roffset, Ftos_f); | |
2372 __ push(ftos); | |
2373 if (!is_static) { | |
2374 patch_bytecode(Bytecodes::_fast_fgetfield, G3_scratch, G4_scratch); | |
2375 } | |
2376 __ ba(false, checkVolatile); | |
2377 __ delayed()->tst(Lscratch); | |
2378 | |
2379 __ bind(notFloat); | |
2380 | |
2381 | |
2382 // dtos | |
2383 __ ldf(FloatRegisterImpl::D, Rclass, Roffset, Ftos_d); | |
2384 __ push(dtos); | |
2385 if (!is_static) { | |
2386 patch_bytecode(Bytecodes::_fast_dgetfield, G3_scratch, G4_scratch); | |
2387 } | |
2388 | |
2389 __ bind(checkVolatile); | |
2390 if (__ membar_has_effect(membar_bits)) { | |
2391 // __ tst(Lscratch); executed in delay slot | |
2392 __ br(Assembler::zero, false, Assembler::pt, exit); | |
2393 __ delayed()->nop(); | |
2394 volatile_barrier(membar_bits); | |
2395 } | |
2396 | |
2397 __ bind(exit); | |
2398 } | |
2399 | |
2400 | |
2401 void TemplateTable::getfield(int byte_no) { | |
2402 getfield_or_static(byte_no, false); | |
2403 } | |
2404 | |
2405 void TemplateTable::getstatic(int byte_no) { | |
2406 getfield_or_static(byte_no, true); | |
2407 } | |
2408 | |
2409 | |
2410 void TemplateTable::fast_accessfield(TosState state) { | |
2411 transition(atos, state); | |
2412 Register Rcache = G3_scratch; | |
2413 Register index = G4_scratch; | |
2414 Register Roffset = G4_scratch; | |
2415 Register Rflags = Rcache; | |
2416 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2417 | |
2418 __ get_cache_and_index_at_bcp(Rcache, index, 1); | |
2419 jvmti_post_field_access(Rcache, index, /*is_static*/false, /*has_tos*/true); | |
2420 | |
727 | 2421 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Roffset); |
0 | 2422 |
2423 __ null_check(Otos_i); | |
2424 __ verify_oop(Otos_i); | |
2425 | |
2426 Label exit; | |
2427 | |
2428 Assembler::Membar_mask_bits membar_bits = | |
2429 Assembler::Membar_mask_bits(Assembler::LoadLoad | Assembler::LoadStore); | |
2430 if (__ membar_has_effect(membar_bits)) { | |
2431 // Get volatile flag | |
727 | 2432 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Rflags); |
0 | 2433 __ set((1 << ConstantPoolCacheEntry::volatileField), Lscratch); |
2434 } | |
2435 | |
2436 switch (bytecode()) { | |
2437 case Bytecodes::_fast_bgetfield: | |
2438 __ ldsb(Otos_i, Roffset, Otos_i); | |
2439 break; | |
2440 case Bytecodes::_fast_cgetfield: | |
2441 __ lduh(Otos_i, Roffset, Otos_i); | |
2442 break; | |
2443 case Bytecodes::_fast_sgetfield: | |
2444 __ ldsh(Otos_i, Roffset, Otos_i); | |
2445 break; | |
2446 case Bytecodes::_fast_igetfield: | |
2447 __ ld(Otos_i, Roffset, Otos_i); | |
2448 break; | |
2449 case Bytecodes::_fast_lgetfield: | |
2450 __ ld_long(Otos_i, Roffset, Otos_l); | |
2451 break; | |
2452 case Bytecodes::_fast_fgetfield: | |
2453 __ ldf(FloatRegisterImpl::S, Otos_i, Roffset, Ftos_f); | |
2454 break; | |
2455 case Bytecodes::_fast_dgetfield: | |
2456 __ ldf(FloatRegisterImpl::D, Otos_i, Roffset, Ftos_d); | |
2457 break; | |
2458 case Bytecodes::_fast_agetfield: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2459 __ load_heap_oop(Otos_i, Roffset, Otos_i); |
0 | 2460 break; |
2461 default: | |
2462 ShouldNotReachHere(); | |
2463 } | |
2464 | |
2465 if (__ membar_has_effect(membar_bits)) { | |
2466 __ btst(Lscratch, Rflags); | |
2467 __ br(Assembler::zero, false, Assembler::pt, exit); | |
2468 __ delayed()->nop(); | |
2469 volatile_barrier(membar_bits); | |
2470 __ bind(exit); | |
2471 } | |
2472 | |
2473 if (state == atos) { | |
2474 __ verify_oop(Otos_i); // does not blow flags! | |
2475 } | |
2476 } | |
2477 | |
2478 void TemplateTable::jvmti_post_fast_field_mod() { | |
2479 if (JvmtiExport::can_post_field_modification()) { | |
2480 // Check to see if a field modification watch has been set before we take | |
2481 // the time to call into the VM. | |
2482 Label done; | |
727 | 2483 AddressLiteral get_field_modification_count_addr(JvmtiExport::get_field_modification_count_addr()); |
0 | 2484 __ load_contents(get_field_modification_count_addr, G4_scratch); |
2485 __ tst(G4_scratch); | |
2486 __ br(Assembler::zero, false, Assembler::pt, done); | |
2487 __ delayed()->nop(); | |
2488 __ pop_ptr(G4_scratch); // copy the object pointer from tos | |
2489 __ verify_oop(G4_scratch); | |
2490 __ push_ptr(G4_scratch); // put the object pointer back on tos | |
2491 __ get_cache_entry_pointer_at_bcp(G1_scratch, G3_scratch, 1); | |
2492 // Save tos values before call_VM() clobbers them. Since we have | |
2493 // to do it for every data type, we use the saved values as the | |
2494 // jvalue object. | |
2495 switch (bytecode()) { // save tos values before call_VM() clobbers them | |
2496 case Bytecodes::_fast_aputfield: __ push_ptr(Otos_i); break; | |
2497 case Bytecodes::_fast_bputfield: // fall through | |
2498 case Bytecodes::_fast_sputfield: // fall through | |
2499 case Bytecodes::_fast_cputfield: // fall through | |
2500 case Bytecodes::_fast_iputfield: __ push_i(Otos_i); break; | |
2501 case Bytecodes::_fast_dputfield: __ push_d(Ftos_d); break; | |
2502 case Bytecodes::_fast_fputfield: __ push_f(Ftos_f); break; | |
2503 // get words in right order for use as jvalue object | |
2504 case Bytecodes::_fast_lputfield: __ push_l(Otos_l); break; | |
2505 } | |
2506 // setup pointer to jvalue object | |
2507 __ mov(Lesp, G3_scratch); __ inc(G3_scratch, wordSize); | |
2508 // G4_scratch: object pointer | |
2509 // G1_scratch: cache entry pointer | |
2510 // G3_scratch: jvalue object on the stack | |
2511 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), G4_scratch, G1_scratch, G3_scratch); | |
2512 switch (bytecode()) { // restore tos values | |
2513 case Bytecodes::_fast_aputfield: __ pop_ptr(Otos_i); break; | |
2514 case Bytecodes::_fast_bputfield: // fall through | |
2515 case Bytecodes::_fast_sputfield: // fall through | |
2516 case Bytecodes::_fast_cputfield: // fall through | |
2517 case Bytecodes::_fast_iputfield: __ pop_i(Otos_i); break; | |
2518 case Bytecodes::_fast_dputfield: __ pop_d(Ftos_d); break; | |
2519 case Bytecodes::_fast_fputfield: __ pop_f(Ftos_f); break; | |
2520 case Bytecodes::_fast_lputfield: __ pop_l(Otos_l); break; | |
2521 } | |
2522 __ bind(done); | |
2523 } | |
2524 } | |
2525 | |
2526 // The registers Rcache and index expected to be set before call. | |
2527 // The function may destroy various registers, just not the Rcache and index registers. | |
2528 void TemplateTable::jvmti_post_field_mod(Register Rcache, Register index, bool is_static) { | |
2529 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2530 | |
2531 if (JvmtiExport::can_post_field_modification()) { | |
2532 // Check to see if a field modification watch has been set before we take | |
2533 // the time to call into the VM. | |
2534 Label Label1; | |
2535 assert_different_registers(Rcache, index, G1_scratch); | |
727 | 2536 AddressLiteral get_field_modification_count_addr(JvmtiExport::get_field_modification_count_addr()); |
0 | 2537 __ load_contents(get_field_modification_count_addr, G1_scratch); |
2538 __ tst(G1_scratch); | |
2539 __ br(Assembler::zero, false, Assembler::pt, Label1); | |
2540 __ delayed()->nop(); | |
2541 | |
2542 // The Rcache and index registers have been already set. | |
2543 // This allows to eliminate this call but the Rcache and index | |
2544 // registers must be correspondingly used after this line. | |
2545 __ get_cache_and_index_at_bcp(G1_scratch, G4_scratch, 1); | |
2546 | |
2547 __ add(G1_scratch, in_bytes(cp_base_offset), G3_scratch); | |
2548 if (is_static) { | |
2549 // Life is simple. Null out the object pointer. | |
2550 __ clr(G4_scratch); | |
2551 } else { | |
2552 Register Rflags = G1_scratch; | |
2553 // Life is harder. The stack holds the value on top, followed by the | |
2554 // object. We don't know the size of the value, though; it could be | |
2555 // one or two words depending on its type. As a result, we must find | |
2556 // the type to determine where the object is. | |
2557 | |
2558 Label two_word, valsizeknown; | |
727 | 2559 __ ld_ptr(G1_scratch, cp_base_offset + ConstantPoolCacheEntry::flags_offset(), Rflags); |
0 | 2560 __ mov(Lesp, G4_scratch); |
2561 __ srl(Rflags, ConstantPoolCacheEntry::tosBits, Rflags); | |
2562 // Make sure we don't need to mask Rflags for tosBits after the above shift | |
2563 ConstantPoolCacheEntry::verify_tosBits(); | |
2564 __ cmp(Rflags, ltos); | |
2565 __ br(Assembler::equal, false, Assembler::pt, two_word); | |
2566 __ delayed()->cmp(Rflags, dtos); | |
2567 __ br(Assembler::equal, false, Assembler::pt, two_word); | |
2568 __ delayed()->nop(); | |
2569 __ inc(G4_scratch, Interpreter::expr_offset_in_bytes(1)); | |
2570 __ br(Assembler::always, false, Assembler::pt, valsizeknown); | |
2571 __ delayed()->nop(); | |
2572 __ bind(two_word); | |
2573 | |
2574 __ inc(G4_scratch, Interpreter::expr_offset_in_bytes(2)); | |
2575 | |
2576 __ bind(valsizeknown); | |
2577 // setup object pointer | |
2578 __ ld_ptr(G4_scratch, 0, G4_scratch); | |
2579 __ verify_oop(G4_scratch); | |
2580 } | |
2581 // setup pointer to jvalue object | |
2582 __ mov(Lesp, G1_scratch); __ inc(G1_scratch, wordSize); | |
2583 // G4_scratch: object pointer or NULL if static | |
2584 // G3_scratch: cache entry pointer | |
2585 // G1_scratch: jvalue object on the stack | |
2586 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), | |
2587 G4_scratch, G3_scratch, G1_scratch); | |
2588 __ get_cache_and_index_at_bcp(Rcache, index, 1); | |
2589 __ bind(Label1); | |
2590 } | |
2591 } | |
2592 | |
2593 void TemplateTable::pop_and_check_object(Register r) { | |
2594 __ pop_ptr(r); | |
2595 __ null_check(r); // for field access must check obj. | |
2596 __ verify_oop(r); | |
2597 } | |
2598 | |
2599 void TemplateTable::putfield_or_static(int byte_no, bool is_static) { | |
2600 transition(vtos, vtos); | |
2601 Register Rcache = G3_scratch; | |
2602 Register index = G4_scratch; | |
2603 Register Rclass = Rcache; | |
2604 Register Roffset= G4_scratch; | |
2605 Register Rflags = G1_scratch; | |
2606 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2607 | |
1565 | 2608 resolve_cache_and_index(byte_no, noreg, Rcache, index, sizeof(u2)); |
0 | 2609 jvmti_post_field_mod(Rcache, index, is_static); |
2610 load_field_cp_cache_entry(Rclass, Rcache, index, Roffset, Rflags, is_static); | |
2611 | |
2612 Assembler::Membar_mask_bits read_bits = | |
2613 Assembler::Membar_mask_bits(Assembler::LoadStore | Assembler::StoreStore); | |
2614 Assembler::Membar_mask_bits write_bits = Assembler::StoreLoad; | |
2615 | |
2616 Label notVolatile, checkVolatile, exit; | |
2617 if (__ membar_has_effect(read_bits) || __ membar_has_effect(write_bits)) { | |
2618 __ set((1 << ConstantPoolCacheEntry::volatileField), Lscratch); | |
2619 __ and3(Rflags, Lscratch, Lscratch); | |
2620 | |
2621 if (__ membar_has_effect(read_bits)) { | |
2622 __ tst(Lscratch); | |
2623 __ br(Assembler::zero, false, Assembler::pt, notVolatile); | |
2624 __ delayed()->nop(); | |
2625 volatile_barrier(read_bits); | |
2626 __ bind(notVolatile); | |
2627 } | |
2628 } | |
2629 | |
2630 __ srl(Rflags, ConstantPoolCacheEntry::tosBits, Rflags); | |
2631 // Make sure we don't need to mask Rflags for tosBits after the above shift | |
2632 ConstantPoolCacheEntry::verify_tosBits(); | |
2633 | |
2634 // compute field type | |
2635 Label notInt, notShort, notChar, notObj, notByte, notLong, notFloat; | |
2636 | |
2637 if (is_static) { | |
2638 // putstatic with object type most likely, check that first | |
2639 __ cmp(Rflags, atos ); | |
2640 __ br(Assembler::notEqual, false, Assembler::pt, notObj); | |
2641 __ delayed() ->cmp(Rflags, itos ); | |
2642 | |
2643 // atos | |
2644 __ pop_ptr(); | |
2645 __ verify_oop(Otos_i); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
2646 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
2647 do_oop_store(_masm, Rclass, Roffset, 0, Otos_i, G1_scratch, _bs->kind(), false); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
2648 |
0 | 2649 __ ba(false, checkVolatile); |
2650 __ delayed()->tst(Lscratch); | |
2651 | |
2652 __ bind(notObj); | |
2653 | |
2654 // cmp(Rflags, itos ); | |
2655 __ br(Assembler::notEqual, false, Assembler::pt, notInt); | |
2656 __ delayed() ->cmp(Rflags, btos ); | |
2657 | |
2658 // itos | |
2659 __ pop_i(); | |
2660 __ st(Otos_i, Rclass, Roffset); | |
2661 __ ba(false, checkVolatile); | |
2662 __ delayed()->tst(Lscratch); | |
2663 | |
2664 __ bind(notInt); | |
2665 | |
2666 } else { | |
2667 // putfield with int type most likely, check that first | |
2668 __ cmp(Rflags, itos ); | |
2669 __ br(Assembler::notEqual, false, Assembler::pt, notInt); | |
2670 __ delayed() ->cmp(Rflags, atos ); | |
2671 | |
2672 // itos | |
2673 __ pop_i(); | |
2674 pop_and_check_object(Rclass); | |
2675 __ st(Otos_i, Rclass, Roffset); | |
2676 patch_bytecode(Bytecodes::_fast_iputfield, G3_scratch, G4_scratch); | |
2677 __ ba(false, checkVolatile); | |
2678 __ delayed()->tst(Lscratch); | |
2679 | |
2680 __ bind(notInt); | |
2681 // cmp(Rflags, atos ); | |
2682 __ br(Assembler::notEqual, false, Assembler::pt, notObj); | |
2683 __ delayed() ->cmp(Rflags, btos ); | |
2684 | |
2685 // atos | |
2686 __ pop_ptr(); | |
2687 pop_and_check_object(Rclass); | |
2688 __ verify_oop(Otos_i); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
2689 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
2690 do_oop_store(_masm, Rclass, Roffset, 0, Otos_i, G1_scratch, _bs->kind(), false); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
2691 |
0 | 2692 patch_bytecode(Bytecodes::_fast_aputfield, G3_scratch, G4_scratch); |
2693 __ ba(false, checkVolatile); | |
2694 __ delayed()->tst(Lscratch); | |
2695 | |
2696 __ bind(notObj); | |
2697 } | |
2698 | |
2699 // cmp(Rflags, btos ); | |
2700 __ br(Assembler::notEqual, false, Assembler::pt, notByte); | |
2701 __ delayed() ->cmp(Rflags, ltos ); | |
2702 | |
2703 // btos | |
2704 __ pop_i(); | |
2705 if (!is_static) pop_and_check_object(Rclass); | |
2706 __ stb(Otos_i, Rclass, Roffset); | |
2707 if (!is_static) { | |
2708 patch_bytecode(Bytecodes::_fast_bputfield, G3_scratch, G4_scratch); | |
2709 } | |
2710 __ ba(false, checkVolatile); | |
2711 __ delayed()->tst(Lscratch); | |
2712 | |
2713 __ bind(notByte); | |
2714 | |
2715 // cmp(Rflags, ltos ); | |
2716 __ br(Assembler::notEqual, false, Assembler::pt, notLong); | |
2717 __ delayed() ->cmp(Rflags, ctos ); | |
2718 | |
2719 // ltos | |
2720 __ pop_l(); | |
2721 if (!is_static) pop_and_check_object(Rclass); | |
2722 __ st_long(Otos_l, Rclass, Roffset); | |
2723 if (!is_static) { | |
2724 patch_bytecode(Bytecodes::_fast_lputfield, G3_scratch, G4_scratch); | |
2725 } | |
2726 __ ba(false, checkVolatile); | |
2727 __ delayed()->tst(Lscratch); | |
2728 | |
2729 __ bind(notLong); | |
2730 | |
2731 // cmp(Rflags, ctos ); | |
2732 __ br(Assembler::notEqual, false, Assembler::pt, notChar); | |
2733 __ delayed() ->cmp(Rflags, stos ); | |
2734 | |
2735 // ctos (char) | |
2736 __ pop_i(); | |
2737 if (!is_static) pop_and_check_object(Rclass); | |
2738 __ sth(Otos_i, Rclass, Roffset); | |
2739 if (!is_static) { | |
2740 patch_bytecode(Bytecodes::_fast_cputfield, G3_scratch, G4_scratch); | |
2741 } | |
2742 __ ba(false, checkVolatile); | |
2743 __ delayed()->tst(Lscratch); | |
2744 | |
2745 __ bind(notChar); | |
2746 // cmp(Rflags, stos ); | |
2747 __ br(Assembler::notEqual, false, Assembler::pt, notShort); | |
2748 __ delayed() ->cmp(Rflags, ftos ); | |
2749 | |
2750 // stos (char) | |
2751 __ pop_i(); | |
2752 if (!is_static) pop_and_check_object(Rclass); | |
2753 __ sth(Otos_i, Rclass, Roffset); | |
2754 if (!is_static) { | |
2755 patch_bytecode(Bytecodes::_fast_sputfield, G3_scratch, G4_scratch); | |
2756 } | |
2757 __ ba(false, checkVolatile); | |
2758 __ delayed()->tst(Lscratch); | |
2759 | |
2760 __ bind(notShort); | |
2761 // cmp(Rflags, ftos ); | |
2762 __ br(Assembler::notZero, false, Assembler::pt, notFloat); | |
2763 __ delayed()->nop(); | |
2764 | |
2765 // ftos | |
2766 __ pop_f(); | |
2767 if (!is_static) pop_and_check_object(Rclass); | |
2768 __ stf(FloatRegisterImpl::S, Ftos_f, Rclass, Roffset); | |
2769 if (!is_static) { | |
2770 patch_bytecode(Bytecodes::_fast_fputfield, G3_scratch, G4_scratch); | |
2771 } | |
2772 __ ba(false, checkVolatile); | |
2773 __ delayed()->tst(Lscratch); | |
2774 | |
2775 __ bind(notFloat); | |
2776 | |
2777 // dtos | |
2778 __ pop_d(); | |
2779 if (!is_static) pop_and_check_object(Rclass); | |
2780 __ stf(FloatRegisterImpl::D, Ftos_d, Rclass, Roffset); | |
2781 if (!is_static) { | |
2782 patch_bytecode(Bytecodes::_fast_dputfield, G3_scratch, G4_scratch); | |
2783 } | |
2784 | |
2785 __ bind(checkVolatile); | |
2786 __ tst(Lscratch); | |
2787 | |
2788 if (__ membar_has_effect(write_bits)) { | |
2789 // __ tst(Lscratch); in delay slot | |
2790 __ br(Assembler::zero, false, Assembler::pt, exit); | |
2791 __ delayed()->nop(); | |
2792 volatile_barrier(Assembler::StoreLoad); | |
2793 __ bind(exit); | |
2794 } | |
2795 } | |
2796 | |
2797 void TemplateTable::fast_storefield(TosState state) { | |
2798 transition(state, vtos); | |
2799 Register Rcache = G3_scratch; | |
2800 Register Rclass = Rcache; | |
2801 Register Roffset= G4_scratch; | |
2802 Register Rflags = G1_scratch; | |
2803 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2804 | |
2805 jvmti_post_fast_field_mod(); | |
2806 | |
2807 __ get_cache_and_index_at_bcp(Rcache, G4_scratch, 1); | |
2808 | |
2809 Assembler::Membar_mask_bits read_bits = | |
2810 Assembler::Membar_mask_bits(Assembler::LoadStore | Assembler::StoreStore); | |
2811 Assembler::Membar_mask_bits write_bits = Assembler::StoreLoad; | |
2812 | |
2813 Label notVolatile, checkVolatile, exit; | |
2814 if (__ membar_has_effect(read_bits) || __ membar_has_effect(write_bits)) { | |
727 | 2815 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::flags_offset(), Rflags); |
0 | 2816 __ set((1 << ConstantPoolCacheEntry::volatileField), Lscratch); |
2817 __ and3(Rflags, Lscratch, Lscratch); | |
2818 if (__ membar_has_effect(read_bits)) { | |
2819 __ tst(Lscratch); | |
2820 __ br(Assembler::zero, false, Assembler::pt, notVolatile); | |
2821 __ delayed()->nop(); | |
2822 volatile_barrier(read_bits); | |
2823 __ bind(notVolatile); | |
2824 } | |
2825 } | |
2826 | |
727 | 2827 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Roffset); |
0 | 2828 pop_and_check_object(Rclass); |
2829 | |
2830 switch (bytecode()) { | |
2831 case Bytecodes::_fast_bputfield: __ stb(Otos_i, Rclass, Roffset); break; | |
2832 case Bytecodes::_fast_cputfield: /* fall through */ | |
2833 case Bytecodes::_fast_sputfield: __ sth(Otos_i, Rclass, Roffset); break; | |
2834 case Bytecodes::_fast_iputfield: __ st(Otos_i, Rclass, Roffset); break; | |
2835 case Bytecodes::_fast_lputfield: __ st_long(Otos_l, Rclass, Roffset); break; | |
2836 case Bytecodes::_fast_fputfield: | |
2837 __ stf(FloatRegisterImpl::S, Ftos_f, Rclass, Roffset); | |
2838 break; | |
2839 case Bytecodes::_fast_dputfield: | |
2840 __ stf(FloatRegisterImpl::D, Ftos_d, Rclass, Roffset); | |
2841 break; | |
2842 case Bytecodes::_fast_aputfield: | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
2843 do_oop_store(_masm, Rclass, Roffset, 0, Otos_i, G1_scratch, _bs->kind(), false); |
0 | 2844 break; |
2845 default: | |
2846 ShouldNotReachHere(); | |
2847 } | |
2848 | |
2849 if (__ membar_has_effect(write_bits)) { | |
2850 __ tst(Lscratch); | |
2851 __ br(Assembler::zero, false, Assembler::pt, exit); | |
2852 __ delayed()->nop(); | |
2853 volatile_barrier(Assembler::StoreLoad); | |
2854 __ bind(exit); | |
2855 } | |
2856 } | |
2857 | |
2858 | |
2859 void TemplateTable::putfield(int byte_no) { | |
2860 putfield_or_static(byte_no, false); | |
2861 } | |
2862 | |
2863 void TemplateTable::putstatic(int byte_no) { | |
2864 putfield_or_static(byte_no, true); | |
2865 } | |
2866 | |
2867 | |
2868 void TemplateTable::fast_xaccess(TosState state) { | |
2869 transition(vtos, state); | |
2870 Register Rcache = G3_scratch; | |
2871 Register Roffset = G4_scratch; | |
2872 Register Rflags = G4_scratch; | |
2873 Register Rreceiver = Lscratch; | |
2874 | |
1506 | 2875 __ ld_ptr(Llocals, 0, Rreceiver); |
0 | 2876 |
2877 // access constant pool cache (is resolved) | |
2878 __ get_cache_and_index_at_bcp(Rcache, G4_scratch, 2); | |
727 | 2879 __ ld_ptr(Rcache, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f2_offset(), Roffset); |
0 | 2880 __ add(Lbcp, 1, Lbcp); // needed to report exception at the correct bcp |
2881 | |
2882 __ verify_oop(Rreceiver); | |
2883 __ null_check(Rreceiver); | |
2884 if (state == atos) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2885 __ load_heap_oop(Rreceiver, Roffset, Otos_i); |
0 | 2886 } else if (state == itos) { |
2887 __ ld (Rreceiver, Roffset, Otos_i) ; | |
2888 } else if (state == ftos) { | |
2889 __ ldf(FloatRegisterImpl::S, Rreceiver, Roffset, Ftos_f); | |
2890 } else { | |
2891 ShouldNotReachHere(); | |
2892 } | |
2893 | |
2894 Assembler::Membar_mask_bits membar_bits = | |
2895 Assembler::Membar_mask_bits(Assembler::LoadLoad | Assembler::LoadStore); | |
2896 if (__ membar_has_effect(membar_bits)) { | |
2897 | |
2898 // Get is_volatile value in Rflags and check if membar is needed | |
727 | 2899 __ ld_ptr(Rcache, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::flags_offset(), Rflags); |
0 | 2900 |
2901 // Test volatile | |
2902 Label notVolatile; | |
2903 __ set((1 << ConstantPoolCacheEntry::volatileField), Lscratch); | |
2904 __ btst(Rflags, Lscratch); | |
2905 __ br(Assembler::zero, false, Assembler::pt, notVolatile); | |
2906 __ delayed()->nop(); | |
2907 volatile_barrier(membar_bits); | |
2908 __ bind(notVolatile); | |
2909 } | |
2910 | |
2911 __ interp_verify_oop(Otos_i, state, __FILE__, __LINE__); | |
2912 __ sub(Lbcp, 1, Lbcp); | |
2913 } | |
2914 | |
2915 //---------------------------------------------------------------------------------------------------- | |
2916 // Calls | |
2917 | |
2918 void TemplateTable::count_calls(Register method, Register temp) { | |
2919 // implemented elsewhere | |
2920 ShouldNotReachHere(); | |
2921 } | |
2922 | |
2923 void TemplateTable::generate_vtable_call(Register Rrecv, Register Rindex, Register Rret) { | |
2924 Register Rtemp = G4_scratch; | |
2925 Register Rcall = Rindex; | |
2926 assert_different_registers(Rcall, G5_method, Gargs, Rret); | |
2927 | |
2928 // get target methodOop & entry point | |
2929 const int base = instanceKlass::vtable_start_offset() * wordSize; | |
2930 if (vtableEntry::size() % 3 == 0) { | |
2931 // scale the vtable index by 12: | |
2932 int one_third = vtableEntry::size() / 3; | |
2933 __ sll(Rindex, exact_log2(one_third * 1 * wordSize), Rtemp); | |
2934 __ sll(Rindex, exact_log2(one_third * 2 * wordSize), Rindex); | |
2935 __ add(Rindex, Rtemp, Rindex); | |
2936 } else { | |
2937 // scale the vtable index by 8: | |
2938 __ sll(Rindex, exact_log2(vtableEntry::size() * wordSize), Rindex); | |
2939 } | |
2940 | |
2941 __ add(Rrecv, Rindex, Rrecv); | |
2942 __ ld_ptr(Rrecv, base + vtableEntry::method_offset_in_bytes(), G5_method); | |
2943 | |
2944 __ call_from_interpreter(Rcall, Gargs, Rret); | |
2945 } | |
2946 | |
2947 void TemplateTable::invokevirtual(int byte_no) { | |
2948 transition(vtos, vtos); | |
1565 | 2949 assert(byte_no == f2_byte, "use this argument"); |
0 | 2950 |
2951 Register Rscratch = G3_scratch; | |
2952 Register Rtemp = G4_scratch; | |
2953 Register Rret = Lscratch; | |
2954 Register Rrecv = G5_method; | |
2955 Label notFinal; | |
2956 | |
1565 | 2957 load_invoke_cp_cache_entry(byte_no, G5_method, noreg, Rret, true, false, false); |
0 | 2958 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore |
2959 | |
2960 // Check for vfinal | |
2961 __ set((1 << ConstantPoolCacheEntry::vfinalMethod), G4_scratch); | |
2962 __ btst(Rret, G4_scratch); | |
2963 __ br(Assembler::zero, false, Assembler::pt, notFinal); | |
2964 __ delayed()->and3(Rret, 0xFF, G4_scratch); // gets number of parameters | |
2965 | |
2966 patch_bytecode(Bytecodes::_fast_invokevfinal, Rscratch, Rtemp); | |
2967 | |
2968 invokevfinal_helper(Rscratch, Rret); | |
2969 | |
2970 __ bind(notFinal); | |
2971 | |
2972 __ mov(G5_method, Rscratch); // better scratch register | |
2973 __ load_receiver(G4_scratch, O0); // gets receiverOop | |
2974 // receiver is in O0 | |
2975 __ verify_oop(O0); | |
2976 | |
2977 // get return address | |
727 | 2978 AddressLiteral table(Interpreter::return_3_addrs_by_index_table()); |
2979 __ set(table, Rtemp); | |
0 | 2980 __ srl(Rret, ConstantPoolCacheEntry::tosBits, Rret); // get return type |
2981 // Make sure we don't need to mask Rret for tosBits after the above shift | |
2982 ConstantPoolCacheEntry::verify_tosBits(); | |
2983 __ sll(Rret, LogBytesPerWord, Rret); | |
2984 __ ld_ptr(Rtemp, Rret, Rret); // get return address | |
2985 | |
2986 // get receiver klass | |
2987 __ null_check(O0, 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
|
2988 __ load_klass(O0, Rrecv); |
0 | 2989 __ verify_oop(Rrecv); |
2990 | |
2991 __ profile_virtual_call(Rrecv, O4); | |
2992 | |
2993 generate_vtable_call(Rrecv, Rscratch, Rret); | |
2994 } | |
2995 | |
2996 void TemplateTable::fast_invokevfinal(int byte_no) { | |
2997 transition(vtos, vtos); | |
1565 | 2998 assert(byte_no == f2_byte, "use this argument"); |
0 | 2999 |
3000 load_invoke_cp_cache_entry(byte_no, G5_method, noreg, Lscratch, true, | |
1565 | 3001 /*is_invokevfinal*/true, false); |
0 | 3002 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore |
3003 invokevfinal_helper(G3_scratch, Lscratch); | |
3004 } | |
3005 | |
3006 void TemplateTable::invokevfinal_helper(Register Rscratch, Register Rret) { | |
3007 Register Rtemp = G4_scratch; | |
3008 | |
3009 __ verify_oop(G5_method); | |
3010 | |
3011 // Load receiver from stack slot | |
727 | 3012 __ lduh(G5_method, in_bytes(methodOopDesc::size_of_parameters_offset()), G4_scratch); |
0 | 3013 __ load_receiver(G4_scratch, O0); |
3014 | |
3015 // receiver NULL check | |
3016 __ null_check(O0); | |
3017 | |
3018 __ profile_final_call(O4); | |
3019 | |
3020 // get return address | |
727 | 3021 AddressLiteral table(Interpreter::return_3_addrs_by_index_table()); |
3022 __ set(table, Rtemp); | |
0 | 3023 __ srl(Rret, ConstantPoolCacheEntry::tosBits, Rret); // get return type |
3024 // Make sure we don't need to mask Rret for tosBits after the above shift | |
3025 ConstantPoolCacheEntry::verify_tosBits(); | |
3026 __ sll(Rret, LogBytesPerWord, Rret); | |
3027 __ ld_ptr(Rtemp, Rret, Rret); // get return address | |
3028 | |
3029 | |
3030 // do the call | |
3031 __ call_from_interpreter(Rscratch, Gargs, Rret); | |
3032 } | |
3033 | |
3034 void TemplateTable::invokespecial(int byte_no) { | |
3035 transition(vtos, vtos); | |
1565 | 3036 assert(byte_no == f1_byte, "use this argument"); |
0 | 3037 |
3038 Register Rscratch = G3_scratch; | |
3039 Register Rtemp = G4_scratch; | |
3040 Register Rret = Lscratch; | |
3041 | |
1565 | 3042 load_invoke_cp_cache_entry(byte_no, G5_method, noreg, Rret, /*virtual*/ false, false, false); |
0 | 3043 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore |
3044 | |
3045 __ verify_oop(G5_method); | |
3046 | |
727 | 3047 __ lduh(G5_method, in_bytes(methodOopDesc::size_of_parameters_offset()), G4_scratch); |
0 | 3048 __ load_receiver(G4_scratch, O0); |
3049 | |
3050 // receiver NULL check | |
3051 __ null_check(O0); | |
3052 | |
3053 __ profile_call(O4); | |
3054 | |
3055 // get return address | |
727 | 3056 AddressLiteral table(Interpreter::return_3_addrs_by_index_table()); |
3057 __ set(table, Rtemp); | |
0 | 3058 __ srl(Rret, ConstantPoolCacheEntry::tosBits, Rret); // get return type |
3059 // Make sure we don't need to mask Rret for tosBits after the above shift | |
3060 ConstantPoolCacheEntry::verify_tosBits(); | |
3061 __ sll(Rret, LogBytesPerWord, Rret); | |
3062 __ ld_ptr(Rtemp, Rret, Rret); // get return address | |
3063 | |
3064 // do the call | |
3065 __ call_from_interpreter(Rscratch, Gargs, Rret); | |
3066 } | |
3067 | |
3068 void TemplateTable::invokestatic(int byte_no) { | |
3069 transition(vtos, vtos); | |
1565 | 3070 assert(byte_no == f1_byte, "use this argument"); |
0 | 3071 |
3072 Register Rscratch = G3_scratch; | |
3073 Register Rtemp = G4_scratch; | |
3074 Register Rret = Lscratch; | |
3075 | |
1565 | 3076 load_invoke_cp_cache_entry(byte_no, G5_method, noreg, Rret, /*virtual*/ false, false, false); |
0 | 3077 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore |
3078 | |
3079 __ verify_oop(G5_method); | |
3080 | |
3081 __ profile_call(O4); | |
3082 | |
3083 // get return address | |
727 | 3084 AddressLiteral table(Interpreter::return_3_addrs_by_index_table()); |
3085 __ set(table, Rtemp); | |
0 | 3086 __ srl(Rret, ConstantPoolCacheEntry::tosBits, Rret); // get return type |
3087 // Make sure we don't need to mask Rret for tosBits after the above shift | |
3088 ConstantPoolCacheEntry::verify_tosBits(); | |
3089 __ sll(Rret, LogBytesPerWord, Rret); | |
3090 __ ld_ptr(Rtemp, Rret, Rret); // get return address | |
3091 | |
3092 // do the call | |
3093 __ call_from_interpreter(Rscratch, Gargs, Rret); | |
3094 } | |
3095 | |
3096 | |
3097 void TemplateTable::invokeinterface_object_method(Register RklassOop, | |
3098 Register Rcall, | |
3099 Register Rret, | |
3100 Register Rflags) { | |
3101 Register Rscratch = G4_scratch; | |
3102 Register Rindex = Lscratch; | |
3103 | |
3104 assert_different_registers(Rscratch, Rindex, Rret); | |
3105 | |
3106 Label notFinal; | |
3107 | |
3108 // Check for vfinal | |
3109 __ set((1 << ConstantPoolCacheEntry::vfinalMethod), Rscratch); | |
3110 __ btst(Rflags, Rscratch); | |
3111 __ br(Assembler::zero, false, Assembler::pt, notFinal); | |
3112 __ delayed()->nop(); | |
3113 | |
3114 __ profile_final_call(O4); | |
3115 | |
3116 // do the call - the index (f2) contains the methodOop | |
3117 assert_different_registers(G5_method, Gargs, Rcall); | |
3118 __ mov(Rindex, G5_method); | |
3119 __ call_from_interpreter(Rcall, Gargs, Rret); | |
3120 __ bind(notFinal); | |
3121 | |
3122 __ profile_virtual_call(RklassOop, O4); | |
3123 generate_vtable_call(RklassOop, Rindex, Rret); | |
3124 } | |
3125 | |
3126 | |
3127 void TemplateTable::invokeinterface(int byte_no) { | |
3128 transition(vtos, vtos); | |
1565 | 3129 assert(byte_no == f1_byte, "use this argument"); |
0 | 3130 |
3131 Register Rscratch = G4_scratch; | |
3132 Register Rret = G3_scratch; | |
3133 Register Rindex = Lscratch; | |
3134 Register Rinterface = G1_scratch; | |
3135 Register RklassOop = G5_method; | |
3136 Register Rflags = O1; | |
3137 assert_different_registers(Rscratch, G5_method); | |
3138 | |
1565 | 3139 load_invoke_cp_cache_entry(byte_no, Rinterface, Rindex, Rflags, /*virtual*/ false, false, false); |
0 | 3140 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore |
3141 | |
3142 // get receiver | |
3143 __ and3(Rflags, 0xFF, Rscratch); // gets number of parameters | |
3144 __ load_receiver(Rscratch, O0); | |
3145 __ verify_oop(O0); | |
3146 | |
3147 __ mov(Rflags, Rret); | |
3148 | |
3149 // get return address | |
727 | 3150 AddressLiteral table(Interpreter::return_5_addrs_by_index_table()); |
3151 __ set(table, Rscratch); | |
0 | 3152 __ srl(Rret, ConstantPoolCacheEntry::tosBits, Rret); // get return type |
3153 // Make sure we don't need to mask Rret for tosBits after the above shift | |
3154 ConstantPoolCacheEntry::verify_tosBits(); | |
3155 __ sll(Rret, LogBytesPerWord, Rret); | |
3156 __ ld_ptr(Rscratch, Rret, Rret); // get return address | |
3157 | |
3158 // get receiver klass | |
3159 __ null_check(O0, 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
|
3160 __ load_klass(O0, RklassOop); |
0 | 3161 __ verify_oop(RklassOop); |
3162 | |
3163 // Special case of invokeinterface called for virtual method of | |
3164 // java.lang.Object. See cpCacheOop.cpp for details. | |
3165 // This code isn't produced by javac, but could be produced by | |
3166 // another compliant java compiler. | |
3167 Label notMethod; | |
3168 __ set((1 << ConstantPoolCacheEntry::methodInterface), Rscratch); | |
3169 __ btst(Rflags, Rscratch); | |
3170 __ br(Assembler::zero, false, Assembler::pt, notMethod); | |
3171 __ delayed()->nop(); | |
3172 | |
3173 invokeinterface_object_method(RklassOop, Rinterface, Rret, Rflags); | |
3174 | |
3175 __ bind(notMethod); | |
3176 | |
3177 __ profile_virtual_call(RklassOop, O4); | |
3178 | |
3179 // | |
3180 // find entry point to call | |
3181 // | |
3182 | |
3183 // compute start of first itableOffsetEntry (which is at end of vtable) | |
3184 const int base = instanceKlass::vtable_start_offset() * wordSize; | |
3185 Label search; | |
3186 Register Rtemp = Rflags; | |
3187 | |
727 | 3188 __ ld(RklassOop, instanceKlass::vtable_length_offset() * wordSize, Rtemp); |
0 | 3189 if (align_object_offset(1) > 1) { |
3190 __ round_to(Rtemp, align_object_offset(1)); | |
3191 } | |
3192 __ sll(Rtemp, LogBytesPerWord, Rtemp); // Rscratch *= 4; | |
3193 if (Assembler::is_simm13(base)) { | |
3194 __ add(Rtemp, base, Rtemp); | |
3195 } else { | |
3196 __ set(base, Rscratch); | |
3197 __ add(Rscratch, Rtemp, Rtemp); | |
3198 } | |
3199 __ add(RklassOop, Rtemp, Rscratch); | |
3200 | |
3201 __ bind(search); | |
3202 | |
3203 __ ld_ptr(Rscratch, itableOffsetEntry::interface_offset_in_bytes(), Rtemp); | |
3204 { | |
3205 Label ok; | |
3206 | |
3207 // Check that entry is non-null. Null entries are probably a bytecode | |
605 | 3208 // problem. If the interface isn't implemented by the receiver class, |
0 | 3209 // the VM should throw IncompatibleClassChangeError. linkResolver checks |
3210 // this too but that's only if the entry isn't already resolved, so we | |
3211 // need to check again. | |
3212 __ br_notnull( Rtemp, false, Assembler::pt, ok); | |
3213 __ delayed()->nop(); | |
3214 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_IncompatibleClassChangeError)); | |
3215 __ should_not_reach_here(); | |
3216 __ bind(ok); | |
3217 __ verify_oop(Rtemp); | |
3218 } | |
3219 | |
3220 __ verify_oop(Rinterface); | |
3221 | |
3222 __ cmp(Rinterface, Rtemp); | |
3223 __ brx(Assembler::notEqual, true, Assembler::pn, search); | |
3224 __ delayed()->add(Rscratch, itableOffsetEntry::size() * wordSize, Rscratch); | |
3225 | |
3226 // entry found and Rscratch points to it | |
3227 __ ld(Rscratch, itableOffsetEntry::offset_offset_in_bytes(), Rscratch); | |
3228 | |
3229 assert(itableMethodEntry::method_offset_in_bytes() == 0, "adjust instruction below"); | |
3230 __ sll(Rindex, exact_log2(itableMethodEntry::size() * wordSize), Rindex); // Rindex *= 8; | |
3231 __ add(Rscratch, Rindex, Rscratch); | |
3232 __ ld_ptr(RklassOop, Rscratch, G5_method); | |
3233 | |
3234 // Check for abstract method error. | |
3235 { | |
3236 Label ok; | |
3237 __ tst(G5_method); | |
3238 __ brx(Assembler::notZero, false, Assembler::pt, ok); | |
3239 __ delayed()->nop(); | |
3240 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); | |
3241 __ should_not_reach_here(); | |
3242 __ bind(ok); | |
3243 } | |
3244 | |
3245 Register Rcall = Rinterface; | |
3246 assert_different_registers(Rcall, G5_method, Gargs, Rret); | |
3247 | |
3248 __ verify_oop(G5_method); | |
3249 __ call_from_interpreter(Rcall, Gargs, Rret); | |
3250 | |
3251 } | |
3252 | |
3253 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3254 void TemplateTable::invokedynamic(int byte_no) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3255 transition(vtos, vtos); |
1565 | 3256 assert(byte_no == f1_oop, "use this argument"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3257 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3258 if (!EnableInvokeDynamic) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3259 // We should not encounter this bytecode if !EnableInvokeDynamic. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3260 // The verifier will stop it. However, if we get past the verifier, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3261 // this will stop the thread in a reasonable way, without crashing the JVM. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3262 __ call_VM(noreg, CAST_FROM_FN_PTR(address, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3263 InterpreterRuntime::throw_IncompatibleClassChangeError)); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3264 // the call_VM checks for exception, so we should never return here. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3265 __ should_not_reach_here(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3266 return; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3267 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3268 |
1503 | 3269 // G5: CallSite object (f1) |
3270 // XX: unused (f2) | |
3271 // XX: flags (unused) | |
3272 | |
3273 Register G5_callsite = G5_method; | |
3274 Register Rscratch = G3_scratch; | |
3275 Register Rtemp = G1_scratch; | |
3276 Register Rret = Lscratch; | |
3277 | |
1565 | 3278 load_invoke_cp_cache_entry(byte_no, G5_callsite, noreg, Rret, |
3279 /*virtual*/ false, /*vfinal*/ false, /*indy*/ true); | |
1503 | 3280 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore |
3281 | |
3282 __ verify_oop(G5_callsite); | |
3283 | |
3284 // profile this call | |
3285 __ profile_call(O4); | |
3286 | |
3287 // get return address | |
3288 AddressLiteral table(Interpreter::return_5_addrs_by_index_table()); | |
3289 __ set(table, Rtemp); | |
3290 __ srl(Rret, ConstantPoolCacheEntry::tosBits, Rret); // get return type | |
3291 // Make sure we don't need to mask Rret for tosBits after the above shift | |
3292 ConstantPoolCacheEntry::verify_tosBits(); | |
3293 __ sll(Rret, LogBytesPerWord, Rret); | |
3294 __ ld_ptr(Rtemp, Rret, Rret); // get return address | |
3295 | |
1846 | 3296 __ load_heap_oop(G5_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, Rscratch), G3_method_handle); |
1503 | 3297 __ null_check(G3_method_handle); |
3298 | |
3299 // Adjust Rret first so Llast_SP can be same as Rret | |
3300 __ add(Rret, -frame::pc_return_offset, O7); | |
3301 __ add(Lesp, BytesPerWord, Gargs); // setup parameter pointer | |
3302 __ jump_to_method_handle_entry(G3_method_handle, Rtemp, /* emit_delayed_nop */ false); | |
3303 // Record SP so we can remove any stack space allocated by adapter transition | |
3304 __ delayed()->mov(SP, Llast_SP); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3305 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3306 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
3307 |
0 | 3308 //---------------------------------------------------------------------------------------------------- |
3309 // Allocation | |
3310 | |
3311 void TemplateTable::_new() { | |
3312 transition(vtos, atos); | |
3313 | |
3314 Label slow_case; | |
3315 Label done; | |
3316 Label initialize_header; | |
3317 Label initialize_object; // including clearing the fields | |
3318 | |
3319 Register RallocatedObject = Otos_i; | |
3320 Register RinstanceKlass = O1; | |
3321 Register Roffset = O3; | |
3322 Register Rscratch = O4; | |
3323 | |
3324 __ get_2_byte_integer_at_bcp(1, Rscratch, Roffset, InterpreterMacroAssembler::Unsigned); | |
3325 __ get_cpool_and_tags(Rscratch, G3_scratch); | |
3326 // make sure the class we're about to instantiate has been resolved | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3327 // This is done before loading instanceKlass to be consistent with the order |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3328 // how Constant Pool is updated (see constantPoolOopDesc::klass_at_put) |
0 | 3329 __ add(G3_scratch, typeArrayOopDesc::header_size(T_BYTE) * wordSize, G3_scratch); |
3330 __ ldub(G3_scratch, Roffset, G3_scratch); | |
3331 __ cmp(G3_scratch, JVM_CONSTANT_Class); | |
3332 __ br(Assembler::notEqual, false, Assembler::pn, slow_case); | |
3333 __ delayed()->sll(Roffset, LogBytesPerWord, Roffset); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3334 // get instanceKlass |
0 | 3335 //__ sll(Roffset, LogBytesPerWord, Roffset); // executed in delay slot |
3336 __ add(Roffset, sizeof(constantPoolOopDesc), Roffset); | |
3337 __ ld_ptr(Rscratch, Roffset, RinstanceKlass); | |
3338 | |
3339 // make sure klass is fully initialized: | |
3340 __ ld(RinstanceKlass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc), G3_scratch); | |
3341 __ cmp(G3_scratch, instanceKlass::fully_initialized); | |
3342 __ br(Assembler::notEqual, false, Assembler::pn, slow_case); | |
3343 __ delayed()->ld(RinstanceKlass, Klass::layout_helper_offset_in_bytes() + sizeof(oopDesc), Roffset); | |
3344 | |
3345 // get instance_size in instanceKlass (already aligned) | |
3346 //__ ld(RinstanceKlass, Klass::layout_helper_offset_in_bytes() + sizeof(oopDesc), Roffset); | |
3347 | |
3348 // make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class | |
3349 __ btst(Klass::_lh_instance_slow_path_bit, Roffset); | |
3350 __ br(Assembler::notZero, false, Assembler::pn, slow_case); | |
3351 __ delayed()->nop(); | |
3352 | |
3353 // allocate the instance | |
3354 // 1) Try to allocate in the TLAB | |
3355 // 2) if fail, and the TLAB is not full enough to discard, allocate in the shared Eden | |
3356 // 3) if the above fails (or is not applicable), go to a slow case | |
3357 // (creates a new TLAB, etc.) | |
3358 | |
3359 const bool allow_shared_alloc = | |
3360 Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode; | |
3361 | |
3362 if(UseTLAB) { | |
3363 Register RoldTopValue = RallocatedObject; | |
3364 Register RtopAddr = G3_scratch, RtlabWasteLimitValue = G3_scratch; | |
3365 Register RnewTopValue = G1_scratch; | |
3366 Register RendValue = Rscratch; | |
3367 Register RfreeValue = RnewTopValue; | |
3368 | |
3369 // check if we can allocate in the TLAB | |
3370 __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), RoldTopValue); // sets up RalocatedObject | |
3371 __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), RendValue); | |
3372 __ add(RoldTopValue, Roffset, RnewTopValue); | |
3373 | |
3374 // if there is enough space, we do not CAS and do not clear | |
3375 __ cmp(RnewTopValue, RendValue); | |
3376 if(ZeroTLAB) { | |
3377 // the fields have already been cleared | |
3378 __ brx(Assembler::lessEqualUnsigned, true, Assembler::pt, initialize_header); | |
3379 } else { | |
3380 // initialize both the header and fields | |
3381 __ brx(Assembler::lessEqualUnsigned, true, Assembler::pt, initialize_object); | |
3382 } | |
3383 __ delayed()->st_ptr(RnewTopValue, G2_thread, in_bytes(JavaThread::tlab_top_offset())); | |
3384 | |
3385 if (allow_shared_alloc) { | |
3386 // Check if tlab should be discarded (refill_waste_limit >= free) | |
3387 __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue); | |
3388 __ sub(RendValue, RoldTopValue, RfreeValue); | |
3389 #ifdef _LP64 | |
3390 __ srlx(RfreeValue, LogHeapWordSize, RfreeValue); | |
3391 #else | |
3392 __ srl(RfreeValue, LogHeapWordSize, RfreeValue); | |
3393 #endif | |
3394 __ cmp(RtlabWasteLimitValue, RfreeValue); | |
3395 __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, slow_case); // tlab waste is small | |
3396 __ delayed()->nop(); | |
3397 | |
3398 // increment waste limit to prevent getting stuck on this slow path | |
3399 __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue); | |
3400 __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset())); | |
3401 } else { | |
3402 // No allocation in the shared eden. | |
3403 __ br(Assembler::always, false, Assembler::pt, slow_case); | |
3404 __ delayed()->nop(); | |
3405 } | |
3406 } | |
3407 | |
3408 // Allocation in the shared Eden | |
3409 if (allow_shared_alloc) { | |
3410 Register RoldTopValue = G1_scratch; | |
3411 Register RtopAddr = G3_scratch; | |
3412 Register RnewTopValue = RallocatedObject; | |
3413 Register RendValue = Rscratch; | |
3414 | |
3415 __ set((intptr_t)Universe::heap()->top_addr(), RtopAddr); | |
3416 | |
3417 Label retry; | |
3418 __ bind(retry); | |
3419 __ set((intptr_t)Universe::heap()->end_addr(), RendValue); | |
3420 __ ld_ptr(RendValue, 0, RendValue); | |
3421 __ ld_ptr(RtopAddr, 0, RoldTopValue); | |
3422 __ add(RoldTopValue, Roffset, RnewTopValue); | |
3423 | |
3424 // RnewTopValue contains the top address after the new object | |
3425 // has been allocated. | |
3426 __ cmp(RnewTopValue, RendValue); | |
3427 __ brx(Assembler::greaterUnsigned, false, Assembler::pn, slow_case); | |
3428 __ delayed()->nop(); | |
3429 | |
3430 __ casx_under_lock(RtopAddr, RoldTopValue, RnewTopValue, | |
3431 VM_Version::v9_instructions_work() ? NULL : | |
3432 (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr()); | |
3433 | |
3434 // if someone beat us on the allocation, try again, otherwise continue | |
3435 __ cmp(RoldTopValue, RnewTopValue); | |
3436 __ brx(Assembler::notEqual, false, Assembler::pn, retry); | |
3437 __ delayed()->nop(); | |
3438 } | |
3439 | |
3440 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { | |
3441 // clear object fields | |
3442 __ bind(initialize_object); | |
3443 __ deccc(Roffset, sizeof(oopDesc)); | |
3444 __ br(Assembler::zero, false, Assembler::pt, initialize_header); | |
3445 __ delayed()->add(RallocatedObject, sizeof(oopDesc), G3_scratch); | |
3446 | |
3447 // initialize remaining object fields | |
3448 { Label loop; | |
3449 __ subcc(Roffset, wordSize, Roffset); | |
3450 __ bind(loop); | |
3451 //__ subcc(Roffset, wordSize, Roffset); // executed above loop or in delay slot | |
3452 __ st_ptr(G0, G3_scratch, Roffset); | |
3453 __ br(Assembler::notEqual, false, Assembler::pt, loop); | |
3454 __ delayed()->subcc(Roffset, wordSize, Roffset); | |
3455 } | |
3456 __ br(Assembler::always, false, Assembler::pt, initialize_header); | |
3457 __ delayed()->nop(); | |
3458 } | |
3459 | |
3460 // slow case | |
3461 __ bind(slow_case); | |
3462 __ get_2_byte_integer_at_bcp(1, G3_scratch, O2, InterpreterMacroAssembler::Unsigned); | |
3463 __ get_constant_pool(O1); | |
3464 | |
3465 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), O1, O2); | |
3466 | |
3467 __ ba(false, done); | |
3468 __ delayed()->nop(); | |
3469 | |
3470 // Initialize the header: mark, klass | |
3471 __ bind(initialize_header); | |
3472 | |
3473 if (UseBiasedLocking) { | |
3474 __ ld_ptr(RinstanceKlass, Klass::prototype_header_offset_in_bytes() + sizeof(oopDesc), G4_scratch); | |
3475 } else { | |
3476 __ set((intptr_t)markOopDesc::prototype(), G4_scratch); | |
3477 } | |
3478 __ st_ptr(G4_scratch, RallocatedObject, oopDesc::mark_offset_in_bytes()); // mark | |
167
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
3479 __ store_klass_gap(G0, RallocatedObject); // klass gap if compressed |
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
3480 __ store_klass(RinstanceKlass, RallocatedObject); // klass (last for cms) |
0 | 3481 |
3482 { | |
3483 SkipIfEqual skip_if( | |
3484 _masm, G4_scratch, &DTraceAllocProbes, Assembler::zero); | |
3485 // Trigger dtrace event | |
3486 __ push(atos); | |
3487 __ call_VM_leaf(noreg, | |
3488 CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), O0); | |
3489 __ pop(atos); | |
3490 } | |
3491 | |
3492 // continue | |
3493 __ bind(done); | |
3494 } | |
3495 | |
3496 | |
3497 | |
3498 void TemplateTable::newarray() { | |
3499 transition(itos, atos); | |
3500 __ ldub(Lbcp, 1, O1); | |
3501 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::newarray), O1, Otos_i); | |
3502 } | |
3503 | |
3504 | |
3505 void TemplateTable::anewarray() { | |
3506 transition(itos, atos); | |
3507 __ get_constant_pool(O1); | |
3508 __ get_2_byte_integer_at_bcp(1, G4_scratch, O2, InterpreterMacroAssembler::Unsigned); | |
3509 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::anewarray), O1, O2, Otos_i); | |
3510 } | |
3511 | |
3512 | |
3513 void TemplateTable::arraylength() { | |
3514 transition(atos, itos); | |
3515 Label ok; | |
3516 __ verify_oop(Otos_i); | |
3517 __ tst(Otos_i); | |
3518 __ throw_if_not_1_x( Assembler::notZero, ok ); | |
3519 __ delayed()->ld(Otos_i, arrayOopDesc::length_offset_in_bytes(), Otos_i); | |
3520 __ throw_if_not_2( Interpreter::_throw_NullPointerException_entry, G3_scratch, ok); | |
3521 } | |
3522 | |
3523 | |
3524 void TemplateTable::checkcast() { | |
3525 transition(atos, atos); | |
3526 Label done, is_null, quicked, cast_ok, resolved; | |
3527 Register Roffset = G1_scratch; | |
3528 Register RobjKlass = O5; | |
3529 Register RspecifiedKlass = O4; | |
3530 | |
3531 // Check for casting a NULL | |
3532 __ br_null(Otos_i, false, Assembler::pn, is_null); | |
3533 __ delayed()->nop(); | |
3534 | |
3535 // Get value klass in RobjKlass | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3536 __ load_klass(Otos_i, RobjKlass); // get value klass |
0 | 3537 |
3538 // Get constant pool tag | |
3539 __ get_2_byte_integer_at_bcp(1, Lscratch, Roffset, InterpreterMacroAssembler::Unsigned); | |
3540 | |
3541 // See if the checkcast has been quickened | |
3542 __ get_cpool_and_tags(Lscratch, G3_scratch); | |
3543 __ add(G3_scratch, typeArrayOopDesc::header_size(T_BYTE) * wordSize, G3_scratch); | |
3544 __ ldub(G3_scratch, Roffset, G3_scratch); | |
3545 __ cmp(G3_scratch, JVM_CONSTANT_Class); | |
3546 __ br(Assembler::equal, true, Assembler::pt, quicked); | |
3547 __ delayed()->sll(Roffset, LogBytesPerWord, Roffset); | |
3548 | |
3549 __ push_ptr(); // save receiver for result, and for GC | |
3550 call_VM(RspecifiedKlass, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc) ); | |
3551 __ pop_ptr(Otos_i, G3_scratch); // restore receiver | |
3552 | |
3553 __ br(Assembler::always, false, Assembler::pt, resolved); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3554 __ delayed()->nop(); |
0 | 3555 |
3556 // Extract target class from constant pool | |
3557 __ bind(quicked); | |
3558 __ add(Roffset, sizeof(constantPoolOopDesc), Roffset); | |
3559 __ ld_ptr(Lscratch, Roffset, RspecifiedKlass); | |
3560 __ bind(resolved); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3561 __ load_klass(Otos_i, RobjKlass); // get value klass |
0 | 3562 |
3563 // Generate a fast subtype check. Branch to cast_ok if no | |
3564 // failure. Throw exception if failure. | |
3565 __ gen_subtype_check( RobjKlass, RspecifiedKlass, G3_scratch, G4_scratch, G1_scratch, cast_ok ); | |
3566 | |
3567 // Not a subtype; so must throw exception | |
3568 __ throw_if_not_x( Assembler::never, Interpreter::_throw_ClassCastException_entry, G3_scratch ); | |
3569 | |
3570 __ bind(cast_ok); | |
3571 | |
3572 if (ProfileInterpreter) { | |
3573 __ ba(false, done); | |
3574 __ delayed()->nop(); | |
3575 } | |
3576 __ bind(is_null); | |
3577 __ profile_null_seen(G3_scratch); | |
3578 __ bind(done); | |
3579 } | |
3580 | |
3581 | |
3582 void TemplateTable::instanceof() { | |
3583 Label done, is_null, quicked, resolved; | |
3584 transition(atos, itos); | |
3585 Register Roffset = G1_scratch; | |
3586 Register RobjKlass = O5; | |
3587 Register RspecifiedKlass = O4; | |
3588 | |
3589 // Check for casting a NULL | |
3590 __ br_null(Otos_i, false, Assembler::pt, is_null); | |
3591 __ delayed()->nop(); | |
3592 | |
3593 // Get value klass in RobjKlass | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3594 __ load_klass(Otos_i, RobjKlass); // get value klass |
0 | 3595 |
3596 // Get constant pool tag | |
3597 __ get_2_byte_integer_at_bcp(1, Lscratch, Roffset, InterpreterMacroAssembler::Unsigned); | |
3598 | |
3599 // See if the checkcast has been quickened | |
3600 __ get_cpool_and_tags(Lscratch, G3_scratch); | |
3601 __ add(G3_scratch, typeArrayOopDesc::header_size(T_BYTE) * wordSize, G3_scratch); | |
3602 __ ldub(G3_scratch, Roffset, G3_scratch); | |
3603 __ cmp(G3_scratch, JVM_CONSTANT_Class); | |
3604 __ br(Assembler::equal, true, Assembler::pt, quicked); | |
3605 __ delayed()->sll(Roffset, LogBytesPerWord, Roffset); | |
3606 | |
3607 __ push_ptr(); // save receiver for result, and for GC | |
3608 call_VM(RspecifiedKlass, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc) ); | |
3609 __ pop_ptr(Otos_i, G3_scratch); // restore receiver | |
3610 | |
3611 __ br(Assembler::always, false, Assembler::pt, resolved); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3612 __ delayed()->nop(); |
0 | 3613 |
3614 | |
3615 // Extract target class from constant pool | |
3616 __ bind(quicked); | |
3617 __ add(Roffset, sizeof(constantPoolOopDesc), Roffset); | |
3618 __ get_constant_pool(Lscratch); | |
3619 __ ld_ptr(Lscratch, Roffset, RspecifiedKlass); | |
3620 __ bind(resolved); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3621 __ load_klass(Otos_i, RobjKlass); // get value klass |
0 | 3622 |
3623 // Generate a fast subtype check. Branch to cast_ok if no | |
3624 // failure. Return 0 if failure. | |
3625 __ or3(G0, 1, Otos_i); // set result assuming quick tests succeed | |
3626 __ gen_subtype_check( RobjKlass, RspecifiedKlass, G3_scratch, G4_scratch, G1_scratch, done ); | |
3627 // Not a subtype; return 0; | |
3628 __ clr( Otos_i ); | |
3629 | |
3630 if (ProfileInterpreter) { | |
3631 __ ba(false, done); | |
3632 __ delayed()->nop(); | |
3633 } | |
3634 __ bind(is_null); | |
3635 __ profile_null_seen(G3_scratch); | |
3636 __ bind(done); | |
3637 } | |
3638 | |
3639 void TemplateTable::_breakpoint() { | |
3640 | |
3641 // Note: We get here even if we are single stepping.. | |
3642 // jbug inists on setting breakpoints at every bytecode | |
3643 // even if we are in single step mode. | |
3644 | |
3645 transition(vtos, vtos); | |
3646 // get the unpatched byte code | |
3647 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::get_original_bytecode_at), Lmethod, Lbcp); | |
3648 __ mov(O0, Lbyte_code); | |
3649 | |
3650 // post the breakpoint event | |
3651 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::_breakpoint), Lmethod, Lbcp); | |
3652 | |
3653 // complete the execution of original bytecode | |
3654 __ dispatch_normal(vtos); | |
3655 } | |
3656 | |
3657 | |
3658 //---------------------------------------------------------------------------------------------------- | |
3659 // Exceptions | |
3660 | |
3661 void TemplateTable::athrow() { | |
3662 transition(atos, vtos); | |
3663 | |
3664 // This works because exception is cached in Otos_i which is same as O0, | |
3665 // which is same as what throw_exception_entry_expects | |
3666 assert(Otos_i == Oexception, "see explanation above"); | |
3667 | |
3668 __ verify_oop(Otos_i); | |
3669 __ null_check(Otos_i); | |
3670 __ throw_if_not_x(Assembler::never, Interpreter::throw_exception_entry(), G3_scratch); | |
3671 } | |
3672 | |
3673 | |
3674 //---------------------------------------------------------------------------------------------------- | |
3675 // Synchronization | |
3676 | |
3677 | |
3678 // See frame_sparc.hpp for monitor block layout. | |
3679 // Monitor elements are dynamically allocated by growing stack as needed. | |
3680 | |
3681 void TemplateTable::monitorenter() { | |
3682 transition(atos, vtos); | |
3683 __ verify_oop(Otos_i); | |
3684 // Try to acquire a lock on the object | |
3685 // Repeat until succeeded (i.e., until | |
3686 // monitorenter returns true). | |
3687 | |
3688 { Label ok; | |
3689 __ tst(Otos_i); | |
3690 __ throw_if_not_1_x( Assembler::notZero, ok); | |
3691 __ delayed()->mov(Otos_i, Lscratch); // save obj | |
3692 __ throw_if_not_2( Interpreter::_throw_NullPointerException_entry, G3_scratch, ok); | |
3693 } | |
3694 | |
3695 assert(O0 == Otos_i, "Be sure where the object to lock is"); | |
3696 | |
3697 // find a free slot in the monitor block | |
3698 | |
3699 | |
3700 // initialize entry pointer | |
3701 __ clr(O1); // points to free slot or NULL | |
3702 | |
3703 { | |
3704 Label entry, loop, exit; | |
3705 __ add( __ top_most_monitor(), O2 ); // last one to check | |
3706 __ ba( false, entry ); | |
3707 __ delayed()->mov( Lmonitors, O3 ); // first one to check | |
3708 | |
3709 | |
3710 __ bind( loop ); | |
3711 | |
3712 __ verify_oop(O4); // verify each monitor's oop | |
3713 __ tst(O4); // is this entry unused? | |
3714 if (VM_Version::v9_instructions_work()) | |
3715 __ movcc( Assembler::zero, false, Assembler::ptr_cc, O3, O1); | |
3716 else { | |
3717 Label L; | |
3718 __ br( Assembler::zero, true, Assembler::pn, L ); | |
3719 __ delayed()->mov(O3, O1); // rememeber this one if match | |
3720 __ bind(L); | |
3721 } | |
3722 | |
3723 __ cmp(O4, O0); // check if current entry is for same object | |
3724 __ brx( Assembler::equal, false, Assembler::pn, exit ); | |
3725 __ delayed()->inc( O3, frame::interpreter_frame_monitor_size() * wordSize ); // check next one | |
3726 | |
3727 __ bind( entry ); | |
3728 | |
3729 __ cmp( O3, O2 ); | |
3730 __ brx( Assembler::lessEqualUnsigned, true, Assembler::pt, loop ); | |
3731 __ delayed()->ld_ptr(O3, BasicObjectLock::obj_offset_in_bytes(), O4); | |
3732 | |
3733 __ bind( exit ); | |
3734 } | |
3735 | |
3736 { Label allocated; | |
3737 | |
3738 // found free slot? | |
3739 __ br_notnull(O1, false, Assembler::pn, allocated); | |
3740 __ delayed()->nop(); | |
3741 | |
3742 __ add_monitor_to_stack( false, O2, O3 ); | |
3743 __ mov(Lmonitors, O1); | |
3744 | |
3745 __ bind(allocated); | |
3746 } | |
3747 | |
3748 // Increment bcp to point to the next bytecode, so exception handling for async. exceptions work correctly. | |
3749 // The object has already been poped from the stack, so the expression stack looks correct. | |
3750 __ inc(Lbcp); | |
3751 | |
3752 __ st_ptr(O0, O1, BasicObjectLock::obj_offset_in_bytes()); // store object | |
3753 __ lock_object(O1, O0); | |
3754 | |
3755 // check if there's enough space on the stack for the monitors after locking | |
3756 __ generate_stack_overflow_check(0); | |
3757 | |
3758 // The bcp has already been incremented. Just need to dispatch to next instruction. | |
3759 __ dispatch_next(vtos); | |
3760 } | |
3761 | |
3762 | |
3763 void TemplateTable::monitorexit() { | |
3764 transition(atos, vtos); | |
3765 __ verify_oop(Otos_i); | |
3766 __ tst(Otos_i); | |
3767 __ throw_if_not_x( Assembler::notZero, Interpreter::_throw_NullPointerException_entry, G3_scratch ); | |
3768 | |
3769 assert(O0 == Otos_i, "just checking"); | |
3770 | |
3771 { Label entry, loop, found; | |
3772 __ add( __ top_most_monitor(), O2 ); // last one to check | |
3773 __ ba(false, entry ); | |
3774 // use Lscratch to hold monitor elem to check, start with most recent monitor, | |
3775 // By using a local it survives the call to the C routine. | |
3776 __ delayed()->mov( Lmonitors, Lscratch ); | |
3777 | |
3778 __ bind( loop ); | |
3779 | |
3780 __ verify_oop(O4); // verify each monitor's oop | |
3781 __ cmp(O4, O0); // check if current entry is for desired object | |
3782 __ brx( Assembler::equal, true, Assembler::pt, found ); | |
3783 __ delayed()->mov(Lscratch, O1); // pass found entry as argument to monitorexit | |
3784 | |
3785 __ inc( Lscratch, frame::interpreter_frame_monitor_size() * wordSize ); // advance to next | |
3786 | |
3787 __ bind( entry ); | |
3788 | |
3789 __ cmp( Lscratch, O2 ); | |
3790 __ brx( Assembler::lessEqualUnsigned, true, Assembler::pt, loop ); | |
3791 __ delayed()->ld_ptr(Lscratch, BasicObjectLock::obj_offset_in_bytes(), O4); | |
3792 | |
3793 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
3794 __ should_not_reach_here(); | |
3795 | |
3796 __ bind(found); | |
3797 } | |
3798 __ unlock_object(O1); | |
3799 } | |
3800 | |
3801 | |
3802 //---------------------------------------------------------------------------------------------------- | |
3803 // Wide instructions | |
3804 | |
3805 void TemplateTable::wide() { | |
3806 transition(vtos, vtos); | |
3807 __ ldub(Lbcp, 1, G3_scratch);// get next bc | |
3808 __ sll(G3_scratch, LogBytesPerWord, G3_scratch); | |
727 | 3809 AddressLiteral ep(Interpreter::_wentry_point); |
3810 __ set(ep, G4_scratch); | |
3811 __ ld_ptr(G4_scratch, G3_scratch, G3_scratch); | |
0 | 3812 __ jmp(G3_scratch, G0); |
3813 __ delayed()->nop(); | |
3814 // Note: the Lbcp increment step is part of the individual wide bytecode implementations | |
3815 } | |
3816 | |
3817 | |
3818 //---------------------------------------------------------------------------------------------------- | |
3819 // Multi arrays | |
3820 | |
3821 void TemplateTable::multianewarray() { | |
3822 transition(vtos, atos); | |
3823 // put ndims * wordSize into Lscratch | |
3824 __ ldub( Lbcp, 3, Lscratch); | |
1506 | 3825 __ sll( Lscratch, Interpreter::logStackElementSize, Lscratch); |
0 | 3826 // Lesp points past last_dim, so set to O1 to first_dim address |
3827 __ add( Lesp, Lscratch, O1); | |
3828 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::multianewarray), O1); | |
3829 __ add( Lesp, Lscratch, Lesp); // pop all dimensions off the stack | |
3830 } | |
3831 #endif /* !CC_INTERP */ |