Mercurial > hg > truffle
comparison src/share/vm/oops/instanceKlass.cpp @ 6152:958bb4b7be49
Merge
author | asaha |
---|---|
date | Tue, 10 Apr 2012 10:42:34 -0700 |
parents | 6522ad563f99 |
children | 49036505ab5f |
comparison
equal
deleted
inserted
replaced
6151:e778c29768e6 | 6152:958bb4b7be49 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
667 | 667 |
668 objArrayOop instanceKlass::allocate_objArray(int n, int length, TRAPS) { | 668 objArrayOop instanceKlass::allocate_objArray(int n, int length, TRAPS) { |
669 if (length < 0) THROW_0(vmSymbols::java_lang_NegativeArraySizeException()); | 669 if (length < 0) THROW_0(vmSymbols::java_lang_NegativeArraySizeException()); |
670 if (length > arrayOopDesc::max_array_length(T_OBJECT)) { | 670 if (length > arrayOopDesc::max_array_length(T_OBJECT)) { |
671 report_java_out_of_memory("Requested array size exceeds VM limit"); | 671 report_java_out_of_memory("Requested array size exceeds VM limit"); |
672 JvmtiExport::post_array_size_exhausted(); | |
672 THROW_OOP_0(Universe::out_of_memory_error_array_size()); | 673 THROW_OOP_0(Universe::out_of_memory_error_array_size()); |
673 } | 674 } |
674 int size = objArrayOopDesc::object_size(length); | 675 int size = objArrayOopDesc::object_size(length); |
675 klassOop ak = array_klass(n, CHECK_NULL); | 676 klassOop ak = array_klass(n, CHECK_NULL); |
676 KlassHandle h_ak (THREAD, ak); | 677 KlassHandle h_ak (THREAD, ak); |
1130 probe = jni_id_for_impl(this->as_klassOop(), offset); | 1131 probe = jni_id_for_impl(this->as_klassOop(), offset); |
1131 } | 1132 } |
1132 return probe; | 1133 return probe; |
1133 } | 1134 } |
1134 | 1135 |
1136 u2 instanceKlass::enclosing_method_data(int offset) { | |
1137 typeArrayOop inner_class_list = inner_classes(); | |
1138 if (inner_class_list == NULL) { | |
1139 return 0; | |
1140 } | |
1141 int length = inner_class_list->length(); | |
1142 if (length % inner_class_next_offset == 0) { | |
1143 return 0; | |
1144 } else { | |
1145 int index = length - enclosing_method_attribute_size; | |
1146 typeArrayHandle inner_class_list_h(inner_class_list); | |
1147 assert(offset < enclosing_method_attribute_size, "invalid offset"); | |
1148 return inner_class_list_h->ushort_at(index + offset); | |
1149 } | |
1150 } | |
1151 | |
1152 void instanceKlass::set_enclosing_method_indices(u2 class_index, | |
1153 u2 method_index) { | |
1154 typeArrayOop inner_class_list = inner_classes(); | |
1155 assert (inner_class_list != NULL, "_inner_classes list is not set up"); | |
1156 int length = inner_class_list->length(); | |
1157 if (length % inner_class_next_offset == enclosing_method_attribute_size) { | |
1158 int index = length - enclosing_method_attribute_size; | |
1159 typeArrayHandle inner_class_list_h(inner_class_list); | |
1160 inner_class_list_h->ushort_at_put( | |
1161 index + enclosing_method_class_index_offset, class_index); | |
1162 inner_class_list_h->ushort_at_put( | |
1163 index + enclosing_method_method_index_offset, method_index); | |
1164 } | |
1165 } | |
1135 | 1166 |
1136 // Lookup or create a jmethodID. | 1167 // Lookup or create a jmethodID. |
1137 // This code is called by the VMThread and JavaThreads so the | 1168 // This code is called by the VMThread and JavaThreads so the |
1138 // locking has to be done very carefully to avoid deadlocks | 1169 // locking has to be done very carefully to avoid deadlocks |
1139 // and/or other cache consistency problems. | 1170 // and/or other cache consistency problems. |
2104 jint instanceKlass::compute_modifier_flags(TRAPS) const { | 2135 jint instanceKlass::compute_modifier_flags(TRAPS) const { |
2105 klassOop k = as_klassOop(); | 2136 klassOop k = as_klassOop(); |
2106 jint access = access_flags().as_int(); | 2137 jint access = access_flags().as_int(); |
2107 | 2138 |
2108 // But check if it happens to be member class. | 2139 // But check if it happens to be member class. |
2109 typeArrayOop inner_class_list = inner_classes(); | 2140 instanceKlassHandle ik(THREAD, k); |
2110 int length = (inner_class_list == NULL) ? 0 : inner_class_list->length(); | 2141 InnerClassesIterator iter(ik); |
2111 assert (length % instanceKlass::inner_class_next_offset == 0, "just checking"); | 2142 for (; !iter.done(); iter.next()) { |
2112 if (length > 0) { | 2143 int ioff = iter.inner_class_info_index(); |
2113 typeArrayHandle inner_class_list_h(THREAD, inner_class_list); | 2144 // Inner class attribute can be zero, skip it. |
2114 instanceKlassHandle ik(THREAD, k); | 2145 // Strange but true: JVM spec. allows null inner class refs. |
2115 for (int i = 0; i < length; i += instanceKlass::inner_class_next_offset) { | 2146 if (ioff == 0) continue; |
2116 int ioff = inner_class_list_h->ushort_at( | 2147 |
2117 i + instanceKlass::inner_class_inner_class_info_offset); | 2148 // only look at classes that are already loaded |
2118 | 2149 // since we are looking for the flags for our self. |
2119 // Inner class attribute can be zero, skip it. | 2150 Symbol* inner_name = ik->constants()->klass_name_at(ioff); |
2120 // Strange but true: JVM spec. allows null inner class refs. | 2151 if ((ik->name() == inner_name)) { |
2121 if (ioff == 0) continue; | 2152 // This is really a member class. |
2122 | 2153 access = iter.inner_access_flags(); |
2123 // only look at classes that are already loaded | 2154 break; |
2124 // since we are looking for the flags for our self. | |
2125 Symbol* inner_name = ik->constants()->klass_name_at(ioff); | |
2126 if ((ik->name() == inner_name)) { | |
2127 // This is really a member class. | |
2128 access = inner_class_list_h->ushort_at(i + instanceKlass::inner_class_access_flags_offset); | |
2129 break; | |
2130 } | |
2131 } | 2155 } |
2132 } | 2156 } |
2133 // Remember to strip ACC_SUPER bit | 2157 // Remember to strip ACC_SUPER bit |
2134 return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS; | 2158 return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS; |
2135 } | 2159 } |