hotspot/src/share/vm/ci/ciCallSite.cpp
changeset 30296 95baefac8485
parent 29081 c61eb4914428
child 31037 01a5c5fa5681
--- a/hotspot/src/share/vm/ci/ciCallSite.cpp	Wed Apr 15 11:01:56 2015 +0200
+++ b/hotspot/src/share/vm/ci/ciCallSite.cpp	Fri Apr 17 18:17:06 2015 +0300
@@ -50,6 +50,25 @@
 }
 
 // ------------------------------------------------------------------
+// ciCallSite::get_context
+//
+// Return the target MethodHandle of this CallSite.
+ciKlass* ciCallSite::get_context() {
+  assert(!is_constant_call_site(), "");
+
+  VM_ENTRY_MARK;
+  oop call_site_oop = get_oop();
+  InstanceKlass* ctxk = MethodHandles::get_call_site_context(call_site_oop);
+  if (ctxk == NULL) {
+    // The call site doesn't have a context associated. Set it to the default context.
+    oop def_context_oop = java_lang_invoke_CallSite::default_context();
+    java_lang_invoke_CallSite::set_context_cas(call_site_oop, def_context_oop, /*expected=*/NULL);
+    ctxk = MethodHandles::get_call_site_context(call_site_oop);
+  }
+  return (CURRENT_ENV->get_metadata(ctxk))->as_klass();
+}
+
+// ------------------------------------------------------------------
 // ciCallSite::print
 //
 // Print debugging information about the CallSite.