Mercurial > hg > truffle
annotate src/cpu/x86/vm/vtableStubs_x86_32.cpp @ 425:81a0cbe3b284 jdk7-b40
6771977: Bump HS14 build number to 07
Summary: Update the Hotspot build number to 07
Reviewed-by: jcoomes
author | trims |
---|---|
date | Fri, 14 Nov 2008 19:26:03 -0800 |
parents | 9ee9cf798b59 |
children | 9adddb8c0fc8 |
rev | line source |
---|---|
0 | 1 /* |
337 | 2 * Copyright 1997-2008 Sun Microsystems, Inc. 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 * | |
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_x86_32.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 #ifndef PRODUCT | |
34 extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index); | |
35 #endif | |
36 | |
37 // used by compiler only; may use only caller saved registers rax, rbx, rcx. | |
38 // rdx holds first int arg, rsi, rdi, rbp are callee-save & must be preserved. | |
39 // Leave receiver in rcx; required behavior when +OptoArgsInRegisters | |
40 // is modifed to put first oop in rcx. | |
41 // | |
42 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { | |
43 const int i486_code_length = VtableStub::pd_code_size_limit(true); | |
44 VtableStub* s = new(i486_code_length) VtableStub(true, vtable_index); | |
45 ResourceMark rm; | |
46 CodeBuffer cb(s->entry_point(), i486_code_length); | |
47 MacroAssembler* masm = new MacroAssembler(&cb); | |
48 | |
49 #ifndef PRODUCT | |
50 | |
51 if (CountCompiledCalls) { | |
304 | 52 __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr())); |
0 | 53 } |
54 #endif /* PRODUCT */ | |
55 | |
56 // get receiver (need to skip return address on top of stack) | |
57 assert(VtableStub::receiver_location() == rcx->as_VMReg(), "receiver expected in rcx"); | |
58 | |
59 // get receiver klass | |
60 address npe_addr = __ pc(); | |
304 | 61 __ movptr(rax, Address(rcx, oopDesc::klass_offset_in_bytes())); |
0 | 62 // compute entry offset (in words) |
63 int entry_offset = instanceKlass::vtable_start_offset() + vtable_index*vtableEntry::size(); | |
64 #ifndef PRODUCT | |
65 if (DebugVtables) { | |
66 Label L; | |
67 // check offset vs vtable length | |
68 __ cmpl(Address(rax, instanceKlass::vtable_length_offset()*wordSize), vtable_index*vtableEntry::size()); | |
69 __ jcc(Assembler::greater, L); | |
70 __ movl(rbx, vtable_index); | |
71 __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), rcx, rbx); | |
72 __ bind(L); | |
73 } | |
74 #endif // PRODUCT | |
75 | |
76 const Register method = rbx; | |
77 | |
78 // load methodOop and target address | |
304 | 79 __ movptr(method, Address(rax, entry_offset*wordSize + vtableEntry::method_offset_in_bytes())); |
0 | 80 if (DebugVtables) { |
81 Label L; | |
304 | 82 __ cmpptr(method, (int32_t)NULL_WORD); |
0 | 83 __ jcc(Assembler::equal, L); |
304 | 84 __ cmpptr(Address(method, methodOopDesc::from_compiled_offset()), (int32_t)NULL_WORD); |
0 | 85 __ jcc(Assembler::notZero, L); |
86 __ stop("Vtable entry is NULL"); | |
87 __ bind(L); | |
88 } | |
89 | |
90 // rax,: receiver klass | |
91 // method (rbx): methodOop | |
92 // rcx: receiver | |
93 address ame_addr = __ pc(); | |
94 __ jmp( Address(method, methodOopDesc::from_compiled_offset())); | |
95 | |
96 masm->flush(); | |
97 s->set_exception_points(npe_addr, ame_addr); | |
98 return s; | |
99 } | |
100 | |
101 | |
102 VtableStub* VtableStubs::create_itable_stub(int vtable_index) { | |
103 // Note well: pd_code_size_limit is the absolute minimum we can get away with. If you | |
104 // add code here, bump the code stub size returned by pd_code_size_limit! | |
105 const int i486_code_length = VtableStub::pd_code_size_limit(false); | |
106 VtableStub* s = new(i486_code_length) VtableStub(false, vtable_index); | |
107 ResourceMark rm; | |
108 CodeBuffer cb(s->entry_point(), i486_code_length); | |
109 MacroAssembler* masm = new MacroAssembler(&cb); | |
110 | |
111 // Entry arguments: | |
112 // rax,: Interface | |
113 // rcx: Receiver | |
114 | |
115 #ifndef PRODUCT | |
116 if (CountCompiledCalls) { | |
304 | 117 __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr())); |
0 | 118 } |
119 #endif /* PRODUCT */ | |
120 // get receiver (need to skip return address on top of stack) | |
121 | |
122 assert(VtableStub::receiver_location() == rcx->as_VMReg(), "receiver expected in rcx"); | |
123 | |
124 // get receiver klass (also an implicit null-check) | |
125 address npe_addr = __ pc(); | |
304 | 126 __ movptr(rbx, Address(rcx, oopDesc::klass_offset_in_bytes())); |
0 | 127 |
304 | 128 __ mov(rsi, rbx); // Save klass in free register |
0 | 129 // Most registers are in use, so save a few |
304 | 130 __ push(rdx); |
0 | 131 // compute itable entry offset (in words) |
132 const int base = instanceKlass::vtable_start_offset() * wordSize; | |
133 assert(vtableEntry::size() * wordSize == 4, "adjust the scaling in the code below"); | |
134 __ movl(rdx, Address(rbx, instanceKlass::vtable_length_offset() * wordSize)); // Get length of vtable | |
304 | 135 __ lea(rbx, Address(rbx, rdx, Address::times_ptr, base)); |
0 | 136 if (HeapWordsPerLong > 1) { |
137 // Round up to align_object_offset boundary | |
138 __ round_to(rbx, BytesPerLong); | |
139 } | |
140 | |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
141 Label hit, next, entry, throw_icce; |
0 | 142 |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
143 __ jmpb(entry); |
0 | 144 |
145 __ bind(next); | |
304 | 146 __ addptr(rbx, itableOffsetEntry::size() * wordSize); |
0 | 147 |
148 __ bind(entry); | |
149 | |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
150 // If the entry is NULL then we've reached the end of the table |
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
151 // without finding the expected interface, so throw an exception |
304 | 152 __ movptr(rdx, Address(rbx, itableOffsetEntry::interface_offset_in_bytes())); |
153 __ testptr(rdx, rdx); | |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
154 __ jcc(Assembler::zero, throw_icce); |
304 | 155 __ cmpptr(rax, rdx); |
0 | 156 __ jcc(Assembler::notEqual, next); |
157 | |
158 // We found a hit, move offset into rbx, | |
159 __ movl(rdx, Address(rbx, itableOffsetEntry::offset_offset_in_bytes())); | |
160 | |
161 // Compute itableMethodEntry. | |
162 const int method_offset = (itableMethodEntry::size() * wordSize * vtable_index) + itableMethodEntry::method_offset_in_bytes(); | |
163 | |
164 // Get methodOop and entrypoint for compiler | |
165 const Register method = rbx; | |
304 | 166 __ movptr(method, Address(rsi, rdx, Address::times_1, method_offset)); |
0 | 167 |
168 // Restore saved register, before possible trap. | |
304 | 169 __ pop(rdx); |
0 | 170 |
171 // method (rbx): methodOop | |
172 // rcx: receiver | |
173 | |
174 #ifdef ASSERT | |
175 if (DebugVtables) { | |
176 Label L1; | |
304 | 177 __ cmpptr(method, (int32_t)NULL_WORD); |
0 | 178 __ jcc(Assembler::equal, L1); |
304 | 179 __ cmpptr(Address(method, methodOopDesc::from_compiled_offset()), (int32_t)NULL_WORD); |
0 | 180 __ jcc(Assembler::notZero, L1); |
181 __ stop("methodOop is null"); | |
182 __ bind(L1); | |
183 } | |
184 #endif // ASSERT | |
185 | |
186 address ame_addr = __ pc(); | |
187 __ jmp(Address(method, methodOopDesc::from_compiled_offset())); | |
188 | |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
189 __ bind(throw_icce); |
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
190 // Restore saved register |
304 | 191 __ pop(rdx); |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
192 __ jump(RuntimeAddress(StubRoutines::throw_IncompatibleClassChangeError_entry())); |
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
193 |
0 | 194 masm->flush(); |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
195 |
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
196 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
197 |
0 | 198 s->set_exception_points(npe_addr, ame_addr); |
199 return s; | |
200 } | |
201 | |
202 | |
203 | |
204 int VtableStub::pd_code_size_limit(bool is_vtable_stub) { | |
205 if (is_vtable_stub) { | |
206 // Vtable stub size | |
207 return (DebugVtables ? 210 : 16) + (CountCompiledCalls ? 6 : 0); | |
208 } else { | |
209 // Itable stub size | |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
210 return (DebugVtables ? 144 : 64) + (CountCompiledCalls ? 6 : 0); |
0 | 211 } |
212 } | |
213 | |
214 int VtableStub::pd_code_alignment() { | |
215 return wordSize; | |
216 } |