src/share/vm/prims/whitebox.cpp

changeset 9703
2fdf635bcf28
parent 9637
eef07cd490d4
parent 9690
61d955db2a5b
child 9931
fd44df5e3bc3
equal deleted inserted replaced
9647:42d198677884 9703:2fdf635bcf28
1 /* 1 /*
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 26
27 #include "memory/metadataFactory.hpp" 27 #include "memory/metadataFactory.hpp"
28 #include "memory/metaspaceShared.hpp" 28 #include "memory/metaspaceShared.hpp"
29 #include "memory/iterator.hpp"
29 #include "memory/universe.hpp" 30 #include "memory/universe.hpp"
30 #include "oops/oop.inline.hpp" 31 #include "oops/oop.inline.hpp"
31 32
32 #include "classfile/symbolTable.hpp" 33 #include "classfile/symbolTable.hpp"
33 #include "classfile/classLoaderData.hpp" 34 #include "classfile/classLoaderData.hpp"
581 VM_WhiteBoxOperation() { } 582 VM_WhiteBoxOperation() { }
582 VMOp_Type type() const { return VMOp_WhiteBoxOperation; } 583 VMOp_Type type() const { return VMOp_WhiteBoxOperation; }
583 bool allow_nested_vm_operations() const { return true; } 584 bool allow_nested_vm_operations() const { return true; }
584 }; 585 };
585 586
586 class AlwaysFalseClosure : public BoolObjectClosure {
587 public:
588 bool do_object_b(oop p) { return false; }
589 };
590
591 static AlwaysFalseClosure always_false; 587 static AlwaysFalseClosure always_false;
592 588
593 class VM_WhiteBoxCleanMethodData : public VM_WhiteBoxOperation { 589 class VM_WhiteBoxCleanMethodData : public VM_WhiteBoxOperation {
594 public: 590 public:
595 VM_WhiteBoxCleanMethodData(MethodData* mdo) : _mdo(mdo) { } 591 VM_WhiteBoxCleanMethodData(MethodData* mdo) : _mdo(mdo) { }
633 mcs->set_rate(0.0F); 629 mcs->set_rate(0.0F);
634 mh->set_prev_event_count(0); 630 mh->set_prev_event_count(0);
635 mh->set_prev_time(0); 631 mh->set_prev_time(0);
636 #endif 632 #endif
637 } 633 }
634 WB_END
635
636 WB_ENTRY(void, WB_MarkMethodProfiled(JNIEnv* env, jobject o, jobject method))
637 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
638 CHECK_JNI_EXCEPTION(env);
639 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
640
641 MethodData* mdo = mh->method_data();
642 if (mdo == NULL) {
643 Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR);
644 mdo = mh->method_data();
645 }
646 mdo->init();
647 InvocationCounter* icnt = mdo->invocation_counter();
648 InvocationCounter* bcnt = mdo->backedge_counter();
649 // set i-counter according to AdvancedThresholdPolicy::is_method_profiled
650 // because SimpleThresholdPolicy::call_predicate_helper uses > in jdk8u, that's why we need to plus one.
651 icnt->set(InvocationCounter::wait_for_compile, Tier4MinInvocationThreshold + 1);
652 bcnt->set(InvocationCounter::wait_for_compile, Tier4CompileThreshold + 1);
638 WB_END 653 WB_END
639 654
640 template <typename T> 655 template <typename T>
641 static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAt)(const char*, T*)) { 656 static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAt)(const char*, T*)) {
642 if (name == NULL) { 657 if (name == NULL) {
850 int insts_size = code->insts_size(); 865 int insts_size = code->insts_size();
851 866
852 ThreadToNativeFromVM ttn(thread); 867 ThreadToNativeFromVM ttn(thread);
853 jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); 868 jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string());
854 CHECK_JNI_EXCEPTION_(env, NULL); 869 CHECK_JNI_EXCEPTION_(env, NULL);
855 result = env->NewObjectArray(2, clazz, NULL); 870 result = env->NewObjectArray(3, clazz, NULL);
856 if (result == NULL) { 871 if (result == NULL) {
857 return result; 872 return result;
858 } 873 }
859 874
860 jobject obj = integerBox(thread, env, code->comp_level()); 875 jobject level = integerBox(thread, env, code->comp_level());
861 CHECK_JNI_EXCEPTION_(env, NULL); 876 CHECK_JNI_EXCEPTION_(env, NULL);
862 env->SetObjectArrayElement(result, 0, obj); 877 env->SetObjectArrayElement(result, 0, level);
878
879 jobject id = integerBox(thread, env, code->compile_id());
880 CHECK_JNI_EXCEPTION_(env, NULL);
881 env->SetObjectArrayElement(result, 1, id);
863 882
864 jbyteArray insts = env->NewByteArray(insts_size); 883 jbyteArray insts = env->NewByteArray(insts_size);
865 CHECK_JNI_EXCEPTION_(env, NULL); 884 CHECK_JNI_EXCEPTION_(env, NULL);
866 env->SetByteArrayRegion(insts, 0, insts_size, (jbyte*) code->insts_begin()); 885 env->SetByteArrayRegion(insts, 0, insts_size, (jbyte*) code->insts_begin());
867 env->SetObjectArrayElement(result, 1, insts); 886 env->SetObjectArrayElement(result, 2, insts);
868 887
869 return result; 888 return result;
870 WB_END 889 WB_END
871 890
872 891
1121 CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_TestSetForceInlineMethod}, 1140 CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_TestSetForceInlineMethod},
1122 {CC"enqueueMethodForCompilation", 1141 {CC"enqueueMethodForCompilation",
1123 CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation}, 1142 CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation},
1124 {CC"clearMethodState", 1143 {CC"clearMethodState",
1125 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, 1144 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState},
1145 {CC"markMethodProfiled",
1146 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_MarkMethodProfiled},
1126 {CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag}, 1147 {CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},
1127 {CC"setIntxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag}, 1148 {CC"setIntxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag},
1128 {CC"setUintxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag}, 1149 {CC"setUintxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},
1129 {CC"setUint64VMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag}, 1150 {CC"setUint64VMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag},
1130 {CC"setDoubleVMFlag", CC"(Ljava/lang/String;D)V",(void*)&WB_SetDoubleVMFlag}, 1151 {CC"setDoubleVMFlag", CC"(Ljava/lang/String;D)V",(void*)&WB_SetDoubleVMFlag},

mercurial