26 |
26 |
27 #include "memory/universe.hpp" |
27 #include "memory/universe.hpp" |
28 #include "oops/oop.inline.hpp" |
28 #include "oops/oop.inline.hpp" |
29 |
29 |
30 #include "classfile/symbolTable.hpp" |
30 #include "classfile/symbolTable.hpp" |
|
31 #include "classfile/classLoaderData.hpp" |
31 |
32 |
32 #include "prims/whitebox.hpp" |
33 #include "prims/whitebox.hpp" |
33 #include "prims/wbtestmethods/parserTests.hpp" |
34 #include "prims/wbtestmethods/parserTests.hpp" |
34 |
35 |
35 #include "runtime/interfaceSupport.hpp" |
36 #include "runtime/interfaceSupport.hpp" |
48 return (jlong)(void*)JNIHandles::resolve(obj); |
49 return (jlong)(void*)JNIHandles::resolve(obj); |
49 WB_END |
50 WB_END |
50 |
51 |
51 WB_ENTRY(jint, WB_GetHeapOopSize(JNIEnv* env, jobject o)) |
52 WB_ENTRY(jint, WB_GetHeapOopSize(JNIEnv* env, jobject o)) |
52 return heapOopSize; |
53 return heapOopSize; |
|
54 WB_END |
|
55 |
|
56 |
|
57 class WBIsKlassAliveClosure : public KlassClosure { |
|
58 Symbol* _name; |
|
59 bool _found; |
|
60 public: |
|
61 WBIsKlassAliveClosure(Symbol* name) : _name(name), _found(false) {} |
|
62 |
|
63 void do_klass(Klass* k) { |
|
64 if (_found) return; |
|
65 Symbol* ksym = k->name(); |
|
66 if (ksym->fast_compare(_name) == 0) { |
|
67 _found = true; |
|
68 } |
|
69 } |
|
70 |
|
71 bool found() const { |
|
72 return _found; |
|
73 } |
|
74 }; |
|
75 |
|
76 WB_ENTRY(jboolean, WB_IsClassAlive(JNIEnv* env, jobject target, jstring name)) |
|
77 Handle h_name = JNIHandles::resolve(name); |
|
78 if (h_name.is_null()) return false; |
|
79 Symbol* sym = java_lang_String::as_symbol(h_name, CHECK_false); |
|
80 TempNewSymbol tsym(sym); // Make sure to decrement reference count on sym on return |
|
81 |
|
82 WBIsKlassAliveClosure closure(sym); |
|
83 ClassLoaderDataGraph::classes_do(&closure); |
|
84 |
|
85 return closure.found(); |
53 WB_END |
86 WB_END |
54 |
87 |
55 #ifndef SERIALGC |
88 #ifndef SERIALGC |
56 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj)) |
89 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj)) |
57 G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
90 G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
82 Symbol* signature_symbol) { |
115 Symbol* signature_symbol) { |
83 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); |
116 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); |
84 Thread* THREAD = Thread::current(); |
117 Thread* THREAD = Thread::current(); |
85 |
118 |
86 //Get the class of our object |
119 //Get the class of our object |
87 klassOop arg_klass = object->klass(); |
120 Klass* arg_klass = object->klass(); |
88 //Turn it into an instance-klass |
121 //Turn it into an instance-klass |
89 instanceKlass* ik = instanceKlass::cast(arg_klass); |
122 InstanceKlass* ik = InstanceKlass::cast(arg_klass); |
90 |
123 |
91 //Create symbols to look for in the class |
124 //Create symbols to look for in the class |
92 TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name), |
125 TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name), |
93 THREAD); |
126 THREAD); |
94 |
127 |
95 //To be filled in with an offset of the field we're looking for |
128 //To be filled in with an offset of the field we're looking for |
96 fieldDescriptor fd; |
129 fieldDescriptor fd; |
97 |
130 |
98 klassOop res = ik->find_field(name_symbol, signature_symbol, &fd); |
131 Klass* res = ik->find_field(name_symbol, signature_symbol, &fd); |
99 if (res == NULL) { |
132 if (res == NULL) { |
100 tty->print_cr("Invalid layout of %s at %s", ik->external_name(), |
133 tty->print_cr("Invalid layout of %s at %s", ik->external_name(), |
101 name_symbol->as_C_string()); |
134 name_symbol->as_C_string()); |
102 fatal("Invalid layout of preloaded class"); |
135 fatal("Invalid layout of preloaded class"); |
103 } |
136 } |
131 #define CC (char*) |
164 #define CC (char*) |
132 |
165 |
133 static JNINativeMethod methods[] = { |
166 static JNINativeMethod methods[] = { |
134 {CC"getObjectAddress", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, |
167 {CC"getObjectAddress", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress }, |
135 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, |
168 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, |
|
169 {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, |
136 {CC "parseCommandLine", |
170 {CC "parseCommandLine", |
137 CC "(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;", |
171 CC "(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;", |
138 (void*) &WB_ParseCommandLine |
172 (void*) &WB_ParseCommandLine |
139 }, |
173 }, |
140 #ifndef SERIALGC |
174 #ifndef SERIALGC |