diff -r 42d198677884 -r 2fdf635bcf28 src/share/vm/prims/whitebox.cpp --- a/src/share/vm/prims/whitebox.cpp Thu Sep 05 18:40:52 2019 +0800 +++ b/src/share/vm/prims/whitebox.cpp Thu Sep 05 18:52:27 2019 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "memory/metadataFactory.hpp" #include "memory/metaspaceShared.hpp" +#include "memory/iterator.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" @@ -583,11 +584,6 @@ bool allow_nested_vm_operations() const { return true; } }; -class AlwaysFalseClosure : public BoolObjectClosure { - public: - bool do_object_b(oop p) { return false; } -}; - static AlwaysFalseClosure always_false; class VM_WhiteBoxCleanMethodData : public VM_WhiteBoxOperation { @@ -637,6 +633,25 @@ } WB_END +WB_ENTRY(void, WB_MarkMethodProfiled(JNIEnv* env, jobject o, jobject method)) + jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION(env); + methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); + + MethodData* mdo = mh->method_data(); + if (mdo == NULL) { + Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR); + mdo = mh->method_data(); + } + mdo->init(); + InvocationCounter* icnt = mdo->invocation_counter(); + InvocationCounter* bcnt = mdo->backedge_counter(); + // set i-counter according to AdvancedThresholdPolicy::is_method_profiled + // because SimpleThresholdPolicy::call_predicate_helper uses > in jdk8u, that's why we need to plus one. + icnt->set(InvocationCounter::wait_for_compile, Tier4MinInvocationThreshold + 1); + bcnt->set(InvocationCounter::wait_for_compile, Tier4CompileThreshold + 1); +WB_END + template static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAt)(const char*, T*)) { if (name == NULL) { @@ -852,19 +867,23 @@ ThreadToNativeFromVM ttn(thread); jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); CHECK_JNI_EXCEPTION_(env, NULL); - result = env->NewObjectArray(2, clazz, NULL); + result = env->NewObjectArray(3, clazz, NULL); if (result == NULL) { return result; } - jobject obj = integerBox(thread, env, code->comp_level()); + jobject level = integerBox(thread, env, code->comp_level()); CHECK_JNI_EXCEPTION_(env, NULL); - env->SetObjectArrayElement(result, 0, obj); + env->SetObjectArrayElement(result, 0, level); + + jobject id = integerBox(thread, env, code->compile_id()); + CHECK_JNI_EXCEPTION_(env, NULL); + env->SetObjectArrayElement(result, 1, id); jbyteArray insts = env->NewByteArray(insts_size); CHECK_JNI_EXCEPTION_(env, NULL); env->SetByteArrayRegion(insts, 0, insts_size, (jbyte*) code->insts_begin()); - env->SetObjectArrayElement(result, 1, insts); + env->SetObjectArrayElement(result, 2, insts); return result; WB_END @@ -1123,6 +1142,8 @@ CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation}, {CC"clearMethodState", CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, + {CC"markMethodProfiled", + CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_MarkMethodProfiled}, {CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag}, {CC"setIntxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag}, {CC"setUintxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},