src/cpu/mips/vm/frame_mips.hpp

Tue, 26 Jul 2016 17:06:17 +0800

author
fujie
date
Tue, 26 Jul 2016 17:06:17 +0800
changeset 41
d885f8d65c58
parent 1
2d8a650513c2
child 6880
52ea28d233d2
permissions
-rw-r--r--

Add multiply word to GPR instruction (mul) in MIPS assembler.

     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     9  *
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13  * version 2 for more details (a copy is included in the LICENSE file that
    14  * accompanied this code).
    15  *
    16  * You should have received a copy of the GNU General Public License version
    17  * 2 along with this work; if not, write to the Free Software Foundation,
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19  *
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * or visit www.oracle.com if you need additional information or have any
    22  * questions.
    23  *
    24  */
    26 #ifndef CPU_MIPS_VM_FRAME_MIPS_HPP
    27 #define CPU_MIPS_VM_FRAME_MIPS_HPP
    29 #include "runtime/synchronizer.hpp"
    30 #include "utilities/top.hpp"
    32 // A frame represents a physical stack frame (an activation).  Frames can be
    33 // C or Java frames, and the Java frames can be interpreted or compiled.
    34 // In contrast, vframes represent source-level activations, so that one physical frame
    35 // can correspond to multiple source level frames because of inlining.
    36 // A frame is comprised of {pc, fp, sp}
    37 // ------------------------------ Asm interpreter ----------------------------------------
    38 // Layout of asm interpreter frame:
    39 //    [expression stack      ] * <- sp
    40 //    [monitors              ]   \
    41 //     ...                        | monitor block size
    42 //    [monitors              ]   /
    43 //    [monitor block size    ]
    44 //    [byte code index/pointr]                   = bcx()                bcx_offset
    45 //    [pointer to locals     ]                   = locals()             locals_offset
    46 //    [constant pool cache   ]                   = cache()              cache_offset
    47 //    [methodData            ]                   = mdp()                mdx_offset
    48 //    [methodOop             ]                   = method()             method_offset
    49 //    [last sp               ]                   = last_sp()            last_sp_offset
    50 //    [old stack pointer     ]                     (sender_sp)          sender_sp_offset
    51 //    [old frame pointer     ]   <- fp           = link()
    52 //    [return pc             ]
    53 //    [oop temp              ]                     (only for native calls)
    54 //    [locals and parameters ]
    55 //                               <- sender sp
    56 // ------------------------------ Asm interpreter ----------------------------------------
    58 // ------------------------------ C++ interpreter ----------------------------------------
    59 //
    60 // Layout of C++ interpreter frame: (While executing in BytecodeInterpreter::run)
    61 //
    62 //                             <- SP (current esp/rsp)
    63 //    [local variables         ] BytecodeInterpreter::run local variables
    64 //    ...                        BytecodeInterpreter::run local variables
    65 //    [local variables         ] BytecodeInterpreter::run local variables
    66 //    [old frame pointer       ]   fp [ BytecodeInterpreter::run's ebp/rbp ]
    67 //    [return pc               ]  (return to frame manager)
    68 //    [interpreter_state*      ]  (arg to BytecodeInterpreter::run)   --------------
    69 //    [expression stack        ] <- last_Java_sp                           |
    70 //    [...                     ] * <- interpreter_state.stack              |
    71 //    [expression stack        ] * <- interpreter_state.stack_base         |
    72 //    [monitors                ]   \                                       |
    73 //     ...                          | monitor block size                   |
    74 //    [monitors                ]   / <- interpreter_state.monitor_base     |
    75 //    [struct interpretState   ] <-----------------------------------------|
    76 //    [return pc               ] (return to callee of frame manager [1]
    77 //    [locals and parameters   ]
    78 //                               <- sender sp
    80 // [1] When the c++ interpreter calls a new method it returns to the frame
    81 //     manager which allocates a new frame on the stack. In that case there
    82 //     is no real callee of this newly allocated frame. The frame manager is
    83 //     aware of the  additional frame(s) and will pop them as nested calls
    84 //     complete. Howevers tTo make it look good in the debugger the frame
    85 //     manager actually installs a dummy pc pointing to RecursiveInterpreterActivation
    86 //     with a fake interpreter_state* parameter to make it easy to debug
    87 //     nested calls.
    89 // Note that contrary to the layout for the assembly interpreter the
    90 // expression stack allocated for the C++ interpreter is full sized.
    91 // However this is not as bad as it seems as the interpreter frame_manager
    92 // will truncate the unused space on succesive method calls.
    93 //
    94 // ------------------------------ C++ interpreter ----------------------------------------
    96 // Layout of interpreter frame:
    97 // 
    98 //    [ monitor entry            ] <--- sp
    99 //      ...
   100 //    [ monitor entry            ]
   101 // -7 [ monitor block top        ] ( the top monitor entry )
   102 // -6 [ byte code pointer        ] (if native, bcp = 0)
   103 // -5 [ constant pool cache      ]
   104 // -4 [ methodData      	 ] mdx_offset(not core only)
   105 // -3 [ methodOop                ]
   106 // -2 [ locals offset		 ] 
   107 // -1 [ sender's sp              ]
   108 //  0 [ sender's fp              ] <--fp
   109 //  1 [ return address           ]  
   110 //  2 [ oop temp offset 	 ] (only for native calls)
   111 //  3 [ result handler offset	 ] (only for native calls)
   112 //  4 [ result type info         ] (only for native calls)
   113 //    [ local var m-1            ]
   114 //      ...
   115 //    [ local var 0              ]
   116 //    [ argumnet word n-1        ] <--- ( sender's sp )
   117 //        ...
   118 //    [ argument word 0          ] <--- S7
   120  public:
   121   enum {
   122     pc_return_offset                                 =  0,
   123     // All frames
   124     link_offset                                      =  0,
   125     return_addr_offset                               =  1,
   126     // non-interpreter frames
   127     sender_sp_offset                                 =  2,
   129 #ifndef CC_INTERP
   131     // Interpreter frames
   132     interpreter_frame_return_addr_offset             =  1,
   133     interpreter_frame_result_handler_offset          =  3, // for native calls only
   134     interpreter_frame_oop_temp_offset                =  2, // for native calls only
   136     interpreter_frame_sender_fp_offset         	     =  0,
   137     interpreter_frame_sender_sp_offset               = -1,
   138     // outgoing sp before a call to an invoked method
   139     interpreter_frame_last_sp_offset                 = interpreter_frame_sender_sp_offset - 1,
   140     interpreter_frame_locals_offset        	     = interpreter_frame_last_sp_offset - 1,
   141     interpreter_frame_method_offset                  = interpreter_frame_locals_offset - 1,
   142     interpreter_frame_mdx_offset                     = interpreter_frame_method_offset - 1,
   143     interpreter_frame_cache_offset                   = interpreter_frame_mdx_offset - 1,
   144     //    interpreter_frame_locals_offset                  = interpreter_frame_cache_offset - 1,
   145     interpreter_frame_bcx_offset                     = interpreter_frame_cache_offset - 1,
   146     interpreter_frame_initial_sp_offset              = interpreter_frame_bcx_offset - 1,
   148     interpreter_frame_monitor_block_top_offset       = interpreter_frame_initial_sp_offset,
   149     interpreter_frame_monitor_block_bottom_offset    = interpreter_frame_initial_sp_offset,
   151 #endif // CC_INTERP
   153     // Entry frames
   154 #ifdef _LP64
   155     entry_frame_call_wrapper_offset                  =  -9,
   156 #else
   157     entry_frame_call_wrapper_offset                  =  2,
   158 #endif // AMD64
   160     // Native frames
   162     native_frame_initial_param_offset                =  2
   164   };
   166   intptr_t ptr_at(int offset) const {
   167     return *ptr_at_addr(offset);
   168   }
   170   void ptr_at_put(int offset, intptr_t value) {
   171     *ptr_at_addr(offset) = value;
   172   }
   174  private:
   175   // an additional field beyond _sp and _pc:
   176   intptr_t*   _fp; // frame pointer
   177   // The interpreter and adapters will extend the frame of the caller.
   178   // Since oopMaps are based on the sp of the caller before extension
   179   // we need to know that value. However in order to compute the address
   180   // of the return address we need the real "raw" sp. Since sparc already
   181   // uses sp() to mean "raw" sp and unextended_sp() to mean the caller's
   182   // original sp we use that convention.
   184   intptr_t*     _unextended_sp;
   185   void adjust_unextended_sp();
   187   intptr_t* ptr_at_addr(int offset) const {
   188     return (intptr_t*) addr_at(offset);
   189   }
   190 #ifdef ASSERT
   191   // Used in frame::sender_for_{interpreter,compiled}_frame
   192     static void verify_deopt_original_pc(   nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return = false);
   193   static void verify_deopt_mh_original_pc(nmethod* nm, intptr_t* unextended_sp) {
   194     verify_deopt_original_pc(nm, unextended_sp, true);
   195   }
   196 #endif
   198  public:
   199   // Constructors
   201   frame(intptr_t* sp, intptr_t* fp, address pc);
   203   frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);
   205   frame(intptr_t* sp, intptr_t* fp);
   207   // accessors for the instance variables
   208   intptr_t*   fp() const { return _fp; }
   210   inline address* sender_pc_addr() const;
   212   // return address of param, zero origin index.
   213   inline address* native_param_addr(int idx) const;
   215   // expression stack tos if we are nested in a java call
   216   intptr_t* interpreter_frame_last_sp() const;
   218 #ifndef CC_INTERP
   219   // deoptimization support
   220   void interpreter_frame_set_last_sp(intptr_t* sp);
   221 #endif // CC_INTERP
   223 #ifdef CC_INTERP
   224   inline interpreterState get_interpreterState() const;
   225 #endif // CC_INTERP
   226 #endif // CPU_MIPS_VM_FRAME_MIPS_HPP

mercurial