Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8321039: [lworld] Substitutability code must recognize new annotations #960

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion make/data/hotspot-symbols/symbols-unix
Original file line number Diff line number Diff line change
@@ -137,7 +137,6 @@ JVM_GetSystemPackage
JVM_GetSystemPackages
JVM_GetTemporaryDirectory
JVM_GetVmArguments
JVM_GetZeroInstance
JVM_Halt
JVM_HasReferencePendingList
JVM_HoldsLock
3 changes: 0 additions & 3 deletions src/hotspot/share/include/jvm.h
Original file line number Diff line number Diff line change
@@ -1137,9 +1137,6 @@ JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
JNIEXPORT jstring JNICALL
JVM_GetTemporaryDirectory(JNIEnv *env);

JNIEXPORT jobject JNICALL
JVM_GetZeroInstance(JNIEnv *env, jclass cls);

JNIEXPORT jarray JNICALL
JVM_NewNullRestrictedArray(JNIEnv *env, jclass elmClass, jint len);

17 changes: 0 additions & 17 deletions src/hotspot/share/prims/jvm.cpp
Original file line number Diff line number Diff line change
@@ -423,23 +423,6 @@ JVM_ENTRY(jstring, JVM_GetTemporaryDirectory(JNIEnv *env))
return (jstring) JNIHandles::make_local(THREAD, h());
JVM_END

JVM_ENTRY(jobject, JVM_GetZeroInstance(JNIEnv *env, jclass cls)) {
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
k->initialize(CHECK_NULL);
if (!k->is_value_class()) {
ResourceMark rm;
THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), err_msg("%s not a value class", k->external_name()));
}
InlineKlass* vk = InlineKlass::cast(k);
if (!vk->is_implicitly_constructible()) {
ResourceMark rm;
THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), err_msg("%s not implicitly constructible", vk->external_name()));
}
oop v = vk->default_value();
return JNIHandles::make_local(THREAD, v);
}
JVM_END

JVM_ENTRY(jarray, JVM_NewNullRestrictedArray(JNIEnv *env, jclass elmClass, jint len))
if (len < 0) {
THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "Array length is negative");
8 changes: 8 additions & 0 deletions src/hotspot/share/prims/unsafe.cpp
Original file line number Diff line number Diff line change
@@ -344,6 +344,13 @@ UNSAFE_ENTRY(jboolean, Unsafe_IsFlattenedArray(JNIEnv *env, jobject unsafe, jcla
return k->is_flatArray_klass();
} UNSAFE_END

UNSAFE_ENTRY(jobject, Unsafe_UninitializedDefaultValue(JNIEnv *env, jobject unsafe, jclass vc)) {
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(vc));
InlineKlass* vk = InlineKlass::cast(k);
oop v = vk->default_value();
return JNIHandles::make_local(THREAD, v);
} UNSAFE_END

UNSAFE_ENTRY(jobject, Unsafe_GetValue(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jclass vc)) {
oop base = JNIHandles::resolve(obj);
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(vc));
@@ -997,6 +1004,7 @@ static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = {
{CC "isFlattenedField0", CC "(" OBJ ")Z", FN_PTR(Unsafe_IsFlattenedField)},
{CC "getValue", CC "(" OBJ "J" CLS ")" OBJ, FN_PTR(Unsafe_GetValue)},
{CC "putValue", CC "(" OBJ "J" CLS OBJ ")V", FN_PTR(Unsafe_PutValue)},
{CC "uninitializedDefaultValue", CC "(" CLS ")" OBJ, FN_PTR(Unsafe_UninitializedDefaultValue)},
{CC "makePrivateBuffer", CC "(" OBJ ")" OBJ, FN_PTR(Unsafe_MakePrivateBuffer)},
{CC "finishPrivateBuffer", CC "(" OBJ ")" OBJ, FN_PTR(Unsafe_FinishPrivateBuffer)},
{CC "valueHeaderSize", CC "(" CLS ")J", FN_PTR(Unsafe_ValueHeaderSize)},
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/io/ObjectStreamClass.java
Original file line number Diff line number Diff line change
@@ -1962,7 +1962,8 @@ private static final class FieldReflector {
*/
static Object newValueInstance(Class<?> clazz) throws InstantiationException{
assert clazz.isValue() : "Should be a value class";
Object obj = ValueClass.zeroInstance(clazz);
// may not be implicitly constructible; so allocate with Unsafe
Object obj = UNSAFE.uninitializedDefaultValue(clazz);
return UNSAFE.makePrivateBuffer(obj);
}

5 changes: 5 additions & 0 deletions src/java.base/share/classes/jdk/internal/misc/Unsafe.java
Original file line number Diff line number Diff line change
@@ -311,6 +311,11 @@ public Object getNullRestrictedReferenceVolatile(Object o, long offset, Class<?>
return ref != null ? ref : ValueClass.zeroInstance(type);
}

/**
* Returns an uninitialized default instance of the given value class.
*/
public native <V> V uninitializedDefaultValue(Class<?> type);

/**
* Returns an object instance with a private buffered value whose layout
* and contents is exactly the given value instance. The return object
13 changes: 11 additions & 2 deletions src/java.base/share/classes/jdk/internal/value/ValueClass.java
Original file line number Diff line number Diff line change
@@ -27,12 +27,13 @@

import jdk.internal.access.JavaLangAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.Unsafe;

/**
* Utilities to access
*/
public class ValueClass {
private static final JavaLangAccess javaLangAccess = SharedSecrets.getJavaLangAccess();
private static final Unsafe UNSAFE = Unsafe.getUnsafe();

/**
* Returns true if the given {@code Class} object is implicitly constructible
@@ -46,7 +47,15 @@ public class ValueClass {
* value class type or is not annotated with
* {@link jdk.internal.vm.annotation.ImplicitlyConstructible}
*/
public static native <T> T zeroInstance(Class<T> cls);
public static <T> T zeroInstance(Class<T> cls) {
if (!cls.isValue()) {
throw new IllegalArgumentException(cls.getName() + " not a value class");
}
if (!isImplicitlyConstructible(cls)) {
throw new IllegalArgumentException(cls.getName() + " not implicitly constructible");
}
return UNSAFE.uninitializedDefaultValue(cls);
}

/**
* Allocate an array of a value class type with components that behave in
5 changes: 0 additions & 5 deletions src/java.base/share/native/libjava/ValueClass.c
Original file line number Diff line number Diff line change
@@ -33,11 +33,6 @@ Java_jdk_internal_value_ValueClass_isImplicitlyConstructible(JNIEnv *env, jclass
return JVM_IsImplicitlyConstructibleClass(env, cls);
}

JNIEXPORT jobject JNICALL
Java_jdk_internal_value_ValueClass_zeroInstance(JNIEnv *env, jclass dummy, jclass cls) {
return JVM_GetZeroInstance(env, cls);
}

JNIEXPORT jarray JNICALL
Java_jdk_internal_value_ValueClass_newNullRestrictedArray(JNIEnv *env, jclass cls, jclass elmClass, jint len)
{