1.1 --- a/src/cpu/x86/vm/vtableStubs_x86_64.cpp Tue Apr 07 19:04:24 2009 -0700 1.2 +++ b/src/cpu/x86/vm/vtableStubs_x86_64.cpp Wed Apr 08 00:12:59 2009 -0700 1.3 @@ -106,6 +106,9 @@ 1.4 (int)(s->code_end() - __ pc())); 1.5 } 1.6 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); 1.7 + // shut the door on sizing bugs 1.8 + int slop = 3; // 32-bit offset is this much larger than an 8-bit one 1.9 + assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset"); 1.10 1.11 s->set_exception_points(npe_addr, ame_addr); 1.12 return s; 1.13 @@ -191,6 +194,9 @@ 1.14 (int)(s->code_end() - __ pc())); 1.15 } 1.16 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); 1.17 + // shut the door on sizing bugs 1.18 + int slop = 3; // 32-bit offset is this much larger than an 8-bit one 1.19 + assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset"); 1.20 1.21 s->set_exception_points(npe_addr, ame_addr); 1.22 return s; 1.23 @@ -206,6 +212,39 @@ 1.24 return (DebugVtables ? 512 : 72) + (CountCompiledCalls ? 13 : 0) + 1.25 (UseCompressedOops ? 32 : 0); // 2 leaqs 1.26 } 1.27 + // In order to tune these parameters, run the JVM with VM options 1.28 + // +PrintMiscellaneous and +WizardMode to see information about 1.29 + // actual itable stubs. Look for lines like this: 1.30 + // itable #1 at 0x5551212[71] left over: 3 1.31 + // Reduce the constants so that the "left over" number is >=3 1.32 + // for the common cases. 1.33 + // Do not aim at a left-over number of zero, because a 1.34 + // large vtable or itable index (>= 32) will require a 32-bit 1.35 + // immediate displacement instead of an 8-bit one. 1.36 + // 1.37 + // The JVM98 app. _202_jess has a megamorphic interface call. 1.38 + // The itable code looks like this: 1.39 + // Decoding VtableStub itbl[1]@12 1.40 + // mov 0x8(%rsi),%r10 1.41 + // mov 0x198(%r10),%r11d 1.42 + // lea 0x218(%r10,%r11,8),%r11 1.43 + // lea 0x8(%r10),%r10 1.44 + // mov (%r11),%rbx 1.45 + // cmp %rbx,%rax 1.46 + // je success 1.47 + // loop: 1.48 + // test %rbx,%rbx 1.49 + // je throw_icce 1.50 + // add $0x10,%r11 1.51 + // mov (%r11),%rbx 1.52 + // cmp %rbx,%rax 1.53 + // jne loop 1.54 + // success: 1.55 + // mov 0x8(%r11),%r11d 1.56 + // mov (%r10,%r11,1),%rbx 1.57 + // jmpq *0x60(%rbx) 1.58 + // throw_icce: 1.59 + // jmpq throw_ICCE_entry 1.60 } 1.61 1.62 int VtableStub::pd_code_alignment() {