comparison src/share/vm/oops/method.cpp @ 6940:18fb7da42534

8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass Summary: Change types of above methods and field to InstanceKlass and remove unneeded casts from the source files. Reviewed-by: dholmes, coleenp, zgu Contributed-by: harold.seigel@oracle.com
author coleenp
date Tue, 06 Nov 2012 15:09:37 -0500
parents ec204374e626
children e522a00b91aa 070d523b96a7
comparison
equal deleted inserted replaced
6939:c284cf4781f0 6940:18fb7da42534
241 if (!VerifyStack && !VerifyLastFrame) { 241 if (!VerifyStack && !VerifyLastFrame) {
242 // verify stack calls this outside VM thread 242 // verify stack calls this outside VM thread
243 warning("oopmap should only be accessed by the " 243 warning("oopmap should only be accessed by the "
244 "VM, GC task or CMS threads (or during debugging)"); 244 "VM, GC task or CMS threads (or during debugging)");
245 InterpreterOopMap local_mask; 245 InterpreterOopMap local_mask;
246 InstanceKlass::cast(method_holder())->mask_for(h_this, bci, &local_mask); 246 method_holder()->mask_for(h_this, bci, &local_mask);
247 local_mask.print(); 247 local_mask.print();
248 } 248 }
249 } 249 }
250 #endif 250 #endif
251 InstanceKlass::cast(method_holder())->mask_for(h_this, bci, mask); 251 method_holder()->mask_for(h_this, bci, mask);
252 return; 252 return;
253 } 253 }
254 254
255 255
256 int Method::bci_from(address bcp) const { 256 int Method::bci_from(address bcp) const {
521 521
522 522
523 bool Method::is_final_method() const { 523 bool Method::is_final_method() const {
524 // %%% Should return true for private methods also, 524 // %%% Should return true for private methods also,
525 // since there is no way to override them. 525 // since there is no way to override them.
526 return is_final() || Klass::cast(method_holder())->is_final(); 526 return is_final() || method_holder()->is_final();
527 } 527 }
528 528
529 529
530 bool Method::is_strict_method() const { 530 bool Method::is_strict_method() const {
531 return is_strict(); 531 return is_strict();
553 return name() == vmSymbols::object_initializer_name() || is_static_initializer(); 553 return name() == vmSymbols::object_initializer_name() || is_static_initializer();
554 } 554 }
555 555
556 bool Method::has_valid_initializer_flags() const { 556 bool Method::has_valid_initializer_flags() const {
557 return (is_static() || 557 return (is_static() ||
558 InstanceKlass::cast(method_holder())->major_version() < 51); 558 method_holder()->major_version() < 51);
559 } 559 }
560 560
561 bool Method::is_static_initializer() const { 561 bool Method::is_static_initializer() const {
562 // For classfiles version 51 or greater, ensure that the clinit method is 562 // For classfiles version 51 or greater, ensure that the clinit method is
563 // static. Non-static methods with the name "<clinit>" are not static 563 // static. Non-static methods with the name "<clinit>" are not static
615 615
616 bool Method::is_klass_loaded_by_klass_index(int klass_index) const { 616 bool Method::is_klass_loaded_by_klass_index(int klass_index) const {
617 if( constants()->tag_at(klass_index).is_unresolved_klass() ) { 617 if( constants()->tag_at(klass_index).is_unresolved_klass() ) {
618 Thread *thread = Thread::current(); 618 Thread *thread = Thread::current();
619 Symbol* klass_name = constants()->klass_name_at(klass_index); 619 Symbol* klass_name = constants()->klass_name_at(klass_index);
620 Handle loader(thread, InstanceKlass::cast(method_holder())->class_loader()); 620 Handle loader(thread, method_holder()->class_loader());
621 Handle prot (thread, Klass::cast(method_holder())->protection_domain()); 621 Handle prot (thread, Klass::cast(method_holder())->protection_domain());
622 return SystemDictionary::find(klass_name, loader, prot, thread) != NULL; 622 return SystemDictionary::find(klass_name, loader, prot, thread) != NULL;
623 } else { 623 } else {
624 return true; 624 return true;
625 } 625 }
933 933
934 if (ik->is_interface()) return false; 934 if (ik->is_interface()) return false;
935 935
936 // If method is an interface, we skip it - except if it 936 // If method is an interface, we skip it - except if it
937 // is a miranda method 937 // is a miranda method
938 if (InstanceKlass::cast(method_holder())->is_interface()) { 938 if (method_holder()->is_interface()) {
939 // Check that method is not a miranda method 939 // Check that method is not a miranda method
940 if (ik->lookup_method(name(), signature()) == NULL) { 940 if (ik->lookup_method(name(), signature()) == NULL) {
941 // No implementation exist - so miranda method 941 // No implementation exist - so miranda method
942 return false; 942 return false;
943 } 943 }
1018 constantPoolHandle cp; 1018 constantPoolHandle cp;
1019 { 1019 {
1020 ConstantPool* cp_oop = ConstantPool::allocate(loader_data, cp_length, CHECK_(empty)); 1020 ConstantPool* cp_oop = ConstantPool::allocate(loader_data, cp_length, CHECK_(empty));
1021 cp = constantPoolHandle(THREAD, cp_oop); 1021 cp = constantPoolHandle(THREAD, cp_oop);
1022 } 1022 }
1023 cp->set_pool_holder(holder()); 1023 cp->set_pool_holder(InstanceKlass::cast(holder()));
1024 cp->symbol_at_put(_imcp_invoke_name, name); 1024 cp->symbol_at_put(_imcp_invoke_name, name);
1025 cp->symbol_at_put(_imcp_invoke_signature, signature); 1025 cp->symbol_at_put(_imcp_invoke_signature, signature);
1026 cp->set_preresolution(); 1026 cp->set_preresolution();
1027 1027
1028 // decide on access bits: public or not? 1028 // decide on access bits: public or not?
1235 // Hopefully, the signature contains only well-known classes. 1235 // Hopefully, the signature contains only well-known classes.
1236 // We could scan for this and return true/false, but the caller won't care. 1236 // We could scan for this and return true/false, but the caller won't care.
1237 return false; 1237 return false;
1238 } 1238 }
1239 bool sig_is_loaded = true; 1239 bool sig_is_loaded = true;
1240 Handle class_loader(THREAD, InstanceKlass::cast(m->method_holder())->class_loader()); 1240 Handle class_loader(THREAD, m->method_holder()->class_loader());
1241 Handle protection_domain(THREAD, Klass::cast(m->method_holder())->protection_domain()); 1241 Handle protection_domain(THREAD, m->method_holder()->protection_domain());
1242 ResourceMark rm(THREAD); 1242 ResourceMark rm(THREAD);
1243 Symbol* signature = m->signature(); 1243 Symbol* signature = m->signature();
1244 for(SignatureStream ss(signature); !ss.is_done(); ss.next()) { 1244 for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
1245 if (ss.is_object()) { 1245 if (ss.is_object()) {
1246 Symbol* sym = ss.as_symbol(CHECK_(false)); 1246 Symbol* sym = ss.as_symbol(CHECK_(false));
1262 } 1262 }
1263 return sig_is_loaded; 1263 return sig_is_loaded;
1264 } 1264 }
1265 1265
1266 bool Method::has_unloaded_classes_in_signature(methodHandle m, TRAPS) { 1266 bool Method::has_unloaded_classes_in_signature(methodHandle m, TRAPS) {
1267 Handle class_loader(THREAD, InstanceKlass::cast(m->method_holder())->class_loader()); 1267 Handle class_loader(THREAD, m->method_holder()->class_loader());
1268 Handle protection_domain(THREAD, Klass::cast(m->method_holder())->protection_domain()); 1268 Handle protection_domain(THREAD, m->method_holder()->protection_domain());
1269 ResourceMark rm(THREAD); 1269 ResourceMark rm(THREAD);
1270 Symbol* signature = m->signature(); 1270 Symbol* signature = m->signature();
1271 for(SignatureStream ss(signature); !ss.is_done(); ss.next()) { 1271 for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
1272 if (ss.type() == T_OBJECT) { 1272 if (ss.type() == T_OBJECT) {
1273 Symbol* name = ss.as_symbol_or_null(); 1273 Symbol* name = ss.as_symbol_or_null();
1470 return true; 1470 return true;
1471 } 1471 }
1472 1472
1473 1473
1474 Bytecodes::Code Method::orig_bytecode_at(int bci) const { 1474 Bytecodes::Code Method::orig_bytecode_at(int bci) const {
1475 BreakpointInfo* bp = InstanceKlass::cast(method_holder())->breakpoints(); 1475 BreakpointInfo* bp = method_holder()->breakpoints();
1476 for (; bp != NULL; bp = bp->next()) { 1476 for (; bp != NULL; bp = bp->next()) {
1477 if (bp->match(this, bci)) { 1477 if (bp->match(this, bci)) {
1478 return bp->orig_bytecode(); 1478 return bp->orig_bytecode();
1479 } 1479 }
1480 } 1480 }
1482 return Bytecodes::_shouldnotreachhere; 1482 return Bytecodes::_shouldnotreachhere;
1483 } 1483 }
1484 1484
1485 void Method::set_orig_bytecode_at(int bci, Bytecodes::Code code) { 1485 void Method::set_orig_bytecode_at(int bci, Bytecodes::Code code) {
1486 assert(code != Bytecodes::_breakpoint, "cannot patch breakpoints this way"); 1486 assert(code != Bytecodes::_breakpoint, "cannot patch breakpoints this way");
1487 BreakpointInfo* bp = InstanceKlass::cast(method_holder())->breakpoints(); 1487 BreakpointInfo* bp = method_holder()->breakpoints();
1488 for (; bp != NULL; bp = bp->next()) { 1488 for (; bp != NULL; bp = bp->next()) {
1489 if (bp->match(this, bci)) { 1489 if (bp->match(this, bci)) {
1490 bp->set_orig_bytecode(code); 1490 bp->set_orig_bytecode(code);
1491 // and continue, in case there is more than one 1491 // and continue, in case there is more than one
1492 } 1492 }
1493 } 1493 }
1494 } 1494 }
1495 1495
1496 void Method::set_breakpoint(int bci) { 1496 void Method::set_breakpoint(int bci) {
1497 InstanceKlass* ik = InstanceKlass::cast(method_holder()); 1497 InstanceKlass* ik = method_holder();
1498 BreakpointInfo *bp = new BreakpointInfo(this, bci); 1498 BreakpointInfo *bp = new BreakpointInfo(this, bci);
1499 bp->set_next(ik->breakpoints()); 1499 bp->set_next(ik->breakpoints());
1500 ik->set_breakpoints(bp); 1500 ik->set_breakpoints(bp);
1501 // do this last: 1501 // do this last:
1502 bp->set(this); 1502 bp->set(this);
1503 } 1503 }
1504 1504
1505 static void clear_matches(Method* m, int bci) { 1505 static void clear_matches(Method* m, int bci) {
1506 InstanceKlass* ik = InstanceKlass::cast(m->method_holder()); 1506 InstanceKlass* ik = m->method_holder();
1507 BreakpointInfo* prev_bp = NULL; 1507 BreakpointInfo* prev_bp = NULL;
1508 BreakpointInfo* next_bp; 1508 BreakpointInfo* next_bp;
1509 for (BreakpointInfo* bp = ik->breakpoints(); bp != NULL; bp = next_bp) { 1509 for (BreakpointInfo* bp = ik->breakpoints(); bp != NULL; bp = next_bp) {
1510 next_bp = bp->next(); 1510 next_bp = bp->next();
1511 // bci value of -1 is used to delete all breakpoints in method m (ex: clear_all_breakpoint). 1511 // bci value of -1 is used to delete all breakpoints in method m (ex: clear_all_breakpoint).
1784 } 1784 }
1785 1785
1786 bool Method::is_method_id(jmethodID mid) { 1786 bool Method::is_method_id(jmethodID mid) {
1787 Method* m = resolve_jmethod_id(mid); 1787 Method* m = resolve_jmethod_id(mid);
1788 assert(m != NULL, "should be called with non-null method"); 1788 assert(m != NULL, "should be called with non-null method");
1789 InstanceKlass* ik = InstanceKlass::cast(m->method_holder()); 1789 InstanceKlass* ik = m->method_holder();
1790 ClassLoaderData* cld = ik->class_loader_data(); 1790 ClassLoaderData* cld = ik->class_loader_data();
1791 if (cld->jmethod_ids() == NULL) return false; 1791 if (cld->jmethod_ids() == NULL) return false;
1792 return (cld->jmethod_ids()->contains((Method**)mid)); 1792 return (cld->jmethod_ids()->contains((Method**)mid));
1793 } 1793 }
1794 1794