提交 2c075412 编写于 作者: K Kuai Wei 提交者: 云矅

[JWarmUP] port jwarmup to dragonwell 8u (JDK part)

Summary:
port jwarmup to dragonwell 8u
ref T19299187

Test Plan: see hotspot part

Reviewers: 三红, yumin.qi

Reviewed By: 三红, yumin.qi

Subscribers: 麦庶

Differential Revision: https://aone.alibaba-inc.com/code/D852150
上级 423f7215
......@@ -554,7 +554,8 @@ EXCLUDE_PROPWARN_PKGS = com.sun.java.swing.plaf.windows \
# with a new module system (being discussed for JDK 8).
#
EXPORTED_PRIVATE_PKGS = com.oracle.net \
com.oracle.nio
com.oracle.nio \
com.alibaba.jwarmup
$(IMAGES_OUTPUTDIR)/symbols/_the.symbols: $(IMAGES_OUTPUTDIR)/lib/rt.jar
$(RM) -r $(IMAGES_OUTPUTDIR)/symbols/META-INF/sym
......
......@@ -2556,4 +2556,5 @@ javax/swing/plaf/basic/BasicToolBarSeparatorUI
java/awt/event/AdjustmentEvent
java/awt/MenuBar
sun/awt/X11/XErrorEvent
com/alibaba/jwarmup/JWarmUp
# eea35d9d56e0006e
......@@ -141,6 +141,7 @@ LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/l
$(JDK_TOPDIR)/src/share/native/java/nio \
$(JDK_TOPDIR)/src/share/native/java/security \
$(JDK_TOPDIR)/src/share/native/common \
$(JDK_TOPDIR)/src/share/native/com/alibaba/jwarmup \
$(JDK_TOPDIR)/src/share/native/sun/misc \
$(JDK_TOPDIR)/src/share/native/sun/reflect \
$(JDK_TOPDIR)/src/share/native/java/util \
......
......@@ -215,6 +215,7 @@ SUNWprivate_1.1 {
Java_java_lang_System_setIn0;
Java_java_lang_System_setOut0;
Java_java_lang_Thread_registerNatives;
Java_com_alibaba_jwarmup_JWarmUp_registerNatives;
Java_java_lang_Throwable_fillInStackTrace;
Java_java_lang_Throwable_getStackTraceDepth;
Java_java_lang_Throwable_getStackTraceElement;
......
......@@ -10,6 +10,7 @@ text: .text%collapse: OUTPUTDIR/canonicalize_md.o;
text: .text%Java_java_lang_Object_registerNatives;
text: .text%Java_java_lang_System_registerNatives;
text: .text%Java_java_lang_Thread_registerNatives;
text: .text%Java_com_alibaba_jwarmup_JWarmUp_registerNatives;
text: .text%Java_java_security_AccessController_getStackAccessControlContext;
text: .text%Java_java_security_AccessController_getInheritedAccessControlContext;
text: .text%Java_java_lang_ClassLoader_registerNatives;
......
/*
* Copyright (c) 2019 Alibaba Group Holding Limited. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Alibaba designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.alibaba.jwarmup;
public class JWarmUp {
/* Make sure registerNatives is the first thing <clinit> does. */
private static native void registerNatives();
static {
registerNatives();
}
private static boolean hasNotified = false;
/**
* Notify jvm that application startup is done.
* <p>
* Should be explicitly call after startup of application if
* CompilationWarmUpOptimistic is off. Otherwise, it does
* nothing and just prints a warning message.
*
* @version 1.8
*/
public static synchronized void notifyApplicationStartUpIsDone() {
if (!hasNotified) {
hasNotified = true;
notifyApplicationStartUpIsDone0();
}
}
/**
* Notify jvm to deoptimize warmup methods
* <p>
* Should be explicitly call after startup of application
* and warmup compilation is completed
* vm option CompilationWarmUpExplicitDeopt must be on
* Otherwise, it does nothing and just prints a warning message.
*
* @version 1.8
*/
public static synchronized void notifyJVMDeoptWarmUpMethods() {
if (hasNotified && checkIfCompilationIsComplete()) {
notifyJVMDeoptWarmUpMethods0();
}
}
/**
* Check if the last compilation submitted by JWarmUp is complete.
* <p>
* call this method after <code>notifyApplicationStartUpIsDone</code>
*
* @return true if the last compilation task is complete.
*
* @version 1.8
*/
public static synchronized boolean checkIfCompilationIsComplete() {
if (!hasNotified) {
throw new IllegalStateException("Must call checkIfCompilationIsComplete() after notifyApplicationStartUpIsDone()");
} else {
return checkIfCompilationIsComplete0();
}
}
/**
* dummy function used internal, DO NOT call this
*/
private void dummy() {
throw new UnsupportedOperationException("dummy function");
}
private native static void notifyApplicationStartUpIsDone0();
private native static boolean checkIfCompilationIsComplete0();
private native static void notifyJVMDeoptWarmUpMethods0();
}
......@@ -330,6 +330,15 @@ JNIEXPORT jclass JNICALL
JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass,
jstring currClassName);
JNIEXPORT void JNICALL
JVM_NotifyApplicationStartUpIsDone(JNIEnv *env, jclass clz);
JNIEXPORT jboolean JNICALL
JVM_CheckJWarmUpCompilationIsComplete(JNIEnv *env, jclass clz);
JNIEXPORT void JNICALL
JVM_NotifyJVMDeoptWarmUpMethods(JNIEnv* env, jclass clz);
/*
* java.lang.reflect.Array
*/
......
/*
* Copyright (c) 2019 Alibaba Group Holding Limited. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Alibaba designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "jni.h"
#include "jvm.h"
#include "com_alibaba_jwarmup_JWarmUp.h"
#define ARRAY_LENGTH(a) (sizeof(a)/sizeof(a[0]))
static JNINativeMethod jwarmup_methods[] = {
{"notifyApplicationStartUpIsDone0","()V", (void *)&JVM_NotifyApplicationStartUpIsDone},
{"checkIfCompilationIsComplete0","()Z", (void *)&JVM_CheckJWarmUpCompilationIsComplete},
{"notifyJVMDeoptWarmUpMethods0","()V", (void *)&JVM_NotifyJVMDeoptWarmUpMethods}
};
JNIEXPORT void JNICALL
Java_com_alibaba_jwarmup_JWarmUp_registerNatives(JNIEnv *env, jclass cls)
{
(*env)->RegisterNatives(env, cls, jwarmup_methods, ARRAY_LENGTH(jwarmup_methods));
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册