1328 |
1328 |
1329 // Detect implicit-null-check opportunities. Basically, find NULL checks |
1329 // Detect implicit-null-check opportunities. Basically, find NULL checks |
1330 // with suitable memory ops nearby. Use the memory op to do the NULL check. |
1330 // with suitable memory ops nearby. Use the memory op to do the NULL check. |
1331 // I can generate a memory op if there is not one nearby. |
1331 // I can generate a memory op if there is not one nearby. |
1332 if (C->is_method_compilation()) { |
1332 if (C->is_method_compilation()) { |
1333 // Don't do it for natives, adapters, or runtime stubs |
|
1334 int allowed_reasons = 0; |
|
1335 // ...and don't do it when there have been too many traps, globally. |
|
1336 for (int reason = (int)Deoptimization::Reason_none+1; |
|
1337 reason < Compile::trapHistLength; reason++) { |
|
1338 assert(reason < BitsPerInt, "recode bit map"); |
|
1339 if (!C->too_many_traps((Deoptimization::DeoptReason) reason)) |
|
1340 allowed_reasons |= nth_bit(reason); |
|
1341 } |
|
1342 // By reversing the loop direction we get a very minor gain on mpegaudio. |
1333 // By reversing the loop direction we get a very minor gain on mpegaudio. |
1343 // Feel free to revert to a forward loop for clarity. |
1334 // Feel free to revert to a forward loop for clarity. |
1344 // for( int i=0; i < (int)matcher._null_check_tests.size(); i+=2 ) { |
1335 // for( int i=0; i < (int)matcher._null_check_tests.size(); i+=2 ) { |
1345 for (int i = _matcher._null_check_tests.size() - 2; i >= 0; i -= 2) { |
1336 for (int i = _matcher._null_check_tests.size() - 2; i >= 0; i -= 2) { |
1346 Node* proj = _matcher._null_check_tests[i]; |
1337 Node* proj = _matcher._null_check_tests[i]; |
1347 Node* val = _matcher._null_check_tests[i + 1]; |
1338 Node* val = _matcher._null_check_tests[i + 1]; |
1348 Block* block = get_block_for_node(proj); |
1339 Block* block = get_block_for_node(proj); |
1349 implicit_null_check(block, proj, val, allowed_reasons); |
1340 implicit_null_check(block, proj, val, C->allowed_deopt_reasons()); |
1350 // The implicit_null_check will only perform the transformation |
1341 // The implicit_null_check will only perform the transformation |
1351 // if the null branch is truly uncommon, *and* it leads to an |
1342 // if the null branch is truly uncommon, *and* it leads to an |
1352 // uncommon trap. Combined with the too_many_traps guards |
1343 // uncommon trap. Combined with the too_many_traps guards |
1353 // above, this prevents SEGV storms reported in 6366351, |
1344 // above, this prevents SEGV storms reported in 6366351, |
1354 // by recompiling offending methods without this optimization. |
1345 // by recompiling offending methods without this optimization. |