hotspot/src/share/vm/prims/whitebox.cpp
changeset 28203 905c60857879
parent 28163 322d55d167be
parent 28199 b7fb20a745f7
child 28393 18701d7781e7
child 28372 ce0aad4b8c44
equal deleted inserted replaced
28184:2ebaca4f00e2 28203:905c60857879
    67 #define SIZE_T_MAX_VALUE ((size_t) -1)
    67 #define SIZE_T_MAX_VALUE ((size_t) -1)
    68 
    68 
    69 bool WhiteBox::_used = false;
    69 bool WhiteBox::_used = false;
    70 volatile bool WhiteBox::compilation_locked = false;
    70 volatile bool WhiteBox::compilation_locked = false;
    71 
    71 
       
    72 class VM_WhiteBoxOperation : public VM_Operation {
       
    73  public:
       
    74   VM_WhiteBoxOperation()                         { }
       
    75   VMOp_Type type()                  const        { return VMOp_WhiteBoxOperation; }
       
    76   bool allow_nested_vm_operations() const        { return true; }
       
    77 };
       
    78 
       
    79 
    72 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj))
    80 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj))
    73   return (jlong)(void*)JNIHandles::resolve(obj);
    81   return (jlong)(void*)JNIHandles::resolve(obj);
    74 WB_END
    82 WB_END
    75 
    83 
    76 WB_ENTRY(jint, WB_GetHeapOopSize(JNIEnv* env, jobject o))
    84 WB_ENTRY(jint, WB_GetHeapOopSize(JNIEnv* env, jobject o))
   402   assert(method != NULL, "method should not be null");
   410   assert(method != NULL, "method should not be null");
   403   ThreadToNativeFromVM ttn(thread);
   411   ThreadToNativeFromVM ttn(thread);
   404   return env->FromReflectedMethod(method);
   412   return env->FromReflectedMethod(method);
   405 }
   413 }
   406 
   414 
       
   415 // Deoptimizes all compiled frames and makes nmethods not entrant if it's requested
       
   416 class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation {
       
   417  private:
       
   418   int _result;
       
   419   const bool _make_not_entrant;
       
   420  public:
       
   421   VM_WhiteBoxDeoptimizeFrames(bool make_not_entrant) :
       
   422         _result(0), _make_not_entrant(make_not_entrant) { }
       
   423   int  result() const { return _result; }
       
   424 
       
   425   void doit() {
       
   426     for (JavaThread* t = Threads::first(); t != NULL; t = t->next()) {
       
   427       if (t->has_last_Java_frame()) {
       
   428         for (StackFrameStream fst(t, UseBiasedLocking); !fst.is_done(); fst.next()) {
       
   429           frame* f = fst.current();
       
   430           if (f->can_be_deoptimized() && !f->is_deoptimized_frame()) {
       
   431             RegisterMap* reg_map = fst.register_map();
       
   432             Deoptimization::deoptimize(t, *f, reg_map);
       
   433             if (_make_not_entrant) {
       
   434                 nmethod* nm = CodeCache::find_nmethod(f->pc());
       
   435                 assert(nm != NULL, "sanity check");
       
   436                 nm->make_not_entrant();
       
   437             }
       
   438             ++_result;
       
   439           }
       
   440         }
       
   441       }
       
   442     }
       
   443   }
       
   444 };
       
   445 
       
   446 WB_ENTRY(jint, WB_DeoptimizeFrames(JNIEnv* env, jobject o, jboolean make_not_entrant))
       
   447   VM_WhiteBoxDeoptimizeFrames op(make_not_entrant == JNI_TRUE);
       
   448   VMThread::execute(&op);
       
   449   return op.result();
       
   450 WB_END
       
   451 
   407 WB_ENTRY(void, WB_DeoptimizeAll(JNIEnv* env, jobject o))
   452 WB_ENTRY(void, WB_DeoptimizeAll(JNIEnv* env, jobject o))
   408   MutexLockerEx mu(Compile_lock);
   453   MutexLockerEx mu(Compile_lock);
   409   CodeCache::mark_all_nmethods_for_deoptimization();
   454   CodeCache::mark_all_nmethods_for_deoptimization();
   410   VM_Deoptimize op;
   455   VM_Deoptimize op;
   411   VMThread::execute(&op);
   456   VMThread::execute(&op);
   523   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
   568   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
   524   nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
   569   nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
   525   MutexLockerEx mu(Compile_lock);
   570   MutexLockerEx mu(Compile_lock);
   526   return (mh->queued_for_compilation() || nm != NULL);
   571   return (mh->queued_for_compilation() || nm != NULL);
   527 WB_END
   572 WB_END
   528 
       
   529 class VM_WhiteBoxOperation : public VM_Operation {
       
   530  public:
       
   531   VM_WhiteBoxOperation()                         { }
       
   532   VMOp_Type type()                  const        { return VMOp_WhiteBoxOperation; }
       
   533   bool allow_nested_vm_operations() const        { return true; }
       
   534 };
       
   535 
   573 
   536 class AlwaysFalseClosure : public BoolObjectClosure {
   574 class AlwaysFalseClosure : public BoolObjectClosure {
   537  public:
   575  public:
   538   bool do_object_b(oop p) { return false; }
   576   bool do_object_b(oop p) { return false; }
   539 };
   577 };
   758   }
   796   }
   759   if (needFree) {
   797   if (needFree) {
   760     FREE_C_HEAP_ARRAY(char, ccstrResult);
   798     FREE_C_HEAP_ARRAY(char, ccstrResult);
   761   }
   799   }
   762 WB_END
   800 WB_END
   763 
       
   764 
   801 
   765 WB_ENTRY(void, WB_LockCompilation(JNIEnv* env, jobject o, jlong timeout))
   802 WB_ENTRY(void, WB_LockCompilation(JNIEnv* env, jobject o, jlong timeout))
   766   WhiteBox::compilation_locked = true;
   803   WhiteBox::compilation_locked = true;
   767 WB_END
   804 WB_END
   768 
   805 
  1207   {CC"NMTReleaseMemory",    CC"(JJ)V",                (void*)&WB_NMTReleaseMemory   },
  1244   {CC"NMTReleaseMemory",    CC"(JJ)V",                (void*)&WB_NMTReleaseMemory   },
  1208   {CC"NMTIsDetailSupported",CC"()Z",                  (void*)&WB_NMTIsDetailSupported},
  1245   {CC"NMTIsDetailSupported",CC"()Z",                  (void*)&WB_NMTIsDetailSupported},
  1209   {CC"NMTChangeTrackingLevel", CC"()Z",               (void*)&WB_NMTChangeTrackingLevel},
  1246   {CC"NMTChangeTrackingLevel", CC"()Z",               (void*)&WB_NMTChangeTrackingLevel},
  1210   {CC"NMTGetHashSize",      CC"()I",                  (void*)&WB_NMTGetHashSize     },
  1247   {CC"NMTGetHashSize",      CC"()I",                  (void*)&WB_NMTGetHashSize     },
  1211 #endif // INCLUDE_NMT
  1248 #endif // INCLUDE_NMT
       
  1249   {CC"deoptimizeFrames",   CC"(Z)I",                  (void*)&WB_DeoptimizeFrames  },
  1212   {CC"deoptimizeAll",      CC"()V",                   (void*)&WB_DeoptimizeAll     },
  1250   {CC"deoptimizeAll",      CC"()V",                   (void*)&WB_DeoptimizeAll     },
  1213   {CC"deoptimizeMethod",   CC"(Ljava/lang/reflect/Executable;Z)I",
  1251   {CC"deoptimizeMethod",   CC"(Ljava/lang/reflect/Executable;Z)I",
  1214                                                       (void*)&WB_DeoptimizeMethod  },
  1252                                                       (void*)&WB_DeoptimizeMethod  },
  1215   {CC"isMethodCompiled",   CC"(Ljava/lang/reflect/Executable;Z)Z",
  1253   {CC"isMethodCompiled",   CC"(Ljava/lang/reflect/Executable;Z)Z",
  1216                                                       (void*)&WB_IsMethodCompiled  },
  1254                                                       (void*)&WB_IsMethodCompiled  },