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

JDK-8272397: [lworld] Move ValueBootstrapMethods to java.lang.runtime #529

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -518,7 +518,7 @@ JRT_ENTRY(int, Runtime1::substitutability_check(JavaThread* current, oopDesc* le
args.push_oop(Handle(THREAD, right));
JavaValue result(T_BOOLEAN);
JavaCalls::call_static(&result,
vmClasses::ValueBootstrapMethods_klass(),
vmClasses::PrimitiveObjectMethods_klass(),
vmSymbols::isSubstitutable_name(),
vmSymbols::object_object_boolean_signature(),
&args, CHECK_0);
@@ -124,7 +124,7 @@
do_klass(Context_klass, java_lang_invoke_MethodHandleNatives_CallSiteContext ) \
do_klass(ConstantCallSite_klass, java_lang_invoke_ConstantCallSite ) \
do_klass(MutableCallSite_klass, java_lang_invoke_MutableCallSite ) \
do_klass(ValueBootstrapMethods_klass, java_lang_invoke_ValueBootstrapMethods ) \
do_klass(PrimitiveObjectMethods_klass, java_lang_runtime_PrimitiveObjectMethods ) \
do_klass(VolatileCallSite_klass, java_lang_invoke_VolatileCallSite ) \
/* Note: MethodHandle must be first, and VolatileCallSite last in group */ \
\
@@ -715,9 +715,9 @@
template(toFileURL_signature, "(Ljava/lang/String;)Ljava/net/URL;") \
template(url_void_signature, "(Ljava/net/URL;)V") \
\
template(java_lang_invoke_ValueBootstrapMethods, "java/lang/invoke/ValueBootstrapMethods") \
template(isSubstitutable_name, "isSubstitutable") \
template(inlineObjectHashCode_name, "inlineObjectHashCode") \
template(java_lang_runtime_PrimitiveObjectMethods, "java/lang/runtime/PrimitiveObjectMethods") \
template(isSubstitutable_name, "isSubstitutable") \
template(primitiveObjectHashCode_name, "primitiveObjectHashCode") \
\
/*end*/

@@ -122,7 +122,7 @@ LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
LatestMethodCache* Universe::_throw_no_such_method_error_cache = NULL;
LatestMethodCache* Universe::_do_stack_walk_cache = NULL;
LatestMethodCache* Universe::_is_substitutable_cache = NULL;
LatestMethodCache* Universe::_inline_type_hash_code_cache = NULL;
LatestMethodCache* Universe::_primitive_type_hash_code_cache = NULL;

bool Universe::_verify_in_progress = false;
long Universe::verify_flags = Universe::Verify_All;
@@ -232,7 +232,7 @@ void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
_throw_no_such_method_error_cache->metaspace_pointers_do(it);
_do_stack_walk_cache->metaspace_pointers_do(it);
_is_substitutable_cache->metaspace_pointers_do(it);
_inline_type_hash_code_cache->metaspace_pointers_do(it);
_primitive_type_hash_code_cache->metaspace_pointers_do(it);
}

// Serialize metadata and pointers to primitive type mirrors in and out of CDS archive
@@ -283,7 +283,7 @@ void Universe::serialize(SerializeClosure* f) {
_throw_no_such_method_error_cache->serialize(f);
_do_stack_walk_cache->serialize(f);
_is_substitutable_cache->serialize(f);
_inline_type_hash_code_cache->serialize(f);
_primitive_type_hash_code_cache->serialize(f);
}


@@ -796,7 +796,7 @@ jint universe_init() {
Universe::_throw_no_such_method_error_cache = new LatestMethodCache();
Universe::_do_stack_walk_cache = new LatestMethodCache();
Universe::_is_substitutable_cache = new LatestMethodCache();
Universe::_inline_type_hash_code_cache = new LatestMethodCache();
Universe::_primitive_type_hash_code_cache = new LatestMethodCache();

#if INCLUDE_CDS
if (UseSharedSpaces) {
@@ -963,12 +963,12 @@ void Universe::initialize_known_methods(TRAPS) {
// Set up substitutability testing
ResourceMark rm;
initialize_known_method(_is_substitutable_cache,
vmClasses::ValueBootstrapMethods_klass(),
vmClasses::PrimitiveObjectMethods_klass(),
vmSymbols::isSubstitutable_name()->as_C_string(),
vmSymbols::object_object_boolean_signature(), true, CHECK);
initialize_known_method(_inline_type_hash_code_cache,
vmClasses::ValueBootstrapMethods_klass(),
vmSymbols::inlineObjectHashCode_name()->as_C_string(),
initialize_known_method(_primitive_type_hash_code_cache,
vmClasses::PrimitiveObjectMethods_klass(),
vmSymbols::primitiveObjectHashCode_name()->as_C_string(),
vmSymbols::object_int_signature(), true, CHECK);
}

@@ -117,8 +117,8 @@ class Universe: AllStatic {
static LatestMethodCache* _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError() method
static LatestMethodCache* _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError() method
static LatestMethodCache* _do_stack_walk_cache; // method for stack walker callback
static LatestMethodCache* _is_substitutable_cache; // ValueBootstrapMethods.isSubstitutable() method
static LatestMethodCache* _inline_type_hash_code_cache; // ValueBootstrapMethods.inlineObjectHashCode() method
static LatestMethodCache* _is_substitutable_cache; // PrimitiveObjectMethods.isSubstitutable() method
static LatestMethodCache* _primitive_type_hash_code_cache; // PrimitiveObjectMethods.primitiveObjectHashCode() method

static Array<int>* _the_empty_int_array; // Canonicalized int array
static Array<u2>* _the_empty_short_array; // Canonicalized short array
@@ -263,7 +263,7 @@ class Universe: AllStatic {
static Method* do_stack_walk_method() { return _do_stack_walk_cache->get_method(); }

static Method* is_substitutable_method() { return _is_substitutable_cache->get_method(); }
static Method* inline_type_hash_code_method() { return _inline_type_hash_code_cache->get_method(); }
static Method* primitive_type_hash_code_method() { return _primitive_type_hash_code_cache->get_method(); }

static oop the_null_sentinel();
static address the_null_sentinel_addr() { return (address) &_the_null_sentinel; }
@@ -2284,7 +2284,7 @@ void Parse::do_acmp(BoolTest::mask btest, Node* left, Node* right) {
}

// Both operands are values types of the same class, we need to perform a
// substitutability test. Delegate to ValueBootstrapMethods::isSubstitutable().
// substitutability test. Delegate to PrimitiveObjectMethods::isSubstitutable().
Node* ne_io_phi = PhiNode::make(ne_region, i_o());
Node* mem = reset_memory();
Node* ne_mem_phi = PhiNode::make(ne_region, mem);
@@ -2299,7 +2299,7 @@ void Parse::do_acmp(BoolTest::mask btest, Node* left, Node* right) {
set_all_memory(mem);

kill_dead_locals();
ciMethod* subst_method = ciEnv::current()->ValueBootstrapMethods_klass()->find_method(ciSymbols::isSubstitutable_name(), ciSymbols::object_object_boolean_signature());
ciMethod* subst_method = ciEnv::current()->PrimitiveObjectMethods_klass()->find_method(ciSymbols::isSubstitutable_name(), ciSymbols::object_object_boolean_signature());
CallStaticJavaNode *call = new CallStaticJavaNode(C, TypeFunc::make(subst_method), SharedRuntime::get_resolve_static_call_stub(), subst_method);
call->set_override_symbolic_info(true);
call->init_req(TypeFunc::Parms, not_null_left);
@@ -2309,7 +2309,7 @@ void Parse::do_acmp(BoolTest::mask btest, Node* left, Node* right) {
Node* ret = set_results_for_java_call(call, false, true);
dec_sp(2);

// Test the return value of ValueBootstrapMethods::isSubstitutable()
// Test the return value of PrimitiveObjectMethods::isSubstitutable()
Node* subst_cmp = _gvn.transform(new CmpINode(ret, intcon(1)));
Node* ctl = C->top();
if (btest == BoolTest::eq) {
@@ -608,7 +608,7 @@ JVM_ENTRY(jint, JVM_IHashCode(JNIEnv* env, jobject handle))
JavaCallArguments args;
Handle ho(THREAD, obj);
args.push_oop(ho);
methodHandle method(THREAD, Universe::inline_type_hash_code_method());
methodHandle method(THREAD, Universe::primitive_type_hash_code_method());
JavaCalls::call(&result, method, &args, THREAD);
if (HAS_PENDING_EXCEPTION) {
if (!PENDING_EXCEPTION->is_a(vmClasses::Error_klass())) {
@@ -316,7 +316,7 @@ bool JNIHandles::is_same_object(jobject handle1, jobject handle2) {
if (EnableValhalla) {
if (!ret && obj1 != NULL && obj2 != NULL && obj1->klass() == obj2->klass() && obj1->klass()->is_inline_klass()) {
// The two references are different, they are not null and they are both inline types,
// a full substitutability test is required, calling ValueBootstrapMethods.isSubstitutable()
// a full substitutability test is required, calling PrimitiveObjectMethods.isSubstitutable()
// (similarly to InterpreterRuntime::is_substitutable)
JavaThread* THREAD = JavaThread::current();
Handle ha(THREAD, obj1);
@@ -1096,10 +1096,10 @@ Handle SharedRuntime::find_callee_info_helper(vframeStream& vfst, Bytecodes::Cod
bc = Bytecodes::_invokestatic;
methodHandle attached_method(THREAD, extract_attached_method(vfst));
assert(attached_method.not_null(), "must have attached method");
vmClasses::ValueBootstrapMethods_klass()->initialize(CHECK_NH);
vmClasses::PrimitiveObjectMethods_klass()->initialize(CHECK_NH);
LinkResolver::resolve_invoke(callinfo, receiver, attached_method, bc, false, CHECK_NH);
#ifdef ASSERT
Method* is_subst = vmClasses::ValueBootstrapMethods_klass()->find_method(vmSymbols::isSubstitutable_name(), vmSymbols::object_object_boolean_signature());
Method* is_subst = vmClasses::PrimitiveObjectMethods_klass()->find_method(vmSymbols::isSubstitutable_name(), vmSymbols::object_object_boolean_signature());
assert(callinfo.selected_method() == is_subst, "must be isSubstitutable method");
#endif
return receiver;
@@ -42,6 +42,7 @@

import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.Collections;
@@ -1503,6 +1504,16 @@ public VarHandle collectCoordinates(VarHandle target, int pos, MethodHandle filt
public VarHandle insertCoordinates(VarHandle target, int pos, Object... values) {
return VarHandles.insertCoordinates(target, pos, values);
}

@Override
public MethodHandle findStatic(Class<?> cls, String name, MethodType methodType) throws NoSuchMethodException, IllegalAccessException {
return IMPL_LOOKUP.findStatic(cls, name, methodType);
}

@Override
public MethodHandle unreflectGetter(Field field) throws IllegalAccessException {
return IMPL_LOOKUP.unreflectGetter(field);
}
});
}

@@ -66,7 +66,9 @@ private ObjectMethods() { }
private static final MethodHandle STRING_FORMAT;
private static final MethodHandle HASH_COMBINER;

private static final HashMap<Class<?>, MethodHandle> primitiveEquals = new HashMap<>();
/* package-private */
static final HashMap<Class<?>, MethodHandle> primitiveEquals = new HashMap<>();

private static final HashMap<Class<?>, MethodHandle> primitiveHashers = new HashMap<>();
private static final HashMap<Class<?>, MethodHandle> primitiveToString = new HashMap<>();