hotspot/src/cpu/x86/vm/frame_x86.hpp
author coleenp
Fri, 18 Mar 2016 15:14:22 -0400
changeset 37152 29e68f1d35bb
parent 35214 d86005e0b4c2
child 37466 287c4ebd11b0
permissions -rw-r--r--
8152065: TraceBytecodes breaks the interpreter expression stack Summary: Move trace_bytecode to InterpreterRuntime and make trace_bytecode an IRT_LEAF so that safepoints are not allowed. Reviewed-by: jiangli, dholmes, dcubed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
37152
29e68f1d35bb 8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents: 35214
diff changeset
     2
 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4752
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4752
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4752
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef CPU_X86_VM_FRAME_X86_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define CPU_X86_VM_FRAME_X86_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "runtime/synchronizer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "utilities/top.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// A frame represents a physical stack frame (an activation).  Frames can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// C or Java frames, and the Java frames can be interpreted or compiled.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// In contrast, vframes represent source-level activations, so that one physical frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// can correspond to multiple source level frames because of inlining.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// A frame is comprised of {pc, fp, sp}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// ------------------------------ Asm interpreter ----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Layout of asm interpreter frame:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//    [expression stack      ] * <- sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//    [monitors              ]   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
//     ...                        | monitor block size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//    [monitors              ]   /
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//    [monitor block size    ]
25714
87fa6860b5ae 8004128: NPG: remove stackwalking in Threads::gc_prologue and gc_epilogue code
coleenp
parents: 22234
diff changeset
    43
//    [byte code pointer     ]                   = bcp()                bcp_offset
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//    [pointer to locals     ]                   = locals()             locals_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//    [constant pool cache   ]                   = cache()              cache_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//    [methodData            ]                   = mdp()                mdx_offset
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11486
diff changeset
    47
//    [Method*               ]                   = method()             method_offset
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//    [last sp               ]                   = last_sp()            last_sp_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//    [old stack pointer     ]                     (sender_sp)          sender_sp_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//    [old frame pointer     ]   <- fp           = link()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//    [return pc             ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//    [oop temp              ]                     (only for native calls)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//    [locals and parameters ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//                               <- sender sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// ------------------------------ Asm interpreter ----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    pc_return_offset                                 =  0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    // All frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    link_offset                                      =  0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    return_addr_offset                               =  1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    // non-interpreter frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    sender_sp_offset                                 =  2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    // Interpreter frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    interpreter_frame_result_handler_offset          =  3, // for native calls only
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    interpreter_frame_oop_temp_offset                =  2, // for native calls only
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    interpreter_frame_sender_sp_offset               = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    // outgoing sp before a call to an invoked method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    interpreter_frame_last_sp_offset                 = interpreter_frame_sender_sp_offset - 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    interpreter_frame_method_offset                  = interpreter_frame_last_sp_offset - 1,
25714
87fa6860b5ae 8004128: NPG: remove stackwalking in Threads::gc_prologue and gc_epilogue code
coleenp
parents: 22234
diff changeset
    74
    interpreter_frame_mdp_offset                     = interpreter_frame_method_offset - 1,
87fa6860b5ae 8004128: NPG: remove stackwalking in Threads::gc_prologue and gc_epilogue code
coleenp
parents: 22234
diff changeset
    75
    interpreter_frame_cache_offset                   = interpreter_frame_mdp_offset - 1,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    interpreter_frame_locals_offset                  = interpreter_frame_cache_offset - 1,
25714
87fa6860b5ae 8004128: NPG: remove stackwalking in Threads::gc_prologue and gc_epilogue code
coleenp
parents: 22234
diff changeset
    77
    interpreter_frame_bcp_offset                     = interpreter_frame_locals_offset - 1,
87fa6860b5ae 8004128: NPG: remove stackwalking in Threads::gc_prologue and gc_epilogue code
coleenp
parents: 22234
diff changeset
    78
    interpreter_frame_initial_sp_offset              = interpreter_frame_bcp_offset - 1,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    interpreter_frame_monitor_block_top_offset       = interpreter_frame_initial_sp_offset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    interpreter_frame_monitor_block_bottom_offset    = interpreter_frame_initial_sp_offset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    // Entry frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
#ifdef _WIN64
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30305
diff changeset
    86
    entry_frame_after_call_words                     =  60,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    entry_frame_call_wrapper_offset                  =  2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
29571
6627b10e05f8 6313046: Remove unused frame::native_param_addr code
mikael
parents: 26821
diff changeset
    89
    arg_reg_save_area_bytes                          = 32 // Register argument save area
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    entry_frame_after_call_words                     = 13,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    entry_frame_call_wrapper_offset                  = -6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
29571
6627b10e05f8 6313046: Remove unused frame::native_param_addr code
mikael
parents: 26821
diff changeset
    94
    arg_reg_save_area_bytes                          =  0
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
#endif // _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
#else
29571
6627b10e05f8 6313046: Remove unused frame::native_param_addr code
mikael
parents: 26821
diff changeset
    97
    entry_frame_call_wrapper_offset                  =  2
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  intptr_t ptr_at(int offset) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    return *ptr_at_addr(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  void ptr_at_put(int offset, intptr_t value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    *ptr_at_addr(offset) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // an additional field beyond _sp and _pc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  intptr_t*   _fp; // frame pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // The interpreter and adapters will extend the frame of the caller.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Since oopMaps are based on the sp of the caller before extension
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // we need to know that value. However in order to compute the address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // of the return address we need the real "raw" sp. Since sparc already
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // uses sp() to mean "raw" sp and unextended_sp() to mean the caller's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // original sp we use that convention.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  intptr_t*     _unextended_sp;
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 8874
diff changeset
   120
  void adjust_unextended_sp();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  intptr_t* ptr_at_addr(int offset) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    return (intptr_t*) addr_at(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
15937
fd3d2d0175f9 8006498: #if <symbol> is wrong in the code.
jprovino
parents: 13728
diff changeset
   126
#ifdef ASSERT
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1
diff changeset
   127
  // Used in frame::sender_for_{interpreter,compiled}_frame
30305
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 29571
diff changeset
   128
  static void verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp);
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1
diff changeset
   129
#endif
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1
diff changeset
   130
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // Constructors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  frame(intptr_t* sp, intptr_t* fp, address pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  frame(intptr_t* sp, intptr_t* fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
26821
ce9f82507dc2 8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents: 25714
diff changeset
   140
  void init(intptr_t* sp, intptr_t* fp, address pc);
ce9f82507dc2 8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents: 25714
diff changeset
   141
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // accessors for the instance variables
11486
cdc636532368 7120448: Fix FP values for compiled frames in frame::describe
bdelsart
parents: 9630
diff changeset
   143
  // Note: not necessarily the real 'frame pointer' (see real_fp)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  intptr_t*   fp() const { return _fp; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  inline address* sender_pc_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // expression stack tos if we are nested in a java call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  intptr_t* interpreter_frame_last_sp() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 8874
diff changeset
   151
  // helper to update a map with callee-saved RBP
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 8874
diff changeset
   152
  static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 8874
diff changeset
   153
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // deoptimization support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  void interpreter_frame_set_last_sp(intptr_t* sp);
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   156
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   157
#endif // CPU_X86_VM_FRAME_X86_HPP