< prev index next >

src/hotspot/share/prims/methodHandles.cpp

Print this page
rev 54621 : imported patch 8221734-v1


  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.inline.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "code/dependencyContext.hpp"
  30 #include "compiler/compileBroker.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/oopMapCache.hpp"
  33 #include "interpreter/linkResolver.hpp"
  34 #include "memory/allocation.inline.hpp"
  35 #include "memory/oopFactory.hpp"
  36 #include "memory/resourceArea.hpp"
  37 #include "oops/objArrayOop.inline.hpp"
  38 #include "oops/oop.inline.hpp"
  39 #include "oops/typeArrayOop.inline.hpp"
  40 #include "prims/methodHandles.hpp"
  41 #include "runtime/compilationPolicy.hpp"

  42 #include "runtime/fieldDescriptor.inline.hpp"
  43 #include "runtime/handles.inline.hpp"
  44 #include "runtime/interfaceSupport.inline.hpp"
  45 #include "runtime/javaCalls.hpp"
  46 #include "runtime/jniHandles.inline.hpp"
  47 #include "runtime/timerTrace.hpp"
  48 #include "runtime/reflection.hpp"
  49 #include "runtime/safepointVerifiers.hpp"
  50 #include "runtime/signature.hpp"
  51 #include "runtime/stubRoutines.hpp"
  52 #include "utilities/exceptions.hpp"
  53 
  54 
  55 /*
  56  * JSR 292 reference implementation: method handles
  57  * The JDK 7 reference implementation represented method handle
  58  * combinations as chains.  Each link in the chain had a "vmentry"
  59  * field which pointed at a bit of assembly code which performed
  60  * one transformation before dispatching to the next link in the chain.
  61  *


1089   oop context = java_lang_invoke_CallSite::context_no_keepalive(call_site);
1090   DependencyContext deps = java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(context);
1091   deps.clean_unloading_dependents();
1092 }
1093 
1094 void MethodHandles::flush_dependent_nmethods(Handle call_site, Handle target) {
1095   assert_lock_strong(Compile_lock);
1096 
1097   int marked = 0;
1098   CallSiteDepChange changes(call_site, target);
1099   {
1100     NoSafepointVerifier nsv;
1101     MutexLockerEx mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1102 
1103     oop context = java_lang_invoke_CallSite::context_no_keepalive(call_site());
1104     DependencyContext deps = java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(context);
1105     marked = deps.mark_dependent_nmethods(changes);
1106   }
1107   if (marked > 0) {
1108     // At least one nmethod has been marked for deoptimization.
1109     VM_Deoptimize op;
1110     VMThread::execute(&op);
1111   }
1112 }
1113 
1114 void MethodHandles::trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid) {
1115   if (TraceMethodHandles) {
1116     const char* name = vmIntrinsics::name_at(iid);
1117     if (*name == '_')  name += 1;
1118     const size_t len = strlen(name) + 50;
1119     char* qname = NEW_C_HEAP_ARRAY(char, len, mtInternal);
1120     const char* suffix = "";
1121     if (is_signature_polymorphic(iid)) {
1122       if (is_signature_polymorphic_static(iid))
1123         suffix = "/static";
1124       else
1125         suffix = "/private";
1126     }
1127     jio_snprintf(qname, len, "MethodHandle::interpreter_entry::%s%s", name, suffix);
1128     trace_method_handle(_masm, qname);
1129     // Note:  Don't free the allocated char array because it's used
1130     // during runtime.


1486 }
1487 JVM_END
1488 
1489 // It is called by a Cleaner object which ensures that dropped CallSites properly
1490 // deallocate their dependency information.
1491 JVM_ENTRY(void, MHN_clearCallSiteContext(JNIEnv* env, jobject igcls, jobject context_jh)) {
1492   Handle context(THREAD, JNIHandles::resolve_non_null(context_jh));
1493   {
1494     // Walk all nmethods depending on this call site.
1495     MutexLocker mu1(Compile_lock, thread);
1496 
1497     int marked = 0;
1498     {
1499       NoSafepointVerifier nsv;
1500       MutexLockerEx mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1501       DependencyContext deps = java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(context());
1502       marked = deps.remove_all_dependents();
1503     }
1504     if (marked > 0) {
1505       // At least one nmethod has been marked for deoptimization
1506       VM_Deoptimize op;
1507       VMThread::execute(&op);
1508     }
1509   }
1510 }
1511 JVM_END
1512 
1513 /**
1514  * Throws a java/lang/UnsupportedOperationException unconditionally.
1515  * This is required by the specification of MethodHandle.invoke if
1516  * invoked directly.
1517  */
1518 JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv* env, jobject mh, jobjectArray args)) {
1519   THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invoke cannot be invoked reflectively");
1520   return NULL;
1521 }
1522 JVM_END
1523 
1524 /**
1525  * Throws a java/lang/UnsupportedOperationException unconditionally.
1526  * This is required by the specification of MethodHandle.invokeExact if
1527  * invoked directly.




  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.inline.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "code/dependencyContext.hpp"
  30 #include "compiler/compileBroker.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/oopMapCache.hpp"
  33 #include "interpreter/linkResolver.hpp"
  34 #include "memory/allocation.inline.hpp"
  35 #include "memory/oopFactory.hpp"
  36 #include "memory/resourceArea.hpp"
  37 #include "oops/objArrayOop.inline.hpp"
  38 #include "oops/oop.inline.hpp"
  39 #include "oops/typeArrayOop.inline.hpp"
  40 #include "prims/methodHandles.hpp"
  41 #include "runtime/compilationPolicy.hpp"
  42 #include "runtime/deoptimization.hpp"
  43 #include "runtime/fieldDescriptor.inline.hpp"
  44 #include "runtime/handles.inline.hpp"
  45 #include "runtime/interfaceSupport.inline.hpp"
  46 #include "runtime/javaCalls.hpp"
  47 #include "runtime/jniHandles.inline.hpp"
  48 #include "runtime/timerTrace.hpp"
  49 #include "runtime/reflection.hpp"
  50 #include "runtime/safepointVerifiers.hpp"
  51 #include "runtime/signature.hpp"
  52 #include "runtime/stubRoutines.hpp"
  53 #include "utilities/exceptions.hpp"
  54 
  55 
  56 /*
  57  * JSR 292 reference implementation: method handles
  58  * The JDK 7 reference implementation represented method handle
  59  * combinations as chains.  Each link in the chain had a "vmentry"
  60  * field which pointed at a bit of assembly code which performed
  61  * one transformation before dispatching to the next link in the chain.
  62  *


1090   oop context = java_lang_invoke_CallSite::context_no_keepalive(call_site);
1091   DependencyContext deps = java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(context);
1092   deps.clean_unloading_dependents();
1093 }
1094 
1095 void MethodHandles::flush_dependent_nmethods(Handle call_site, Handle target) {
1096   assert_lock_strong(Compile_lock);
1097 
1098   int marked = 0;
1099   CallSiteDepChange changes(call_site, target);
1100   {
1101     NoSafepointVerifier nsv;
1102     MutexLockerEx mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1103 
1104     oop context = java_lang_invoke_CallSite::context_no_keepalive(call_site());
1105     DependencyContext deps = java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(context);
1106     marked = deps.mark_dependent_nmethods(changes);
1107   }
1108   if (marked > 0) {
1109     // At least one nmethod has been marked for deoptimization.
1110     Deoptimization::deoptimize_all_marked();

1111   }
1112 }
1113 
1114 void MethodHandles::trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid) {
1115   if (TraceMethodHandles) {
1116     const char* name = vmIntrinsics::name_at(iid);
1117     if (*name == '_')  name += 1;
1118     const size_t len = strlen(name) + 50;
1119     char* qname = NEW_C_HEAP_ARRAY(char, len, mtInternal);
1120     const char* suffix = "";
1121     if (is_signature_polymorphic(iid)) {
1122       if (is_signature_polymorphic_static(iid))
1123         suffix = "/static";
1124       else
1125         suffix = "/private";
1126     }
1127     jio_snprintf(qname, len, "MethodHandle::interpreter_entry::%s%s", name, suffix);
1128     trace_method_handle(_masm, qname);
1129     // Note:  Don't free the allocated char array because it's used
1130     // during runtime.


1486 }
1487 JVM_END
1488 
1489 // It is called by a Cleaner object which ensures that dropped CallSites properly
1490 // deallocate their dependency information.
1491 JVM_ENTRY(void, MHN_clearCallSiteContext(JNIEnv* env, jobject igcls, jobject context_jh)) {
1492   Handle context(THREAD, JNIHandles::resolve_non_null(context_jh));
1493   {
1494     // Walk all nmethods depending on this call site.
1495     MutexLocker mu1(Compile_lock, thread);
1496 
1497     int marked = 0;
1498     {
1499       NoSafepointVerifier nsv;
1500       MutexLockerEx mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1501       DependencyContext deps = java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(context());
1502       marked = deps.remove_all_dependents();
1503     }
1504     if (marked > 0) {
1505       // At least one nmethod has been marked for deoptimization
1506       Deoptimization::deoptimize_all_marked();

1507     }
1508   }
1509 }
1510 JVM_END
1511 
1512 /**
1513  * Throws a java/lang/UnsupportedOperationException unconditionally.
1514  * This is required by the specification of MethodHandle.invoke if
1515  * invoked directly.
1516  */
1517 JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv* env, jobject mh, jobjectArray args)) {
1518   THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invoke cannot be invoked reflectively");
1519   return NULL;
1520 }
1521 JVM_END
1522 
1523 /**
1524  * Throws a java/lang/UnsupportedOperationException unconditionally.
1525  * This is required by the specification of MethodHandle.invokeExact if
1526  * invoked directly.


< prev index next >