65 _oop_recorder = env->oop_recorder();
66 _log = env->log();
67 _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0);
68 #if INCLUDE_JVMCI
69 _using_dep_values = false;
70 #endif
71 DEBUG_ONLY(_deps[end_marker] = nullptr);
72 for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) {
73 _deps[i] = new(arena) GrowableArray<ciBaseObject*>(arena, 10, 0, nullptr);
74 }
75 _content_bytes = nullptr;
76 _size_in_bytes = (size_t)-1;
77
78 assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT), "sanity");
79 }
80
81 void Dependencies::assert_evol_method(ciMethod* m) {
82 assert_common_1(evol_method, m);
83 }
84
85 void Dependencies::assert_leaf_type(ciKlass* ctxk) {
86 if (ctxk->is_array_klass()) {
87 // As a special case, support this assertion on an array type,
88 // which reduces to an assertion on its element type.
89 // Note that this cannot be done with assertions that
90 // relate to concreteness or abstractness.
91 ciType* elemt = ctxk->as_array_klass()->base_element_type();
92 if (!elemt->is_instance_klass()) return; // Ex: int[][]
93 ctxk = elemt->as_instance_klass();
94 //if (ctxk->is_final()) return; // Ex: String[][]
95 }
96 check_ctxk(ctxk);
97 assert_common_1(leaf_type, ctxk);
98 }
99
100 void Dependencies::assert_abstract_with_unique_concrete_subtype(ciKlass* ctxk, ciKlass* conck) {
101 check_ctxk_abstract(ctxk);
102 assert_common_2(abstract_with_unique_concrete_subtype, ctxk, conck);
103 }
104
568
569 // write a sentinel byte to mark the end
570 bytes.write_byte(end_marker);
571
572 // round it out to a word boundary
573 while (bytes.position() % sizeof(HeapWord) != 0) {
574 bytes.write_byte(end_marker);
575 }
576
577 // check whether the dept byte encoding really works
578 assert((jbyte)default_context_type_bit != 0, "byte overflow");
579
580 _content_bytes = bytes.buffer();
581 _size_in_bytes = bytes.position();
582 }
583
584
585 const char* Dependencies::_dep_name[TYPE_LIMIT] = {
586 "end_marker",
587 "evol_method",
588 "leaf_type",
589 "abstract_with_unique_concrete_subtype",
590 "unique_concrete_method_2",
591 "unique_concrete_method_4",
592 "unique_implementor",
593 "no_finalizable_subclasses",
594 "call_site_target_value"
595 };
596
597 int Dependencies::_dep_args[TYPE_LIMIT] = {
598 -1,// end_marker
599 1, // evol_method m
600 1, // leaf_type ctxk
601 2, // abstract_with_unique_concrete_subtype ctxk, k
602 2, // unique_concrete_method_2 ctxk, m
603 4, // unique_concrete_method_4 ctxk, m, resolved_klass, resolved_method
604 2, // unique_implementor ctxk, implementor
605 1, // no_finalizable_subclasses ctxk
606 2 // call_site_target_value call_site, method_handle
607 };
608
609 const char* Dependencies::dep_name(Dependencies::DepType dept) {
610 if (!dept_in_mask(dept, all_types)) return "?bad-dep?";
611 return _dep_name[dept];
612 }
613
614 int Dependencies::dep_args(Dependencies::DepType dept) {
615 if (!dept_in_mask(dept, all_types)) return -1;
616 return _dep_args[dept];
617 }
618
619 void Dependencies::check_valid_dependency_type(DepType dept) {
1677 bool Dependencies::is_concrete_klass(ciInstanceKlass* k) {
1678 if (k->is_abstract()) return false;
1679 // We could also return false if k does not yet appear to be
1680 // instantiated, if the VM version supports this distinction also.
1681 //if (k->is_not_instantiated()) return false;
1682 return true;
1683 }
1684
1685 bool Dependencies::has_finalizable_subclass(ciInstanceKlass* k) {
1686 return k->has_finalizable_subclass();
1687 }
1688
1689 // Any use of the contents (bytecodes) of a method must be
1690 // marked by an "evol_method" dependency, if those contents
1691 // can change. (Note: A method is always dependent on itself.)
1692 Klass* Dependencies::check_evol_method(Method* m) {
1693 assert(must_be_in_vm(), "raw oops here");
1694 // Did somebody do a JVMTI RedefineClasses while our backs were turned?
1695 // Or is there a now a breakpoint?
1696 // (Assumes compiled code cannot handle bkpts; change if UseFastBreakpoints.)
1697 if (m->is_old()
1698 || m->number_of_breakpoints() > 0) {
1699 return m->method_holder();
1700 } else {
1701 return nullptr;
1702 }
1703 }
1704
1705 // This is a strong assertion: It is that the given type
1706 // has no subtypes whatever. It is most useful for
1707 // optimizing checks on reflected types or on array types.
1708 // (Checks on types which are derived from real instances
1709 // can be optimized more strongly than this, because we
1710 // know that the checked type comes from a concrete type,
1711 // and therefore we can disregard abstract types.)
1712 Klass* Dependencies::check_leaf_type(InstanceKlass* ctxk) {
1713 assert(must_be_in_vm(), "raw oops here");
1714 assert_locked_or_safepoint(Compile_lock);
1715 Klass* sub = ctxk->subklass();
1716 if (sub != nullptr) {
1717 return sub;
1718 } else if (ctxk->nof_implementors() != 0) {
2055 if (witness != nullptr) {
2056 LogTarget(Debug, dependencies) lt;
2057 if (lt.is_enabled()) {
2058 LogStream ls(<);
2059 print_dependency(&ls, witness, /*verbose=*/ true);
2060 }
2061 // The following is a no-op unless logging is enabled:
2062 log_dependency(witness);
2063 }
2064 }
2065
2066 Klass* Dependencies::DepStream::check_new_klass_dependency(NewKlassDepChange* changes) {
2067 assert_locked_or_safepoint(Compile_lock);
2068 Dependencies::check_valid_dependency_type(type());
2069
2070 Klass* witness = nullptr;
2071 switch (type()) {
2072 case evol_method:
2073 witness = check_evol_method(method_argument(0));
2074 break;
2075 case leaf_type:
2076 witness = check_leaf_type(context_type());
2077 break;
2078 case abstract_with_unique_concrete_subtype:
2079 witness = check_abstract_with_unique_concrete_subtype(context_type(), type_argument(1), changes);
2080 break;
2081 case unique_concrete_method_2:
2082 witness = check_unique_concrete_method(context_type(), method_argument(1), changes);
2083 break;
2084 case unique_concrete_method_4:
2085 witness = check_unique_concrete_method(context_type(), method_argument(1), type_argument(2), method_argument(3), changes);
2086 break;
2087 case unique_implementor:
2088 witness = check_unique_implementor(context_type(), type_argument(1), changes);
2089 break;
2090 case no_finalizable_subclasses:
2091 witness = check_has_no_finalizable_subclasses(context_type(), changes);
2092 break;
2093 default:
2094 witness = nullptr;
|
65 _oop_recorder = env->oop_recorder();
66 _log = env->log();
67 _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0);
68 #if INCLUDE_JVMCI
69 _using_dep_values = false;
70 #endif
71 DEBUG_ONLY(_deps[end_marker] = nullptr);
72 for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) {
73 _deps[i] = new(arena) GrowableArray<ciBaseObject*>(arena, 10, 0, nullptr);
74 }
75 _content_bytes = nullptr;
76 _size_in_bytes = (size_t)-1;
77
78 assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT), "sanity");
79 }
80
81 void Dependencies::assert_evol_method(ciMethod* m) {
82 assert_common_1(evol_method, m);
83 }
84
85 void Dependencies::assert_mismatch_calling_convention(ciMethod* m) {
86 assert_common_1(mismatch_calling_convention, m);
87 }
88
89 void Dependencies::assert_leaf_type(ciKlass* ctxk) {
90 if (ctxk->is_array_klass()) {
91 // As a special case, support this assertion on an array type,
92 // which reduces to an assertion on its element type.
93 // Note that this cannot be done with assertions that
94 // relate to concreteness or abstractness.
95 ciType* elemt = ctxk->as_array_klass()->base_element_type();
96 if (!elemt->is_instance_klass()) return; // Ex: int[][]
97 ctxk = elemt->as_instance_klass();
98 //if (ctxk->is_final()) return; // Ex: String[][]
99 }
100 check_ctxk(ctxk);
101 assert_common_1(leaf_type, ctxk);
102 }
103
104 void Dependencies::assert_abstract_with_unique_concrete_subtype(ciKlass* ctxk, ciKlass* conck) {
105 check_ctxk_abstract(ctxk);
106 assert_common_2(abstract_with_unique_concrete_subtype, ctxk, conck);
107 }
108
572
573 // write a sentinel byte to mark the end
574 bytes.write_byte(end_marker);
575
576 // round it out to a word boundary
577 while (bytes.position() % sizeof(HeapWord) != 0) {
578 bytes.write_byte(end_marker);
579 }
580
581 // check whether the dept byte encoding really works
582 assert((jbyte)default_context_type_bit != 0, "byte overflow");
583
584 _content_bytes = bytes.buffer();
585 _size_in_bytes = bytes.position();
586 }
587
588
589 const char* Dependencies::_dep_name[TYPE_LIMIT] = {
590 "end_marker",
591 "evol_method",
592 "mismatch_calling_convention",
593 "leaf_type",
594 "abstract_with_unique_concrete_subtype",
595 "unique_concrete_method_2",
596 "unique_concrete_method_4",
597 "unique_implementor",
598 "no_finalizable_subclasses",
599 "call_site_target_value"
600 };
601
602 int Dependencies::_dep_args[TYPE_LIMIT] = {
603 -1,// end_marker
604 1, // evol_method m
605 1, // mismatch_calling_convention m
606 1, // leaf_type ctxk
607 2, // abstract_with_unique_concrete_subtype ctxk, k
608 2, // unique_concrete_method_2 ctxk, m
609 4, // unique_concrete_method_4 ctxk, m, resolved_klass, resolved_method
610 2, // unique_implementor ctxk, implementor
611 1, // no_finalizable_subclasses ctxk
612 2 // call_site_target_value call_site, method_handle
613 };
614
615 const char* Dependencies::dep_name(Dependencies::DepType dept) {
616 if (!dept_in_mask(dept, all_types)) return "?bad-dep?";
617 return _dep_name[dept];
618 }
619
620 int Dependencies::dep_args(Dependencies::DepType dept) {
621 if (!dept_in_mask(dept, all_types)) return -1;
622 return _dep_args[dept];
623 }
624
625 void Dependencies::check_valid_dependency_type(DepType dept) {
1683 bool Dependencies::is_concrete_klass(ciInstanceKlass* k) {
1684 if (k->is_abstract()) return false;
1685 // We could also return false if k does not yet appear to be
1686 // instantiated, if the VM version supports this distinction also.
1687 //if (k->is_not_instantiated()) return false;
1688 return true;
1689 }
1690
1691 bool Dependencies::has_finalizable_subclass(ciInstanceKlass* k) {
1692 return k->has_finalizable_subclass();
1693 }
1694
1695 // Any use of the contents (bytecodes) of a method must be
1696 // marked by an "evol_method" dependency, if those contents
1697 // can change. (Note: A method is always dependent on itself.)
1698 Klass* Dependencies::check_evol_method(Method* m) {
1699 assert(must_be_in_vm(), "raw oops here");
1700 // Did somebody do a JVMTI RedefineClasses while our backs were turned?
1701 // Or is there a now a breakpoint?
1702 // (Assumes compiled code cannot handle bkpts; change if UseFastBreakpoints.)
1703 if (m->is_old() || m->number_of_breakpoints() > 0) {
1704 return m->method_holder();
1705 } else {
1706 return nullptr;
1707 }
1708 }
1709
1710 Klass* Dependencies::check_mismatch_calling_convention(Method* m) {
1711 assert(must_be_in_vm(), "raw oops here");
1712 if (m->mismatch()) {
1713 return m->method_holder();
1714 } else {
1715 return nullptr;
1716 }
1717 }
1718
1719 // This is a strong assertion: It is that the given type
1720 // has no subtypes whatever. It is most useful for
1721 // optimizing checks on reflected types or on array types.
1722 // (Checks on types which are derived from real instances
1723 // can be optimized more strongly than this, because we
1724 // know that the checked type comes from a concrete type,
1725 // and therefore we can disregard abstract types.)
1726 Klass* Dependencies::check_leaf_type(InstanceKlass* ctxk) {
1727 assert(must_be_in_vm(), "raw oops here");
1728 assert_locked_or_safepoint(Compile_lock);
1729 Klass* sub = ctxk->subklass();
1730 if (sub != nullptr) {
1731 return sub;
1732 } else if (ctxk->nof_implementors() != 0) {
2069 if (witness != nullptr) {
2070 LogTarget(Debug, dependencies) lt;
2071 if (lt.is_enabled()) {
2072 LogStream ls(<);
2073 print_dependency(&ls, witness, /*verbose=*/ true);
2074 }
2075 // The following is a no-op unless logging is enabled:
2076 log_dependency(witness);
2077 }
2078 }
2079
2080 Klass* Dependencies::DepStream::check_new_klass_dependency(NewKlassDepChange* changes) {
2081 assert_locked_or_safepoint(Compile_lock);
2082 Dependencies::check_valid_dependency_type(type());
2083
2084 Klass* witness = nullptr;
2085 switch (type()) {
2086 case evol_method:
2087 witness = check_evol_method(method_argument(0));
2088 break;
2089 case mismatch_calling_convention:
2090 witness = check_mismatch_calling_convention(method_argument(0));
2091 break;
2092 case leaf_type:
2093 witness = check_leaf_type(context_type());
2094 break;
2095 case abstract_with_unique_concrete_subtype:
2096 witness = check_abstract_with_unique_concrete_subtype(context_type(), type_argument(1), changes);
2097 break;
2098 case unique_concrete_method_2:
2099 witness = check_unique_concrete_method(context_type(), method_argument(1), changes);
2100 break;
2101 case unique_concrete_method_4:
2102 witness = check_unique_concrete_method(context_type(), method_argument(1), type_argument(2), method_argument(3), changes);
2103 break;
2104 case unique_implementor:
2105 witness = check_unique_implementor(context_type(), type_argument(1), changes);
2106 break;
2107 case no_finalizable_subclasses:
2108 witness = check_has_no_finalizable_subclasses(context_type(), changes);
2109 break;
2110 default:
2111 witness = nullptr;
|