Mercurial > hg > truffle
comparison src/cpu/x86/vm/vtableStubs_x86_64.cpp @ 709:1d037ecd7960
6827505: sizing logic for vtable and itable stubs needs self-check
Summary: Asserts and comments to help maintain the correct sizing of certain stubs
Reviewed-by: kvn
author | jrose |
---|---|
date | Wed, 08 Apr 2009 00:12:59 -0700 |
parents | 9adddb8c0fc8 |
children | bd02caa94611 |
comparison
equal
deleted
inserted
replaced
708:f2049ae95c3d | 709:1d037ecd7960 |
---|---|
104 vtable_index, s->entry_point(), | 104 vtable_index, s->entry_point(), |
105 (int)(s->code_end() - s->entry_point()), | 105 (int)(s->code_end() - s->entry_point()), |
106 (int)(s->code_end() - __ pc())); | 106 (int)(s->code_end() - __ pc())); |
107 } | 107 } |
108 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); | 108 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
109 // shut the door on sizing bugs | |
110 int slop = 3; // 32-bit offset is this much larger than an 8-bit one | |
111 assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset"); | |
109 | 112 |
110 s->set_exception_points(npe_addr, ame_addr); | 113 s->set_exception_points(npe_addr, ame_addr); |
111 return s; | 114 return s; |
112 } | 115 } |
113 | 116 |
189 itable_index, s->entry_point(), | 192 itable_index, s->entry_point(), |
190 (int)(s->code_end() - s->entry_point()), | 193 (int)(s->code_end() - s->entry_point()), |
191 (int)(s->code_end() - __ pc())); | 194 (int)(s->code_end() - __ pc())); |
192 } | 195 } |
193 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); | 196 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
197 // shut the door on sizing bugs | |
198 int slop = 3; // 32-bit offset is this much larger than an 8-bit one | |
199 assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset"); | |
194 | 200 |
195 s->set_exception_points(npe_addr, ame_addr); | 201 s->set_exception_points(npe_addr, ame_addr); |
196 return s; | 202 return s; |
197 } | 203 } |
198 | 204 |
204 } else { | 210 } else { |
205 // Itable stub size | 211 // Itable stub size |
206 return (DebugVtables ? 512 : 72) + (CountCompiledCalls ? 13 : 0) + | 212 return (DebugVtables ? 512 : 72) + (CountCompiledCalls ? 13 : 0) + |
207 (UseCompressedOops ? 32 : 0); // 2 leaqs | 213 (UseCompressedOops ? 32 : 0); // 2 leaqs |
208 } | 214 } |
215 // In order to tune these parameters, run the JVM with VM options | |
216 // +PrintMiscellaneous and +WizardMode to see information about | |
217 // actual itable stubs. Look for lines like this: | |
218 // itable #1 at 0x5551212[71] left over: 3 | |
219 // Reduce the constants so that the "left over" number is >=3 | |
220 // for the common cases. | |
221 // Do not aim at a left-over number of zero, because a | |
222 // large vtable or itable index (>= 32) will require a 32-bit | |
223 // immediate displacement instead of an 8-bit one. | |
224 // | |
225 // The JVM98 app. _202_jess has a megamorphic interface call. | |
226 // The itable code looks like this: | |
227 // Decoding VtableStub itbl[1]@12 | |
228 // mov 0x8(%rsi),%r10 | |
229 // mov 0x198(%r10),%r11d | |
230 // lea 0x218(%r10,%r11,8),%r11 | |
231 // lea 0x8(%r10),%r10 | |
232 // mov (%r11),%rbx | |
233 // cmp %rbx,%rax | |
234 // je success | |
235 // loop: | |
236 // test %rbx,%rbx | |
237 // je throw_icce | |
238 // add $0x10,%r11 | |
239 // mov (%r11),%rbx | |
240 // cmp %rbx,%rax | |
241 // jne loop | |
242 // success: | |
243 // mov 0x8(%r11),%r11d | |
244 // mov (%r10,%r11,1),%rbx | |
245 // jmpq *0x60(%rbx) | |
246 // throw_icce: | |
247 // jmpq throw_ICCE_entry | |
209 } | 248 } |
210 | 249 |
211 int VtableStub::pd_code_alignment() { | 250 int VtableStub::pd_code_alignment() { |
212 return wordSize; | 251 return wordSize; |
213 } | 252 } |