comparison src/share/vm/oops/methodData.cpp @ 14726:92aa6797d639

Backed out merge changeset: b51e29501f30 Backed out merge revision to its first parent (8f483e200405)
author Doug Simon <doug.simon@oracle.com>
date Mon, 24 Mar 2014 21:30:43 +0100
parents b51e29501f30
children
comparison
equal deleted inserted replaced
14719:0bdd0d157040 14726:92aa6797d639
1123 parameters_type_data()->post_initialize(NULL, this); 1123 parameters_type_data()->post_initialize(NULL, this);
1124 } 1124 }
1125 } 1125 }
1126 1126
1127 // Initialize the MethodData* corresponding to a given method. 1127 // Initialize the MethodData* corresponding to a given method.
1128 MethodData::MethodData(methodHandle method, int size, TRAPS) 1128 MethodData::MethodData(methodHandle method, int size, TRAPS) {
1129 : _extra_data_lock(Monitor::leaf, "MDO extra data lock") {
1130 // Set the method back-pointer. 1129 // Set the method back-pointer.
1131 _method = method(); 1130 _method = method();
1132 initialize(); 1131 initialize();
1133 } 1132 }
1134 1133
1302 fatal(err_msg("unexpected tag %d", dp->tag())); 1301 fatal(err_msg("unexpected tag %d", dp->tag()));
1303 } 1302 }
1304 return (DataLayout*)((address)dp + DataLayout::compute_size_in_bytes(nb_cells)); 1303 return (DataLayout*)((address)dp + DataLayout::compute_size_in_bytes(nb_cells));
1305 } 1304 }
1306 1305
1307 ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp, bool concurrent) { 1306 ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp) {
1308 DataLayout* end = extra_data_limit(); 1307 DataLayout* end = extra_data_limit();
1309 1308
1310 for (;; dp = next_extra(dp)) { 1309 for (;; dp = next_extra(dp)) {
1311 assert(dp < end, "moved past end of extra data"); 1310 assert(dp < end, "moved past end of extra data");
1312 // No need for "OrderAccess::load_acquire" ops, 1311 // No need for "OrderAccess::load_acquire" ops,
1324 break; 1323 break;
1325 case DataLayout::speculative_trap_data_tag: 1324 case DataLayout::speculative_trap_data_tag:
1326 if (m != NULL) { 1325 if (m != NULL) {
1327 SpeculativeTrapData* data = new SpeculativeTrapData(dp); 1326 SpeculativeTrapData* data = new SpeculativeTrapData(dp);
1328 // data->method() may be null in case of a concurrent 1327 // data->method() may be null in case of a concurrent
1329 // allocation. Maybe it's for the same method. Try to use that 1328 // allocation. Assume it's for the same method and use that
1330 // entry in that case. 1329 // entry in that case.
1331 if (dp->bci() == bci) { 1330 if (dp->bci() == bci) {
1332 if (data->method() == NULL) { 1331 if (data->method() == NULL) {
1333 assert(concurrent, "impossible because no concurrent allocation");
1334 return NULL; 1332 return NULL;
1335 } else if (data->method() == m) { 1333 } else if (data->method() == m) {
1336 return data; 1334 return data;
1337 } 1335 }
1338 } 1336 }
1357 DataLayout* end = extra_data_limit(); 1355 DataLayout* end = extra_data_limit();
1358 1356
1359 // Allocation in the extra data space has to be atomic because not 1357 // Allocation in the extra data space has to be atomic because not
1360 // all entries have the same size and non atomic concurrent 1358 // all entries have the same size and non atomic concurrent
1361 // allocation would result in a corrupted extra data space. 1359 // allocation would result in a corrupted extra data space.
1362 ProfileData* result = bci_to_extra_data_helper(bci, m, dp, true); 1360 while (true) {
1363 if (result != NULL) { 1361 ProfileData* result = bci_to_extra_data_helper(bci, m, dp);
1364 return result; 1362 if (result != NULL) {
1365 }
1366
1367 if (create_if_missing && dp < end) {
1368 MutexLocker ml(&_extra_data_lock);
1369 // Check again now that we have the lock. Another thread may
1370 // have added extra data entries.
1371 ProfileData* result = bci_to_extra_data_helper(bci, m, dp, false);
1372 if (result != NULL || dp >= end) {
1373 return result; 1363 return result;
1374 } 1364 }
1375 1365
1376 assert(dp->tag() == DataLayout::no_tag || (dp->tag() == DataLayout::speculative_trap_data_tag && m != NULL), "should be free"); 1366 if (create_if_missing && dp < end) {
1377 assert(next_extra(dp)->tag() == DataLayout::no_tag || next_extra(dp)->tag() == DataLayout::arg_info_data_tag, "should be free or arg info"); 1367 assert(dp->tag() == DataLayout::no_tag || (dp->tag() == DataLayout::speculative_trap_data_tag && m != NULL), "should be free");
1378 u1 tag = m == NULL ? DataLayout::bit_data_tag : DataLayout::speculative_trap_data_tag; 1368 assert(next_extra(dp)->tag() == DataLayout::no_tag || next_extra(dp)->tag() == DataLayout::arg_info_data_tag, "should be free or arg info");
1379 // SpeculativeTrapData is 2 slots. Make sure we have room. 1369 u1 tag = m == NULL ? DataLayout::bit_data_tag : DataLayout::speculative_trap_data_tag;
1380 if (m != NULL && next_extra(dp)->tag() != DataLayout::no_tag) { 1370 // SpeculativeTrapData is 2 slots. Make sure we have room.
1381 return NULL; 1371 if (m != NULL && next_extra(dp)->tag() != DataLayout::no_tag) {
1382 } 1372 return NULL;
1383 DataLayout temp; 1373 }
1384 temp.initialize(tag, bci, 0); 1374 DataLayout temp;
1385 1375 temp.initialize(tag, bci, 0);
1386 dp->set_header(temp.header()); 1376 // May have been set concurrently
1387 assert(dp->tag() == tag, "sane"); 1377 if (dp->header() != temp.header() && !dp->atomic_set_header(temp.header())) {
1388 assert(dp->bci() == bci, "no concurrent allocation"); 1378 // Allocation failure because of concurrent allocation. Try
1389 if (tag == DataLayout::bit_data_tag) { 1379 // again.
1390 return new BitData(dp); 1380 continue;
1391 } else { 1381 }
1392 SpeculativeTrapData* data = new SpeculativeTrapData(dp); 1382 assert(dp->tag() == tag, "sane");
1393 data->set_method(m); 1383 assert(dp->bci() == bci, "no concurrent allocation");
1394 return data; 1384 if (tag == DataLayout::bit_data_tag) {
1395 } 1385 return new BitData(dp);
1386 } else {
1387 // If being allocated concurrently, one trap may be lost
1388 SpeculativeTrapData* data = new SpeculativeTrapData(dp);
1389 data->set_method(m);
1390 return data;
1391 }
1392 }
1393 return NULL;
1396 } 1394 }
1397 return NULL; 1395 return NULL;
1398 } 1396 }
1399 1397
1400 ArgInfoData *MethodData::arg_info() { 1398 ArgInfoData *MethodData::arg_info() {