< prev index next >

src/hotspot/share/opto/parseHelper.cpp

Print this page
rev 48535 : [mq]: 8194984
   1 /*
   2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 442   store_to_memory(NULL, adr_node, incr, T_BYTE, adr_type, MemNode::unordered);
 443 }
 444 
 445 //----------------------------profile_taken_branch-----------------------------
 446 void Parse::profile_taken_branch(int target_bci, bool force_update) {
 447   // This is a potential osr_site if we have a backedge.
 448   int cur_bci = bci();
 449   bool osr_site =
 450     (target_bci <= cur_bci) && count_invocations() && UseOnStackReplacement;
 451 
 452   // If we are going to OSR, restart at the target bytecode.
 453   set_bci(target_bci);
 454 
 455   // To do: factor out the the limit calculations below. These duplicate
 456   // the similar limit calculations in the interpreter.
 457 
 458   if (method_data_update() || force_update) {
 459     ciMethodData* md = method()->method_data();
 460     assert(md != NULL, "expected valid ciMethodData");
 461     ciProfileData* data = md->bci_to_data(cur_bci);
 462     assert(data->is_JumpData(), "need JumpData for taken branch");
 463     increment_md_counter_at(md, data, JumpData::taken_offset());
 464   }
 465 
 466   // In the new tiered system this is all we need to do. In the old
 467   // (c2 based) tiered sytem we must do the code below.
 468 #ifndef TIERED
 469   if (method_data_update()) {
 470     ciMethodData* md = method()->method_data();
 471     if (osr_site) {
 472       ciProfileData* data = md->bci_to_data(cur_bci);

 473       int limit = (CompileThreshold
 474                    * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
 475       test_for_osr_md_counter_at(md, data, JumpData::taken_offset(), limit);
 476     }
 477   } else {
 478     // With method data update off, use the invocation counter to trigger an
 479     // OSR compilation, as done in the interpreter.
 480     if (osr_site) {
 481       int limit = (CompileThreshold * OnStackReplacePercentage) / 100;
 482       increment_and_test_invocation_counter(limit);
 483     }
 484   }
 485 #endif // TIERED
 486 
 487   // Restore the original bytecode.
 488   set_bci(cur_bci);
 489 }
 490 
 491 //--------------------------profile_not_taken_branch---------------------------
 492 void Parse::profile_not_taken_branch(bool force_update) {
 493 
 494   if (method_data_update() || force_update) {
 495     ciMethodData* md = method()->method_data();
 496     assert(md != NULL, "expected valid ciMethodData");
 497     ciProfileData* data = md->bci_to_data(bci());
 498     assert(data->is_BranchData(), "need BranchData for not taken branch");
 499     increment_md_counter_at(md, data, BranchData::not_taken_offset());
 500   }
 501 
 502 }
 503 
 504 //---------------------------------profile_call--------------------------------
 505 void Parse::profile_call(Node* receiver) {
 506   if (!method_data_update()) return;
 507 
 508   switch (bc()) {
 509   case Bytecodes::_invokevirtual:
 510   case Bytecodes::_invokeinterface:
 511     profile_receiver_type(receiver);
 512     break;
 513   case Bytecodes::_invokestatic:
 514   case Bytecodes::_invokedynamic:
 515   case Bytecodes::_invokespecial:
 516     profile_generic_call();
 517     break;
 518   default: fatal("unexpected call bytecode");
 519   }
 520 }
 521 
 522 //------------------------------profile_generic_call---------------------------
 523 void Parse::profile_generic_call() {
 524   assert(method_data_update(), "must be generating profile code");
 525 
 526   ciMethodData* md = method()->method_data();
 527   assert(md != NULL, "expected valid ciMethodData");
 528   ciProfileData* data = md->bci_to_data(bci());
 529   assert(data->is_CounterData(), "need CounterData for not taken branch");
 530   increment_md_counter_at(md, data, CounterData::count_offset());
 531 }
 532 
 533 //-----------------------------profile_receiver_type---------------------------
 534 void Parse::profile_receiver_type(Node* receiver) {
 535   assert(method_data_update(), "must be generating profile code");
 536 
 537   ciMethodData* md = method()->method_data();
 538   assert(md != NULL, "expected valid ciMethodData");
 539   ciProfileData* data = md->bci_to_data(bci());
 540   assert(data->is_ReceiverTypeData(), "need ReceiverTypeData here");
 541 
 542   // Skip if we aren't tracking receivers
 543   if (TypeProfileWidth < 1) {
 544     increment_md_counter_at(md, data, CounterData::count_offset());
 545     return;
 546   }
 547   ciReceiverTypeData* rdata = (ciReceiverTypeData*)data->as_ReceiverTypeData();
 548 
 549   Node* method_data = method_data_addressing(md, rdata, in_ByteSize(0));
 550 
 551   // Using an adr_type of TypePtr::BOTTOM to work around anti-dep problems.
 552   // A better solution might be to use TypeRawPtr::BOTTOM with RC_NARROW_MEM.
 553   make_runtime_call(RC_LEAF, OptoRuntime::profile_receiver_type_Type(),
 554                     CAST_FROM_FN_PTR(address,
 555                                      OptoRuntime::profile_receiver_type_C),
 556                     "profile_receiver_type_C",
 557                     TypePtr::BOTTOM,
 558                     method_data, receiver);
 559 }
 560 
 561 //---------------------------------profile_ret---------------------------------
 562 void Parse::profile_ret(int target_bci) {
 563   if (!method_data_update()) return;
 564 
 565   // Skip if we aren't tracking ret targets
 566   if (TypeProfileWidth < 1) return;
 567 
 568   ciMethodData* md = method()->method_data();
 569   assert(md != NULL, "expected valid ciMethodData");
 570   ciProfileData* data = md->bci_to_data(bci());
 571   assert(data->is_RetData(), "need RetData for ret");
 572   ciRetData* ret_data = (ciRetData*)data->as_RetData();
 573 
 574   // Look for the target_bci is already in the table
 575   uint row;
 576   bool table_full = true;
 577   for (row = 0; row < ret_data->row_limit(); row++) {
 578     int key = ret_data->bci(row);
 579     table_full &= (key != RetData::no_bci);
 580     if (key == target_bci) break;
 581   }
 582 
 583   if (row >= ret_data->row_limit()) {
 584     // The target_bci was not found in the table.
 585     if (!table_full) {
 586       // XXX: Make slow call to update RetData
 587     }
 588     return;
 589   }
 590 
 591   // the target_bci is already in the table
 592   increment_md_counter_at(md, data, RetData::bci_count_offset(row));
 593 }
 594 
 595 //--------------------------profile_null_checkcast----------------------------
 596 void Parse::profile_null_checkcast() {
 597   // Set the null-seen flag, done in conjunction with the usual null check. We
 598   // never unset the flag, so this is a one-way switch.
 599   if (!method_data_update()) return;
 600 
 601   ciMethodData* md = method()->method_data();
 602   assert(md != NULL, "expected valid ciMethodData");
 603   ciProfileData* data = md->bci_to_data(bci());
 604   assert(data->is_BitData(), "need BitData for checkcast");
 605   set_md_flag_at(md, data, BitData::null_seen_byte_constant());
 606 }
 607 
 608 //-----------------------------profile_switch_case-----------------------------
 609 void Parse::profile_switch_case(int table_index) {
 610   if (!method_data_update()) return;
 611 
 612   ciMethodData* md = method()->method_data();
 613   assert(md != NULL, "expected valid ciMethodData");
 614 
 615   ciProfileData* data = md->bci_to_data(bci());
 616   assert(data->is_MultiBranchData(), "need MultiBranchData for switch case");
 617   if (table_index >= 0) {
 618     increment_md_counter_at(md, data, MultiBranchData::case_count_offset(table_index));
 619   } else {
 620     increment_md_counter_at(md, data, MultiBranchData::default_count_offset());
 621   }
 622 }
   1 /*
   2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 442   store_to_memory(NULL, adr_node, incr, T_BYTE, adr_type, MemNode::unordered);
 443 }
 444 
 445 //----------------------------profile_taken_branch-----------------------------
 446 void Parse::profile_taken_branch(int target_bci, bool force_update) {
 447   // This is a potential osr_site if we have a backedge.
 448   int cur_bci = bci();
 449   bool osr_site =
 450     (target_bci <= cur_bci) && count_invocations() && UseOnStackReplacement;
 451 
 452   // If we are going to OSR, restart at the target bytecode.
 453   set_bci(target_bci);
 454 
 455   // To do: factor out the the limit calculations below. These duplicate
 456   // the similar limit calculations in the interpreter.
 457 
 458   if (method_data_update() || force_update) {
 459     ciMethodData* md = method()->method_data();
 460     assert(md != NULL, "expected valid ciMethodData");
 461     ciProfileData* data = md->bci_to_data(cur_bci);
 462     assert(data != NULL && data->is_JumpData(), "need JumpData for taken branch");
 463     increment_md_counter_at(md, data, JumpData::taken_offset());
 464   }
 465 
 466   // In the new tiered system this is all we need to do. In the old
 467   // (c2 based) tiered sytem we must do the code below.
 468 #ifndef TIERED
 469   if (method_data_update()) {
 470     ciMethodData* md = method()->method_data();
 471     if (osr_site) {
 472       ciProfileData* data = md->bci_to_data(cur_bci);
 473       assert(data != NULL && data->is_JumpData(), "need JumpData for taken branch");
 474       int limit = (CompileThreshold
 475                    * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
 476       test_for_osr_md_counter_at(md, data, JumpData::taken_offset(), limit);
 477     }
 478   } else {
 479     // With method data update off, use the invocation counter to trigger an
 480     // OSR compilation, as done in the interpreter.
 481     if (osr_site) {
 482       int limit = (CompileThreshold * OnStackReplacePercentage) / 100;
 483       increment_and_test_invocation_counter(limit);
 484     }
 485   }
 486 #endif // TIERED
 487 
 488   // Restore the original bytecode.
 489   set_bci(cur_bci);
 490 }
 491 
 492 //--------------------------profile_not_taken_branch---------------------------
 493 void Parse::profile_not_taken_branch(bool force_update) {
 494 
 495   if (method_data_update() || force_update) {
 496     ciMethodData* md = method()->method_data();
 497     assert(md != NULL, "expected valid ciMethodData");
 498     ciProfileData* data = md->bci_to_data(bci());
 499     assert(data != NULL && data->is_BranchData(), "need BranchData for not taken branch");
 500     increment_md_counter_at(md, data, BranchData::not_taken_offset());
 501   }
 502 
 503 }
 504 
 505 //---------------------------------profile_call--------------------------------
 506 void Parse::profile_call(Node* receiver) {
 507   if (!method_data_update()) return;
 508 
 509   switch (bc()) {
 510   case Bytecodes::_invokevirtual:
 511   case Bytecodes::_invokeinterface:
 512     profile_receiver_type(receiver);
 513     break;
 514   case Bytecodes::_invokestatic:
 515   case Bytecodes::_invokedynamic:
 516   case Bytecodes::_invokespecial:
 517     profile_generic_call();
 518     break;
 519   default: fatal("unexpected call bytecode");
 520   }
 521 }
 522 
 523 //------------------------------profile_generic_call---------------------------
 524 void Parse::profile_generic_call() {
 525   assert(method_data_update(), "must be generating profile code");
 526 
 527   ciMethodData* md = method()->method_data();
 528   assert(md != NULL, "expected valid ciMethodData");
 529   ciProfileData* data = md->bci_to_data(bci());
 530   assert(data != NULL && data->is_CounterData(), "need CounterData for not taken branch");
 531   increment_md_counter_at(md, data, CounterData::count_offset());
 532 }
 533 
 534 //-----------------------------profile_receiver_type---------------------------
 535 void Parse::profile_receiver_type(Node* receiver) {
 536   assert(method_data_update(), "must be generating profile code");
 537 
 538   ciMethodData* md = method()->method_data();
 539   assert(md != NULL, "expected valid ciMethodData");
 540   ciProfileData* data = md->bci_to_data(bci());
 541   assert(data != NULL && data->is_ReceiverTypeData(), "need ReceiverTypeData here");
 542 
 543   // Skip if we aren't tracking receivers
 544   if (TypeProfileWidth < 1) {
 545     increment_md_counter_at(md, data, CounterData::count_offset());
 546     return;
 547   }
 548   ciReceiverTypeData* rdata = (ciReceiverTypeData*)data->as_ReceiverTypeData();
 549 
 550   Node* method_data = method_data_addressing(md, rdata, in_ByteSize(0));
 551 
 552   // Using an adr_type of TypePtr::BOTTOM to work around anti-dep problems.
 553   // A better solution might be to use TypeRawPtr::BOTTOM with RC_NARROW_MEM.
 554   make_runtime_call(RC_LEAF, OptoRuntime::profile_receiver_type_Type(),
 555                     CAST_FROM_FN_PTR(address,
 556                                      OptoRuntime::profile_receiver_type_C),
 557                     "profile_receiver_type_C",
 558                     TypePtr::BOTTOM,
 559                     method_data, receiver);
 560 }
 561 
 562 //---------------------------------profile_ret---------------------------------
 563 void Parse::profile_ret(int target_bci) {
 564   if (!method_data_update()) return;
 565 
 566   // Skip if we aren't tracking ret targets
 567   if (TypeProfileWidth < 1) return;
 568 
 569   ciMethodData* md = method()->method_data();
 570   assert(md != NULL, "expected valid ciMethodData");
 571   ciProfileData* data = md->bci_to_data(bci());
 572   assert(data != NULL && data->is_RetData(), "need RetData for ret");
 573   ciRetData* ret_data = (ciRetData*)data->as_RetData();
 574 
 575   // Look for the target_bci is already in the table
 576   uint row;
 577   bool table_full = true;
 578   for (row = 0; row < ret_data->row_limit(); row++) {
 579     int key = ret_data->bci(row);
 580     table_full &= (key != RetData::no_bci);
 581     if (key == target_bci) break;
 582   }
 583 
 584   if (row >= ret_data->row_limit()) {
 585     // The target_bci was not found in the table.
 586     if (!table_full) {
 587       // XXX: Make slow call to update RetData
 588     }
 589     return;
 590   }
 591 
 592   // the target_bci is already in the table
 593   increment_md_counter_at(md, data, RetData::bci_count_offset(row));
 594 }
 595 
 596 //--------------------------profile_null_checkcast----------------------------
 597 void Parse::profile_null_checkcast() {
 598   // Set the null-seen flag, done in conjunction with the usual null check. We
 599   // never unset the flag, so this is a one-way switch.
 600   if (!method_data_update()) return;
 601 
 602   ciMethodData* md = method()->method_data();
 603   assert(md != NULL, "expected valid ciMethodData");
 604   ciProfileData* data = md->bci_to_data(bci());
 605   assert(data != NULL && data->is_BitData(), "need BitData for checkcast");
 606   set_md_flag_at(md, data, BitData::null_seen_byte_constant());
 607 }
 608 
 609 //-----------------------------profile_switch_case-----------------------------
 610 void Parse::profile_switch_case(int table_index) {
 611   if (!method_data_update()) return;
 612 
 613   ciMethodData* md = method()->method_data();
 614   assert(md != NULL, "expected valid ciMethodData");
 615 
 616   ciProfileData* data = md->bci_to_data(bci());
 617   assert(data != NULL && data->is_MultiBranchData(), "need MultiBranchData for switch case");
 618   if (table_index >= 0) {
 619     increment_md_counter_at(md, data, MultiBranchData::case_count_offset(table_index));
 620   } else {
 621     increment_md_counter_at(md, data, MultiBranchData::default_count_offset());
 622   }
 623 }
< prev index next >