src/share/vm/prims/whitebox.cpp

Tue, 02 Apr 2013 11:28:33 +0200

author
mgerdin
date
Tue, 02 Apr 2013 11:28:33 +0200
changeset 4850
ede380e13960
parent 4592
12e01444ca2d
child 4885
3b890cd4da64
child 4908
b84fd7d73702
permissions
-rw-r--r--

8009763: Add WB test for String.intern()
Summary: Add convenience method in StringTable, add WhiteBox method and simple sanity test
Reviewed-by: mgerdin, zgu
Contributed-by: leonid.mesnik@oracle.com

mgerdin@3619 1 /*
mgerdin@3619 2 * Copyright (c) 2012, 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
mgerdin@3619 36 #include "runtime/interfaceSupport.hpp"
mgerdin@3619 37 #include "runtime/os.hpp"
mgerdin@3619 38 #include "utilities/debug.hpp"
jprovino@4542 39 #include "utilities/macros.hpp"
mgerdin@3619 40
jprovino@4542 41 #if INCLUDE_ALL_GCS
mgerdin@3619 42 #include "gc_implementation/g1/concurrentMark.hpp"
mgerdin@3619 43 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
mgerdin@3619 44 #include "gc_implementation/g1/heapRegionRemSet.hpp"
jprovino@4542 45 #endif // INCLUDE_ALL_GCS
mgerdin@3619 46
ctornqvi@4512 47 #ifdef INCLUDE_NMT
ctornqvi@4512 48 #include "services/memTracker.hpp"
ctornqvi@4512 49 #endif // INCLUDE_NMT
ctornqvi@4512 50
iignatyev@4592 51 #include "compiler/compileBroker.hpp"
iignatyev@4592 52
mgerdin@3619 53 bool WhiteBox::_used = false;
mgerdin@3619 54
mgerdin@3619 55 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj))
mgerdin@3619 56 return (jlong)(void*)JNIHandles::resolve(obj);
mgerdin@3619 57 WB_END
mgerdin@3619 58
mgerdin@3619 59 WB_ENTRY(jint, WB_GetHeapOopSize(JNIEnv* env, jobject o))
mgerdin@3619 60 return heapOopSize;
mgerdin@3619 61 WB_END
mgerdin@3619 62
coleenp@4037 63
coleenp@4037 64 class WBIsKlassAliveClosure : public KlassClosure {
coleenp@4037 65 Symbol* _name;
coleenp@4037 66 bool _found;
coleenp@4037 67 public:
coleenp@4037 68 WBIsKlassAliveClosure(Symbol* name) : _name(name), _found(false) {}
coleenp@4037 69
coleenp@4037 70 void do_klass(Klass* k) {
coleenp@4037 71 if (_found) return;
coleenp@4037 72 Symbol* ksym = k->name();
coleenp@4037 73 if (ksym->fast_compare(_name) == 0) {
coleenp@4037 74 _found = true;
coleenp@4037 75 }
coleenp@4037 76 }
coleenp@4037 77
coleenp@4037 78 bool found() const {
coleenp@4037 79 return _found;
coleenp@4037 80 }
coleenp@4037 81 };
coleenp@4037 82
coleenp@4037 83 WB_ENTRY(jboolean, WB_IsClassAlive(JNIEnv* env, jobject target, jstring name))
coleenp@4037 84 Handle h_name = JNIHandles::resolve(name);
coleenp@4037 85 if (h_name.is_null()) return false;
coleenp@4037 86 Symbol* sym = java_lang_String::as_symbol(h_name, CHECK_false);
coleenp@4037 87 TempNewSymbol tsym(sym); // Make sure to decrement reference count on sym on return
coleenp@4037 88
coleenp@4037 89 WBIsKlassAliveClosure closure(sym);
coleenp@4037 90 ClassLoaderDataGraph::classes_do(&closure);
coleenp@4037 91
coleenp@4037 92 return closure.found();
coleenp@4037 93 WB_END
coleenp@4037 94
jprovino@4542 95 #if INCLUDE_ALL_GCS
mgerdin@3619 96 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj))
mgerdin@3619 97 G1CollectedHeap* g1 = G1CollectedHeap::heap();
mgerdin@3619 98 oop result = JNIHandles::resolve(obj);
mgerdin@3619 99 const HeapRegion* hr = g1->heap_region_containing(result);
mgerdin@3619 100 return hr->isHumongous();
mgerdin@3619 101 WB_END
mgerdin@3619 102
mgerdin@3619 103 WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
mgerdin@3619 104 G1CollectedHeap* g1 = G1CollectedHeap::heap();
mgerdin@3619 105 size_t nr = g1->free_regions();
mgerdin@3619 106 return (jlong)nr;
mgerdin@3619 107 WB_END
mgerdin@3619 108
mgerdin@3619 109 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
mgerdin@3619 110 G1CollectedHeap* g1 = G1CollectedHeap::heap();
mgerdin@3619 111 ConcurrentMark* cm = g1->concurrent_mark();
mgerdin@3619 112 return cm->concurrent_marking_in_progress();
mgerdin@3619 113 WB_END
mgerdin@3619 114
mgerdin@3619 115 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
mgerdin@3619 116 return (jint)HeapRegion::GrainBytes;
mgerdin@3619 117 WB_END
jprovino@4542 118 #endif // INCLUDE_ALL_GCS
mgerdin@3619 119
ctornqvi@4512 120 #ifdef INCLUDE_NMT
ctornqvi@4512 121 // Keep track of the 3 allocations in NMTAllocTest so we can free them later
ctornqvi@4512 122 // on and verify that they're not visible anymore
ctornqvi@4512 123 static void* nmtMtTest1 = NULL, *nmtMtTest2 = NULL, *nmtMtTest3 = NULL;
ctornqvi@4512 124
ctornqvi@4512 125 // Alloc memory using the test memory type so that we can use that to see if
ctornqvi@4512 126 // NMT picks it up correctly
ctornqvi@4512 127 WB_ENTRY(jboolean, WB_NMTAllocTest(JNIEnv* env))
ctornqvi@4512 128 void *mem;
ctornqvi@4512 129
ctornqvi@4512 130 if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) {
ctornqvi@4512 131 return false;
ctornqvi@4512 132 }
ctornqvi@4512 133
ctornqvi@4512 134 // Allocate 2 * 128k + 256k + 1024k and free the 1024k one to make sure we track
ctornqvi@4512 135 // everything correctly. Total should be 512k held alive.
ctornqvi@4512 136 nmtMtTest1 = os::malloc(128 * 1024, mtTest);
ctornqvi@4512 137 mem = os::malloc(1024 * 1024, mtTest);
ctornqvi@4512 138 nmtMtTest2 = os::malloc(256 * 1024, mtTest);
ctornqvi@4512 139 os::free(mem, mtTest);
ctornqvi@4512 140 nmtMtTest3 = os::malloc(128 * 1024, mtTest);
ctornqvi@4512 141
ctornqvi@4512 142 return true;
ctornqvi@4512 143 WB_END
ctornqvi@4512 144
ctornqvi@4512 145 // Free the memory allocated by NMTAllocTest
ctornqvi@4512 146 WB_ENTRY(jboolean, WB_NMTFreeTestMemory(JNIEnv* env))
ctornqvi@4512 147
ctornqvi@4512 148 if (nmtMtTest1 == NULL || nmtMtTest2 == NULL || nmtMtTest3 == NULL) {
ctornqvi@4512 149 return false;
ctornqvi@4512 150 }
ctornqvi@4512 151
ctornqvi@4512 152 os::free(nmtMtTest1, mtTest);
ctornqvi@4512 153 nmtMtTest1 = NULL;
ctornqvi@4512 154 os::free(nmtMtTest2, mtTest);
ctornqvi@4512 155 nmtMtTest2 = NULL;
ctornqvi@4512 156 os::free(nmtMtTest3, mtTest);
ctornqvi@4512 157 nmtMtTest3 = NULL;
ctornqvi@4512 158
ctornqvi@4512 159 return true;
ctornqvi@4512 160 WB_END
ctornqvi@4512 161
ctornqvi@4512 162 // Block until the current generation of NMT data to be merged, used to reliably test the NMT feature
ctornqvi@4512 163 WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env))
ctornqvi@4512 164
ctornqvi@4512 165 if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) {
ctornqvi@4512 166 return false;
ctornqvi@4512 167 }
ctornqvi@4512 168
ctornqvi@4512 169 return MemTracker::wbtest_wait_for_data_merge();
ctornqvi@4512 170 WB_END
ctornqvi@4512 171
ctornqvi@4512 172 #endif // INCLUDE_NMT
ctornqvi@4512 173
iignatyev@4592 174 static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) {
iignatyev@4592 175 assert(method != NULL, "method should not be null");
iignatyev@4592 176 ThreadToNativeFromVM ttn(thread);
iignatyev@4592 177 return env->FromReflectedMethod(method);
iignatyev@4592 178 }
iignatyev@4592 179
iignatyev@4592 180 WB_ENTRY(void, WB_DeoptimizeAll(JNIEnv* env, jobject o))
iignatyev@4592 181 MutexLockerEx mu(Compile_lock);
iignatyev@4592 182 CodeCache::mark_all_nmethods_for_deoptimization();
iignatyev@4592 183 VM_Deoptimize op;
iignatyev@4592 184 VMThread::execute(&op);
iignatyev@4592 185 WB_END
iignatyev@4592 186
iignatyev@4592 187 WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method))
iignatyev@4592 188 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
iignatyev@4592 189 MutexLockerEx mu(Compile_lock);
iignatyev@4592 190 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
iignatyev@4592 191 int result = 0;
iignatyev@4592 192 nmethod* code = mh->code();
iignatyev@4592 193 if (code != NULL) {
iignatyev@4592 194 code->mark_for_deoptimization();
iignatyev@4592 195 ++result;
iignatyev@4592 196 }
iignatyev@4592 197 result += CodeCache::mark_for_deoptimization(mh());
iignatyev@4592 198 if (result > 0) {
iignatyev@4592 199 VM_Deoptimize op;
iignatyev@4592 200 VMThread::execute(&op);
iignatyev@4592 201 }
iignatyev@4592 202 return result;
iignatyev@4592 203 WB_END
iignatyev@4592 204
iignatyev@4592 205 WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method))
iignatyev@4592 206 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
iignatyev@4592 207 MutexLockerEx mu(Compile_lock);
iignatyev@4592 208 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
iignatyev@4592 209 nmethod* code = mh->code();
iignatyev@4592 210 if (code == NULL) {
iignatyev@4592 211 return JNI_FALSE;
iignatyev@4592 212 }
iignatyev@4592 213 return (code->is_alive() && !code->is_marked_for_deoptimization());
iignatyev@4592 214 WB_END
iignatyev@4592 215
iignatyev@4592 216 WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method))
iignatyev@4592 217 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
iignatyev@4592 218 MutexLockerEx mu(Compile_lock);
iignatyev@4592 219 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
iignatyev@4592 220 return !mh->is_not_compilable();
iignatyev@4592 221 WB_END
iignatyev@4592 222
iignatyev@4592 223 WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method))
iignatyev@4592 224 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
iignatyev@4592 225 MutexLockerEx mu(Compile_lock);
iignatyev@4592 226 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
iignatyev@4592 227 return mh->queued_for_compilation();
iignatyev@4592 228 WB_END
iignatyev@4592 229
iignatyev@4592 230 WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method))
iignatyev@4592 231 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
iignatyev@4592 232 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
iignatyev@4592 233 nmethod* code = mh->code();
iignatyev@4592 234 return (code != NULL ? code->comp_level() : CompLevel_none);
iignatyev@4592 235 WB_END
iignatyev@4592 236
iignatyev@4592 237
iignatyev@4592 238 WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method))
iignatyev@4592 239 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
iignatyev@4592 240 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
iignatyev@4592 241 mh->set_not_compilable();
iignatyev@4592 242 WB_END
iignatyev@4592 243
iignatyev@4592 244 WB_ENTRY(jboolean, WB_SetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
iignatyev@4592 245 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
iignatyev@4592 246 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
iignatyev@4592 247 bool result = mh->dont_inline();
iignatyev@4592 248 mh->set_dont_inline(value == JNI_TRUE);
iignatyev@4592 249 return result;
iignatyev@4592 250 WB_END
iignatyev@4592 251
iignatyev@4592 252 WB_ENTRY(jint, WB_GetCompileQueuesSize(JNIEnv* env, jobject o))
iignatyev@4592 253 return CompileBroker::queue_size(CompLevel_full_optimization) /* C2 */ +
iignatyev@4592 254 CompileBroker::queue_size(CompLevel_full_profile) /* C1 */;
iignatyev@4592 255 WB_END
iignatyev@4592 256
mgerdin@4850 257 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
mgerdin@4850 258 ResourceMark rm(THREAD);
mgerdin@4850 259 int len;
mgerdin@4850 260 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len);
mgerdin@4850 261 oop found_string = StringTable::the_table()->lookup(name, len);
mgerdin@4850 262 if (found_string == NULL) {
mgerdin@4850 263 return false;
mgerdin@4850 264 }
mgerdin@4850 265 return true;
mgerdin@4850 266 WB_END
mgerdin@4850 267
mgerdin@4850 268
mgerdin@4850 269 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
mgerdin@4850 270 Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true);
mgerdin@4850 271 Universe::heap()->collect(GCCause::_last_ditch_collection);
mgerdin@4850 272 WB_END
mgerdin@4850 273
mgerdin@4850 274
nloodin@3681 275 //Some convenience methods to deal with objects from java
nloodin@3681 276 int WhiteBox::offset_for_field(const char* field_name, oop object,
nloodin@3681 277 Symbol* signature_symbol) {
nloodin@3681 278 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
nloodin@3681 279 Thread* THREAD = Thread::current();
nloodin@3681 280
nloodin@3681 281 //Get the class of our object
coleenp@4037 282 Klass* arg_klass = object->klass();
nloodin@3681 283 //Turn it into an instance-klass
coleenp@4037 284 InstanceKlass* ik = InstanceKlass::cast(arg_klass);
nloodin@3681 285
nloodin@3681 286 //Create symbols to look for in the class
nloodin@3681 287 TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name),
nloodin@3681 288 THREAD);
nloodin@3681 289
nloodin@3681 290 //To be filled in with an offset of the field we're looking for
nloodin@3681 291 fieldDescriptor fd;
nloodin@3681 292
coleenp@4037 293 Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);
nloodin@3681 294 if (res == NULL) {
nloodin@3681 295 tty->print_cr("Invalid layout of %s at %s", ik->external_name(),
nloodin@3681 296 name_symbol->as_C_string());
nloodin@3681 297 fatal("Invalid layout of preloaded class");
nloodin@3681 298 }
nloodin@3681 299
nloodin@3681 300 //fetch the field at the offset we've found
nloodin@3681 301 int dest_offset = fd.offset();
nloodin@3681 302
nloodin@3681 303 return dest_offset;
nloodin@3681 304 }
nloodin@3681 305
nloodin@3681 306
nloodin@3681 307 const char* WhiteBox::lookup_jstring(const char* field_name, oop object) {
nloodin@3681 308 int offset = offset_for_field(field_name, object,
nloodin@3681 309 vmSymbols::string_signature());
nloodin@3681 310 oop string = object->obj_field(offset);
sla@3905 311 if (string == NULL) {
sla@3905 312 return NULL;
sla@3905 313 }
nloodin@3681 314 const char* ret = java_lang_String::as_utf8_string(string);
nloodin@3681 315 return ret;
nloodin@3681 316 }
nloodin@3681 317
nloodin@3681 318 bool WhiteBox::lookup_bool(const char* field_name, oop object) {
nloodin@3681 319 int offset =
nloodin@3681 320 offset_for_field(field_name, object, vmSymbols::bool_signature());
nloodin@3681 321 bool ret = (object->bool_field(offset) == JNI_TRUE);
nloodin@3681 322 return ret;
nloodin@3681 323 }
nloodin@3681 324
nloodin@3681 325
mgerdin@3619 326 #define CC (char*)
mgerdin@3619 327
mgerdin@3619 328 static JNINativeMethod methods[] = {
mgerdin@3619 329 {CC"getObjectAddress", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress },
mgerdin@3619 330 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize },
iignatyev@4592 331 {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive },
iignatyev@4592 332 {CC"parseCommandLine",
iignatyev@4592 333 CC"(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
nloodin@3681 334 (void*) &WB_ParseCommandLine
nloodin@3681 335 },
jprovino@4542 336 #if INCLUDE_ALL_GCS
mgerdin@3619 337 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark},
mgerdin@3619 338 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous },
mgerdin@3619 339 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions },
mgerdin@3619 340 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize },
jprovino@4542 341 #endif // INCLUDE_ALL_GCS
ctornqvi@4512 342 #ifdef INCLUDE_NMT
ctornqvi@4512 343 {CC"NMTAllocTest", CC"()Z", (void*)&WB_NMTAllocTest },
ctornqvi@4512 344 {CC"NMTFreeTestMemory", CC"()Z", (void*)&WB_NMTFreeTestMemory },
ctornqvi@4512 345 {CC"NMTWaitForDataMerge",CC"()Z", (void*)&WB_NMTWaitForDataMerge},
ctornqvi@4512 346 #endif // INCLUDE_NMT
iignatyev@4592 347 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll },
iignatyev@4592 348 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Method;)I",
iignatyev@4592 349 (void*)&WB_DeoptimizeMethod },
iignatyev@4592 350 {CC"isMethodCompiled", CC"(Ljava/lang/reflect/Method;)Z",
iignatyev@4592 351 (void*)&WB_IsMethodCompiled },
iignatyev@4592 352 {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Method;)Z",
iignatyev@4592 353 (void*)&WB_IsMethodCompilable},
iignatyev@4592 354 {CC"isMethodQueuedForCompilation",
iignatyev@4592 355 CC"(Ljava/lang/reflect/Method;)Z", (void*)&WB_IsMethodQueuedForCompilation},
iignatyev@4592 356 {CC"makeMethodNotCompilable",
iignatyev@4592 357 CC"(Ljava/lang/reflect/Method;)V", (void*)&WB_MakeMethodNotCompilable},
iignatyev@4592 358 {CC"setDontInlineMethod",
iignatyev@4592 359 CC"(Ljava/lang/reflect/Method;Z)Z", (void*)&WB_SetDontInlineMethod},
iignatyev@4592 360 {CC"getMethodCompilationLevel",
iignatyev@4592 361 CC"(Ljava/lang/reflect/Method;)I", (void*)&WB_GetMethodCompilationLevel},
iignatyev@4592 362 {CC"getCompileQueuesSize",
iignatyev@4592 363 CC"()I", (void*)&WB_GetCompileQueuesSize},
mgerdin@4850 364 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable },
mgerdin@4850 365 {CC"fullGC", CC"()V", (void*)&WB_FullGC },
mgerdin@3619 366 };
mgerdin@3619 367
mgerdin@3619 368 #undef CC
mgerdin@3619 369
mgerdin@3619 370 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
mgerdin@3619 371 {
mgerdin@3619 372 if (WhiteBoxAPI) {
mgerdin@3619 373 // Make sure that wbclass is loaded by the null classloader
mgerdin@3619 374 instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass());
mgerdin@3619 375 Handle loader(ikh->class_loader());
mgerdin@3619 376 if (loader.is_null()) {
mgerdin@3619 377 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
mgerdin@3619 378 jint result = env->RegisterNatives(wbclass, methods, sizeof(methods)/sizeof(methods[0]));
mgerdin@3619 379 if (result == 0) {
mgerdin@3619 380 WhiteBox::set_used();
mgerdin@3619 381 }
mgerdin@3619 382 }
mgerdin@3619 383 }
mgerdin@3619 384 }
mgerdin@3619 385 JVM_END

mercurial