Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/instanceKlass.cpp @ 20785:9906d432d6db jdk8u31-b11
8064524: Compiler code generation improvements
Reviewed-by: jrose, acorn, vlivanov
author | drchase |
---|---|
date | Mon, 01 Dec 2014 13:06:20 -0500 |
parents | bd4d69d9cb7d |
children | c4f1e23c4139 |
comparison
equal
deleted
inserted
replaced
20784:b3a8626eefc5 | 20785:9906d432d6db |
---|---|
1433 Method* InstanceKlass::find_method(Symbol* name, Symbol* signature) const { | 1433 Method* InstanceKlass::find_method(Symbol* name, Symbol* signature) const { |
1434 return find_method_impl(name, signature, false); | 1434 return find_method_impl(name, signature, false); |
1435 } | 1435 } |
1436 | 1436 |
1437 Method* InstanceKlass::find_method_impl(Symbol* name, Symbol* signature, bool skipping_overpass) const { | 1437 Method* InstanceKlass::find_method_impl(Symbol* name, Symbol* signature, bool skipping_overpass) const { |
1438 return InstanceKlass::find_method_impl(methods(), name, signature, skipping_overpass); | 1438 return InstanceKlass::find_method_impl(methods(), name, signature, skipping_overpass, false); |
1439 } | 1439 } |
1440 | 1440 |
1441 // find_instance_method looks up the name/signature in the local methods array | 1441 // find_instance_method looks up the name/signature in the local methods array |
1442 // and skips over static methods | 1442 // and skips over static methods |
1443 Method* InstanceKlass::find_instance_method( | 1443 Method* InstanceKlass::find_instance_method( |
1444 Array<Method*>* methods, Symbol* name, Symbol* signature) { | 1444 Array<Method*>* methods, Symbol* name, Symbol* signature) { |
1445 Method* meth = InstanceKlass::find_method(methods, name, signature); | 1445 Method* meth = InstanceKlass::find_method_impl(methods, name, signature, false, true); |
1446 if (meth != NULL && meth->is_static()) { | |
1447 meth = NULL; | |
1448 } | |
1449 return meth; | 1446 return meth; |
1447 } | |
1448 | |
1449 // find_instance_method looks up the name/signature in the local methods array | |
1450 // and skips over static methods | |
1451 Method* InstanceKlass::find_instance_method(Symbol* name, Symbol* signature) { | |
1452 return InstanceKlass::find_instance_method(methods(), name, signature); | |
1450 } | 1453 } |
1451 | 1454 |
1452 // find_method looks up the name/signature in the local methods array | 1455 // find_method looks up the name/signature in the local methods array |
1453 Method* InstanceKlass::find_method( | 1456 Method* InstanceKlass::find_method( |
1454 Array<Method*>* methods, Symbol* name, Symbol* signature) { | 1457 Array<Method*>* methods, Symbol* name, Symbol* signature) { |
1455 return InstanceKlass::find_method_impl(methods, name, signature, false); | 1458 return InstanceKlass::find_method_impl(methods, name, signature, false, false); |
1456 } | 1459 } |
1457 | 1460 |
1458 Method* InstanceKlass::find_method_impl( | 1461 Method* InstanceKlass::find_method_impl( |
1459 Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass) { | 1462 Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass, bool skipping_static) { |
1460 int hit = find_method_index(methods, name, signature, skipping_overpass); | 1463 int hit = find_method_index(methods, name, signature, skipping_overpass, skipping_static); |
1461 return hit >= 0 ? methods->at(hit): NULL; | 1464 return hit >= 0 ? methods->at(hit): NULL; |
1465 } | |
1466 | |
1467 bool InstanceKlass::method_matches(Method* m, Symbol* signature, bool skipping_overpass, bool skipping_static) { | |
1468 return (m->signature() == signature) && | |
1469 (!skipping_overpass || !m->is_overpass()) && | |
1470 (!skipping_static || !m->is_static()); | |
1462 } | 1471 } |
1463 | 1472 |
1464 // Used directly for default_methods to find the index into the | 1473 // Used directly for default_methods to find the index into the |
1465 // default_vtable_indices, and indirectly by find_method | 1474 // default_vtable_indices, and indirectly by find_method |
1466 // find_method_index looks in the local methods array to return the index | 1475 // find_method_index looks in the local methods array to return the index |
1467 // of the matching name/signature. If, overpass methods are being ignored, | 1476 // of the matching name/signature. If, overpass methods are being ignored, |
1468 // the search continues to find a potential non-overpass match. This capability | 1477 // the search continues to find a potential non-overpass match. This capability |
1469 // is important during method resolution to prefer a static method, for example, | 1478 // is important during method resolution to prefer a static method, for example, |
1470 // over an overpass method. | 1479 // over an overpass method. |
1471 int InstanceKlass::find_method_index( | 1480 int InstanceKlass::find_method_index( |
1472 Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass) { | 1481 Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass, bool skipping_static) { |
1473 int hit = binary_search(methods, name); | 1482 int hit = binary_search(methods, name); |
1474 if (hit != -1) { | 1483 if (hit != -1) { |
1475 Method* m = methods->at(hit); | 1484 Method* m = methods->at(hit); |
1485 | |
1476 // Do linear search to find matching signature. First, quick check | 1486 // Do linear search to find matching signature. First, quick check |
1477 // for common case, ignoring overpasses if requested. | 1487 // for common case, ignoring overpasses if requested. |
1478 if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return hit; | 1488 if (method_matches(m, signature, skipping_overpass, skipping_static)) return hit; |
1479 | 1489 |
1480 // search downwards through overloaded methods | 1490 // search downwards through overloaded methods |
1481 int i; | 1491 int i; |
1482 for (i = hit - 1; i >= 0; --i) { | 1492 for (i = hit - 1; i >= 0; --i) { |
1483 Method* m = methods->at(i); | 1493 Method* m = methods->at(i); |
1484 assert(m->is_method(), "must be method"); | 1494 assert(m->is_method(), "must be method"); |
1485 if (m->name() != name) break; | 1495 if (m->name() != name) break; |
1486 if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return i; | 1496 if (method_matches(m, signature, skipping_overpass, skipping_static)) return i; |
1487 } | 1497 } |
1488 // search upwards | 1498 // search upwards |
1489 for (i = hit + 1; i < methods->length(); ++i) { | 1499 for (i = hit + 1; i < methods->length(); ++i) { |
1490 Method* m = methods->at(i); | 1500 Method* m = methods->at(i); |
1491 assert(m->is_method(), "must be method"); | 1501 assert(m->is_method(), "must be method"); |
1492 if (m->name() != name) break; | 1502 if (m->name() != name) break; |
1493 if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return i; | 1503 if (method_matches(m, signature, skipping_overpass, skipping_static)) return i; |
1494 } | 1504 } |
1495 // not found | 1505 // not found |
1496 #ifdef ASSERT | 1506 #ifdef ASSERT |
1497 int index = skipping_overpass ? -1 : linear_search(methods, name, signature); | 1507 int index = skipping_overpass || skipping_static ? -1 : linear_search(methods, name, signature); |
1498 assert(index == -1, err_msg("binary search should have found entry %d", index)); | 1508 assert(index == -1, err_msg("binary search should have found entry %d", index)); |
1499 #endif | 1509 #endif |
1500 } | 1510 } |
1501 return -1; | 1511 return -1; |
1502 } | 1512 } |