168 assert((field_index & field_index_mask) == field_index, "field_index in range"); 169 set_flags(make_flags(field_type, option_bits | (1 << is_field_entry_shift), field_index)); 170 } 171 void set_method_flags(TosState return_type, int option_bits, int method_params) { 172 assert((method_params & parameter_size_mask) == method_params, "method_params in range"); 173 set_flags(make_flags(return_type, option_bits, method_params)); 174 } 175 176 public: 177 // specific bit definitions for the flags field: 178 // (Note: the interpreter must use these definitions to access the CP cache.) 179 enum { 180 // high order bits are the TosState corresponding to field type or method return type 181 tos_state_bits = 4, 182 tos_state_mask = right_n_bits(tos_state_bits), 183 tos_state_shift = BitsPerInt - tos_state_bits, // see verify_tos_state_shift below 184 // misc. option bits; can be any bit position in [16..27] 185 is_field_entry_shift = 26, // (F) is it a field or a method? 186 has_method_type_shift = 25, // (M) does the call site have a MethodType? 187 has_appendix_shift = 24, // (A) does the call site have an appendix argument? 188 is_flattenable_field = 24, // (N) is the field flattenable (must never be null) 189 is_forced_virtual_shift = 23, // (I) is the interface reference forced to virtual mode? 190 is_flatten_field = 23, // (i) is the value field flatten? 191 is_final_shift = 22, // (f) is the field or method final? 192 is_volatile_shift = 21, // (v) is the field volatile? 193 is_vfinal_shift = 20, // (vf) did the call resolve to a final method? 194 indy_resolution_failed_shift= 19, // (indy_rf) did call site specifier resolution fail ? 195 // low order bits give field index (for FieldInfo) or method parameter size: 196 field_index_bits = 16, 197 field_index_mask = right_n_bits(field_index_bits), 198 parameter_size_bits = 8, // subset of field_index_mask, range is 0..255 199 parameter_size_mask = right_n_bits(parameter_size_bits), 200 option_bits_mask = ~(((~0u) << tos_state_shift) | (field_index_mask | parameter_size_mask)) 201 }; 202 203 // specific bit definitions for the indices field: 204 enum { 205 cp_index_bits = 2*BitsPerByte, 206 cp_index_mask = right_n_bits(cp_index_bits), 207 bytecode_1_shift = cp_index_bits, 208 bytecode_1_mask = right_n_bits(BitsPerByte), // == (u1)0xFF 209 bytecode_2_shift = cp_index_bits + BitsPerByte, 210 bytecode_2_mask = right_n_bits(BitsPerByte) // == (u1)0xFF 350 Bytecodes::Code bytecode_1() const { return Bytecodes::cast((indices_ord() >> bytecode_1_shift) & bytecode_1_mask); } 351 Bytecodes::Code bytecode_2() const { return Bytecodes::cast((indices_ord() >> bytecode_2_shift) & bytecode_2_mask); } 352 Metadata* f1_ord() const { return (Metadata *)OrderAccess::load_acquire(&_f1); } 353 Method* f1_as_method() const { Metadata* f1 = f1_ord(); assert(f1 == NULL || f1->is_method(), ""); return (Method*)f1; } 354 Klass* f1_as_klass() const { Metadata* f1 = f1_ord(); assert(f1 == NULL || f1->is_klass(), ""); return (Klass*)f1; } 355 // Use the accessor f1() to acquire _f1's value. This is needed for 356 // example in BytecodeInterpreter::run(), where is_f1_null() is 357 // called to check if an invokedynamic call is resolved. This load 358 // of _f1 must be ordered with the loads performed by 359 // cache->main_entry_index(). 360 bool is_f1_null() const { Metadata* f1 = f1_ord(); return f1 == NULL; } // classifies a CPC entry as unbound 361 int f2_as_index() const { assert(!is_vfinal(), ""); return (int) _f2; } 362 Method* f2_as_vfinal_method() const { assert(is_vfinal(), ""); return (Method*)_f2; } 363 Method* f2_as_interface_method() const { assert(bytecode_1() == Bytecodes::_invokeinterface, ""); return (Method*)_f2; } 364 int f2_as_offset() const { assert(is_field_entry(), ""); return (int)_f2; } 365 intx flags_ord() const { return (intx)OrderAccess::load_acquire(&_flags); } 366 int field_index() const { assert(is_field_entry(), ""); return (_flags & field_index_mask); } 367 int parameter_size() const { assert(is_method_entry(), ""); return (_flags & parameter_size_mask); } 368 bool is_volatile() const { return (_flags & (1 << is_volatile_shift)) != 0; } 369 bool is_final() const { return (_flags & (1 << is_final_shift)) != 0; } 370 bool is_flatten() const { return (_flags & (1 << is_flatten_field)) != 0; } 371 bool is_forced_virtual() const { return (_flags & (1 << is_forced_virtual_shift)) != 0; } 372 bool is_vfinal() const { return (_flags & (1 << is_vfinal_shift)) != 0; } 373 bool indy_resolution_failed() const { intx flags = flags_ord(); return (flags & (1 << indy_resolution_failed_shift)) != 0; } 374 bool has_appendix() const { return (!is_f1_null()) && (_flags & (1 << has_appendix_shift)) != 0; } 375 bool has_method_type() const { return (!is_f1_null()) && (_flags & (1 << has_method_type_shift)) != 0; } 376 bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; } 377 bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; } 378 bool is_long() const { return flag_state() == ltos; } 379 bool is_double() const { return flag_state() == dtos; } 380 bool is_flattenable() const { return (_flags & (1 << is_flattenable_field)) != 0; } 381 TosState flag_state() const { assert((uint)number_of_states <= (uint)tos_state_mask+1, ""); 382 return (TosState)((_flags >> tos_state_shift) & tos_state_mask); } 383 void set_indy_resolution_failed(); 384 385 // Code generation support 386 static WordSize size() { 387 return in_WordSize(align_up((int)sizeof(ConstantPoolCacheEntry), wordSize) / wordSize); 388 } 389 static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); } 390 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); } 391 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); } 392 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); } 393 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); } 394 395 #if INCLUDE_JVMTI 396 // RedefineClasses() API support: 397 // If this ConstantPoolCacheEntry refers to old_method then update it 398 // to refer to new_method. 399 // trace_name_printed is set to true if the current call has 400 // printed the klass name so that other routines in the adjust_* | 168 assert((field_index & field_index_mask) == field_index, "field_index in range"); 169 set_flags(make_flags(field_type, option_bits | (1 << is_field_entry_shift), field_index)); 170 } 171 void set_method_flags(TosState return_type, int option_bits, int method_params) { 172 assert((method_params & parameter_size_mask) == method_params, "method_params in range"); 173 set_flags(make_flags(return_type, option_bits, method_params)); 174 } 175 176 public: 177 // specific bit definitions for the flags field: 178 // (Note: the interpreter must use these definitions to access the CP cache.) 179 enum { 180 // high order bits are the TosState corresponding to field type or method return type 181 tos_state_bits = 4, 182 tos_state_mask = right_n_bits(tos_state_bits), 183 tos_state_shift = BitsPerInt - tos_state_bits, // see verify_tos_state_shift below 184 // misc. option bits; can be any bit position in [16..27] 185 is_field_entry_shift = 26, // (F) is it a field or a method? 186 has_method_type_shift = 25, // (M) does the call site have a MethodType? 187 has_appendix_shift = 24, // (A) does the call site have an appendix argument? 188 is_flattenable_field_shift = 24, // (N) is the field flattenable (must never be null) 189 is_forced_virtual_shift = 23, // (I) is the interface reference forced to virtual mode? 190 is_flattened_field_shift = 23, // (i) is the value field flattened? 191 is_final_shift = 22, // (f) is the field or method final? 192 is_volatile_shift = 21, // (v) is the field volatile? 193 is_vfinal_shift = 20, // (vf) did the call resolve to a final method? 194 indy_resolution_failed_shift= 19, // (indy_rf) did call site specifier resolution fail ? 195 // low order bits give field index (for FieldInfo) or method parameter size: 196 field_index_bits = 16, 197 field_index_mask = right_n_bits(field_index_bits), 198 parameter_size_bits = 8, // subset of field_index_mask, range is 0..255 199 parameter_size_mask = right_n_bits(parameter_size_bits), 200 option_bits_mask = ~(((~0u) << tos_state_shift) | (field_index_mask | parameter_size_mask)) 201 }; 202 203 // specific bit definitions for the indices field: 204 enum { 205 cp_index_bits = 2*BitsPerByte, 206 cp_index_mask = right_n_bits(cp_index_bits), 207 bytecode_1_shift = cp_index_bits, 208 bytecode_1_mask = right_n_bits(BitsPerByte), // == (u1)0xFF 209 bytecode_2_shift = cp_index_bits + BitsPerByte, 210 bytecode_2_mask = right_n_bits(BitsPerByte) // == (u1)0xFF 350 Bytecodes::Code bytecode_1() const { return Bytecodes::cast((indices_ord() >> bytecode_1_shift) & bytecode_1_mask); } 351 Bytecodes::Code bytecode_2() const { return Bytecodes::cast((indices_ord() >> bytecode_2_shift) & bytecode_2_mask); } 352 Metadata* f1_ord() const { return (Metadata *)OrderAccess::load_acquire(&_f1); } 353 Method* f1_as_method() const { Metadata* f1 = f1_ord(); assert(f1 == NULL || f1->is_method(), ""); return (Method*)f1; } 354 Klass* f1_as_klass() const { Metadata* f1 = f1_ord(); assert(f1 == NULL || f1->is_klass(), ""); return (Klass*)f1; } 355 // Use the accessor f1() to acquire _f1's value. This is needed for 356 // example in BytecodeInterpreter::run(), where is_f1_null() is 357 // called to check if an invokedynamic call is resolved. This load 358 // of _f1 must be ordered with the loads performed by 359 // cache->main_entry_index(). 360 bool is_f1_null() const { Metadata* f1 = f1_ord(); return f1 == NULL; } // classifies a CPC entry as unbound 361 int f2_as_index() const { assert(!is_vfinal(), ""); return (int) _f2; } 362 Method* f2_as_vfinal_method() const { assert(is_vfinal(), ""); return (Method*)_f2; } 363 Method* f2_as_interface_method() const { assert(bytecode_1() == Bytecodes::_invokeinterface, ""); return (Method*)_f2; } 364 int f2_as_offset() const { assert(is_field_entry(), ""); return (int)_f2; } 365 intx flags_ord() const { return (intx)OrderAccess::load_acquire(&_flags); } 366 int field_index() const { assert(is_field_entry(), ""); return (_flags & field_index_mask); } 367 int parameter_size() const { assert(is_method_entry(), ""); return (_flags & parameter_size_mask); } 368 bool is_volatile() const { return (_flags & (1 << is_volatile_shift)) != 0; } 369 bool is_final() const { return (_flags & (1 << is_final_shift)) != 0; } 370 bool is_flattened() const { return (_flags & (1 << is_flattened_field_shift)) != 0; } 371 bool is_forced_virtual() const { return (_flags & (1 << is_forced_virtual_shift)) != 0; } 372 bool is_vfinal() const { return (_flags & (1 << is_vfinal_shift)) != 0; } 373 bool indy_resolution_failed() const { intx flags = flags_ord(); return (flags & (1 << indy_resolution_failed_shift)) != 0; } 374 bool has_appendix() const { return (!is_f1_null()) && (_flags & (1 << has_appendix_shift)) != 0; } 375 bool has_method_type() const { return (!is_f1_null()) && (_flags & (1 << has_method_type_shift)) != 0; } 376 bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; } 377 bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; } 378 bool is_long() const { return flag_state() == ltos; } 379 bool is_double() const { return flag_state() == dtos; } 380 bool is_flattenable() const { return (_flags & (1 << is_flattenable_field_shift)) != 0; } 381 TosState flag_state() const { assert((uint)number_of_states <= (uint)tos_state_mask+1, ""); 382 return (TosState)((_flags >> tos_state_shift) & tos_state_mask); } 383 void set_indy_resolution_failed(); 384 385 // Code generation support 386 static WordSize size() { 387 return in_WordSize(align_up((int)sizeof(ConstantPoolCacheEntry), wordSize) / wordSize); 388 } 389 static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); } 390 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); } 391 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); } 392 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); } 393 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); } 394 395 #if INCLUDE_JVMTI 396 // RedefineClasses() API support: 397 // If this ConstantPoolCacheEntry refers to old_method then update it 398 // to refer to new_method. 399 // trace_name_printed is set to true if the current call has 400 // printed the klass name so that other routines in the adjust_* |