< prev index next >

src/share/vm/prims/whitebox.cpp

Print this page
rev 7508 : 8028595: WhiteBox API for stress testing of TieredCompilation
Reviewed-by:

@@ -67,10 +67,18 @@
 #define SIZE_T_MAX_VALUE ((size_t) -1)
 
 bool WhiteBox::_used = false;
 volatile bool WhiteBox::compilation_locked = false;
 
+class VM_WhiteBoxOperation : public VM_Operation {
+ public:
+  VM_WhiteBoxOperation()                         { }
+  VMOp_Type type()                  const        { return VMOp_WhiteBoxOperation; }
+  bool allow_nested_vm_operations() const        { return true; }
+};
+
+
 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj))
   return (jlong)(void*)JNIHandles::resolve(obj);
 WB_END
 
 WB_ENTRY(jint, WB_GetHeapOopSize(JNIEnv* env, jobject o))

@@ -402,10 +410,47 @@
   assert(method != NULL, "method should not be null");
   ThreadToNativeFromVM ttn(thread);
   return env->FromReflectedMethod(method);
 }
 
+// Deoptimizes all compiled frames and makes nmethods not entrant if it's requested
+class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation {
+ private:
+  int _result;
+  const bool _make_not_entrant;
+ public:
+  VM_WhiteBoxDeoptimizeFrames(bool make_not_entrant) :
+        _result(0), _make_not_entrant(make_not_entrant) { }
+  int  result() const { return _result; }
+
+  void doit() {
+    for (JavaThread* t = Threads::first(); t != NULL; t = t->next()) {
+      if (t->has_last_Java_frame()) {
+        for (StackFrameStream fst(t, UseBiasedLocking); !fst.is_done(); fst.next()) {
+          frame* f = fst.current();
+          if (f->can_be_deoptimized() && !f->is_deoptimized_frame()) {
+            RegisterMap* reg_map = fst.register_map();
+            Deoptimization::deoptimize(t, *f, reg_map);
+            if (_make_not_entrant) {
+                nmethod* nm = CodeCache::find_nmethod(f->pc());
+                assert(nm != NULL, "sanity check");
+                nm->make_not_entrant();
+            }
+            ++_result;
+          }
+        }
+      }
+    }
+  }
+};
+
+WB_ENTRY(jint, WB_DeoptimizeFrames(JNIEnv* env, jobject o, jboolean make_not_entrant))
+  VM_WhiteBoxDeoptimizeFrames op(make_not_entrant);
+  VMThread::execute(&op);
+  return op.result();
+WB_END
+
 WB_ENTRY(void, WB_DeoptimizeAll(JNIEnv* env, jobject o))
   MutexLockerEx mu(Compile_lock);
   CodeCache::mark_all_nmethods_for_deoptimization();
   VM_Deoptimize op;
   VMThread::execute(&op);

@@ -524,17 +569,10 @@
   nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
   MutexLockerEx mu(Compile_lock);
   return (mh->queued_for_compilation() || nm != NULL);
 WB_END
 
-class VM_WhiteBoxOperation : public VM_Operation {
- public:
-  VM_WhiteBoxOperation()                         { }
-  VMOp_Type type()                  const        { return VMOp_WhiteBoxOperation; }
-  bool allow_nested_vm_operations() const        { return true; }
-};
-
 class AlwaysFalseClosure : public BoolObjectClosure {
  public:
   bool do_object_b(oop p) { return false; }
 };
 

@@ -759,11 +797,10 @@
   if (needFree) {
     FREE_C_HEAP_ARRAY(char, ccstrResult);
   }
 WB_END
 
-
 WB_ENTRY(void, WB_LockCompilation(JNIEnv* env, jobject o, jlong timeout))
   WhiteBox::compilation_locked = true;
 WB_END
 
 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))

@@ -1199,10 +1236,11 @@
   {CC"NMTReleaseMemory",    CC"(JJ)V",                (void*)&WB_NMTReleaseMemory   },
   {CC"NMTIsDetailSupported",CC"()Z",                  (void*)&WB_NMTIsDetailSupported},
   {CC"NMTChangeTrackingLevel", CC"()Z",               (void*)&WB_NMTChangeTrackingLevel},
   {CC"NMTGetHashSize",      CC"()I",                  (void*)&WB_NMTGetHashSize     },
 #endif // INCLUDE_NMT
+  {CC"deoptimizeFrames",   CC"(Z)I",                  (void*)&WB_DeoptimizeFrames  },
   {CC"deoptimizeAll",      CC"()V",                   (void*)&WB_DeoptimizeAll     },
   {CC"deoptimizeMethod",   CC"(Ljava/lang/reflect/Executable;Z)I",
                                                       (void*)&WB_DeoptimizeMethod  },
   {CC"isMethodCompiled",   CC"(Ljava/lang/reflect/Executable;Z)Z",
                                                       (void*)&WB_IsMethodCompiled  },
< prev index next >