Mon, 03 Feb 2014 15:24:20 +0100
8033126: Can't call default methods from JNI
Reviewed-by: dholmes, acorn, kamg
mgerdin@3619 | 1 | /* |
hseigel@4987 | 2 | * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
mgerdin@3619 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
mgerdin@3619 | 4 | * |
mgerdin@3619 | 5 | * This code is free software; you can redistribute it and/or modify it |
mgerdin@3619 | 6 | * under the terms of the GNU General Public License version 2 only, as |
mgerdin@3619 | 7 | * published by the Free Software Foundation. |
mgerdin@3619 | 8 | * |
mgerdin@3619 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
mgerdin@3619 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
mgerdin@3619 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
mgerdin@3619 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
mgerdin@3619 | 13 | * accompanied this code). |
mgerdin@3619 | 14 | * |
mgerdin@3619 | 15 | * You should have received a copy of the GNU General Public License version |
mgerdin@3619 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
mgerdin@3619 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
mgerdin@3619 | 18 | * |
mgerdin@3619 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
mgerdin@3619 | 20 | * or visit www.oracle.com if you need additional information or have any |
mgerdin@3619 | 21 | * questions. |
mgerdin@3619 | 22 | * |
mgerdin@3619 | 23 | */ |
mgerdin@3619 | 24 | |
mgerdin@3619 | 25 | #include "precompiled.hpp" |
mgerdin@3619 | 26 | |
mgerdin@3619 | 27 | #include "memory/universe.hpp" |
mgerdin@3619 | 28 | #include "oops/oop.inline.hpp" |
nloodin@3681 | 29 | |
nloodin@3681 | 30 | #include "classfile/symbolTable.hpp" |
coleenp@4037 | 31 | #include "classfile/classLoaderData.hpp" |
nloodin@3681 | 32 | |
mgerdin@3619 | 33 | #include "prims/whitebox.hpp" |
nloodin@3681 | 34 | #include "prims/wbtestmethods/parserTests.hpp" |
nloodin@3681 | 35 | |
tschatzl@5701 | 36 | #include "runtime/arguments.hpp" |
mgerdin@3619 | 37 | #include "runtime/interfaceSupport.hpp" |
mgerdin@3619 | 38 | #include "runtime/os.hpp" |
mgerdin@3619 | 39 | #include "utilities/debug.hpp" |
jprovino@4542 | 40 | #include "utilities/macros.hpp" |
mikael@5174 | 41 | #include "utilities/exceptions.hpp" |
mgerdin@3619 | 42 | |
jprovino@4542 | 43 | #if INCLUDE_ALL_GCS |
mgerdin@3619 | 44 | #include "gc_implementation/g1/concurrentMark.hpp" |
mgerdin@3619 | 45 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
mgerdin@3619 | 46 | #include "gc_implementation/g1/heapRegionRemSet.hpp" |
jprovino@4542 | 47 | #endif // INCLUDE_ALL_GCS |
mgerdin@3619 | 48 | |
ctornqvi@4512 | 49 | #ifdef INCLUDE_NMT |
ctornqvi@4512 | 50 | #include "services/memTracker.hpp" |
ctornqvi@4512 | 51 | #endif // INCLUDE_NMT |
ctornqvi@4512 | 52 | |
iignatyev@4592 | 53 | #include "compiler/compileBroker.hpp" |
iignatyev@4908 | 54 | #include "runtime/compilationPolicy.hpp" |
iignatyev@4592 | 55 | |
mgerdin@6078 | 56 | #define SIZE_T_MAX_VALUE ((size_t) -1) |
mgerdin@6078 | 57 | |
mgerdin@3619 | 58 | bool WhiteBox::_used = false; |
mgerdin@3619 | 59 | |
mgerdin@3619 | 60 | WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj)) |
mgerdin@3619 | 61 | return (jlong)(void*)JNIHandles::resolve(obj); |
mgerdin@3619 | 62 | WB_END |
mgerdin@3619 | 63 | |
mgerdin@3619 | 64 | WB_ENTRY(jint, WB_GetHeapOopSize(JNIEnv* env, jobject o)) |
mgerdin@3619 | 65 | return heapOopSize; |
mgerdin@3619 | 66 | WB_END |
mgerdin@3619 | 67 | |
coleenp@4037 | 68 | |
coleenp@4037 | 69 | class WBIsKlassAliveClosure : public KlassClosure { |
coleenp@4037 | 70 | Symbol* _name; |
coleenp@4037 | 71 | bool _found; |
coleenp@4037 | 72 | public: |
coleenp@4037 | 73 | WBIsKlassAliveClosure(Symbol* name) : _name(name), _found(false) {} |
coleenp@4037 | 74 | |
coleenp@4037 | 75 | void do_klass(Klass* k) { |
coleenp@4037 | 76 | if (_found) return; |
coleenp@4037 | 77 | Symbol* ksym = k->name(); |
coleenp@4037 | 78 | if (ksym->fast_compare(_name) == 0) { |
coleenp@4037 | 79 | _found = true; |
coleenp@4037 | 80 | } |
coleenp@4037 | 81 | } |
coleenp@4037 | 82 | |
coleenp@4037 | 83 | bool found() const { |
coleenp@4037 | 84 | return _found; |
coleenp@4037 | 85 | } |
coleenp@4037 | 86 | }; |
coleenp@4037 | 87 | |
coleenp@4037 | 88 | WB_ENTRY(jboolean, WB_IsClassAlive(JNIEnv* env, jobject target, jstring name)) |
coleenp@4037 | 89 | Handle h_name = JNIHandles::resolve(name); |
coleenp@4037 | 90 | if (h_name.is_null()) return false; |
coleenp@4037 | 91 | Symbol* sym = java_lang_String::as_symbol(h_name, CHECK_false); |
coleenp@4037 | 92 | TempNewSymbol tsym(sym); // Make sure to decrement reference count on sym on return |
coleenp@4037 | 93 | |
coleenp@4037 | 94 | WBIsKlassAliveClosure closure(sym); |
coleenp@4037 | 95 | ClassLoaderDataGraph::classes_do(&closure); |
coleenp@4037 | 96 | |
coleenp@4037 | 97 | return closure.found(); |
coleenp@4037 | 98 | WB_END |
coleenp@4037 | 99 | |
tschatzl@5701 | 100 | WB_ENTRY(jlong, WB_GetCompressedOopsMaxHeapSize(JNIEnv* env, jobject o)) { |
tschatzl@5701 | 101 | return (jlong)Arguments::max_heap_for_compressed_oops(); |
tschatzl@5701 | 102 | } |
tschatzl@5701 | 103 | WB_END |
tschatzl@5701 | 104 | |
tschatzl@5073 | 105 | WB_ENTRY(void, WB_PrintHeapSizes(JNIEnv* env, jobject o)) { |
tschatzl@5073 | 106 | CollectorPolicy * p = Universe::heap()->collector_policy(); |
tschatzl@5073 | 107 | gclog_or_tty->print_cr("Minimum heap "SIZE_FORMAT" Initial heap " |
tschatzl@5073 | 108 | SIZE_FORMAT" Maximum heap "SIZE_FORMAT" Min alignment "SIZE_FORMAT" Max alignment "SIZE_FORMAT, |
tschatzl@5073 | 109 | p->min_heap_byte_size(), p->initial_heap_byte_size(), p->max_heap_byte_size(), |
jwilhelm@6085 | 110 | p->space_alignment(), p->heap_alignment()); |
tschatzl@5073 | 111 | } |
tschatzl@5073 | 112 | WB_END |
tschatzl@5073 | 113 | |
mgerdin@6078 | 114 | #ifndef PRODUCT |
mgerdin@6078 | 115 | // Forward declaration |
mgerdin@6078 | 116 | void TestReservedSpace_test(); |
mgerdin@6078 | 117 | void TestReserveMemorySpecial_test(); |
mgerdin@6078 | 118 | void TestVirtualSpace_test(); |
mgerdin@6078 | 119 | void TestMetaspaceAux_test(); |
mgerdin@6078 | 120 | #endif |
mgerdin@6078 | 121 | |
mgerdin@6078 | 122 | WB_ENTRY(void, WB_RunMemoryUnitTests(JNIEnv* env, jobject o)) |
mgerdin@6078 | 123 | #ifndef PRODUCT |
mgerdin@6078 | 124 | TestReservedSpace_test(); |
mgerdin@6078 | 125 | TestReserveMemorySpecial_test(); |
mgerdin@6078 | 126 | TestVirtualSpace_test(); |
mgerdin@6078 | 127 | TestMetaspaceAux_test(); |
mgerdin@6078 | 128 | #endif |
mgerdin@6078 | 129 | WB_END |
mgerdin@6078 | 130 | |
mgerdin@6078 | 131 | WB_ENTRY(void, WB_ReadFromNoaccessArea(JNIEnv* env, jobject o)) |
mgerdin@6078 | 132 | size_t granularity = os::vm_allocation_granularity(); |
mgerdin@6078 | 133 | ReservedHeapSpace rhs(100 * granularity, granularity, false, NULL); |
mgerdin@6078 | 134 | VirtualSpace vs; |
mgerdin@6078 | 135 | vs.initialize(rhs, 50 * granularity); |
mgerdin@6078 | 136 | |
mgerdin@6078 | 137 | //Check if constraints are complied |
mgerdin@6078 | 138 | if (!( UseCompressedOops && rhs.base() != NULL && |
mgerdin@6078 | 139 | Universe::narrow_oop_base() != NULL && |
mgerdin@6078 | 140 | Universe::narrow_oop_use_implicit_null_checks() )) { |
mgerdin@6078 | 141 | tty->print_cr("WB_ReadFromNoaccessArea method is useless:\n " |
mgerdin@6078 | 142 | "\tUseCompressedOops is %d\n" |
mgerdin@6078 | 143 | "\trhs.base() is "PTR_FORMAT"\n" |
mgerdin@6078 | 144 | "\tUniverse::narrow_oop_base() is "PTR_FORMAT"\n" |
mgerdin@6078 | 145 | "\tUniverse::narrow_oop_use_implicit_null_checks() is %d", |
mgerdin@6078 | 146 | UseCompressedOops, |
mgerdin@6078 | 147 | rhs.base(), |
mgerdin@6078 | 148 | Universe::narrow_oop_base(), |
mgerdin@6078 | 149 | Universe::narrow_oop_use_implicit_null_checks()); |
mgerdin@6078 | 150 | return; |
mgerdin@6078 | 151 | } |
mgerdin@6078 | 152 | tty->print_cr("Reading from no access area... "); |
mgerdin@6078 | 153 | tty->print_cr("*(vs.low_boundary() - rhs.noaccess_prefix() / 2 ) = %c", |
mgerdin@6078 | 154 | *(vs.low_boundary() - rhs.noaccess_prefix() / 2 )); |
mgerdin@6078 | 155 | WB_END |
mgerdin@6078 | 156 | |
mgerdin@6078 | 157 | static jint wb_stress_virtual_space_resize(size_t reserved_space_size, |
mgerdin@6078 | 158 | size_t magnitude, size_t iterations) { |
mgerdin@6078 | 159 | size_t granularity = os::vm_allocation_granularity(); |
mgerdin@6078 | 160 | ReservedHeapSpace rhs(reserved_space_size * granularity, granularity, false, NULL); |
mgerdin@6078 | 161 | VirtualSpace vs; |
mgerdin@6078 | 162 | if (!vs.initialize(rhs, 0)) { |
mgerdin@6078 | 163 | tty->print_cr("Failed to initialize VirtualSpace. Can't proceed."); |
mgerdin@6078 | 164 | return 3; |
mgerdin@6078 | 165 | } |
mgerdin@6078 | 166 | |
mgerdin@6078 | 167 | long seed = os::random(); |
mgerdin@6078 | 168 | tty->print_cr("Random seed is %ld", seed); |
mgerdin@6078 | 169 | os::init_random(seed); |
mgerdin@6078 | 170 | |
mgerdin@6078 | 171 | for (size_t i = 0; i < iterations; i++) { |
mgerdin@6078 | 172 | |
mgerdin@6078 | 173 | // Whether we will shrink or grow |
mgerdin@6078 | 174 | bool shrink = os::random() % 2L == 0; |
mgerdin@6078 | 175 | |
mgerdin@6078 | 176 | // Get random delta to resize virtual space |
mgerdin@6078 | 177 | size_t delta = (size_t)os::random() % magnitude; |
mgerdin@6078 | 178 | |
mgerdin@6078 | 179 | // If we are about to shrink virtual space below zero, then expand instead |
mgerdin@6078 | 180 | if (shrink && vs.committed_size() < delta) { |
mgerdin@6078 | 181 | shrink = false; |
mgerdin@6078 | 182 | } |
mgerdin@6078 | 183 | |
mgerdin@6078 | 184 | // Resizing by delta |
mgerdin@6078 | 185 | if (shrink) { |
mgerdin@6078 | 186 | vs.shrink_by(delta); |
mgerdin@6078 | 187 | } else { |
mgerdin@6078 | 188 | // If expanding fails expand_by will silently return false |
mgerdin@6078 | 189 | vs.expand_by(delta, true); |
mgerdin@6078 | 190 | } |
mgerdin@6078 | 191 | } |
mgerdin@6078 | 192 | return 0; |
mgerdin@6078 | 193 | } |
mgerdin@6078 | 194 | |
mgerdin@6078 | 195 | WB_ENTRY(jint, WB_StressVirtualSpaceResize(JNIEnv* env, jobject o, |
mgerdin@6078 | 196 | jlong reserved_space_size, jlong magnitude, jlong iterations)) |
mgerdin@6078 | 197 | tty->print_cr("reservedSpaceSize="JLONG_FORMAT", magnitude="JLONG_FORMAT", " |
mgerdin@6078 | 198 | "iterations="JLONG_FORMAT"\n", reserved_space_size, magnitude, |
mgerdin@6078 | 199 | iterations); |
mgerdin@6078 | 200 | if (reserved_space_size < 0 || magnitude < 0 || iterations < 0) { |
mgerdin@6078 | 201 | tty->print_cr("One of variables printed above is negative. Can't proceed.\n"); |
mgerdin@6078 | 202 | return 1; |
mgerdin@6078 | 203 | } |
mgerdin@6078 | 204 | |
mgerdin@6078 | 205 | // sizeof(size_t) depends on whether OS is 32bit or 64bit. sizeof(jlong) is |
mgerdin@6078 | 206 | // always 8 byte. That's why we should avoid overflow in case of 32bit platform. |
mgerdin@6078 | 207 | if (sizeof(size_t) < sizeof(jlong)) { |
mgerdin@6078 | 208 | jlong size_t_max_value = (jlong) SIZE_T_MAX_VALUE; |
mgerdin@6078 | 209 | if (reserved_space_size > size_t_max_value || magnitude > size_t_max_value |
mgerdin@6078 | 210 | || iterations > size_t_max_value) { |
mgerdin@6078 | 211 | tty->print_cr("One of variables printed above overflows size_t. Can't proceed.\n"); |
mgerdin@6078 | 212 | return 2; |
mgerdin@6078 | 213 | } |
mgerdin@6078 | 214 | } |
mgerdin@6078 | 215 | |
mgerdin@6078 | 216 | return wb_stress_virtual_space_resize((size_t) reserved_space_size, |
mgerdin@6078 | 217 | (size_t) magnitude, (size_t) iterations); |
mgerdin@6078 | 218 | WB_END |
mgerdin@6078 | 219 | |
jprovino@4542 | 220 | #if INCLUDE_ALL_GCS |
mgerdin@3619 | 221 | WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj)) |
mgerdin@3619 | 222 | G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
mgerdin@3619 | 223 | oop result = JNIHandles::resolve(obj); |
mgerdin@3619 | 224 | const HeapRegion* hr = g1->heap_region_containing(result); |
mgerdin@3619 | 225 | return hr->isHumongous(); |
mgerdin@3619 | 226 | WB_END |
mgerdin@3619 | 227 | |
mgerdin@3619 | 228 | WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o)) |
mgerdin@3619 | 229 | G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
mgerdin@3619 | 230 | size_t nr = g1->free_regions(); |
mgerdin@3619 | 231 | return (jlong)nr; |
mgerdin@3619 | 232 | WB_END |
mgerdin@3619 | 233 | |
mgerdin@3619 | 234 | WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o)) |
mgerdin@3619 | 235 | G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
mgerdin@3619 | 236 | ConcurrentMark* cm = g1->concurrent_mark(); |
mgerdin@3619 | 237 | return cm->concurrent_marking_in_progress(); |
mgerdin@3619 | 238 | WB_END |
mgerdin@3619 | 239 | |
mgerdin@3619 | 240 | WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o)) |
mgerdin@3619 | 241 | return (jint)HeapRegion::GrainBytes; |
mgerdin@3619 | 242 | WB_END |
jprovino@4542 | 243 | #endif // INCLUDE_ALL_GCS |
mgerdin@3619 | 244 | |
cjplummer@5586 | 245 | #if INCLUDE_NMT |
ctornqvi@4512 | 246 | // Alloc memory using the test memory type so that we can use that to see if |
ctornqvi@4512 | 247 | // NMT picks it up correctly |
ctornqvi@4885 | 248 | WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) |
ctornqvi@4885 | 249 | jlong addr = 0; |
ctornqvi@4512 | 250 | |
ctornqvi@4885 | 251 | if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { |
ctornqvi@4885 | 252 | addr = (jlong)(uintptr_t)os::malloc(size, mtTest); |
ctornqvi@4512 | 253 | } |
ctornqvi@4512 | 254 | |
ctornqvi@4885 | 255 | return addr; |
ctornqvi@4512 | 256 | WB_END |
ctornqvi@4512 | 257 | |
ctornqvi@4512 | 258 | // Free the memory allocated by NMTAllocTest |
ctornqvi@4885 | 259 | WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem)) |
ctornqvi@4885 | 260 | os::free((void*)(uintptr_t)mem, mtTest); |
ctornqvi@4885 | 261 | WB_END |
ctornqvi@4512 | 262 | |
ctornqvi@4885 | 263 | WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size)) |
ctornqvi@4885 | 264 | jlong addr = 0; |
ctornqvi@4885 | 265 | |
ctornqvi@4885 | 266 | if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { |
ctornqvi@4885 | 267 | addr = (jlong)(uintptr_t)os::reserve_memory(size); |
ctornqvi@4885 | 268 | MemTracker::record_virtual_memory_type((address)addr, mtTest); |
ctornqvi@4512 | 269 | } |
ctornqvi@4512 | 270 | |
ctornqvi@4885 | 271 | return addr; |
ctornqvi@4885 | 272 | WB_END |
ctornqvi@4512 | 273 | |
ctornqvi@4885 | 274 | |
ctornqvi@4885 | 275 | WB_ENTRY(void, WB_NMTCommitMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) |
dcubed@5255 | 276 | os::commit_memory((char *)(uintptr_t)addr, size, !ExecMem); |
ctornqvi@4885 | 277 | MemTracker::record_virtual_memory_type((address)(uintptr_t)addr, mtTest); |
ctornqvi@4885 | 278 | WB_END |
ctornqvi@4885 | 279 | |
ctornqvi@4885 | 280 | WB_ENTRY(void, WB_NMTUncommitMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) |
ctornqvi@4885 | 281 | os::uncommit_memory((char *)(uintptr_t)addr, size); |
ctornqvi@4885 | 282 | WB_END |
ctornqvi@4885 | 283 | |
ctornqvi@4885 | 284 | WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) |
ctornqvi@4885 | 285 | os::release_memory((char *)(uintptr_t)addr, size); |
ctornqvi@4512 | 286 | WB_END |
ctornqvi@4512 | 287 | |
ctornqvi@4512 | 288 | // Block until the current generation of NMT data to be merged, used to reliably test the NMT feature |
ctornqvi@4512 | 289 | WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env)) |
ctornqvi@4512 | 290 | |
ctornqvi@4512 | 291 | if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { |
ctornqvi@4512 | 292 | return false; |
ctornqvi@4512 | 293 | } |
ctornqvi@4512 | 294 | |
ctornqvi@4512 | 295 | return MemTracker::wbtest_wait_for_data_merge(); |
ctornqvi@4512 | 296 | WB_END |
ctornqvi@4512 | 297 | |
cjplummer@5586 | 298 | WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env)) |
cjplummer@5586 | 299 | return MemTracker::tracking_level() == MemTracker::NMT_detail; |
cjplummer@5586 | 300 | WB_END |
cjplummer@5586 | 301 | |
ctornqvi@4512 | 302 | #endif // INCLUDE_NMT |
ctornqvi@4512 | 303 | |
iignatyev@4592 | 304 | static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { |
iignatyev@4592 | 305 | assert(method != NULL, "method should not be null"); |
iignatyev@4592 | 306 | ThreadToNativeFromVM ttn(thread); |
iignatyev@4592 | 307 | return env->FromReflectedMethod(method); |
iignatyev@4592 | 308 | } |
iignatyev@4592 | 309 | |
iignatyev@4592 | 310 | WB_ENTRY(void, WB_DeoptimizeAll(JNIEnv* env, jobject o)) |
iignatyev@4592 | 311 | MutexLockerEx mu(Compile_lock); |
iignatyev@4592 | 312 | CodeCache::mark_all_nmethods_for_deoptimization(); |
iignatyev@4592 | 313 | VM_Deoptimize op; |
iignatyev@4592 | 314 | VMThread::execute(&op); |
iignatyev@4592 | 315 | WB_END |
iignatyev@4592 | 316 | |
iignatyev@5541 | 317 | WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) |
iignatyev@4592 | 318 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4592 | 319 | MutexLockerEx mu(Compile_lock); |
iignatyev@4592 | 320 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@4592 | 321 | int result = 0; |
iignatyev@5541 | 322 | nmethod* code; |
iignatyev@5541 | 323 | if (is_osr) { |
iignatyev@5541 | 324 | int bci = InvocationEntryBci; |
iignatyev@5541 | 325 | while ((code = mh->lookup_osr_nmethod_for(bci, CompLevel_none, false)) != NULL) { |
iignatyev@5541 | 326 | code->mark_for_deoptimization(); |
iignatyev@5541 | 327 | ++result; |
iignatyev@5541 | 328 | bci = code->osr_entry_bci() + 1; |
iignatyev@5541 | 329 | } |
iignatyev@5541 | 330 | } else { |
iignatyev@5541 | 331 | code = mh->code(); |
iignatyev@5541 | 332 | } |
iignatyev@4592 | 333 | if (code != NULL) { |
iignatyev@4592 | 334 | code->mark_for_deoptimization(); |
iignatyev@4592 | 335 | ++result; |
iignatyev@4592 | 336 | } |
iignatyev@4592 | 337 | result += CodeCache::mark_for_deoptimization(mh()); |
iignatyev@4592 | 338 | if (result > 0) { |
iignatyev@4592 | 339 | VM_Deoptimize op; |
iignatyev@4592 | 340 | VMThread::execute(&op); |
iignatyev@4592 | 341 | } |
iignatyev@4592 | 342 | return result; |
iignatyev@4592 | 343 | WB_END |
iignatyev@4592 | 344 | |
iignatyev@5541 | 345 | WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) |
iignatyev@4592 | 346 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4592 | 347 | MutexLockerEx mu(Compile_lock); |
iignatyev@4592 | 348 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@5541 | 349 | nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); |
iignatyev@4592 | 350 | if (code == NULL) { |
iignatyev@4592 | 351 | return JNI_FALSE; |
iignatyev@4592 | 352 | } |
iignatyev@4592 | 353 | return (code->is_alive() && !code->is_marked_for_deoptimization()); |
iignatyev@4592 | 354 | WB_END |
iignatyev@4592 | 355 | |
iignatyev@5541 | 356 | WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) |
iignatyev@4592 | 357 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4592 | 358 | MutexLockerEx mu(Compile_lock); |
iignatyev@4592 | 359 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@5541 | 360 | if (is_osr) { |
iignatyev@5541 | 361 | return CompilationPolicy::can_be_osr_compiled(mh, comp_level); |
iignatyev@5541 | 362 | } else { |
iignatyev@5541 | 363 | return CompilationPolicy::can_be_compiled(mh, comp_level); |
iignatyev@5541 | 364 | } |
iignatyev@4592 | 365 | WB_END |
iignatyev@4592 | 366 | |
iignatyev@4592 | 367 | WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method)) |
iignatyev@4592 | 368 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4592 | 369 | MutexLockerEx mu(Compile_lock); |
iignatyev@4592 | 370 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@4592 | 371 | return mh->queued_for_compilation(); |
iignatyev@4592 | 372 | WB_END |
iignatyev@4592 | 373 | |
iignatyev@5541 | 374 | WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) |
iignatyev@4592 | 375 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4592 | 376 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@5541 | 377 | nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); |
iignatyev@4592 | 378 | return (code != NULL ? code->comp_level() : CompLevel_none); |
iignatyev@4592 | 379 | WB_END |
iignatyev@4592 | 380 | |
iignatyev@5541 | 381 | WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) |
iignatyev@4592 | 382 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4592 | 383 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@5541 | 384 | if (is_osr) { |
iignatyev@5541 | 385 | mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox"); |
iignatyev@5541 | 386 | } else { |
iignatyev@5541 | 387 | mh->set_not_compilable(comp_level, true /* report */, "WhiteBox"); |
iignatyev@5541 | 388 | } |
iignatyev@5541 | 389 | WB_END |
iignatyev@5541 | 390 | |
iignatyev@5541 | 391 | WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method)) |
iignatyev@5541 | 392 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@5541 | 393 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@5541 | 394 | nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false); |
iignatyev@5541 | 395 | return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci); |
iignatyev@4592 | 396 | WB_END |
iignatyev@4592 | 397 | |
iignatyev@4908 | 398 | WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) |
iignatyev@4592 | 399 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4592 | 400 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@4592 | 401 | bool result = mh->dont_inline(); |
iignatyev@4592 | 402 | mh->set_dont_inline(value == JNI_TRUE); |
iignatyev@4592 | 403 | return result; |
iignatyev@4592 | 404 | WB_END |
iignatyev@4592 | 405 | |
iignatyev@5541 | 406 | WB_ENTRY(jint, WB_GetCompileQueueSize(JNIEnv* env, jobject o, jint comp_level)) |
iignatyev@5541 | 407 | if (comp_level == CompLevel_any) { |
iignatyev@5541 | 408 | return CompileBroker::queue_size(CompLevel_full_optimization) /* C2 */ + |
iignatyev@5541 | 409 | CompileBroker::queue_size(CompLevel_full_profile) /* C1 */; |
iignatyev@5541 | 410 | } else { |
iignatyev@5541 | 411 | return CompileBroker::queue_size(comp_level); |
iignatyev@5541 | 412 | } |
iignatyev@4592 | 413 | WB_END |
iignatyev@4592 | 414 | |
iignatyev@4908 | 415 | WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) |
iignatyev@4908 | 416 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4908 | 417 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@4908 | 418 | bool result = mh->force_inline(); |
iignatyev@4908 | 419 | mh->set_force_inline(value == JNI_TRUE); |
iignatyev@4908 | 420 | return result; |
iignatyev@4908 | 421 | WB_END |
iignatyev@4908 | 422 | |
iignatyev@5541 | 423 | WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci)) |
iignatyev@4908 | 424 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4908 | 425 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@5541 | 426 | nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD); |
iignatyev@4908 | 427 | MutexLockerEx mu(Compile_lock); |
iignatyev@4908 | 428 | return (mh->queued_for_compilation() || nm != NULL); |
iignatyev@4908 | 429 | WB_END |
iignatyev@4908 | 430 | |
iignatyev@4908 | 431 | WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) |
iignatyev@4908 | 432 | jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
iignatyev@4908 | 433 | methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
iignatyev@4908 | 434 | MutexLockerEx mu(Compile_lock); |
iignatyev@4908 | 435 | MethodData* mdo = mh->method_data(); |
jiangli@4938 | 436 | MethodCounters* mcs = mh->method_counters(); |
iignatyev@4908 | 437 | |
iignatyev@4908 | 438 | if (mdo != NULL) { |
iignatyev@4908 | 439 | mdo->init(); |
iignatyev@4908 | 440 | ResourceMark rm; |
iignatyev@4908 | 441 | int arg_count = mdo->method()->size_of_parameters(); |
iignatyev@4908 | 442 | for (int i = 0; i < arg_count; i++) { |
iignatyev@4908 | 443 | mdo->set_arg_modified(i, 0); |
iignatyev@4908 | 444 | } |
iignatyev@4908 | 445 | } |
iignatyev@4908 | 446 | |
iignatyev@4908 | 447 | mh->clear_not_c1_compilable(); |
iignatyev@4908 | 448 | mh->clear_not_c2_compilable(); |
iignatyev@4908 | 449 | mh->clear_not_c2_osr_compilable(); |
iignatyev@4908 | 450 | NOT_PRODUCT(mh->set_compiled_invocation_count(0)); |
jiangli@4938 | 451 | if (mcs != NULL) { |
jiangli@4938 | 452 | mcs->backedge_counter()->init(); |
jiangli@4938 | 453 | mcs->invocation_counter()->init(); |
jiangli@4938 | 454 | mcs->set_interpreter_invocation_count(0); |
jiangli@4938 | 455 | mcs->set_interpreter_throwout_count(0); |
iignatyev@4908 | 456 | |
iignatyev@4908 | 457 | #ifdef TIERED |
jiangli@4938 | 458 | mcs->set_rate(0.0F); |
jiangli@4938 | 459 | mh->set_prev_event_count(0, THREAD); |
jiangli@4938 | 460 | mh->set_prev_time(0, THREAD); |
iignatyev@4908 | 461 | #endif |
jiangli@4938 | 462 | } |
iignatyev@4908 | 463 | WB_END |
iignatyev@4908 | 464 | |
mgerdin@4850 | 465 | WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString)) |
mgerdin@4850 | 466 | ResourceMark rm(THREAD); |
mgerdin@4850 | 467 | int len; |
hseigel@4987 | 468 | jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false); |
hseigel@4987 | 469 | return (StringTable::lookup(name, len) != NULL); |
mgerdin@4850 | 470 | WB_END |
mgerdin@4850 | 471 | |
mgerdin@4850 | 472 | WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) |
mgerdin@4850 | 473 | Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true); |
mgerdin@4850 | 474 | Universe::heap()->collect(GCCause::_last_ditch_collection); |
mgerdin@4850 | 475 | WB_END |
mgerdin@4850 | 476 | |
mikael@4989 | 477 | |
mikael@5174 | 478 | WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o)) |
mikael@5174 | 479 | // static+volatile in order to force the read to happen |
mikael@5174 | 480 | // (not be eliminated by the compiler) |
mikael@5174 | 481 | static char c; |
mikael@5174 | 482 | static volatile char* p; |
mikael@5174 | 483 | |
mikael@5174 | 484 | p = os::reserve_memory(os::vm_allocation_granularity(), NULL, 0); |
mikael@5174 | 485 | if (p == NULL) { |
mikael@5174 | 486 | THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "Failed to reserve memory"); |
mikael@5174 | 487 | } |
mikael@5174 | 488 | |
mikael@5174 | 489 | c = *p; |
mikael@4989 | 490 | WB_END |
mikael@4989 | 491 | |
nloodin@3681 | 492 | //Some convenience methods to deal with objects from java |
nloodin@3681 | 493 | int WhiteBox::offset_for_field(const char* field_name, oop object, |
nloodin@3681 | 494 | Symbol* signature_symbol) { |
nloodin@3681 | 495 | assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); |
nloodin@3681 | 496 | Thread* THREAD = Thread::current(); |
nloodin@3681 | 497 | |
nloodin@3681 | 498 | //Get the class of our object |
coleenp@4037 | 499 | Klass* arg_klass = object->klass(); |
nloodin@3681 | 500 | //Turn it into an instance-klass |
coleenp@4037 | 501 | InstanceKlass* ik = InstanceKlass::cast(arg_klass); |
nloodin@3681 | 502 | |
nloodin@3681 | 503 | //Create symbols to look for in the class |
nloodin@3681 | 504 | TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name), |
nloodin@3681 | 505 | THREAD); |
nloodin@3681 | 506 | |
nloodin@3681 | 507 | //To be filled in with an offset of the field we're looking for |
nloodin@3681 | 508 | fieldDescriptor fd; |
nloodin@3681 | 509 | |
coleenp@4037 | 510 | Klass* res = ik->find_field(name_symbol, signature_symbol, &fd); |
nloodin@3681 | 511 | if (res == NULL) { |
nloodin@3681 | 512 | tty->print_cr("Invalid layout of %s at %s", ik->external_name(), |
nloodin@3681 | 513 | name_symbol->as_C_string()); |
nloodin@3681 | 514 | fatal("Invalid layout of preloaded class"); |
nloodin@3681 | 515 | } |
nloodin@3681 | 516 | |
nloodin@3681 | 517 | //fetch the field at the offset we've found |
nloodin@3681 | 518 | int dest_offset = fd.offset(); |
nloodin@3681 | 519 | |
nloodin@3681 | 520 | return dest_offset; |
nloodin@3681 | 521 | } |
nloodin@3681 | 522 | |
nloodin@3681 | 523 | |
nloodin@3681 | 524 | const char* WhiteBox::lookup_jstring(const char* field_name, oop object) { |
nloodin@3681 | 525 | int offset = offset_for_field(field_name, object, |
nloodin@3681 | 526 | vmSymbols::string_signature()); |
nloodin@3681 | 527 | oop string = object->obj_field(offset); |
sla@3905 | 528 | if (string == NULL) { |
sla@3905 | 529 | return NULL; |
sla@3905 | 530 | } |
nloodin@3681 | 531 | const char* ret = java_lang_String::as_utf8_string(string); |
nloodin@3681 | 532 | return ret; |
nloodin@3681 | 533 | } |
nloodin@3681 | 534 | |
nloodin@3681 | 535 | bool WhiteBox::lookup_bool(const char* field_name, oop object) { |
nloodin@3681 | 536 | int offset = |
nloodin@3681 | 537 | offset_for_field(field_name, object, vmSymbols::bool_signature()); |
nloodin@3681 | 538 | bool ret = (object->bool_field(offset) == JNI_TRUE); |
nloodin@3681 | 539 | return ret; |
nloodin@3681 | 540 | } |
nloodin@3681 | 541 | |
nloodin@3681 | 542 | |
mgerdin@3619 | 543 | #define CC (char*) |
mgerdin@3619 | 544 | |
mgerdin@3619 | 545 | static JNINativeMethod methods[] = { |
mgerdin@3619 | 546 | {CC"getObjectAddress", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, |
mgerdin@3619 | 547 | {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, |
iignatyev@4592 | 548 | {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, |
iignatyev@4592 | 549 | {CC"parseCommandLine", |
iignatyev@4592 | 550 | CC"(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;", |
nloodin@3681 | 551 | (void*) &WB_ParseCommandLine |
nloodin@3681 | 552 | }, |
tschatzl@5701 | 553 | {CC"getCompressedOopsMaxHeapSize", CC"()J", |
tschatzl@5701 | 554 | (void*)&WB_GetCompressedOopsMaxHeapSize}, |
tschatzl@5073 | 555 | {CC"printHeapSizes", CC"()V", (void*)&WB_PrintHeapSizes }, |
mgerdin@6078 | 556 | {CC"runMemoryUnitTests", CC"()V", (void*)&WB_RunMemoryUnitTests}, |
mgerdin@6078 | 557 | {CC"readFromNoaccessArea",CC"()V", (void*)&WB_ReadFromNoaccessArea}, |
mgerdin@6078 | 558 | {CC"stressVirtualSpaceResize",CC"(JJJ)I", (void*)&WB_StressVirtualSpaceResize}, |
jprovino@4542 | 559 | #if INCLUDE_ALL_GCS |
mgerdin@3619 | 560 | {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark}, |
mgerdin@3619 | 561 | {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous }, |
mgerdin@3619 | 562 | {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions }, |
mgerdin@3619 | 563 | {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize }, |
jprovino@4542 | 564 | #endif // INCLUDE_ALL_GCS |
cjplummer@5586 | 565 | #if INCLUDE_NMT |
ctornqvi@4885 | 566 | {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, |
ctornqvi@4885 | 567 | {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, |
ctornqvi@4885 | 568 | {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, |
ctornqvi@4885 | 569 | {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory }, |
ctornqvi@4885 | 570 | {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory }, |
ctornqvi@4885 | 571 | {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, |
ctornqvi@4885 | 572 | {CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge}, |
cjplummer@5586 | 573 | {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, |
ctornqvi@4512 | 574 | #endif // INCLUDE_NMT |
iignatyev@4592 | 575 | {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, |
iignatyev@5541 | 576 | {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I", |
iignatyev@4592 | 577 | (void*)&WB_DeoptimizeMethod }, |
iignatyev@5541 | 578 | {CC"isMethodCompiled", CC"(Ljava/lang/reflect/Executable;Z)Z", |
iignatyev@4592 | 579 | (void*)&WB_IsMethodCompiled }, |
iignatyev@5541 | 580 | {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Executable;IZ)Z", |
iignatyev@4592 | 581 | (void*)&WB_IsMethodCompilable}, |
iignatyev@4592 | 582 | {CC"isMethodQueuedForCompilation", |
iignatyev@4951 | 583 | CC"(Ljava/lang/reflect/Executable;)Z", (void*)&WB_IsMethodQueuedForCompilation}, |
iignatyev@4592 | 584 | {CC"makeMethodNotCompilable", |
iignatyev@5541 | 585 | CC"(Ljava/lang/reflect/Executable;IZ)V", (void*)&WB_MakeMethodNotCompilable}, |
iignatyev@4908 | 586 | {CC"testSetDontInlineMethod", |
iignatyev@4951 | 587 | CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_TestSetDontInlineMethod}, |
iignatyev@4592 | 588 | {CC"getMethodCompilationLevel", |
iignatyev@5541 | 589 | CC"(Ljava/lang/reflect/Executable;Z)I", (void*)&WB_GetMethodCompilationLevel}, |
iignatyev@5541 | 590 | {CC"getMethodEntryBci", |
iignatyev@5541 | 591 | CC"(Ljava/lang/reflect/Executable;)I", (void*)&WB_GetMethodEntryBci}, |
iignatyev@5541 | 592 | {CC"getCompileQueueSize", |
iignatyev@5541 | 593 | CC"(I)I", (void*)&WB_GetCompileQueueSize}, |
iignatyev@4908 | 594 | {CC"testSetForceInlineMethod", |
iignatyev@4951 | 595 | CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_TestSetForceInlineMethod}, |
iignatyev@4908 | 596 | {CC"enqueueMethodForCompilation", |
iignatyev@5541 | 597 | CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation}, |
iignatyev@4908 | 598 | {CC"clearMethodState", |
iignatyev@4951 | 599 | CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, |
mgerdin@4850 | 600 | {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, |
mgerdin@4850 | 601 | {CC"fullGC", CC"()V", (void*)&WB_FullGC }, |
mikael@5174 | 602 | {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, |
mgerdin@3619 | 603 | }; |
mgerdin@3619 | 604 | |
mgerdin@3619 | 605 | #undef CC |
mgerdin@3619 | 606 | |
mgerdin@3619 | 607 | JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) |
mgerdin@3619 | 608 | { |
mgerdin@3619 | 609 | if (WhiteBoxAPI) { |
mgerdin@3619 | 610 | // Make sure that wbclass is loaded by the null classloader |
mgerdin@3619 | 611 | instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass()); |
mgerdin@3619 | 612 | Handle loader(ikh->class_loader()); |
mgerdin@3619 | 613 | if (loader.is_null()) { |
iignatyev@5028 | 614 | ResourceMark rm; |
mgerdin@3619 | 615 | ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI |
iignatyev@5028 | 616 | bool result = true; |
iignatyev@5028 | 617 | // one by one registration natives for exception catching |
iignatyev@5028 | 618 | jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string()); |
iignatyev@5028 | 619 | for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) { |
iignatyev@5028 | 620 | if (env->RegisterNatives(wbclass, methods + i, 1) != 0) { |
iignatyev@5028 | 621 | result = false; |
iignatyev@5028 | 622 | if (env->ExceptionCheck() && env->IsInstanceOf(env->ExceptionOccurred(), exceptionKlass)) { |
iignatyev@5028 | 623 | // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native |
iignatyev@5028 | 624 | // ignoring the exception |
iignatyev@5028 | 625 | tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature); |
iignatyev@5028 | 626 | env->ExceptionClear(); |
iignatyev@5028 | 627 | } else { |
iignatyev@5028 | 628 | // register is failed w/o exception or w/ unexpected exception |
iignatyev@5028 | 629 | tty->print_cr("Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered", methods[i].name, methods[i].signature); |
iignatyev@5028 | 630 | env->UnregisterNatives(wbclass); |
iignatyev@5028 | 631 | break; |
iignatyev@5028 | 632 | } |
iignatyev@5028 | 633 | } |
iignatyev@5028 | 634 | } |
iignatyev@5028 | 635 | |
iignatyev@5028 | 636 | if (result) { |
mgerdin@3619 | 637 | WhiteBox::set_used(); |
mgerdin@3619 | 638 | } |
mgerdin@3619 | 639 | } |
mgerdin@3619 | 640 | } |
mgerdin@3619 | 641 | } |
mgerdin@3619 | 642 | JVM_END |