comparison src/share/vm/opto/type.cpp @ 989:148e5441d916

6863023: need non-perm oops in code cache for JSR 292 Summary: Make a special root-list for those few nmethods which might contain non-perm oops. Reviewed-by: twisti, kvn, never, jmasa, ysr
author jrose
date Tue, 15 Sep 2009 21:53:47 -0700
parents c7e94e8fff43
children 6a8ccac44f41
comparison
equal deleted inserted replaced
987:00977607da34 989:148e5441d916
2409 } 2409 }
2410 } 2410 }
2411 2411
2412 //------------------------------make_from_constant----------------------------- 2412 //------------------------------make_from_constant-----------------------------
2413 // Make a java pointer from an oop constant 2413 // Make a java pointer from an oop constant
2414 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o) { 2414 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) {
2415 if (o->is_method_data() || o->is_method()) { 2415 if (o->is_method_data() || o->is_method()) {
2416 // Treat much like a typeArray of bytes, like below, but fake the type... 2416 // Treat much like a typeArray of bytes, like below, but fake the type...
2417 assert(o->has_encoding(), "must be a perm space object");
2418 const Type* etype = (Type*)get_const_basic_type(T_BYTE); 2417 const Type* etype = (Type*)get_const_basic_type(T_BYTE);
2419 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); 2418 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
2420 ciKlass *klass = ciTypeArrayKlass::make((BasicType) T_BYTE); 2419 ciKlass *klass = ciTypeArrayKlass::make((BasicType) T_BYTE);
2421 assert(o->has_encoding(), "method data oops should be tenured"); 2420 assert(o->can_be_constant(), "method data oops should be tenured");
2422 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 2421 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2423 return arr; 2422 return arr;
2424 } else { 2423 } else {
2425 assert(o->is_java_object(), "must be java language object"); 2424 assert(o->is_java_object(), "must be java language object");
2426 assert(!o->is_null_object(), "null object not yet handled here."); 2425 assert(!o->is_null_object(), "null object not yet handled here.");
2427 ciKlass *klass = o->klass(); 2426 ciKlass *klass = o->klass();
2428 if (klass->is_instance_klass()) { 2427 if (klass->is_instance_klass()) {
2429 // Element is an instance 2428 // Element is an instance
2430 if (!o->has_encoding()) { // not a perm-space constant 2429 if (require_constant) {
2431 // %%% remove this restriction by rewriting non-perm ConPNodes in a later phase 2430 if (!o->can_be_constant()) return NULL;
2431 } else if (!o->should_be_constant()) {
2432 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0); 2432 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
2433 } 2433 }
2434 return TypeInstPtr::make(o); 2434 return TypeInstPtr::make(o);
2435 } else if (klass->is_obj_array_klass()) { 2435 } else if (klass->is_obj_array_klass()) {
2436 // Element is an object array. Recursively call ourself. 2436 // Element is an object array. Recursively call ourself.
2438 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass()); 2438 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass());
2439 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 2439 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
2440 // We used to pass NotNull in here, asserting that the sub-arrays 2440 // We used to pass NotNull in here, asserting that the sub-arrays
2441 // are all not-null. This is not true in generally, as code can 2441 // are all not-null. This is not true in generally, as code can
2442 // slam NULLs down in the subarrays. 2442 // slam NULLs down in the subarrays.
2443 if (!o->has_encoding()) { // not a perm-space constant 2443 if (require_constant) {
2444 // %%% remove this restriction by rewriting non-perm ConPNodes in a later phase 2444 if (!o->can_be_constant()) return NULL;
2445 } else if (!o->should_be_constant()) {
2445 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 2446 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2446 } 2447 }
2447 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 2448 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2448 return arr; 2449 return arr;
2449 } else if (klass->is_type_array_klass()) { 2450 } else if (klass->is_type_array_klass()) {
2451 const Type* etype = 2452 const Type* etype =
2452 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); 2453 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
2453 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 2454 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
2454 // We used to pass NotNull in here, asserting that the array pointer 2455 // We used to pass NotNull in here, asserting that the array pointer
2455 // is not-null. That was not true in general. 2456 // is not-null. That was not true in general.
2456 if (!o->has_encoding()) { // not a perm-space constant 2457 if (require_constant) {
2457 // %%% remove this restriction by rewriting non-perm ConPNodes in a later phase 2458 if (!o->can_be_constant()) return NULL;
2459 } else if (!o->should_be_constant()) {
2458 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 2460 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2459 } 2461 }
2460 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 2462 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2461 return arr; 2463 return arr;
2462 } 2464 }
2481 // but this assertion here is to help prevent its occurence. 2483 // but this assertion here is to help prevent its occurence.
2482 tty->print_cr("Found oop constant with non-zero offset"); 2484 tty->print_cr("Found oop constant with non-zero offset");
2483 ShouldNotReachHere(); 2485 ShouldNotReachHere();
2484 } 2486 }
2485 2487
2486 return (intptr_t)const_oop()->encoding(); 2488 return (intptr_t)const_oop()->constant_encoding();
2487 } 2489 }
2488 2490
2489 2491
2490 //-----------------------------filter------------------------------------------ 2492 //-----------------------------filter------------------------------------------
2491 // Do not allow interface-vs.-noninterface joins to collapse to top. 2493 // Do not allow interface-vs.-noninterface joins to collapse to top.
3336 return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id ); 3338 return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id );
3337 case Constant: { 3339 case Constant: {
3338 ciObject* o = const_oop(); 3340 ciObject* o = const_oop();
3339 if( _ptr == Constant ) { 3341 if( _ptr == Constant ) {
3340 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { 3342 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) {
3343 xk = (klass() == tap->klass());
3341 ptr = NotNull; 3344 ptr = NotNull;
3342 o = NULL; 3345 o = NULL;
3343 instance_id = InstanceBot; 3346 instance_id = InstanceBot;
3347 } else {
3348 xk = true;
3344 } 3349 }
3345 } else if( above_centerline(_ptr) ) { 3350 } else if( above_centerline(_ptr) ) {
3346 o = tap->const_oop(); 3351 o = tap->const_oop();
3352 xk = true;
3353 } else {
3354 xk = this->_klass_is_exact;
3347 } 3355 }
3348 xk = true;
3349 return TypeAryPtr::make( ptr, o, tary, tap->_klass, xk, off, instance_id ); 3356 return TypeAryPtr::make( ptr, o, tary, tap->_klass, xk, off, instance_id );
3350 } 3357 }
3351 case NotNull: 3358 case NotNull:
3352 case BotPTR: 3359 case BotPTR:
3353 // Compute new klass on demand, do not use tap->_klass 3360 // Compute new klass on demand, do not use tap->_klass