Mercurial > hg > truffle
comparison src/share/vm/oops/instanceKlass.cpp @ 17891:b6a2ba7d3ea7 hs25.20-b11
Merge
author | amurillo |
---|---|
date | Thu, 17 Apr 2014 16:09:07 -0700 |
parents | 386dd1c71858 |
children | 78bbf4d43a14 |
comparison
equal
deleted
inserted
replaced
17862:70dc2c030c69 | 17891:b6a2ba7d3ea7 |
---|---|
1327 } | 1327 } |
1328 } | 1328 } |
1329 } | 1329 } |
1330 | 1330 |
1331 | 1331 |
1332 void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, TRAPS), TRAPS) { | 1332 void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle mirror, TRAPS) { |
1333 instanceKlassHandle h_this(THREAD, this); | 1333 instanceKlassHandle h_this(THREAD, this); |
1334 do_local_static_fields_impl(h_this, f, CHECK); | 1334 do_local_static_fields_impl(h_this, f, mirror, CHECK); |
1335 } | 1335 } |
1336 | 1336 |
1337 | 1337 |
1338 void InstanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) { | 1338 void InstanceKlass::do_local_static_fields_impl(instanceKlassHandle this_k, |
1339 for (JavaFieldStream fs(this_oop()); !fs.done(); fs.next()) { | 1339 void f(fieldDescriptor* fd, Handle mirror, TRAPS), Handle mirror, TRAPS) { |
1340 for (JavaFieldStream fs(this_k()); !fs.done(); fs.next()) { | |
1340 if (fs.access_flags().is_static()) { | 1341 if (fs.access_flags().is_static()) { |
1341 fieldDescriptor& fd = fs.field_descriptor(); | 1342 fieldDescriptor& fd = fs.field_descriptor(); |
1342 f(&fd, CHECK); | 1343 f(&fd, mirror, CHECK); |
1343 } | 1344 } |
1344 } | 1345 } |
1345 } | 1346 } |
1346 | 1347 |
1347 | 1348 |
1426 return -1; | 1427 return -1; |
1427 } | 1428 } |
1428 | 1429 |
1429 // find_method looks up the name/signature in the local methods array | 1430 // find_method looks up the name/signature in the local methods array |
1430 Method* InstanceKlass::find_method(Symbol* name, Symbol* signature) const { | 1431 Method* InstanceKlass::find_method(Symbol* name, Symbol* signature) const { |
1431 return InstanceKlass::find_method(methods(), name, signature); | 1432 return find_method_impl(name, signature, false); |
1433 } | |
1434 | |
1435 Method* InstanceKlass::find_method_impl(Symbol* name, Symbol* signature, bool skipping_overpass) const { | |
1436 return InstanceKlass::find_method_impl(methods(), name, signature, skipping_overpass); | |
1432 } | 1437 } |
1433 | 1438 |
1434 // find_instance_method looks up the name/signature in the local methods array | 1439 // find_instance_method looks up the name/signature in the local methods array |
1435 // and skips over static methods | 1440 // and skips over static methods |
1436 Method* InstanceKlass::find_instance_method( | 1441 Method* InstanceKlass::find_instance_method( |
1443 } | 1448 } |
1444 | 1449 |
1445 // find_method looks up the name/signature in the local methods array | 1450 // find_method looks up the name/signature in the local methods array |
1446 Method* InstanceKlass::find_method( | 1451 Method* InstanceKlass::find_method( |
1447 Array<Method*>* methods, Symbol* name, Symbol* signature) { | 1452 Array<Method*>* methods, Symbol* name, Symbol* signature) { |
1448 int hit = find_method_index(methods, name, signature); | 1453 return InstanceKlass::find_method_impl(methods, name, signature, false); |
1454 } | |
1455 | |
1456 Method* InstanceKlass::find_method_impl( | |
1457 Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass) { | |
1458 int hit = find_method_index(methods, name, signature, skipping_overpass); | |
1449 return hit >= 0 ? methods->at(hit): NULL; | 1459 return hit >= 0 ? methods->at(hit): NULL; |
1450 } | 1460 } |
1451 | 1461 |
1452 // Used directly for default_methods to find the index into the | 1462 // Used directly for default_methods to find the index into the |
1453 // default_vtable_indices, and indirectly by find_method | 1463 // default_vtable_indices, and indirectly by find_method |
1454 // find_method_index looks in the local methods array to return the index | 1464 // find_method_index looks in the local methods array to return the index |
1455 // of the matching name/signature | 1465 // of the matching name/signature. If, overpass methods are being ignored, |
1466 // the search continues to find a potential non-overpass match. This capability | |
1467 // is important during method resolution to prefer a static method, for example, | |
1468 // over an overpass method. | |
1456 int InstanceKlass::find_method_index( | 1469 int InstanceKlass::find_method_index( |
1457 Array<Method*>* methods, Symbol* name, Symbol* signature) { | 1470 Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass) { |
1458 int hit = binary_search(methods, name); | 1471 int hit = binary_search(methods, name); |
1459 if (hit != -1) { | 1472 if (hit != -1) { |
1460 Method* m = methods->at(hit); | 1473 Method* m = methods->at(hit); |
1461 // Do linear search to find matching signature. First, quick check | 1474 // Do linear search to find matching signature. First, quick check |
1462 // for common case | 1475 // for common case, ignoring overpasses if requested. |
1463 if (m->signature() == signature) return hit; | 1476 if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return hit; |
1477 | |
1464 // search downwards through overloaded methods | 1478 // search downwards through overloaded methods |
1465 int i; | 1479 int i; |
1466 for (i = hit - 1; i >= 0; --i) { | 1480 for (i = hit - 1; i >= 0; --i) { |
1467 Method* m = methods->at(i); | 1481 Method* m = methods->at(i); |
1468 assert(m->is_method(), "must be method"); | 1482 assert(m->is_method(), "must be method"); |
1469 if (m->name() != name) break; | 1483 if (m->name() != name) break; |
1470 if (m->signature() == signature) return i; | 1484 if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return i; |
1471 } | 1485 } |
1472 // search upwards | 1486 // search upwards |
1473 for (i = hit + 1; i < methods->length(); ++i) { | 1487 for (i = hit + 1; i < methods->length(); ++i) { |
1474 Method* m = methods->at(i); | 1488 Method* m = methods->at(i); |
1475 assert(m->is_method(), "must be method"); | 1489 assert(m->is_method(), "must be method"); |
1476 if (m->name() != name) break; | 1490 if (m->name() != name) break; |
1477 if (m->signature() == signature) return i; | 1491 if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return i; |
1478 } | 1492 } |
1479 // not found | 1493 // not found |
1480 #ifdef ASSERT | 1494 #ifdef ASSERT |
1481 int index = linear_search(methods, name, signature); | 1495 int index = skipping_overpass ? -1 : linear_search(methods, name, signature); |
1482 assert(index == -1, err_msg("binary search should have found entry %d", index)); | 1496 assert(index == -1, err_msg("binary search should have found entry %d", index)); |
1483 #endif | 1497 #endif |
1484 } | 1498 } |
1485 return -1; | 1499 return -1; |
1486 } | 1500 } |
1502 return -1; | 1516 return -1; |
1503 } | 1517 } |
1504 | 1518 |
1505 // uncached_lookup_method searches both the local class methods array and all | 1519 // uncached_lookup_method searches both the local class methods array and all |
1506 // superclasses methods arrays, skipping any overpass methods in superclasses. | 1520 // superclasses methods arrays, skipping any overpass methods in superclasses. |
1507 Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { | 1521 Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const { |
1522 MethodLookupMode lookup_mode = mode; | |
1508 Klass* klass = const_cast<InstanceKlass*>(this); | 1523 Klass* klass = const_cast<InstanceKlass*>(this); |
1509 bool dont_ignore_overpasses = true; // For the class being searched, find its overpasses. | |
1510 while (klass != NULL) { | 1524 while (klass != NULL) { |
1511 Method* method = InstanceKlass::cast(klass)->find_method(name, signature); | 1525 Method* method = InstanceKlass::cast(klass)->find_method_impl(name, signature, (lookup_mode == skip_overpass)); |
1512 if ((method != NULL) && (dont_ignore_overpasses || !method->is_overpass())) { | 1526 if (method != NULL) { |
1513 return method; | 1527 return method; |
1514 } | 1528 } |
1515 klass = InstanceKlass::cast(klass)->super(); | 1529 klass = InstanceKlass::cast(klass)->super(); |
1516 dont_ignore_overpasses = false; // Ignore overpass methods in all superclasses. | 1530 lookup_mode = skip_overpass; // Always ignore overpass methods in superclasses |
1517 } | 1531 } |
1518 return NULL; | 1532 return NULL; |
1519 } | 1533 } |
1520 | 1534 |
1521 // lookup a method in the default methods list then in all transitive interfaces | 1535 // lookup a method in the default methods list then in all transitive interfaces |
1526 if (default_methods() != NULL) { | 1540 if (default_methods() != NULL) { |
1527 m = find_method(default_methods(), name, signature); | 1541 m = find_method(default_methods(), name, signature); |
1528 } | 1542 } |
1529 // Look up interfaces | 1543 // Look up interfaces |
1530 if (m == NULL) { | 1544 if (m == NULL) { |
1531 m = lookup_method_in_all_interfaces(name, signature, false); | 1545 m = lookup_method_in_all_interfaces(name, signature, normal); |
1532 } | 1546 } |
1533 return m; | 1547 return m; |
1534 } | 1548 } |
1535 | 1549 |
1536 // lookup a method in all the interfaces that this class implements | 1550 // lookup a method in all the interfaces that this class implements |
1537 // Do NOT return private or static methods, new in JDK8 which are not externally visible | 1551 // Do NOT return private or static methods, new in JDK8 which are not externally visible |
1538 // They should only be found in the initial InterfaceMethodRef | 1552 // They should only be found in the initial InterfaceMethodRef |
1539 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, | 1553 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, |
1540 Symbol* signature, | 1554 Symbol* signature, |
1541 bool skip_default_methods) const { | 1555 MethodLookupMode mode) const { |
1542 Array<Klass*>* all_ifs = transitive_interfaces(); | 1556 Array<Klass*>* all_ifs = transitive_interfaces(); |
1543 int num_ifs = all_ifs->length(); | 1557 int num_ifs = all_ifs->length(); |
1544 InstanceKlass *ik = NULL; | 1558 InstanceKlass *ik = NULL; |
1545 for (int i = 0; i < num_ifs; i++) { | 1559 for (int i = 0; i < num_ifs; i++) { |
1546 ik = InstanceKlass::cast(all_ifs->at(i)); | 1560 ik = InstanceKlass::cast(all_ifs->at(i)); |
1547 Method* m = ik->lookup_method(name, signature); | 1561 Method* m = ik->lookup_method(name, signature); |
1548 if (m != NULL && m->is_public() && !m->is_static() && | 1562 if (m != NULL && m->is_public() && !m->is_static() && |
1549 (!skip_default_methods || !m->is_default_method())) { | 1563 ((mode != skip_defaults) || !m->is_default_method())) { |
1550 return m; | 1564 return m; |
1551 } | 1565 } |
1552 } | 1566 } |
1553 return NULL; | 1567 return NULL; |
1554 } | 1568 } |
2278 | 2292 |
2279 Array<Method*>* methods = ik->methods(); | 2293 Array<Method*>* methods = ik->methods(); |
2280 int num_methods = methods->length(); | 2294 int num_methods = methods->length(); |
2281 for (int index2 = 0; index2 < num_methods; ++index2) { | 2295 for (int index2 = 0; index2 < num_methods; ++index2) { |
2282 methodHandle m(THREAD, methods->at(index2)); | 2296 methodHandle m(THREAD, methods->at(index2)); |
2283 m()->link_method(m, CHECK); | 2297 m->restore_unshareable_info(CHECK); |
2284 // restore method's vtable by calling a virtual function | |
2285 m->restore_vtable(); | |
2286 } | 2298 } |
2287 if (JvmtiExport::has_redefined_a_class()) { | 2299 if (JvmtiExport::has_redefined_a_class()) { |
2288 // Reinitialize vtable because RedefineClasses may have changed some | 2300 // Reinitialize vtable because RedefineClasses may have changed some |
2289 // entries in this vtable for super classes so the CDS vtable might | 2301 // entries in this vtable for super classes so the CDS vtable might |
2290 // point to old or obsolete entries. RedefineClasses doesn't fix up | 2302 // point to old or obsolete entries. RedefineClasses doesn't fix up |