Mercurial > hg > graal-compiler
comparison src/share/vm/oops/instanceKlass.cpp @ 6988:2cb439954abf
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Mon, 19 Nov 2012 15:36:13 +0100 |
parents | 41938af2b3d8 80e866b1d053 |
children | 5d0bb7d52783 |
comparison
equal
deleted
inserted
replaced
6963:dd0dd0321e2a | 6988:2cb439954abf |
---|---|
725 this_oop->set_init_thread(self); | 725 this_oop->set_init_thread(self); |
726 } | 726 } |
727 | 727 |
728 // Step 7 | 728 // Step 7 |
729 Klass* super_klass = this_oop->super(); | 729 Klass* super_klass = this_oop->super(); |
730 if (super_klass != NULL && !this_oop->is_interface() && Klass::cast(super_klass)->should_be_initialized()) { | 730 if (super_klass != NULL && !this_oop->is_interface() && super_klass->should_be_initialized()) { |
731 Klass::cast(super_klass)->initialize(THREAD); | 731 super_klass->initialize(THREAD); |
732 | 732 |
733 if (HAS_PENDING_EXCEPTION) { | 733 if (HAS_PENDING_EXCEPTION) { |
734 Handle e(THREAD, PENDING_EXCEPTION); | 734 Handle e(THREAD, PENDING_EXCEPTION); |
735 CLEAR_PENDING_EXCEPTION; | 735 CLEAR_PENDING_EXCEPTION; |
736 { | 736 { |
922 return secondaries; | 922 return secondaries; |
923 } | 923 } |
924 } | 924 } |
925 | 925 |
926 bool InstanceKlass::compute_is_subtype_of(Klass* k) { | 926 bool InstanceKlass::compute_is_subtype_of(Klass* k) { |
927 if (Klass::cast(k)->is_interface()) { | 927 if (k->is_interface()) { |
928 return implements_interface(k); | 928 return implements_interface(k); |
929 } else { | 929 } else { |
930 return Klass::compute_is_subtype_of(k); | 930 return Klass::compute_is_subtype_of(k); |
931 } | 931 } |
932 } | 932 } |
933 | 933 |
934 bool InstanceKlass::implements_interface(Klass* k) const { | 934 bool InstanceKlass::implements_interface(Klass* k) const { |
935 if (this == k) return true; | 935 if (this == k) return true; |
936 assert(Klass::cast(k)->is_interface(), "should be an interface class"); | 936 assert(k->is_interface(), "should be an interface class"); |
937 for (int i = 0; i < transitive_interfaces()->length(); i++) { | 937 for (int i = 0; i < transitive_interfaces()->length(); i++) { |
938 if (transitive_interfaces()->at(i) == k) { | 938 if (transitive_interfaces()->at(i) == k) { |
939 return true; | 939 return true; |
940 } | 940 } |
941 } | 941 } |
1050 } | 1050 } |
1051 return NULL; | 1051 return NULL; |
1052 } | 1052 } |
1053 | 1053 |
1054 void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_oop, TRAPS) { | 1054 void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_oop, TRAPS) { |
1055 if (ReplayCompiles && | |
1056 (ReplaySuppressInitializers == 1 || | |
1057 ReplaySuppressInitializers >= 2 && this_oop->class_loader() != NULL)) { | |
1058 // Hide the existence of the initializer for the purpose of replaying the compile | |
1059 return; | |
1060 } | |
1061 | |
1055 methodHandle h_method(THREAD, this_oop->class_initializer()); | 1062 methodHandle h_method(THREAD, this_oop->class_initializer()); |
1056 assert(!this_oop->is_initialized(), "we cannot initialize twice"); | 1063 assert(!this_oop->is_initialized(), "we cannot initialize twice"); |
1057 if (TraceClassInitialization) { | 1064 if (TraceClassInitialization) { |
1058 tty->print("%d Initializing ", call_class_initializer_impl_counter++); | 1065 tty->print("%d Initializing ", call_class_initializer_impl_counter++); |
1059 this_oop->name()->print_value(); | 1066 this_oop->name()->print_value(); |
1098 | 1105 |
1099 Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { | 1106 Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { |
1100 const int n = local_interfaces()->length(); | 1107 const int n = local_interfaces()->length(); |
1101 for (int i = 0; i < n; i++) { | 1108 for (int i = 0; i < n; i++) { |
1102 Klass* intf1 = local_interfaces()->at(i); | 1109 Klass* intf1 = local_interfaces()->at(i); |
1103 assert(Klass::cast(intf1)->is_interface(), "just checking type"); | 1110 assert(intf1->is_interface(), "just checking type"); |
1104 // search for field in current interface | 1111 // search for field in current interface |
1105 if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) { | 1112 if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) { |
1106 assert(fd->is_static(), "interface field must be static"); | 1113 assert(fd->is_static(), "interface field must be static"); |
1107 return intf1; | 1114 return intf1; |
1108 } | 1115 } |
1169 Klass* klass = const_cast<InstanceKlass*>(this); | 1176 Klass* klass = const_cast<InstanceKlass*>(this); |
1170 while (klass != NULL) { | 1177 while (klass != NULL) { |
1171 if (InstanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) { | 1178 if (InstanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) { |
1172 return true; | 1179 return true; |
1173 } | 1180 } |
1174 klass = Klass::cast(klass)->super(); | 1181 klass = klass->super(); |
1175 } | 1182 } |
1176 return false; | 1183 return false; |
1177 } | 1184 } |
1178 | 1185 |
1179 | 1186 |
2357 | 2364 |
2358 // different verisons of is_same_class_package | 2365 // different verisons of is_same_class_package |
2359 bool InstanceKlass::is_same_class_package(Klass* class2) { | 2366 bool InstanceKlass::is_same_class_package(Klass* class2) { |
2360 Klass* class1 = this; | 2367 Klass* class1 = this; |
2361 oop classloader1 = InstanceKlass::cast(class1)->class_loader(); | 2368 oop classloader1 = InstanceKlass::cast(class1)->class_loader(); |
2362 Symbol* classname1 = Klass::cast(class1)->name(); | 2369 Symbol* classname1 = class1->name(); |
2363 | 2370 |
2364 if (Klass::cast(class2)->oop_is_objArray()) { | 2371 if (class2->oop_is_objArray()) { |
2365 class2 = ObjArrayKlass::cast(class2)->bottom_klass(); | 2372 class2 = ObjArrayKlass::cast(class2)->bottom_klass(); |
2366 } | 2373 } |
2367 oop classloader2; | 2374 oop classloader2; |
2368 if (Klass::cast(class2)->oop_is_instance()) { | 2375 if (class2->oop_is_instance()) { |
2369 classloader2 = InstanceKlass::cast(class2)->class_loader(); | 2376 classloader2 = InstanceKlass::cast(class2)->class_loader(); |
2370 } else { | 2377 } else { |
2371 assert(Klass::cast(class2)->oop_is_typeArray(), "should be type array"); | 2378 assert(class2->oop_is_typeArray(), "should be type array"); |
2372 classloader2 = NULL; | 2379 classloader2 = NULL; |
2373 } | 2380 } |
2374 Symbol* classname2 = Klass::cast(class2)->name(); | 2381 Symbol* classname2 = class2->name(); |
2375 | 2382 |
2376 return InstanceKlass::is_same_class_package(classloader1, classname1, | 2383 return InstanceKlass::is_same_class_package(classloader1, classname1, |
2377 classloader2, classname2); | 2384 classloader2, classname2); |
2378 } | 2385 } |
2379 | 2386 |
2380 bool InstanceKlass::is_same_class_package(oop classloader2, Symbol* classname2) { | 2387 bool InstanceKlass::is_same_class_package(oop classloader2, Symbol* classname2) { |
2381 Klass* class1 = this; | 2388 Klass* class1 = this; |
2382 oop classloader1 = InstanceKlass::cast(class1)->class_loader(); | 2389 oop classloader1 = InstanceKlass::cast(class1)->class_loader(); |
2383 Symbol* classname1 = Klass::cast(class1)->name(); | 2390 Symbol* classname1 = class1->name(); |
2384 | 2391 |
2385 return InstanceKlass::is_same_class_package(classloader1, classname1, | 2392 return InstanceKlass::is_same_class_package(classloader1, classname1, |
2386 classloader2, classname2); | 2393 classloader2, classname2); |
2387 } | 2394 } |
2388 | 2395 |
2469 | 2476 |
2470 // tell if two classes have the same enclosing class (at package level) | 2477 // tell if two classes have the same enclosing class (at package level) |
2471 bool InstanceKlass::is_same_package_member_impl(instanceKlassHandle class1, | 2478 bool InstanceKlass::is_same_package_member_impl(instanceKlassHandle class1, |
2472 Klass* class2_oop, TRAPS) { | 2479 Klass* class2_oop, TRAPS) { |
2473 if (class2_oop == class1()) return true; | 2480 if (class2_oop == class1()) return true; |
2474 if (!Klass::cast(class2_oop)->oop_is_instance()) return false; | 2481 if (!class2_oop->oop_is_instance()) return false; |
2475 instanceKlassHandle class2(THREAD, class2_oop); | 2482 instanceKlassHandle class2(THREAD, class2_oop); |
2476 | 2483 |
2477 // must be in same package before we try anything else | 2484 // must be in same package before we try anything else |
2478 if (!class1->is_same_class_package(class2->class_loader(), class2->name())) | 2485 if (!class1->is_same_class_package(class2->class_loader(), class2->name())) |
2479 return false; | 2486 return false; |
3002 // Verify implementor fields | 3009 // Verify implementor fields |
3003 Klass* im = implementor(); | 3010 Klass* im = implementor(); |
3004 if (im != NULL) { | 3011 if (im != NULL) { |
3005 guarantee(is_interface(), "only interfaces should have implementor set"); | 3012 guarantee(is_interface(), "only interfaces should have implementor set"); |
3006 guarantee(im->is_klass(), "should be klass"); | 3013 guarantee(im->is_klass(), "should be klass"); |
3007 guarantee(!Klass::cast(im)->is_interface() || im == this, | 3014 guarantee(!im->is_interface() || im == this, |
3008 "implementors cannot be interfaces"); | 3015 "implementors cannot be interfaces"); |
3009 } | 3016 } |
3010 | 3017 |
3011 // Verify local interfaces | 3018 // Verify local interfaces |
3012 if (local_interfaces()) { | 3019 if (local_interfaces()) { |
3013 Array<Klass*>* local_interfaces = this->local_interfaces(); | 3020 Array<Klass*>* local_interfaces = this->local_interfaces(); |
3014 for (int j = 0; j < local_interfaces->length(); j++) { | 3021 for (int j = 0; j < local_interfaces->length(); j++) { |
3015 Klass* e = local_interfaces->at(j); | 3022 Klass* e = local_interfaces->at(j); |
3016 guarantee(e->is_klass() && Klass::cast(e)->is_interface(), "invalid local interface"); | 3023 guarantee(e->is_klass() && e->is_interface(), "invalid local interface"); |
3017 } | 3024 } |
3018 } | 3025 } |
3019 | 3026 |
3020 // Verify transitive interfaces | 3027 // Verify transitive interfaces |
3021 if (transitive_interfaces() != NULL) { | 3028 if (transitive_interfaces() != NULL) { |
3022 Array<Klass*>* transitive_interfaces = this->transitive_interfaces(); | 3029 Array<Klass*>* transitive_interfaces = this->transitive_interfaces(); |
3023 for (int j = 0; j < transitive_interfaces->length(); j++) { | 3030 for (int j = 0; j < transitive_interfaces->length(); j++) { |
3024 Klass* e = transitive_interfaces->at(j); | 3031 Klass* e = transitive_interfaces->at(j); |
3025 guarantee(e->is_klass() && Klass::cast(e)->is_interface(), "invalid transitive interface"); | 3032 guarantee(e->is_klass() && e->is_interface(), "invalid transitive interface"); |
3026 } | 3033 } |
3027 } | 3034 } |
3028 | 3035 |
3029 // Verify methods | 3036 // Verify methods |
3030 if (methods() != NULL) { | 3037 if (methods() != NULL) { |