comparison src/share/vm/oops/cpCacheOop.hpp @ 1059:389049f3f393

6858164: invokedynamic code needs some cleanup (post-6655638) Summary: Fix several crashers, remove needless paths for boxed-style bootstrap method call, refactor & simplify APIs for rewriter constantPoolOop, remove sun.dyn.CallSiteImpl Reviewed-by: kvn
author jrose
date Fri, 30 Oct 2009 16:22:59 -0700
parents be93aad57795
children cd5dbf694d45
comparison
equal deleted inserted replaced
1058:73a726751507 1059:389049f3f393
152 enum FlagValues { 152 enum FlagValues {
153 tosBits = 28 153 tosBits = 28
154 }; 154 };
155 155
156 // Initialization 156 // Initialization
157 void set_initial_state(int index); // sets entry to initial state 157 void initialize_entry(int original_index); // initialize primary entry
158 void initialize_secondary_entry(int main_index); // initialize secondary entry
158 159
159 void set_field( // sets entry to resolved field state 160 void set_field( // sets entry to resolved field state
160 Bytecodes::Code get_code, // the bytecode used for reading the field 161 Bytecodes::Code get_code, // the bytecode used for reading the field
161 Bytecodes::Code put_code, // the bytecode used for writing the field 162 Bytecodes::Code put_code, // the bytecode used for writing the field
162 KlassHandle field_holder, // the object/klass holding the field 163 KlassHandle field_holder, // the object/klass holding the field
249 TosState flag_state() const { assert( ( (_flags >> tosBits) & 0x0F ) < number_of_states, "Invalid state in as_flags"); 250 TosState flag_state() const { assert( ( (_flags >> tosBits) & 0x0F ) < number_of_states, "Invalid state in as_flags");
250 return (TosState)((_flags >> tosBits) & 0x0F); } 251 return (TosState)((_flags >> tosBits) & 0x0F); }
251 252
252 // Code generation support 253 // Code generation support
253 static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / HeapWordSize); } 254 static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / HeapWordSize); }
255 static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
254 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); } 256 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
255 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); } 257 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
256 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); } 258 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); }
257 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); } 259 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); }
258 260
319 // Helpers 321 // Helpers
320 constantPoolOop* constant_pool_addr() { return &_constant_pool; } 322 constantPoolOop* constant_pool_addr() { return &_constant_pool; }
321 ConstantPoolCacheEntry* base() const { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); } 323 ConstantPoolCacheEntry* base() const { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); }
322 324
323 friend class constantPoolCacheKlass; 325 friend class constantPoolCacheKlass;
326 friend class ConstantPoolCacheEntry;
324 327
325 public: 328 public:
326 // Initialization 329 // Initialization
327 void initialize(intArray& inverse_index_map); 330 void initialize(intArray& inverse_index_map);
328 331
329 // Secondary indexes. 332 // Secondary indexes.
330 // They must look completely different from normal indexes. 333 // They must look completely different from normal indexes.
331 // The main reason is that byte swapping is sometimes done on normal indexes. 334 // The main reason is that byte swapping is sometimes done on normal indexes.
332 // Also, it is helpful for debugging to tell the two apart. 335 // Also, some of the CP accessors do different things for secondary indexes.
336 // Finally, it is helpful for debugging to tell the two apart.
333 static bool is_secondary_index(int i) { return (i < 0); } 337 static bool is_secondary_index(int i) { return (i < 0); }
334 static int decode_secondary_index(int i) { assert(is_secondary_index(i), ""); return ~i; } 338 static int decode_secondary_index(int i) { assert(is_secondary_index(i), ""); return ~i; }
335 static int encode_secondary_index(int i) { assert(!is_secondary_index(i), ""); return ~i; } 339 static int encode_secondary_index(int i) { assert(!is_secondary_index(i), ""); return ~i; }
336 340
337 // Accessors 341 // Accessors
338 void set_constant_pool(constantPoolOop pool) { oop_store_without_check((oop*)&_constant_pool, (oop)pool); } 342 void set_constant_pool(constantPoolOop pool) { oop_store_without_check((oop*)&_constant_pool, (oop)pool); }
339 constantPoolOop constant_pool() const { return _constant_pool; } 343 constantPoolOop constant_pool() const { return _constant_pool; }
340 ConstantPoolCacheEntry* entry_at(int i) const { assert(0 <= i && i < length(), "index out of bounds"); return base() + i; } 344 // Fetches the entry at the given index.
345 // The entry may be either primary or secondary.
346 // In either case the index must not be encoded or byte-swapped in any way.
347 ConstantPoolCacheEntry* entry_at(int i) const {
348 assert(0 <= i && i < length(), "index out of bounds");
349 return base() + i;
350 }
351 // Fetches the secondary entry referred to by index.
352 // The index may be a secondary index, and must not be byte-swapped.
353 ConstantPoolCacheEntry* secondary_entry_at(int i) const {
354 int raw_index = i;
355 if (is_secondary_index(i)) { // correct these on the fly
356 raw_index = decode_secondary_index(i);
357 }
358 assert(entry_at(raw_index)->is_secondary_entry(), "not a secondary entry");
359 return entry_at(raw_index);
360 }
361 // Given a primary or secondary index, fetch the corresponding primary entry.
362 // Indirect through the secondary entry, if the index is encoded as a secondary index.
363 // The index must not be byte-swapped.
341 ConstantPoolCacheEntry* main_entry_at(int i) const { 364 ConstantPoolCacheEntry* main_entry_at(int i) const {
342 ConstantPoolCacheEntry* e; 365 int primary_index = i;
343 if (is_secondary_index(i)) { 366 if (is_secondary_index(i)) {
344 // run through an extra level of indirection: 367 // run through an extra level of indirection:
345 i = decode_secondary_index(i); 368 int raw_index = decode_secondary_index(i);
346 e = entry_at(i); 369 primary_index = entry_at(raw_index)->main_entry_index();
347 i = e->main_entry_index(); 370 }
348 } 371 assert(!entry_at(primary_index)->is_secondary_entry(), "only one level of indirection");
349 e = entry_at(i); 372 return entry_at(primary_index);
350 assert(!e->is_secondary_entry(), "only one level of indirection");
351 return e;
352 } 373 }
353 374
354 // GC support 375 // GC support
355 // If the _length field has not been set, the size of the 376 // If the _length field has not been set, the size of the
356 // constantPoolCache cannot be correctly calculated. 377 // constantPoolCache cannot be correctly calculated.
357 bool is_conc_safe() { return _is_conc_safe; } 378 bool is_conc_safe() { return _is_conc_safe; }
358 void set_is_conc_safe(bool v) { _is_conc_safe = v; } 379 void set_is_conc_safe(bool v) { _is_conc_safe = v; }
359 380
360 // Code generation 381 // Code generation
361 static ByteSize base_offset() { return in_ByteSize(sizeof(constantPoolCacheOopDesc)); } 382 static ByteSize base_offset() { return in_ByteSize(sizeof(constantPoolCacheOopDesc)); }
383 static ByteSize entry_offset(int raw_index) {
384 int index = raw_index;
385 if (is_secondary_index(raw_index))
386 index = decode_secondary_index(raw_index);
387 return (base_offset() + ConstantPoolCacheEntry::size_in_bytes() * index);
388 }
362 389
363 // RedefineClasses() API support: 390 // RedefineClasses() API support:
364 // If any entry of this constantPoolCache points to any of 391 // If any entry of this constantPoolCache points to any of
365 // old_methods, replace it with the corresponding new_method. 392 // old_methods, replace it with the corresponding new_method.
366 // trace_name_printed is set to true if the current call has 393 // trace_name_printed is set to true if the current call has