3341
3342 /**
3343 * Create constant type for a constant boxed value
3344 */
3345 const Type* TypeInstPtr::get_const_boxed_value() const {
3346 assert(is_ptr_to_boxed_value(), "should be called only for boxed value");
3347 assert((const_oop() != NULL), "should be called only for constant object");
3348 ciConstant constant = const_oop()->as_instance()->field_value_by_offset(offset());
3349 BasicType bt = constant.basic_type();
3350 switch (bt) {
3351 case T_BOOLEAN: return TypeInt::make(constant.as_boolean());
3352 case T_INT: return TypeInt::make(constant.as_int());
3353 case T_CHAR: return TypeInt::make(constant.as_char());
3354 case T_BYTE: return TypeInt::make(constant.as_byte());
3355 case T_SHORT: return TypeInt::make(constant.as_short());
3356 case T_FLOAT: return TypeF::make(constant.as_float());
3357 case T_DOUBLE: return TypeD::make(constant.as_double());
3358 case T_LONG: return TypeLong::make(constant.as_long());
3359 default: break;
3360 }
3361 fatal(err_msg_res("Invalid boxed value type '%s'", type2name(bt)));
3362 return NULL;
3363 }
3364
3365 //------------------------------cast_to_ptr_type-------------------------------
3366 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
3367 if( ptr == _ptr ) return this;
3368 // Reconstruct _sig info here since not a problem with later lazy
3369 // construction, _sig will show up on demand.
3370 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth);
3371 }
3372
3373
3374 //-----------------------------cast_to_exactness-------------------------------
3375 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
3376 if( klass_is_exact == _klass_is_exact ) return this;
3377 if (!UseExactTypes) return this;
3378 if (!_klass->is_loaded()) return this;
3379 ciInstanceKlass* ik = _klass->as_instance_klass();
3380 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
3381 if( ik->is_interface() ) return this; // cannot set xk
|
3341
3342 /**
3343 * Create constant type for a constant boxed value
3344 */
3345 const Type* TypeInstPtr::get_const_boxed_value() const {
3346 assert(is_ptr_to_boxed_value(), "should be called only for boxed value");
3347 assert((const_oop() != NULL), "should be called only for constant object");
3348 ciConstant constant = const_oop()->as_instance()->field_value_by_offset(offset());
3349 BasicType bt = constant.basic_type();
3350 switch (bt) {
3351 case T_BOOLEAN: return TypeInt::make(constant.as_boolean());
3352 case T_INT: return TypeInt::make(constant.as_int());
3353 case T_CHAR: return TypeInt::make(constant.as_char());
3354 case T_BYTE: return TypeInt::make(constant.as_byte());
3355 case T_SHORT: return TypeInt::make(constant.as_short());
3356 case T_FLOAT: return TypeF::make(constant.as_float());
3357 case T_DOUBLE: return TypeD::make(constant.as_double());
3358 case T_LONG: return TypeLong::make(constant.as_long());
3359 default: break;
3360 }
3361 fatal("Invalid boxed value type '%s'", type2name(bt));
3362 return NULL;
3363 }
3364
3365 //------------------------------cast_to_ptr_type-------------------------------
3366 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
3367 if( ptr == _ptr ) return this;
3368 // Reconstruct _sig info here since not a problem with later lazy
3369 // construction, _sig will show up on demand.
3370 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth);
3371 }
3372
3373
3374 //-----------------------------cast_to_exactness-------------------------------
3375 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
3376 if( klass_is_exact == _klass_is_exact ) return this;
3377 if (!UseExactTypes) return this;
3378 if (!_klass->is_loaded()) return this;
3379 ciInstanceKlass* ik = _klass->as_instance_klass();
3380 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
3381 if( ik->is_interface() ) return this; // cannot set xk
|