changeset 1938:1aa5b22a7716

Support for custom stack area (needed for deoptimization).
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Mon, 27 Dec 2010 14:22:55 +0100
parents 4853c5cad3aa
children b7fb5f1e0747
files c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java src/cpu/x86/vm/frame_x86.cpp src/share/vm/c1x/c1x_CodeInstaller.cpp src/share/vm/c1x/c1x_CodeInstaller.hpp src/share/vm/c1x/c1x_TargetMethod.hpp src/share/vm/runtime/stackValue.cpp src/share/vm/runtime/vframe.cpp
diffstat 7 files changed, 31 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Thu Dec 23 22:14:31 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Mon Dec 27 14:22:55 2010 +0100
@@ -218,4 +218,12 @@
     public RiRegisterConfig getRegisterConfig(RiMethod method) {
         return regConfig;
     }
+
+    /**
+     * HotSpots needs an area suitable for storing a program counter for temporary use during the deoptimization process.
+     */
+    @Override
+    public int getCustomStackAreaSize() {
+        return 8;
+    }
 }
--- a/src/cpu/x86/vm/frame_x86.cpp	Thu Dec 23 22:14:31 2010 +0100
+++ b/src/cpu/x86/vm/frame_x86.cpp	Mon Dec 27 14:22:55 2010 +0100
@@ -219,6 +219,9 @@
   if (TracePcPatching) {
     tty->print_cr("patch_pc at address" INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "] ",
                   &((address *)sp())[-1], ((address *)sp())[-1], pc);
+    tty->print_cr("sp[0]: " INTPTR_FORMAT, ((intptr_t*)sp())[0]);
+    tty->print_cr("sp[1]: " INTPTR_FORMAT, ((intptr_t*)sp())[1]);
+    tty->print_cr("sp[2]: " INTPTR_FORMAT, ((intptr_t*)sp())[2]);
   }
   ((address *)sp())[-1] = pc;
   _cb = CodeCache::find_blob(pc);
--- a/src/share/vm/c1x/c1x_CodeInstaller.cpp	Thu Dec 23 22:14:31 2010 +0100
+++ b/src/share/vm/c1x/c1x_CodeInstaller.cpp	Mon Dec 27 14:22:55 2010 +0100
@@ -152,7 +152,7 @@
 }
 
 // constructor used to create a method
-CodeInstaller::CodeInstaller(oop target_method) {
+CodeInstaller::CodeInstaller(Handle target_method) {
   ciMethod *ciMethodObject = NULL;
   {
     No_Safepoint_Verifier no_safepoint;
@@ -175,13 +175,13 @@
 
   int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer
   ThreadToNativeFromVM t((JavaThread*) Thread::current());
-  _env->register_method(ciMethodObject, -1, &_offsets, 0, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
+  _env->register_method(ciMethodObject, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
       &_implicit_exception_table, C1XCompiler::instance(), _env->comp_level(), false, false);
 
 }
 
 // constructor used to create a stub
-CodeInstaller::CodeInstaller(oop target_method, jlong& id) {
+CodeInstaller::CodeInstaller(Handle target_method, jlong& id) {
   No_Safepoint_Verifier no_safepoint;
   _env = CURRENT_ENV;
 
@@ -198,7 +198,7 @@
   id = VmIds::addStub(blob->code_begin());
 }
 
-void CodeInstaller::initialize_fields(oop target_method) {
+void CodeInstaller::initialize_fields(Handle target_method) {
   _citarget_method = HotSpotTargetMethod::targetMethod(target_method);
   _hotspot_method = HotSpotTargetMethod::method(target_method);
   _name = HotSpotTargetMethod::name(target_method);
@@ -208,6 +208,8 @@
   _code = (arrayOop) CiTargetMethod::targetCode(_citarget_method);
   _code_size = CiTargetMethod::targetCodeSize(_citarget_method);
   _frame_size = CiTargetMethod::frameSize(_citarget_method);
+  _custom_stack_area_offset = CiTargetMethod::customStackAreaOffset(_citarget_method);
+
 
   // (very) conservative estimate: each site needs a constant section entry
   _constants_size = _sites->length() * BytesPerLong;
--- a/src/share/vm/c1x/c1x_CodeInstaller.hpp	Thu Dec 23 22:14:31 2010 +0100
+++ b/src/share/vm/c1x/c1x_CodeInstaller.hpp	Mon Dec 27 14:22:55 2010 +0100
@@ -59,6 +59,7 @@
   arrayOop      _code;
   jint          _code_size;
   jint          _frame_size;
+  jint          _custom_stack_area_offset;
   jint          _parameter_count;
   jint          _constants_size;
   jint          _total_size;
@@ -78,14 +79,14 @@
 public:
 
   // constructor used to create a method
-  CodeInstaller(oop target_method);
+  CodeInstaller(Handle target_method);
 
   // constructor used to create a stub
-  CodeInstaller(oop target_method, jlong& id);
+  CodeInstaller(Handle target_method, jlong& id);
 
 private:
   // extract the fields of the CiTargetMethod
-  void initialize_fields(oop target_method);
+  void initialize_fields(Handle target_method);
 
   // perform data and call relocation on the CodeBuffer
   void initialize_buffer(CodeBuffer& buffer);
--- a/src/share/vm/c1x/c1x_TargetMethod.hpp	Thu Dec 23 22:14:31 2010 +0100
+++ b/src/share/vm/c1x/c1x_TargetMethod.hpp	Mon Dec 27 14:22:55 2010 +0100
@@ -83,6 +83,7 @@
   end_class                                                                             \
   start_class(CiTargetMethod)                                                           \
     int_field(CiTargetMethod, frameSize)                                                \
+    int_field(CiTargetMethod, customStackAreaOffset)                                    \
     oop_field(CiTargetMethod, targetCode, "[B")                                         \
     int_field(CiTargetMethod, targetCodeSize)                                           \
   end_class                                                                             \
--- a/src/share/vm/runtime/stackValue.cpp	Thu Dec 23 22:14:31 2010 +0100
+++ b/src/share/vm/runtime/stackValue.cpp	Mon Dec 27 14:22:55 2010 +0100
@@ -116,7 +116,7 @@
 #endif
 #ifndef PRODUCT
       if (!val->is_oop()) {
-        tty->print_cr("found wrong oop %x at location:", val);
+        tty->print_cr("found wrong oop " INTPTR_FORMAT " at location:", val);
         sv->print();
         tty->print_cr("");
         tty->print_cr("one less %d; one more %d", (*(((oop *)value_addr) - 1))->is_oop(), (*(((oop *)value_addr) + 1))->is_oop());
--- a/src/share/vm/runtime/vframe.cpp	Thu Dec 23 22:14:31 2010 +0100
+++ b/src/share/vm/runtime/vframe.cpp	Mon Dec 27 14:22:55 2010 +0100
@@ -549,6 +549,14 @@
     if (size > 4*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size);
 #endif
   }
+
+  tty->print_cr("");
+  int i = -1;
+  for (intptr_t* a = _fr.sp() - 1; a <= _fr.fp(); a++) {
+    oop o = (oop)(*a);
+    tty->print_cr("sp[%d] = " INTPTR_FORMAT " (%d)", i, *a, o->is_oop());
+    ++i;
+  }
 }