Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/methodData.cpp @ 14704:b51e29501f30
Merged with jdk9/dev/hotspot changeset 9486a41de3b7
author | twisti |
---|---|
date | Tue, 18 Mar 2014 20:19:10 -0700 |
parents | 12eaf1a47a90 53ed0f89f44e |
children | 92aa6797d639 |
comparison
equal
deleted
inserted
replaced
14647:8f483e200405 | 14704:b51e29501f30 |
---|---|
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") { | |
1129 // Set the method back-pointer. | 1130 // Set the method back-pointer. |
1130 _method = method(); | 1131 _method = method(); |
1131 initialize(); | 1132 initialize(); |
1132 } | 1133 } |
1133 | 1134 |
1301 fatal(err_msg("unexpected tag %d", dp->tag())); | 1302 fatal(err_msg("unexpected tag %d", dp->tag())); |
1302 } | 1303 } |
1303 return (DataLayout*)((address)dp + DataLayout::compute_size_in_bytes(nb_cells)); | 1304 return (DataLayout*)((address)dp + DataLayout::compute_size_in_bytes(nb_cells)); |
1304 } | 1305 } |
1305 | 1306 |
1306 ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp) { | 1307 ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp, bool concurrent) { |
1307 DataLayout* end = extra_data_limit(); | 1308 DataLayout* end = extra_data_limit(); |
1308 | 1309 |
1309 for (;; dp = next_extra(dp)) { | 1310 for (;; dp = next_extra(dp)) { |
1310 assert(dp < end, "moved past end of extra data"); | 1311 assert(dp < end, "moved past end of extra data"); |
1311 // No need for "OrderAccess::load_acquire" ops, | 1312 // No need for "OrderAccess::load_acquire" ops, |
1323 break; | 1324 break; |
1324 case DataLayout::speculative_trap_data_tag: | 1325 case DataLayout::speculative_trap_data_tag: |
1325 if (m != NULL) { | 1326 if (m != NULL) { |
1326 SpeculativeTrapData* data = new SpeculativeTrapData(dp); | 1327 SpeculativeTrapData* data = new SpeculativeTrapData(dp); |
1327 // data->method() may be null in case of a concurrent | 1328 // data->method() may be null in case of a concurrent |
1328 // allocation. Assume it's for the same method and use that | 1329 // allocation. Maybe it's for the same method. Try to use that |
1329 // entry in that case. | 1330 // entry in that case. |
1330 if (dp->bci() == bci) { | 1331 if (dp->bci() == bci) { |
1331 if (data->method() == NULL) { | 1332 if (data->method() == NULL) { |
1333 assert(concurrent, "impossible because no concurrent allocation"); | |
1332 return NULL; | 1334 return NULL; |
1333 } else if (data->method() == m) { | 1335 } else if (data->method() == m) { |
1334 return data; | 1336 return data; |
1335 } | 1337 } |
1336 } | 1338 } |
1355 DataLayout* end = extra_data_limit(); | 1357 DataLayout* end = extra_data_limit(); |
1356 | 1358 |
1357 // Allocation in the extra data space has to be atomic because not | 1359 // Allocation in the extra data space has to be atomic because not |
1358 // all entries have the same size and non atomic concurrent | 1360 // all entries have the same size and non atomic concurrent |
1359 // allocation would result in a corrupted extra data space. | 1361 // allocation would result in a corrupted extra data space. |
1360 while (true) { | 1362 ProfileData* result = bci_to_extra_data_helper(bci, m, dp, true); |
1361 ProfileData* result = bci_to_extra_data_helper(bci, m, dp); | 1363 if (result != NULL) { |
1362 if (result != NULL) { | 1364 return result; |
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) { | |
1363 return result; | 1373 return result; |
1364 } | 1374 } |
1365 | 1375 |
1366 if (create_if_missing && dp < end) { | 1376 assert(dp->tag() == DataLayout::no_tag || (dp->tag() == DataLayout::speculative_trap_data_tag && m != NULL), "should be free"); |
1367 assert(dp->tag() == DataLayout::no_tag || (dp->tag() == DataLayout::speculative_trap_data_tag && m != NULL), "should be free"); | 1377 assert(next_extra(dp)->tag() == DataLayout::no_tag || next_extra(dp)->tag() == DataLayout::arg_info_data_tag, "should be free or arg info"); |
1368 assert(next_extra(dp)->tag() == DataLayout::no_tag || next_extra(dp)->tag() == DataLayout::arg_info_data_tag, "should be free or arg info"); | 1378 u1 tag = m == NULL ? DataLayout::bit_data_tag : DataLayout::speculative_trap_data_tag; |
1369 u1 tag = m == NULL ? DataLayout::bit_data_tag : DataLayout::speculative_trap_data_tag; | 1379 // SpeculativeTrapData is 2 slots. Make sure we have room. |
1370 // SpeculativeTrapData is 2 slots. Make sure we have room. | 1380 if (m != NULL && next_extra(dp)->tag() != DataLayout::no_tag) { |
1371 if (m != NULL && next_extra(dp)->tag() != DataLayout::no_tag) { | 1381 return NULL; |
1372 return NULL; | 1382 } |
1373 } | 1383 DataLayout temp; |
1374 DataLayout temp; | 1384 temp.initialize(tag, bci, 0); |
1375 temp.initialize(tag, bci, 0); | 1385 |
1376 // May have been set concurrently | 1386 dp->set_header(temp.header()); |
1377 if (dp->header() != temp.header() && !dp->atomic_set_header(temp.header())) { | 1387 assert(dp->tag() == tag, "sane"); |
1378 // Allocation failure because of concurrent allocation. Try | 1388 assert(dp->bci() == bci, "no concurrent allocation"); |
1379 // again. | 1389 if (tag == DataLayout::bit_data_tag) { |
1380 continue; | 1390 return new BitData(dp); |
1381 } | 1391 } else { |
1382 assert(dp->tag() == tag, "sane"); | 1392 SpeculativeTrapData* data = new SpeculativeTrapData(dp); |
1383 assert(dp->bci() == bci, "no concurrent allocation"); | 1393 data->set_method(m); |
1384 if (tag == DataLayout::bit_data_tag) { | 1394 return data; |
1385 return new BitData(dp); | 1395 } |
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; | |
1394 } | 1396 } |
1395 return NULL; | 1397 return NULL; |
1396 } | 1398 } |
1397 | 1399 |
1398 ArgInfoData *MethodData::arg_info() { | 1400 ArgInfoData *MethodData::arg_info() { |