changeset 15176:f24d578e63a9

changed com.oracle.graal.api.code.CompilationResult.getFrameSize() to include the return address size if return address is puhsed onto the stack
author twisti
date Wed, 16 Apr 2014 13:32:54 -1000
parents 78f1a1a70628
children d74a0522ef1b
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java src/share/vm/graal/graalCodeInstaller.cpp
diffstat 3 files changed, 31 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Wed Apr 16 22:54:48 2014 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Wed Apr 16 13:32:54 2014 -1000
@@ -368,7 +368,7 @@
      * starting address of the table. This type of table maybe generated when translating a
      * multi-way branch based on a key value from a dense value set (e.g. the {@code tableswitch}
      * JVM instruction).
-     * 
+     *
      * The table is indexed by the contiguous range of integers from {@link #low} to {@link #high}
      * inclusive.
      */
@@ -525,9 +525,19 @@
     }
 
     /**
-     * Sets the frame size in bytes. Does not include the return address pushed onto the stack, if
-     * any.
-     * 
+     * The frame size of the method in bytes. This includes the return address pushed onto the
+     * stack, if any.
+     *
+     * @return the frame size
+     */
+    public int getFrameSize() {
+        assert frameSize != -1 : "frame size not yet initialized!";
+        return frameSize;
+    }
+
+    /**
+     * Sets the frame size in bytes. This includes the return address pushed onto the stack, if any.
+     *
      * @param size the size of the frame in bytes
      */
     public void setFrameSize(int size) {
@@ -536,7 +546,7 @@
 
     /**
      * Sets the machine that has been generated by the compiler.
-     * 
+     *
      * @param code the machine code generated
      * @param size the size of the machine code
      */
@@ -548,7 +558,7 @@
     /**
      * Records a reference to the data section in the code section (e.g. to load an integer or
      * floating point constant).
-     * 
+     *
      * @param codePos the position in the code where the data reference occurs
      * @param data the data that is referenced
      */
@@ -559,7 +569,7 @@
 
     /**
      * Records a reference to an inlined constant in the code section (e.g. to load a constant oop).
-     * 
+     *
      * @param codePos the position in the code where the inlined constant occurs
      * @param data the data that is referenced
      */
@@ -570,7 +580,7 @@
 
     /**
      * Records a call in the code array.
-     * 
+     *
      * @param codePos the position of the call in the code array
      * @param size the size of the call instruction
      * @param target the being called
@@ -584,7 +594,7 @@
 
     /**
      * Records an exception handler for this method.
-     * 
+     *
      * @param codePos the position in the code that is covered by the handler
      * @param handlerPos the position of the handler
      */
@@ -594,7 +604,7 @@
 
     /**
      * Records an infopoint in the code array.
-     * 
+     *
      * @param codePos the position of the infopoint in the code array
      * @param debugInfo the debug info for the infopoint
      */
@@ -604,10 +614,10 @@
 
     /**
      * Records a custom infopoint in the code section.
-     * 
+     *
      * Compiler implementations can use this method to record non-standard infopoints, which are not
      * handled by the dedicated methods like {@link #recordCall}.
-     * 
+     *
      * @param infopoint the infopoint to record, usually a derived class from {@link Infopoint}
      */
     public void addInfopoint(Infopoint infopoint) {
@@ -621,7 +631,7 @@
 
     /**
      * Records an instruction mark within this method.
-     * 
+     *
      * @param codePos the position in the code that is covered by the handler
      * @param markId the identifier for this mark
      * @param references an array of other marks that this mark references
@@ -636,7 +646,7 @@
      * Allows a method to specify the offset of the epilogue that restores the callee saved
      * registers. Must be called iff the method is a callee saved method and stores callee registers
      * on the stack.
-     * 
+     *
      * @param registerRestoreEpilogueOffset the offset in the machine code where the epilogue begins
      */
     public void setRegisterRestoreEpilogueOffset(int registerRestoreEpilogueOffset) {
@@ -645,16 +655,6 @@
     }
 
     /**
-     * The frame size of the method in bytes.
-     * 
-     * @return the frame size
-     */
-    public int getFrameSize() {
-        assert frameSize != -1 : "frame size not yet initialized!";
-        return frameSize;
-    }
-
-    /**
      * @return the code offset of the start of the epilogue that restores all callee saved
      *         registers, or -1 if this is not a callee saved method
      */
@@ -664,7 +664,7 @@
 
     /**
      * Offset in bytes for the custom stack area (relative to sp).
-     * 
+     *
      * @return the offset in bytes
      */
     public int getCustomStackAreaOffset() {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Wed Apr 16 22:54:48 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Wed Apr 16 13:32:54 2014 -1000
@@ -225,7 +225,11 @@
         Assembler masm = createAssembler(frameMap);
         HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null, omitFrame);
         CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult);
-        crb.setFrameSize(frameMap.frameSize());
+        /*
+         * The frame size we get from the frame map does not include the return address but the
+         * compilation result needs it so add it here.
+         */
+        crb.setFrameSize(frameMap.frameSize() + getTarget().arch.getReturnAddressSize());
         StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot();
         if (deoptimizationRescueSlot != null && stub == null) {
             crb.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot));
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Wed Apr 16 22:54:48 2014 +0200
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Wed Apr 16 13:32:54 2014 -1000
@@ -455,8 +455,7 @@
 
   _code = (arrayOop) CompilationResult::targetCode(comp_result);
   _code_size = CompilationResult::targetCodeSize(comp_result);
-  // The frame size we get from the target method does not include the return address, so add one word for it here.
-  _total_frame_size = CompilationResult::frameSize(comp_result) + HeapWordSize;  // FIXME this is an x86-ism
+  _total_frame_size = CompilationResult::frameSize(comp_result);
   _custom_stack_area_offset = CompilationResult::customStackAreaOffset(comp_result);
 
   // Pre-calculate the constants section size.  This is required for PC-relative addressing.