Mercurial > hg > truffle
comparison src/cpu/x86/vm/vtableStubs_x86_32.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 |
---|---|
106 vtable_index, s->entry_point(), | 106 vtable_index, s->entry_point(), |
107 (int)(s->code_end() - s->entry_point()), | 107 (int)(s->code_end() - s->entry_point()), |
108 (int)(s->code_end() - __ pc())); | 108 (int)(s->code_end() - __ pc())); |
109 } | 109 } |
110 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); | 110 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
111 // shut the door on sizing bugs | |
112 int slop = 3; // 32-bit offset is this much larger than an 8-bit one | |
113 assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset"); | |
111 | 114 |
112 s->set_exception_points(npe_addr, ame_addr); | 115 s->set_exception_points(npe_addr, ame_addr); |
113 return s; | 116 return s; |
114 } | 117 } |
115 | 118 |
179 itable_index, s->entry_point(), | 182 itable_index, s->entry_point(), |
180 (int)(s->code_end() - s->entry_point()), | 183 (int)(s->code_end() - s->entry_point()), |
181 (int)(s->code_end() - __ pc())); | 184 (int)(s->code_end() - __ pc())); |
182 } | 185 } |
183 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); | 186 guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
187 // shut the door on sizing bugs | |
188 int slop = 3; // 32-bit offset is this much larger than an 8-bit one | |
189 assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset"); | |
184 | 190 |
185 s->set_exception_points(npe_addr, ame_addr); | 191 s->set_exception_points(npe_addr, ame_addr); |
186 return s; | 192 return s; |
187 } | 193 } |
188 | 194 |
194 return (DebugVtables ? 210 : 16) + (CountCompiledCalls ? 6 : 0); | 200 return (DebugVtables ? 210 : 16) + (CountCompiledCalls ? 6 : 0); |
195 } else { | 201 } else { |
196 // Itable stub size | 202 // Itable stub size |
197 return (DebugVtables ? 256 : 66) + (CountCompiledCalls ? 6 : 0); | 203 return (DebugVtables ? 256 : 66) + (CountCompiledCalls ? 6 : 0); |
198 } | 204 } |
205 // In order to tune these parameters, run the JVM with VM options | |
206 // +PrintMiscellaneous and +WizardMode to see information about | |
207 // actual itable stubs. Look for lines like this: | |
208 // itable #1 at 0x5551212[65] left over: 3 | |
209 // Reduce the constants so that the "left over" number is >=3 | |
210 // for the common cases. | |
211 // Do not aim at a left-over number of zero, because a | |
212 // large vtable or itable index (> 16) will require a 32-bit | |
213 // immediate displacement instead of an 8-bit one. | |
214 // | |
215 // The JVM98 app. _202_jess has a megamorphic interface call. | |
216 // The itable code looks like this: | |
217 // Decoding VtableStub itbl[1]@1 | |
218 // mov 0x4(%ecx),%esi | |
219 // mov 0xe8(%esi),%edi | |
220 // lea 0x130(%esi,%edi,4),%edi | |
221 // add $0x7,%edi | |
222 // and $0xfffffff8,%edi | |
223 // lea 0x4(%esi),%esi | |
224 // mov (%edi),%ebx | |
225 // cmp %ebx,%eax | |
226 // je success | |
227 // loop: | |
228 // test %ebx,%ebx | |
229 // je throw_icce | |
230 // add $0x8,%edi | |
231 // mov (%edi),%ebx | |
232 // cmp %ebx,%eax | |
233 // jne loop | |
234 // success: | |
235 // mov 0x4(%edi),%edi | |
236 // mov (%esi,%edi,1),%ebx | |
237 // jmp *0x44(%ebx) | |
238 // throw_icce: | |
239 // jmp throw_ICCE_entry | |
199 } | 240 } |
200 | 241 |
201 int VtableStub::pd_code_alignment() { | 242 int VtableStub::pd_code_alignment() { |
202 return wordSize; | 243 return wordSize; |
203 } | 244 } |