8005820: Shark: enable JSR292 support
Reviewed-by: twisti
Contributed-by: Roman Kennke <rkennke@redhat.com>
--- a/hotspot/src/share/vm/compiler/abstractCompiler.hpp Fri Jan 11 16:47:23 2013 -0800
+++ b/hotspot/src/share/vm/compiler/abstractCompiler.hpp Fri Jan 11 16:47:23 2013 -0800
@@ -50,6 +50,7 @@
// Missing feature tests
virtual bool supports_native() { return true; }
virtual bool supports_osr () { return true; }
+ virtual bool can_compile_method(methodHandle method) { return true; }
#if defined(TIERED) || ( !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK))
virtual bool is_c1 () { return false; }
virtual bool is_c2 () { return false; }
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp Fri Jan 11 16:47:23 2013 -0800
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp Fri Jan 11 16:47:23 2013 -0800
@@ -1218,7 +1218,7 @@
// lock, make sure that the compilation
// isn't prohibited in a straightforward way.
- if (compiler(comp_level) == NULL || compilation_is_prohibited(method, osr_bci, comp_level)) {
+ if (compiler(comp_level) == NULL || !compiler(comp_level)->can_compile_method(method) || compilation_is_prohibited(method, osr_bci, comp_level)) {
return NULL;
}
--- a/hotspot/src/share/vm/shark/sharkBlock.cpp Fri Jan 11 16:47:23 2013 -0800
+++ b/hotspot/src/share/vm/shark/sharkBlock.cpp Fri Jan 11 16:47:23 2013 -0800
@@ -1032,7 +1032,7 @@
check_null(value);
object = value->generic_value();
}
- if (is_get && field->is_constant()) {
+ if (is_get && field->is_constant() && field->is_static()) {
SharkConstant *constant = SharkConstant::for_field(iter());
if (constant->is_loaded())
value = constant->value(builder());
--- a/hotspot/src/share/vm/shark/sharkCompiler.hpp Fri Jan 11 16:47:23 2013 -0800
+++ b/hotspot/src/share/vm/shark/sharkCompiler.hpp Fri Jan 11 16:47:23 2013 -0800
@@ -46,6 +46,9 @@
// Missing feature tests
bool supports_native() { return true; }
bool supports_osr() { return true; }
+ bool can_compile_method(methodHandle method) {
+ return ! (method->is_method_handle_intrinsic() || method->is_compiled_lambda_form());
+ }
// Customization
bool needs_adapters() { return false; }
--- a/hotspot/src/share/vm/shark/sharkConstant.cpp Fri Jan 11 16:47:23 2013 -0800
+++ b/hotspot/src/share/vm/shark/sharkConstant.cpp Fri Jan 11 16:47:23 2013 -0800
@@ -37,7 +37,12 @@
ciType *type = NULL;
if (constant.basic_type() == T_OBJECT) {
ciEnv *env = ciEnv::current();
- assert(constant.as_object()->klass() == env->String_klass() || constant.as_object()->klass() == env->Class_klass(), "should be");
+
+ assert(constant.as_object()->klass() == env->String_klass()
+ || constant.as_object()->klass() == env->Class_klass()
+ || constant.as_object()->klass()->is_subtype_of(env->MethodType_klass())
+ || constant.as_object()->klass()->is_subtype_of(env->MethodHandle_klass()), "should be");
+
type = constant.as_object()->klass();
}
return new SharkConstant(constant, type);
--- a/hotspot/src/share/vm/shark/sharkInliner.cpp Fri Jan 11 16:47:23 2013 -0800
+++ b/hotspot/src/share/vm/shark/sharkInliner.cpp Fri Jan 11 16:47:23 2013 -0800
@@ -725,7 +725,7 @@
// Push the result if necessary
if (is_get) {
bool result_pushed = false;
- if (field->is_constant()) {
+ if (field->is_constant() && field->is_static()) {
SharkConstant *sc = SharkConstant::for_field(iter());
if (sc->is_loaded()) {
push(sc->is_nonzero());
--- a/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp Fri Jan 11 16:47:23 2013 -0800
+++ b/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp Fri Jan 11 16:47:23 2013 -0800
@@ -113,7 +113,19 @@
ciSignature* sig;
method = iter()->get_method(will_link, &sig);
assert(will_link, "typeflow responsibility");
-
+ // We can't compile calls to method handle intrinsics, because we use
+ // the interpreter entry points and they expect the top frame to be an
+ // interpreter frame. We need to implement the intrinsics for Shark.
+ if (method->is_method_handle_intrinsic() || method->is_compiled_lambda_form()) {
+ if (SharkPerformanceWarnings) {
+ warning("JSR292 optimization not yet implemented in Shark");
+ }
+ set_trap(
+ Deoptimization::make_trap_request(
+ Deoptimization::Reason_unhandled,
+ Deoptimization::Action_make_not_compilable), bci());
+ return;
+ }
if (!method->holder()->is_linked()) {
set_trap(
Deoptimization::make_trap_request(
@@ -158,6 +170,16 @@
return;
}
break;
+ case Bytecodes::_invokedynamic:
+ case Bytecodes::_invokehandle:
+ if (SharkPerformanceWarnings) {
+ warning("JSR292 optimization not yet implemented in Shark");
+ }
+ set_trap(
+ Deoptimization::make_trap_request(
+ Deoptimization::Reason_unhandled,
+ Deoptimization::Action_make_not_compilable), bci());
+ return;
}
}