comparison src/cpu/sparc/vm/vtableStubs_sparc.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 660978a2a31a
children 6b2273dd6fa9
comparison
equal deleted inserted replaced
708:f2049ae95c3d 709:1d037ecd7960
112 vtable_index, s->entry_point(), 112 vtable_index, s->entry_point(),
113 (int)(s->code_end() - s->entry_point()), 113 (int)(s->code_end() - s->entry_point()),
114 (int)(s->code_end() - __ pc())); 114 (int)(s->code_end() - __ pc()));
115 } 115 }
116 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); 116 guarantee(__ pc() <= s->code_end(), "overflowed buffer");
117 // shut the door on sizing bugs
118 int slop = 2*BytesPerInstWord; // 32-bit offset is this much larger than a 13-bit one
119 assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for sethi;add");
117 120
118 s->set_exception_points(npe_addr, ame_addr); 121 s->set_exception_points(npe_addr, ame_addr);
119 return s; 122 return s;
120 } 123 }
121 124
206 itable_index, s->entry_point(), 209 itable_index, s->entry_point(),
207 (int)(s->code_end() - s->entry_point()), 210 (int)(s->code_end() - s->entry_point()),
208 (int)(s->code_end() - __ pc())); 211 (int)(s->code_end() - __ pc()));
209 } 212 }
210 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); 213 guarantee(__ pc() <= s->code_end(), "overflowed buffer");
214 // shut the door on sizing bugs
215 int slop = 2*BytesPerInstWord; // 32-bit offset is this much larger than a 13-bit one
216 assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for sethi;add");
211 217
212 s->set_exception_points(npe_addr, ame_addr); 218 s->set_exception_points(npe_addr, ame_addr);
213 return s; 219 return s;
214 } 220 }
215 221
231 (UseCompressedOops ? 237 (UseCompressedOops ?
232 ((Universe::narrow_oop_base() == NULL) ? BytesPerInstWord : 2*BytesPerInstWord) : 0); 238 ((Universe::narrow_oop_base() == NULL) ? BytesPerInstWord : 2*BytesPerInstWord) : 0);
233 return (basic + slop); 239 return (basic + slop);
234 } 240 }
235 } 241 }
242
243 // In order to tune these parameters, run the JVM with VM options
244 // +PrintMiscellaneous and +WizardMode to see information about
245 // actual itable stubs. Look for lines like this:
246 // itable #1 at 0x5551212[116] left over: 8
247 // Reduce the constants so that the "left over" number is 8
248 // Do not aim at a left-over number of zero, because a very
249 // large vtable or itable offset (> 4K) will require an extra
250 // sethi/or pair of instructions.
251 //
252 // The JVM98 app. _202_jess has a megamorphic interface call.
253 // The itable code looks like this:
254 // Decoding VtableStub itbl[1]@16
255 // ld [ %o0 + 4 ], %g3
256 // save %sp, -64, %sp
257 // ld [ %g3 + 0xe8 ], %l2
258 // sll %l2, 2, %l2
259 // add %l2, 0x134, %l2
260 // and %l2, -8, %l2 ! NOT_LP64 only
261 // add %g3, %l2, %l2
262 // add %g3, 4, %g3
263 // ld [ %l2 ], %l5
264 // brz,pn %l5, throw_icce
265 // cmp %l5, %g5
266 // be %icc, success
267 // add %l2, 8, %l2
268 // loop:
269 // ld [ %l2 ], %l5
270 // brz,pn %l5, throw_icce
271 // cmp %l5, %g5
272 // bne,pn %icc, loop
273 // add %l2, 8, %l2
274 // success:
275 // ld [ %l2 + -4 ], %l2
276 // ld [ %g3 + %l2 ], %l5
277 // restore %l5, 0, %g5
278 // ld [ %g5 + 0x44 ], %g3
279 // jmp %g3
280 // nop
281 // throw_icce:
282 // sethi %hi(throw_ICCE_entry), %g3
283 // ! 5 more instructions here, LP64_ONLY
284 // jmp %g3 + %lo(throw_ICCE_entry)
285 // restore
236 } 286 }
237 287
238 288
239 int VtableStub::pd_code_alignment() { 289 int VtableStub::pd_code_alignment() {
240 // UltraSPARC cache line size is 8 instructions: 290 // UltraSPARC cache line size is 8 instructions: