author | jrose |
Fri, 06 Mar 2009 21:36:50 -0800 | |
changeset 2149 | 3d362637b307 |
parent 670 | ddf3e9583f2f |
child 2254 | f13dda645a4b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
670 | 2 |
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "incls/_precompiled.incl" |
|
26 |
#include "incls/_vtableStubs_sparc.cpp.incl" |
|
27 |
||
28 |
// machine-dependent part of VtableStubs: create vtableStub of correct size and |
|
29 |
// initialize its code |
|
30 |
||
31 |
#define __ masm-> |
|
32 |
||
33 |
||
34 |
#ifndef PRODUCT |
|
35 |
extern "C" void bad_compiled_vtable_index(JavaThread* thread, oopDesc* receiver, int index); |
|
36 |
#endif |
|
37 |
||
38 |
||
39 |
// Used by compiler only; may use only caller saved, non-argument registers |
|
40 |
// NOTE: %%%% if any change is made to this stub make sure that the function |
|
41 |
// pd_code_size_limit is changed to ensure the correct size for VtableStub |
|
42 |
VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { |
|
43 |
const int sparc_code_length = VtableStub::pd_code_size_limit(true); |
|
44 |
VtableStub* s = new(sparc_code_length) VtableStub(true, vtable_index); |
|
45 |
ResourceMark rm; |
|
46 |
CodeBuffer cb(s->entry_point(), sparc_code_length); |
|
47 |
MacroAssembler* masm = new MacroAssembler(&cb); |
|
48 |
||
49 |
#ifndef PRODUCT |
|
50 |
if (CountCompiledCalls) { |
|
51 |
Address ctr(G5, SharedRuntime::nof_megamorphic_calls_addr()); |
|
52 |
__ sethi(ctr); |
|
53 |
__ ld(ctr, G3_scratch); |
|
54 |
__ inc(G3_scratch); |
|
55 |
__ st(G3_scratch, ctr); |
|
56 |
} |
|
57 |
#endif /* PRODUCT */ |
|
58 |
||
59 |
assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0"); |
|
60 |
||
61 |
// get receiver klass |
|
62 |
address npe_addr = __ pc(); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
189
diff
changeset
|
63 |
__ load_klass(O0, G3_scratch); |
1 | 64 |
|
65 |
// set methodOop (in case of interpreted method), and destination address |
|
66 |
int entry_offset = instanceKlass::vtable_start_offset() + vtable_index*vtableEntry::size(); |
|
67 |
#ifndef PRODUCT |
|
68 |
if (DebugVtables) { |
|
69 |
Label L; |
|
70 |
// check offset vs vtable length |
|
71 |
__ ld(G3_scratch, instanceKlass::vtable_length_offset()*wordSize, G5); |
|
72 |
__ cmp(G5, vtable_index*vtableEntry::size()); |
|
73 |
__ br(Assembler::greaterUnsigned, false, Assembler::pt, L); |
|
74 |
__ delayed()->nop(); |
|
75 |
__ set(vtable_index, O2); |
|
76 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), O0, O2); |
|
77 |
__ bind(L); |
|
78 |
} |
|
79 |
#endif |
|
80 |
int v_off = entry_offset*wordSize + vtableEntry::method_offset_in_bytes(); |
|
81 |
if( __ is_simm13(v_off) ) { |
|
82 |
__ ld_ptr(G3, v_off, G5_method); |
|
83 |
} else { |
|
84 |
__ set(v_off,G5); |
|
85 |
__ ld_ptr(G3, G5, G5_method); |
|
86 |
} |
|
87 |
||
88 |
#ifndef PRODUCT |
|
89 |
if (DebugVtables) { |
|
90 |
Label L; |
|
91 |
__ br_notnull(G5_method, false, Assembler::pt, L); |
|
92 |
__ delayed()->nop(); |
|
93 |
__ stop("Vtable entry is ZERO"); |
|
94 |
__ bind(L); |
|
95 |
} |
|
96 |
#endif |
|
97 |
||
98 |
address ame_addr = __ pc(); // if the vtable entry is null, the method is abstract |
|
99 |
// NOTE: for vtable dispatches, the vtable entry will never be null. |
|
100 |
||
101 |
__ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch); |
|
102 |
||
103 |
// jump to target (either compiled code or c2iadapter) |
|
104 |
__ JMP(G3_scratch, 0); |
|
105 |
// load methodOop (in case we call c2iadapter) |
|
106 |
__ delayed()->nop(); |
|
107 |
||
108 |
masm->flush(); |
|
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
109 |
|
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
110 |
if (PrintMiscellaneous && (WizardMode || Verbose)) { |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
111 |
tty->print_cr("vtable #%d at "PTR_FORMAT"[%d] left over: %d", |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
112 |
vtable_index, s->entry_point(), |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
113 |
(int)(s->code_end() - s->entry_point()), |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
114 |
(int)(s->code_end() - __ pc())); |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
115 |
} |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
116 |
guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
117 |
|
1 | 118 |
s->set_exception_points(npe_addr, ame_addr); |
119 |
return s; |
|
120 |
} |
|
121 |
||
122 |
||
123 |
// NOTE: %%%% if any change is made to this stub make sure that the function |
|
124 |
// pd_code_size_limit is changed to ensure the correct size for VtableStub |
|
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
125 |
VtableStub* VtableStubs::create_itable_stub(int itable_index) { |
1 | 126 |
const int sparc_code_length = VtableStub::pd_code_size_limit(false); |
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
127 |
VtableStub* s = new(sparc_code_length) VtableStub(false, itable_index); |
1 | 128 |
ResourceMark rm; |
129 |
CodeBuffer cb(s->entry_point(), sparc_code_length); |
|
130 |
MacroAssembler* masm = new MacroAssembler(&cb); |
|
131 |
||
132 |
Register G3_klassOop = G3_scratch; |
|
133 |
Register G5_interface = G5; // Passed in as an argument |
|
134 |
Label search; |
|
135 |
||
136 |
// Entry arguments: |
|
137 |
// G5_interface: Interface |
|
138 |
// O0: Receiver |
|
139 |
assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0"); |
|
140 |
||
141 |
// get receiver klass (also an implicit null-check) |
|
142 |
address npe_addr = __ pc(); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
189
diff
changeset
|
143 |
__ load_klass(O0, G3_klassOop); |
1 | 144 |
__ verify_oop(G3_klassOop); |
145 |
||
146 |
// Push a new window to get some temp registers. This chops the head of all |
|
147 |
// my 64-bit %o registers in the LION build, but this is OK because no longs |
|
148 |
// are passed in the %o registers. Instead, longs are passed in G1 and G4 |
|
149 |
// and so those registers are not available here. |
|
150 |
__ save(SP,-frame::register_save_words*wordSize,SP); |
|
151 |
||
152 |
#ifndef PRODUCT |
|
153 |
if (CountCompiledCalls) { |
|
154 |
Address ctr(L0, SharedRuntime::nof_megamorphic_calls_addr()); |
|
155 |
__ sethi(ctr); |
|
156 |
__ ld(ctr, L1); |
|
157 |
__ inc(L1); |
|
158 |
__ st(L1, ctr); |
|
159 |
} |
|
160 |
#endif /* PRODUCT */ |
|
161 |
||
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
162 |
Label throw_icce; |
1 | 163 |
|
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
164 |
Register L5_method = L5; |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
165 |
__ lookup_interface_method(// inputs: rec. class, interface, itable index |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
166 |
G3_klassOop, G5_interface, itable_index, |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
167 |
// outputs: method, scan temp. reg |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
168 |
L5_method, L2, L3, |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
169 |
throw_icce); |
1 | 170 |
|
171 |
#ifndef PRODUCT |
|
172 |
if (DebugVtables) { |
|
173 |
Label L01; |
|
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
174 |
__ bpr(Assembler::rc_nz, false, Assembler::pt, L5_method, L01); |
1 | 175 |
__ delayed()->nop(); |
176 |
__ stop("methodOop is null"); |
|
177 |
__ bind(L01); |
|
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
178 |
__ verify_oop(L5_method); |
1 | 179 |
} |
180 |
#endif |
|
181 |
||
182 |
// If the following load is through a NULL pointer, we'll take an OS |
|
183 |
// exception that should translate into an AbstractMethodError. We need the |
|
184 |
// window count to be correct at that time. |
|
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
185 |
__ restore(L5_method, 0, G5_method); |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
186 |
// Restore registers *before* the AME point. |
1 | 187 |
|
188 |
address ame_addr = __ pc(); // if the vtable entry is null, the method is abstract |
|
189 |
__ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch); |
|
190 |
||
191 |
// G5_method: methodOop |
|
192 |
// O0: Receiver |
|
193 |
// G3_scratch: entry point |
|
194 |
__ JMP(G3_scratch, 0); |
|
195 |
__ delayed()->nop(); |
|
196 |
||
189
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
197 |
__ bind(throw_icce); |
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
198 |
Address icce(G3_scratch, StubRoutines::throw_IncompatibleClassChangeError_entry()); |
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
199 |
__ jump_to(icce, 0); |
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
200 |
__ delayed()->restore(); |
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
201 |
|
1 | 202 |
masm->flush(); |
189
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
203 |
|
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
204 |
if (PrintMiscellaneous && (WizardMode || Verbose)) { |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
205 |
tty->print_cr("itable #%d at "PTR_FORMAT"[%d] left over: %d", |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
206 |
itable_index, s->entry_point(), |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
207 |
(int)(s->code_end() - s->entry_point()), |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
208 |
(int)(s->code_end() - __ pc())); |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
209 |
} |
189
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
210 |
guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
211 |
|
1 | 212 |
s->set_exception_points(npe_addr, ame_addr); |
213 |
return s; |
|
214 |
} |
|
215 |
||
216 |
||
217 |
int VtableStub::pd_code_size_limit(bool is_vtable_stub) { |
|
189
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
218 |
if (TraceJumps || DebugVtables || CountCompiledCalls || VerifyOops) return 1000; |
1 | 219 |
else { |
220 |
const int slop = 2*BytesPerInstWord; // sethi;add (needed for long offsets) |
|
221 |
if (is_vtable_stub) { |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
189
diff
changeset
|
222 |
// ld;ld;ld,jmp,nop |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
189
diff
changeset
|
223 |
const int basic = 5*BytesPerInstWord + |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
189
diff
changeset
|
224 |
// shift;add for load_klass |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
189
diff
changeset
|
225 |
(UseCompressedOops ? 2*BytesPerInstWord : 0); |
1 | 226 |
return basic + slop; |
227 |
} else { |
|
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
670
diff
changeset
|
228 |
const int basic = (28 LP64_ONLY(+ 6)) * BytesPerInstWord + |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
189
diff
changeset
|
229 |
// shift;add for load_klass |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
189
diff
changeset
|
230 |
(UseCompressedOops ? 2*BytesPerInstWord : 0); |
1 | 231 |
return (basic + slop); |
232 |
} |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
||
237 |
int VtableStub::pd_code_alignment() { |
|
238 |
// UltraSPARC cache line size is 8 instructions: |
|
239 |
const unsigned int icache_line_size = 32; |
|
240 |
return icache_line_size; |
|
241 |
} |