1 /*
2 * Copyright (c) 2001, 2016, 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 *
567 // Fixing this remaining case of 4292742 requires some flavor of
568 // escape analysis. Leave that for the future.
569 ciInstance* ex_obj = NULL;
570 switch (reason) {
571 case Deoptimization::Reason_null_check:
572 ex_obj = env()->NullPointerException_instance();
573 break;
574 case Deoptimization::Reason_div0_check:
575 ex_obj = env()->ArithmeticException_instance();
576 break;
577 case Deoptimization::Reason_range_check:
578 ex_obj = env()->ArrayIndexOutOfBoundsException_instance();
579 break;
580 case Deoptimization::Reason_class_check:
581 if (java_bc() == Bytecodes::_aastore) {
582 ex_obj = env()->ArrayStoreException_instance();
583 } else {
584 ex_obj = env()->ClassCastException_instance();
585 }
586 break;
587 }
588 if (failing()) { stop(); return; } // exception allocation might fail
589 if (ex_obj != NULL) {
590 // Cheat with a preallocated exception object.
591 if (C->log() != NULL)
592 C->log()->elem("hot_throw preallocated='1' reason='%s'",
593 Deoptimization::trap_reason_name(reason));
594 const TypeInstPtr* ex_con = TypeInstPtr::make(ex_obj);
595 Node* ex_node = _gvn.transform(ConNode::make(ex_con));
596
597 // Clear the detail message of the preallocated exception object.
598 // Weblogic sometimes mutates the detail message of exceptions
599 // using reflection.
600 int offset = java_lang_Throwable::get_detailMessage_offset();
601 const TypePtr* adr_typ = ex_con->add_offset(offset);
602
603 Node *adr = basic_plus_adr(ex_node, ex_node, offset);
604 const TypeOopPtr* val_type = TypeOopPtr::make_from_klass(env()->String_klass());
605 // Conservatively release stores of object references.
606 Node *store = store_oop_to_object(control(), ex_node, adr, adr_typ, null(), val_type, T_OBJECT, MemNode::release);
804 tty->print_cr("Zombie local %d: ", local);
805 jvms->dump();
806 }
807 return false;
808 }
809 }
810 }
811 return true;
812 }
813
814 #endif //ASSERT
815
816 // Helper function for enforcing certain bytecodes to reexecute if
817 // deoptimization happens
818 static bool should_reexecute_implied_by_bytecode(JVMState *jvms, bool is_anewarray) {
819 ciMethod* cur_method = jvms->method();
820 int cur_bci = jvms->bci();
821 if (cur_method != NULL && cur_bci != InvocationEntryBci) {
822 Bytecodes::Code code = cur_method->java_code_at_bci(cur_bci);
823 return Interpreter::bytecode_should_reexecute(code) ||
824 is_anewarray && code == Bytecodes::_multianewarray;
825 // Reexecute _multianewarray bytecode which was replaced with
826 // sequence of [a]newarray. See Parse::do_multianewarray().
827 //
828 // Note: interpreter should not have it set since this optimization
829 // is limited by dimensions and guarded by flag so in some cases
830 // multianewarray() runtime calls will be generated and
831 // the bytecode should not be reexecutes (stack will not be reset).
832 } else
833 return false;
834 }
835
836 // Helper function for adding JVMState and debug information to node
837 void GraphKit::add_safepoint_edges(SafePointNode* call, bool must_throw) {
838 // Add the safepoint edges to the call (or other safepoint).
839
840 // Make sure dead locals are set to top. This
841 // should help register allocation time and cut down on the size
842 // of the deoptimization information.
843 assert(dead_locals_are_killed(), "garbage in debug info before safepoint");
844
1483 Node* GraphKit::make_load(Node* ctl, Node* adr, const Type* t, BasicType bt,
1484 int adr_idx,
1485 MemNode::MemOrd mo,
1486 LoadNode::ControlDependency control_dependency,
1487 bool require_atomic_access,
1488 bool unaligned,
1489 bool mismatched) {
1490 assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" );
1491 const TypePtr* adr_type = NULL; // debug-mode-only argument
1492 debug_only(adr_type = C->get_adr_type(adr_idx));
1493 Node* mem = memory(adr_idx);
1494 Node* ld;
1495 if (require_atomic_access && bt == T_LONG) {
1496 ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched);
1497 } else if (require_atomic_access && bt == T_DOUBLE) {
1498 ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched);
1499 } else {
1500 ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo, control_dependency, unaligned, mismatched);
1501 }
1502 ld = _gvn.transform(ld);
1503 if ((bt == T_OBJECT) && C->do_escape_analysis() || C->eliminate_boxing()) {
1504 // Improve graph before escape analysis and boxing elimination.
1505 record_for_igvn(ld);
1506 }
1507 return ld;
1508 }
1509
1510 Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt,
1511 int adr_idx,
1512 MemNode::MemOrd mo,
1513 bool require_atomic_access,
1514 bool unaligned,
1515 bool mismatched) {
1516 assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
1517 const TypePtr* adr_type = NULL;
1518 debug_only(adr_type = C->get_adr_type(adr_idx));
1519 Node *mem = memory(adr_idx);
1520 Node* st;
1521 if (require_atomic_access && bt == T_LONG) {
1522 st = StoreLNode::make_atomic(ctl, mem, adr, adr_type, val, mo);
1523 } else if (require_atomic_access && bt == T_DOUBLE) {
2007 // Temporary fix for 6529811 to allow virtual calls to be sure they
2008 // get the chance to go from mono->bi->mega
2009 if (!keep_exact_action &&
2010 Deoptimization::trap_request_index(trap_request) < 0 &&
2011 too_many_recompiles(reason)) {
2012 // This BCI is causing too many recompilations.
2013 if (C->log() != NULL) {
2014 C->log()->elem("observe that='trap_action_change' reason='%s' from='%s' to='none'",
2015 Deoptimization::trap_reason_name(reason),
2016 Deoptimization::trap_action_name(action));
2017 }
2018 action = Deoptimization::Action_none;
2019 trap_request = Deoptimization::make_trap_request(reason, action);
2020 } else {
2021 C->set_trap_can_recompile(true);
2022 }
2023 break;
2024 case Deoptimization::Action_make_not_entrant:
2025 C->set_trap_can_recompile(true);
2026 break;
2027 #ifdef ASSERT
2028 case Deoptimization::Action_none:
2029 case Deoptimization::Action_make_not_compilable:
2030 break;
2031 default:
2032 fatal("unknown action %d: %s", action, Deoptimization::trap_action_name(action));
2033 break;
2034 #endif
2035 }
2036
2037 if (TraceOptoParse) {
2038 char buf[100];
2039 tty->print_cr("Uncommon trap %s at bci:%d",
2040 Deoptimization::format_trap_request(buf, sizeof(buf),
2041 trap_request), bci());
2042 }
2043
2044 CompileLog* log = C->log();
2045 if (log != NULL) {
2046 int kid = (klass == NULL)? -1: log->identify(klass);
2047 log->begin_elem("uncommon_trap bci='%d'", bci());
2048 char buf[100];
2049 log->print(" %s", Deoptimization::format_trap_request(buf, sizeof(buf),
2050 trap_request));
2051 if (kid >= 0) log->print(" klass='%d'", kid);
2052 if (comment != NULL) log->print(" comment='%s'", comment);
2053 log->end_elem();
2054 }
|
1 /*
2 * Copyright (c) 2001, 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 *
567 // Fixing this remaining case of 4292742 requires some flavor of
568 // escape analysis. Leave that for the future.
569 ciInstance* ex_obj = NULL;
570 switch (reason) {
571 case Deoptimization::Reason_null_check:
572 ex_obj = env()->NullPointerException_instance();
573 break;
574 case Deoptimization::Reason_div0_check:
575 ex_obj = env()->ArithmeticException_instance();
576 break;
577 case Deoptimization::Reason_range_check:
578 ex_obj = env()->ArrayIndexOutOfBoundsException_instance();
579 break;
580 case Deoptimization::Reason_class_check:
581 if (java_bc() == Bytecodes::_aastore) {
582 ex_obj = env()->ArrayStoreException_instance();
583 } else {
584 ex_obj = env()->ClassCastException_instance();
585 }
586 break;
587 default:
588 break;
589 }
590 if (failing()) { stop(); return; } // exception allocation might fail
591 if (ex_obj != NULL) {
592 // Cheat with a preallocated exception object.
593 if (C->log() != NULL)
594 C->log()->elem("hot_throw preallocated='1' reason='%s'",
595 Deoptimization::trap_reason_name(reason));
596 const TypeInstPtr* ex_con = TypeInstPtr::make(ex_obj);
597 Node* ex_node = _gvn.transform(ConNode::make(ex_con));
598
599 // Clear the detail message of the preallocated exception object.
600 // Weblogic sometimes mutates the detail message of exceptions
601 // using reflection.
602 int offset = java_lang_Throwable::get_detailMessage_offset();
603 const TypePtr* adr_typ = ex_con->add_offset(offset);
604
605 Node *adr = basic_plus_adr(ex_node, ex_node, offset);
606 const TypeOopPtr* val_type = TypeOopPtr::make_from_klass(env()->String_klass());
607 // Conservatively release stores of object references.
608 Node *store = store_oop_to_object(control(), ex_node, adr, adr_typ, null(), val_type, T_OBJECT, MemNode::release);
806 tty->print_cr("Zombie local %d: ", local);
807 jvms->dump();
808 }
809 return false;
810 }
811 }
812 }
813 return true;
814 }
815
816 #endif //ASSERT
817
818 // Helper function for enforcing certain bytecodes to reexecute if
819 // deoptimization happens
820 static bool should_reexecute_implied_by_bytecode(JVMState *jvms, bool is_anewarray) {
821 ciMethod* cur_method = jvms->method();
822 int cur_bci = jvms->bci();
823 if (cur_method != NULL && cur_bci != InvocationEntryBci) {
824 Bytecodes::Code code = cur_method->java_code_at_bci(cur_bci);
825 return Interpreter::bytecode_should_reexecute(code) ||
826 (is_anewarray && code == Bytecodes::_multianewarray);
827 // Reexecute _multianewarray bytecode which was replaced with
828 // sequence of [a]newarray. See Parse::do_multianewarray().
829 //
830 // Note: interpreter should not have it set since this optimization
831 // is limited by dimensions and guarded by flag so in some cases
832 // multianewarray() runtime calls will be generated and
833 // the bytecode should not be reexecutes (stack will not be reset).
834 } else
835 return false;
836 }
837
838 // Helper function for adding JVMState and debug information to node
839 void GraphKit::add_safepoint_edges(SafePointNode* call, bool must_throw) {
840 // Add the safepoint edges to the call (or other safepoint).
841
842 // Make sure dead locals are set to top. This
843 // should help register allocation time and cut down on the size
844 // of the deoptimization information.
845 assert(dead_locals_are_killed(), "garbage in debug info before safepoint");
846
1485 Node* GraphKit::make_load(Node* ctl, Node* adr, const Type* t, BasicType bt,
1486 int adr_idx,
1487 MemNode::MemOrd mo,
1488 LoadNode::ControlDependency control_dependency,
1489 bool require_atomic_access,
1490 bool unaligned,
1491 bool mismatched) {
1492 assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" );
1493 const TypePtr* adr_type = NULL; // debug-mode-only argument
1494 debug_only(adr_type = C->get_adr_type(adr_idx));
1495 Node* mem = memory(adr_idx);
1496 Node* ld;
1497 if (require_atomic_access && bt == T_LONG) {
1498 ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched);
1499 } else if (require_atomic_access && bt == T_DOUBLE) {
1500 ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched);
1501 } else {
1502 ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo, control_dependency, unaligned, mismatched);
1503 }
1504 ld = _gvn.transform(ld);
1505 if (((bt == T_OBJECT) && C->do_escape_analysis()) || C->eliminate_boxing()) {
1506 // Improve graph before escape analysis and boxing elimination.
1507 record_for_igvn(ld);
1508 }
1509 return ld;
1510 }
1511
1512 Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt,
1513 int adr_idx,
1514 MemNode::MemOrd mo,
1515 bool require_atomic_access,
1516 bool unaligned,
1517 bool mismatched) {
1518 assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
1519 const TypePtr* adr_type = NULL;
1520 debug_only(adr_type = C->get_adr_type(adr_idx));
1521 Node *mem = memory(adr_idx);
1522 Node* st;
1523 if (require_atomic_access && bt == T_LONG) {
1524 st = StoreLNode::make_atomic(ctl, mem, adr, adr_type, val, mo);
1525 } else if (require_atomic_access && bt == T_DOUBLE) {
2009 // Temporary fix for 6529811 to allow virtual calls to be sure they
2010 // get the chance to go from mono->bi->mega
2011 if (!keep_exact_action &&
2012 Deoptimization::trap_request_index(trap_request) < 0 &&
2013 too_many_recompiles(reason)) {
2014 // This BCI is causing too many recompilations.
2015 if (C->log() != NULL) {
2016 C->log()->elem("observe that='trap_action_change' reason='%s' from='%s' to='none'",
2017 Deoptimization::trap_reason_name(reason),
2018 Deoptimization::trap_action_name(action));
2019 }
2020 action = Deoptimization::Action_none;
2021 trap_request = Deoptimization::make_trap_request(reason, action);
2022 } else {
2023 C->set_trap_can_recompile(true);
2024 }
2025 break;
2026 case Deoptimization::Action_make_not_entrant:
2027 C->set_trap_can_recompile(true);
2028 break;
2029 case Deoptimization::Action_none:
2030 case Deoptimization::Action_make_not_compilable:
2031 break;
2032 default:
2033 #ifdef ASSERT
2034 fatal("unknown action %d: %s", action, Deoptimization::trap_action_name(action));
2035 #endif
2036 break;
2037 }
2038
2039 if (TraceOptoParse) {
2040 char buf[100];
2041 tty->print_cr("Uncommon trap %s at bci:%d",
2042 Deoptimization::format_trap_request(buf, sizeof(buf),
2043 trap_request), bci());
2044 }
2045
2046 CompileLog* log = C->log();
2047 if (log != NULL) {
2048 int kid = (klass == NULL)? -1: log->identify(klass);
2049 log->begin_elem("uncommon_trap bci='%d'", bci());
2050 char buf[100];
2051 log->print(" %s", Deoptimization::format_trap_request(buf, sizeof(buf),
2052 trap_request));
2053 if (kid >= 0) log->print(" klass='%d'", kid);
2054 if (comment != NULL) log->print(" comment='%s'", comment);
2055 log->end_elem();
2056 }
|