aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/runtime
diff options
context:
space:
mode:
authorjrose <none@none>2009-03-20 23:19:36 -0700
committerjrose <none@none>2009-03-20 23:19:36 -0700
commitc52da29d35f5056a90751e6ffa59436726f315cb (patch)
treefe710577878d8a1c3487bc0fc4d1b313b90ccd50 /src/share/vm/runtime
parent12e6a2cf4d7aa5511e4bc596a424c22276adea9f (diff)
6814659: separable cleanups and subroutines for 6655638
Summary: preparatory but separable changes for method handles Reviewed-by: kvn, never
Diffstat (limited to 'src/share/vm/runtime')
-rw-r--r--src/share/vm/runtime/fieldDescriptor.cpp14
-rw-r--r--src/share/vm/runtime/handles.hpp10
-rw-r--r--src/share/vm/runtime/reflection.cpp21
-rw-r--r--src/share/vm/runtime/reflection.hpp10
-rw-r--r--src/share/vm/runtime/sharedRuntime.cpp42
-rw-r--r--src/share/vm/runtime/sharedRuntime.hpp5
6 files changed, 44 insertions, 58 deletions
diff --git a/src/share/vm/runtime/fieldDescriptor.cpp b/src/share/vm/runtime/fieldDescriptor.cpp
index d750981a4..a5e40ad8e 100644
--- a/src/share/vm/runtime/fieldDescriptor.cpp
+++ b/src/share/vm/runtime/fieldDescriptor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -107,13 +107,14 @@ void fieldDescriptor::print_on(outputStream* st) const {
void fieldDescriptor::print_on_for(outputStream* st, oop obj) {
print_on(st);
BasicType ft = field_type();
- jint as_int;
+ jint as_int = 0;
switch (ft) {
case T_BYTE:
as_int = (jint)obj->byte_field(offset());
st->print(" %d", obj->byte_field(offset()));
break;
case T_CHAR:
+ as_int = (jint)obj->char_field(offset());
{
jchar c = obj->char_field(offset());
as_int = c;
@@ -128,6 +129,7 @@ void fieldDescriptor::print_on_for(outputStream* st, oop obj) {
st->print(" %f", obj->float_field(offset()));
break;
case T_INT:
+ as_int = obj->int_field(offset());
st->print(" %d", obj->int_field(offset()));
break;
case T_LONG:
@@ -144,12 +146,12 @@ void fieldDescriptor::print_on_for(outputStream* st, oop obj) {
break;
case T_ARRAY:
st->print(" ");
- as_int = obj->int_field(offset());
+ NOT_LP64(as_int = obj->int_field(offset()));
obj->obj_field(offset())->print_value_on(st);
break;
case T_OBJECT:
st->print(" ");
- as_int = obj->int_field(offset());
+ NOT_LP64(as_int = obj->int_field(offset()));
obj->obj_field(offset())->print_value_on(st);
break;
default:
@@ -158,9 +160,9 @@ void fieldDescriptor::print_on_for(outputStream* st, oop obj) {
}
// Print a hint as to the underlying integer representation. This can be wrong for
// pointers on an LP64 machine
- if (ft == T_LONG || ft == T_DOUBLE) {
+ if (ft == T_LONG || ft == T_DOUBLE LP64_ONLY(|| !is_java_primitive(ft)) ) {
st->print(" (%x %x)", obj->int_field(offset()), obj->int_field(offset()+sizeof(jint)));
- } else {
+ } else if (as_int < 0 || as_int > 9) {
st->print(" (%x)", as_int);
}
}
diff --git a/src/share/vm/runtime/handles.hpp b/src/share/vm/runtime/handles.hpp
index 55e9b41fa..c44c6ac3d 100644
--- a/src/share/vm/runtime/handles.hpp
+++ b/src/share/vm/runtime/handles.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -137,6 +137,14 @@ class KlassHandle: public Handle {
assert(is_null() || obj()->is_klass(), "not a klassOop");
}
+ // Direct interface, use very sparingly.
+ // Used by SystemDictionaryHandles to create handles on existing WKKs.
+ // The obj of such a klass handle may be null, because the handle is formed
+ // during system bootstrapping.
+ KlassHandle(klassOop *handle, bool dummy) : Handle((oop*)handle, dummy) {
+ assert(SharedSkipVerify || is_null() || obj() == NULL || obj()->is_klass(), "not a klassOop");
+ }
+
// General access
klassOop operator () () const { return obj(); }
Klass* operator -> () const { return as_klass(); }
diff --git a/src/share/vm/runtime/reflection.cpp b/src/share/vm/runtime/reflection.cpp
index 3bc1b029d..6c7fe33ee 100644
--- a/src/share/vm/runtime/reflection.cpp
+++ b/src/share/vm/runtime/reflection.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -554,10 +554,18 @@ bool Reflection::is_same_class_package(klassOop class1, klassOop class2) {
return instanceKlass::cast(class1)->is_same_class_package(class2);
}
+bool Reflection::is_same_package_member(klassOop class1, klassOop class2, TRAPS) {
+ return instanceKlass::cast(class1)->is_same_package_member(class2, THREAD);
+}
+
// Checks that the 'outer' klass has declared 'inner' as being an inner klass. If not,
// throw an incompatible class change exception
-void Reflection::check_for_inner_class(instanceKlassHandle outer, instanceKlassHandle inner, TRAPS) {
+// If inner_is_member, require the inner to be a member of the outer.
+// If !inner_is_member, require the inner to be anonymous (a non-member).
+// Caller is responsible for figuring out in advance which case must be true.
+void Reflection::check_for_inner_class(instanceKlassHandle outer, instanceKlassHandle inner,
+ bool inner_is_member, TRAPS) {
const int inner_class_info_index = 0;
const int outer_class_info_index = 1;
@@ -567,7 +575,7 @@ void Reflection::check_for_inner_class(instanceKlassHandle outer, instanceKlassH
int ioff = icls->ushort_at(i + inner_class_info_index);
int ooff = icls->ushort_at(i + outer_class_info_index);
- if (ioff != 0 && ooff != 0) {
+ if (inner_is_member && ioff != 0 && ooff != 0) {
klassOop o = cp->klass_at(ooff, CHECK);
if (o == outer()) {
klassOop i = cp->klass_at(ioff, CHECK);
@@ -576,6 +584,13 @@ void Reflection::check_for_inner_class(instanceKlassHandle outer, instanceKlassH
}
}
}
+ if (!inner_is_member && ioff != 0 && ooff == 0 &&
+ cp->klass_name_at_matches(inner, ioff)) {
+ klassOop i = cp->klass_at(ioff, CHECK);
+ if (i == inner()) {
+ return;
+ }
+ }
}
// 'inner' not declared as an inner klass in outer
diff --git a/src/share/vm/runtime/reflection.hpp b/src/share/vm/runtime/reflection.hpp
index 4e8054af5..56a54cd0e 100644
--- a/src/share/vm/runtime/reflection.hpp
+++ b/src/share/vm/runtime/reflection.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -87,12 +87,18 @@ class Reflection: public AllStatic {
bool classloader_only,
bool protected_restriction = false);
static bool is_same_class_package(klassOop class1, klassOop class2);
+ static bool is_same_package_member(klassOop class1, klassOop class2, TRAPS);
static bool can_relax_access_check_for(
klassOop accessor, klassOop accesee, bool classloader_only);
// inner class reflection
- static void check_for_inner_class(instanceKlassHandle outer, instanceKlassHandle inner, TRAPS);
+ // raise an ICCE unless the required relationship can be proven to hold
+ // If inner_is_member, require the inner to be a member of the outer.
+ // If !inner_is_member, require the inner to be anonymous (a non-member).
+ // Caller is responsible for figuring out in advance which case must be true.
+ static void check_for_inner_class(instanceKlassHandle outer, instanceKlassHandle inner,
+ bool inner_is_member, TRAPS);
//
// Support for reflection based on dynamic bytecode generation (JDK 1.4)
diff --git a/src/share/vm/runtime/sharedRuntime.cpp b/src/share/vm/runtime/sharedRuntime.cpp
index 54c94ba03..787674569 100644
--- a/src/share/vm/runtime/sharedRuntime.cpp
+++ b/src/share/vm/runtime/sharedRuntime.cpp
@@ -675,48 +675,6 @@ JRT_ENTRY(void, SharedRuntime::yield_all(JavaThread* thread, int attempts))
JRT_END
-// ---------------------------------------------------------------------------------------------------------
-// Non-product code
-#ifndef PRODUCT
-
-void SharedRuntime::verify_caller_frame(frame caller_frame, methodHandle callee_method) {
- ResourceMark rm;
- assert (caller_frame.is_interpreted_frame(), "sanity check");
- assert (callee_method->has_compiled_code(), "callee must be compiled");
- methodHandle caller_method (Thread::current(), caller_frame.interpreter_frame_method());
- jint bci = caller_frame.interpreter_frame_bci();
- methodHandle method = find_callee_method_inside_interpreter(caller_frame, caller_method, bci);
- assert (callee_method == method, "incorrect method");
-}
-
-methodHandle SharedRuntime::find_callee_method_inside_interpreter(frame caller_frame, methodHandle caller_method, int bci) {
- EXCEPTION_MARK;
- Bytecode_invoke* bytecode = Bytecode_invoke_at(caller_method, bci);
- methodHandle staticCallee = bytecode->static_target(CATCH); // Non-product code
-
- bytecode = Bytecode_invoke_at(caller_method, bci);
- int bytecode_index = bytecode->index();
- Bytecodes::Code bc = bytecode->adjusted_invoke_code();
-
- Handle receiver;
- if (bc == Bytecodes::_invokeinterface ||
- bc == Bytecodes::_invokevirtual ||
- bc == Bytecodes::_invokespecial) {
- symbolHandle signature (THREAD, staticCallee->signature());
- receiver = Handle(THREAD, retrieve_receiver(signature, caller_frame));
- } else {
- receiver = Handle();
- }
- CallInfo result;
- constantPoolHandle constants (THREAD, caller_method->constants());
- LinkResolver::resolve_invoke(result, receiver, constants, bytecode_index, bc, CATCH); // Non-product code
- methodHandle calleeMethod = result.selected_method();
- return calleeMethod;
-}
-
-#endif // PRODUCT
-
-
JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* thread, oopDesc* obj))
assert(obj->is_oop(), "must be a valid oop");
assert(obj->klass()->klass_part()->has_finalizer(), "shouldn't be here otherwise");
diff --git a/src/share/vm/runtime/sharedRuntime.hpp b/src/share/vm/runtime/sharedRuntime.hpp
index bea176a9d..e98f71d1c 100644
--- a/src/share/vm/runtime/sharedRuntime.hpp
+++ b/src/share/vm/runtime/sharedRuntime.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -180,9 +180,6 @@ class SharedRuntime: AllStatic {
static oop retrieve_receiver( symbolHandle sig, frame caller );
- static void verify_caller_frame(frame caller_frame, methodHandle callee_method) PRODUCT_RETURN;
- static methodHandle find_callee_method_inside_interpreter(frame caller_frame, methodHandle caller_method, int bci) PRODUCT_RETURN_(return methodHandle(););
-
static void register_finalizer(JavaThread* thread, oopDesc* obj);
// dtrace notifications