src/hotspot/cpu/s390/frame_s390.cpp
author gromero
Wed, 28 Nov 2018 13:16:54 -0500
changeset 52760 9bce3e729d5f
parent 52055 9f154d0a59f6
child 53590 ce36f8180d03
permissions -rw-r--r--
8214451: PPC64/s390: Clean up unused CRC32 prototype and function Reviewed-by: mdoerr, lucy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 42556
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     3
 * Copyright (c) 2016 SAP SE. All rights reserved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     5
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     9
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    14
 * accompanied this code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    15
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    19
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    22
 * questions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    23
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    24
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    25
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    27
#include "interpreter/interpreter.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "memory/resourceArea.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "oops/markOop.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "oops/oop.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "runtime/frame.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "runtime/handles.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "runtime/javaCalls.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "runtime/monitorChunk.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "runtime/signature.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "runtime/stubCodeGenerator.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
#include "runtime/stubRoutines.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
#include "vmreg_s390.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
#ifdef COMPILER1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
#include "c1/c1_Runtime1.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
#include "runtime/vframeArray.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
// Major contributions by Aha, AS.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
void RegisterMap::check_location_valid() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
// Profiling/safepoint support
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
bool frame::safe_for_sender(JavaThread *thread) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
  bool safe = false;
52055
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    56
  address sp = (address)_sp;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    57
  address fp = (address)_fp;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    58
  address unextended_sp = (address)_unextended_sp;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    59
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    60
  // Consider stack guards when trying to determine "safe" stack pointers
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    61
  static size_t stack_guard_size = os::uses_stack_guard_pages() ?
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    62
    JavaThread::stack_red_zone_size() + JavaThread::stack_yellow_reserved_zone_size() : 0;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    63
  size_t usable_stack_size = thread->stack_size() - stack_guard_size;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    64
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    65
  // sp must be within the usable part of the stack (not in guards)
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    66
  bool sp_safe = (sp < thread->stack_base()) &&
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    67
                 (sp >= thread->stack_base() - usable_stack_size);
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    68
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    69
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    70
  if (!sp_safe) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    71
    return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    72
  }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    73
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    74
  // Unextended sp must be within the stack
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    75
  bool unextended_sp_safe = (unextended_sp < thread->stack_base());
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    76
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    77
  if (!unextended_sp_safe) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    78
    return false;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
  }
52055
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    80
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    81
  // An fp must be within the stack and above (but not equal) sp.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    82
  bool fp_safe = (fp <= thread->stack_base()) &&  (fp > sp);
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    83
  // An interpreter fp must be within the stack and above (but not equal) sp.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    84
  // Moreover, it must be at least the size of the z_ijava_state structure.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    85
  bool fp_interp_safe = (fp <= thread->stack_base()) && (fp > sp) &&
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    86
    ((fp - sp) >= z_ijava_state_size);
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    87
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    88
  // We know sp/unextended_sp are safe, only fp is questionable here
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    89
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    90
  // If the current frame is known to the code cache then we can attempt to
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    91
  // to construct the sender and do some validation of it. This goes a long way
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    92
  // toward eliminating issues when we get in frame construction code
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    93
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    94
  if (_cb != NULL ) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    95
    // Entry frame checks
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    96
    if (is_entry_frame()) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    97
      // An entry frame must have a valid fp.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    98
      return fp_safe && is_entry_frame_valid(thread);
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
    99
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   100
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   101
    // Now check if the frame is complete and the test is
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   102
    // reliable. Unfortunately we can only check frame completeness for
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   103
    // runtime stubs. Other generic buffer blobs are more
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   104
    // problematic so we just assume they are OK. Adapter blobs never have a
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   105
    // complete frame and are never OK. nmethods should be OK on s390.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   106
    if (!_cb->is_frame_complete_at(_pc)) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   107
      if (_cb->is_adapter_blob() || _cb->is_runtime_stub()) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   108
        return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   109
      }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   110
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   111
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   112
    // Could just be some random pointer within the codeBlob.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   113
    if (!_cb->code_contains(_pc)) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   114
      return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   115
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   116
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   117
    if (is_interpreted_frame() && !fp_interp_safe) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   118
      return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   119
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   120
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   121
    z_abi_160* sender_abi = (z_abi_160*) fp;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   122
    intptr_t* sender_sp = (intptr_t*) sender_abi->callers_sp;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   123
    address   sender_pc = (address) sender_abi->return_pc;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   124
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   125
    // We must always be able to find a recognizable pc.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   126
    CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   127
    if (sender_blob == NULL) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   128
      return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   129
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   130
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   131
    // Could be a zombie method
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   132
    if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   133
      return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   134
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   135
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   136
    // It should be safe to construct the sender though it might not be valid.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   137
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   138
    frame sender(sender_sp, sender_pc);
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   139
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   140
    // Do we have a valid fp?
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   141
    address sender_fp = (address) sender.fp();
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   142
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   143
    // sender_fp must be within the stack and above (but not
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   144
    // equal) current frame's fp.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   145
    if (sender_fp > thread->stack_base() || sender_fp <= fp) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   146
        return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   147
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   148
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   149
    // If the potential sender is the interpreter then we can do some more checking.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   150
    if (Interpreter::contains(sender_pc)) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   151
      return sender.is_interpreted_frame_valid(thread);
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   152
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   153
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   154
    // Could just be some random pointer within the codeBlob.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   155
    if (!sender.cb()->code_contains(sender_pc)) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   156
      return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   157
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   158
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   159
    // We should never be able to see an adapter if the current frame is something from code cache.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   160
    if (sender_blob->is_adapter_blob()) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   161
      return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   162
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   163
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   164
    if (sender.is_entry_frame()) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   165
      return sender.is_entry_frame_valid(thread);
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   166
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   167
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   168
    // Frame size is always greater than zero. If the sender frame size is zero or less,
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   169
    // something is really weird and we better give up.
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   170
    if (sender_blob->frame_size() <= 0) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   171
      return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   172
    }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   173
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   174
    return true;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   175
  }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   176
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   177
  // Must be native-compiled frame. Since sender will try and use fp to find
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   178
  // linkages it must be safe
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   179
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   180
  if (!fp_safe) {
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   181
    return false;
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   182
  }
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   183
9f154d0a59f6 8211768: [s390] Implement JFR profiling
ghaug
parents: 47216
diff changeset
   184
  return true;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   185
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   186
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   187
bool frame::is_interpreted_frame() const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   188
  return Interpreter::contains(pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   189
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   190
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   191
// sender_sp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   192
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   193
intptr_t* frame::interpreter_frame_sender_sp() const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   194
  return sender_sp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   195
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   196
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   197
frame frame::sender_for_entry_frame(RegisterMap *map) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   198
  assert(map != NULL, "map must be set");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   199
  // Java frame called from C. Skip all C frames and return top C
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   200
  // frame of that chunk as the sender.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   201
  JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   202
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   203
  assert(!entry_frame_is_first(), "next Java sp must be non zero");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   204
  assert(jfa->last_Java_sp() > _sp, "must be above this frame on stack");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   205
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   206
  map->clear();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   207
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   208
  assert(map->include_argument_oops(), "should be set by clear");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   209
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   210
  if (jfa->last_Java_pc() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   211
    frame fr(jfa->last_Java_sp(), jfa->last_Java_pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   212
    return fr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   213
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   214
  // Last_java_pc is not set if we come here from compiled code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   215
  frame fr(jfa->last_Java_sp());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   216
  return fr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   217
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   218
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   219
frame frame::sender_for_interpreter_frame(RegisterMap *map) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   220
  // Pass callers sender_sp as unextended_sp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   221
  return frame(sender_sp(), sender_pc(), (intptr_t*)(ijava_state()->sender_sp));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   222
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   223
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   224
frame frame::sender_for_compiled_frame(RegisterMap *map) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   225
  assert(map != NULL, "map must be set");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   226
  // Frame owned by compiler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   227
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   228
  address pc = *compiled_sender_pc_addr(_cb);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   229
  frame caller(compiled_sender_sp(_cb), pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   230
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   231
  // Now adjust the map.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   232
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   233
  // Get the rest.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   234
  if (map->update_map()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   235
    // Tell GC to use argument oopmaps for some runtime stubs that need it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   236
    map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   237
    if (_cb->oop_maps() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   238
      OopMapSet::update_register_map(this, map);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   239
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   240
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   241
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   242
  return caller;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   243
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   244
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   245
intptr_t* frame::compiled_sender_sp(CodeBlob* cb) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   246
  return sender_sp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   247
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   248
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   249
address* frame::compiled_sender_pc_addr(CodeBlob* cb) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   250
  return sender_pc_addr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   251
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   252
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   253
frame frame::sender(RegisterMap* map) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   254
  // Default is we don't have to follow them. The sender_for_xxx will
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   255
  // update it accordingly.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   256
  map->set_include_argument_oops(false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   257
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   258
  if (is_entry_frame()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   259
    return sender_for_entry_frame(map);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   260
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   261
  if (is_interpreted_frame()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   262
    return sender_for_interpreter_frame(map);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   263
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   264
  assert(_cb == CodeCache::find_blob(pc()),"Must be the same");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   265
  if (_cb != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   266
    return sender_for_compiled_frame(map);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   267
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   268
  // Must be native-compiled frame, i.e. the marshaling code for native
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   269
  // methods that exists in the core system.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   270
  return frame(sender_sp(), sender_pc());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   271
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   272
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   273
void frame::patch_pc(Thread* thread, address pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   274
  if (TracePcPatching) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   275
    tty->print_cr("patch_pc at address  " PTR_FORMAT " [" PTR_FORMAT " -> " PTR_FORMAT "] ",
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   276
                  p2i(&((address*) _sp)[-1]), p2i(((address*) _sp)[-1]), p2i(pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   277
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   278
  own_abi()->return_pc = (uint64_t)pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   279
  _cb = CodeCache::find_blob(pc);
42556
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   280
  address original_pc = CompiledMethod::get_deopt_original_pc(this);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   281
  if (original_pc != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   282
    assert(original_pc == _pc, "expected original to be stored before patching");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   283
    _deopt_state = is_deoptimized;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   284
    // Leave _pc as is.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   285
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   286
    _deopt_state = not_deoptimized;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   287
    _pc = pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   288
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   289
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   290
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   291
bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   292
  // Is there anything to do?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   293
  assert(is_interpreted_frame(), "Not an interpreted frame");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   294
  return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   295
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   296
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   297
BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   298
  assert(is_interpreted_frame(), "interpreted frame expected");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   299
  Method* method = interpreter_frame_method();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   300
  BasicType type = method->result_type();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   301
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   302
  if (method->is_native()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   303
    address lresult = (address)&(ijava_state()->lresult);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   304
    address fresult = (address)&(ijava_state()->fresult);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   305
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   306
    switch (type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   307
      case T_OBJECT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   308
      case T_ARRAY: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   309
        *oop_result = (oop) (void*) ijava_state()->oop_tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   310
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   311
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   312
      // We use std/stfd to store the values.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   313
      case T_BOOLEAN : value_result->z = (jboolean) *(unsigned long*)lresult; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   314
      case T_INT     : value_result->i = (jint)     *(long*)lresult;          break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   315
      case T_CHAR    : value_result->c = (jchar)    *(unsigned long*)lresult; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   316
      case T_SHORT   : value_result->s = (jshort)   *(long*)lresult;          break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   317
      case T_BYTE    : value_result->z = (jbyte)    *(long*)lresult;          break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   318
      case T_LONG    : value_result->j = (jlong)    *(long*)lresult;          break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   319
      case T_FLOAT   : value_result->f = (jfloat)   *(float*)fresult;        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   320
      case T_DOUBLE  : value_result->d = (jdouble)  *(double*)fresult;        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   321
      case T_VOID    : break; // Nothing to do.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   322
      default        : ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   323
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   324
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   325
    intptr_t* tos_addr = interpreter_frame_tos_address();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   326
    switch (type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   327
      case T_OBJECT:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   328
      case T_ARRAY: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   329
       oop obj = *(oop*)tos_addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   330
       assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   331
       *oop_result = obj;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   332
       break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   333
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   334
      case T_BOOLEAN : value_result->z = (jboolean) *(jint*)tos_addr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   335
      case T_BYTE    : value_result->b = (jbyte) *(jint*)tos_addr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   336
      case T_CHAR    : value_result->c = (jchar) *(jint*)tos_addr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   337
      case T_SHORT   : value_result->s = (jshort) *(jint*)tos_addr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   338
      case T_INT     : value_result->i = *(jint*)tos_addr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   339
      case T_LONG    : value_result->j = *(jlong*)tos_addr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   340
      case T_FLOAT   : value_result->f = *(jfloat*)tos_addr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   341
      case T_DOUBLE  : value_result->d = *(jdouble*)tos_addr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   342
      case T_VOID    : break; // Nothing to do.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   343
      default        : ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   344
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   345
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   346
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   347
  return type;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   348
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   349
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   350
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   351
// Dump all frames starting a given C stack-pointer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   352
// Use max_frames to limit the number of traced frames.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   353
void frame::back_trace(outputStream* st, intptr_t* start_sp, intptr_t* top_pc, unsigned long flags, int max_frames) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   354
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   355
  static char buf[ 150 ];
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   356
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   357
  bool print_outgoing_arguments = flags & 0x1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   358
  bool print_istate_pointers    = flags & 0x2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   359
  int num = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   360
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   361
  intptr_t* current_sp = (intptr_t*) start_sp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   362
  int last_num_jargs = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   363
  int frame_type = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   364
  int last_frame_type = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   365
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   366
  while (current_sp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   367
    intptr_t* current_fp = (intptr_t*) *current_sp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   368
    address   current_pc = (num == 0)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   369
                           ? (address) top_pc
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   370
                           : (address) *((intptr_t*)(((address) current_sp) + _z_abi(return_pc)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   371
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   372
    if ((intptr_t*) current_fp != 0 && (intptr_t*) current_fp <= current_sp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   373
      st->print_cr("ERROR: corrupt stack");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   374
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   375
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   376
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   377
    st->print("#%-3d ", num);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   378
    const char* type_name = "    ";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   379
    const char* function_name = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   380
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   381
    // Detect current frame's frame_type, default to 'C frame'.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   382
    frame_type = 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   383
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   384
    CodeBlob* blob = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   385
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   386
    if (Interpreter::contains(current_pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   387
      frame_type = 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   388
    } else if (StubRoutines::contains(current_pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   389
      if (StubRoutines::returns_to_call_stub(current_pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   390
        frame_type = 2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   391
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   392
        frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   393
        type_name = "stu";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   394
        StubCodeDesc* desc = StubCodeDesc::desc_for (current_pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   395
        if (desc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   396
          function_name = desc->name();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   397
        } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   398
          function_name = "unknown stub";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   399
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   400
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   401
    } else if (CodeCache::contains(current_pc)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   402
      blob = CodeCache::find_blob_unsafe(current_pc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   403
      if (blob) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   404
        if (blob->is_nmethod()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   405
          frame_type = 3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   406
        } else if (blob->is_deoptimization_stub()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   407
          frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   408
          type_name = "deo";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   409
          function_name = "deoptimization blob";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   410
        } else if (blob->is_uncommon_trap_stub()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   411
          frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   412
          type_name = "uct";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   413
          function_name = "uncommon trap blob";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   414
        } else if (blob->is_exception_stub()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   415
          frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   416
          type_name = "exc";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   417
          function_name = "exception blob";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   418
        } else if (blob->is_safepoint_stub()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   419
          frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   420
          type_name = "saf";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   421
          function_name = "safepoint blob";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   422
        } else if (blob->is_runtime_stub()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   423
          frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   424
          type_name = "run";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   425
          function_name = ((RuntimeStub *)blob)->name();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   426
        } else if (blob->is_method_handles_adapter_blob()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   427
          frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   428
          type_name = "mha";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   429
          function_name = "method handles adapter blob";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   430
        } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   431
          frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   432
          type_name = "blo";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   433
          function_name = "unknown code blob";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   434
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   435
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   436
        frame_type = 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   437
        type_name = "blo";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   438
        function_name = "unknown code blob";
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   439
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   440
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   441
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   442
    st->print("sp=" PTR_FORMAT " ", p2i(current_sp));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   443
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   444
    if (frame_type == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   445
      current_pc = (address) *((intptr_t*)(((address) current_sp) + _z_abi(gpr14)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   446
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   447
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   448
    st->print("pc=" PTR_FORMAT " ", p2i(current_pc));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   449
    st->print(" ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   450
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   451
    switch (frame_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   452
      case 0: // C frame:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   453
        {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   454
          st->print("    ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   455
          if (current_pc == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   456
            st->print("? ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   457
          } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   458
             // name
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   459
            int func_offset;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   460
            char demangled_name[256];
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   461
            int demangled_name_len = 256;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   462
            if (os::dll_address_to_function_name(current_pc, demangled_name, demangled_name_len, &func_offset)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   463
              demangled_name[demangled_name_len-1] = '\0';
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   464
              st->print(func_offset == -1 ? "%s " : "%s+0x%x", demangled_name, func_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   465
            } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   466
              st->print("? ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   467
            }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   468
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   469
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   470
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   471
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   472
      case 1: // interpreter frame:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   473
        {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   474
          st->print(" i  ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   475
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   476
          if (last_frame_type != 1) last_num_jargs = 8;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   477
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   478
          // name
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   479
          Method* method = *(Method**)((address)current_fp + _z_ijava_state_neg(method));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   480
          if (method) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   481
            if (method->is_synchronized()) st->print("synchronized ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   482
            if (method->is_static()) st->print("static ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   483
            if (method->is_native()) st->print("native ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   484
            method->name_and_sig_as_C_string(buf, sizeof(buf));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   485
            st->print("%s ", buf);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   486
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   487
          else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   488
            st->print("? ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   489
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   490
          intptr_t* tos = (intptr_t*) *(intptr_t*)((address)current_fp + _z_ijava_state_neg(esp));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   491
          if (print_istate_pointers) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   492
            st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   493
            st->print("     ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   494
            st->print("ts=" PTR_FORMAT " ", p2i(tos));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   495
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   496
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   497
          // Dump some Java stack slots.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   498
          if (print_outgoing_arguments) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   499
            if (method->is_native()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   500
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   501
              intptr_t* cargs = (intptr_t*) (((address)current_sp) + _z_abi(carg_1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   502
              for (int i = 0; i < last_num_jargs; i++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   503
                // Cargs is not prepushed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   504
                st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   505
                st->print("        ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   506
                st->print(PTR_FORMAT, *(cargs));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   507
                cargs++;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   508
              }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   509
#endif /* ASSERT */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   510
            }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   511
            else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   512
              if (tos) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   513
                for (int i = 0; i < last_num_jargs; i++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   514
                  // tos+0 is prepushed, ignore.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   515
                  tos++;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   516
                  if (tos >= (intptr_t *)((address)current_fp + _z_ijava_state_neg(monitors)))
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   517
                    break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   518
                  st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   519
                  st->print("        ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   520
                  st->print(PTR_FORMAT " %+.3e %+.3le", *(tos), *(float*)(tos), *(double*)(tos));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   521
                }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   522
              }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   523
            }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   524
            last_num_jargs = method->size_of_parameters();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   525
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   526
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   527
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   528
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   529
      case 2: // entry frame:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   530
        {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   531
          st->print("v2i ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   532
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   533
          // name
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   534
          st->print("call stub");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   535
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   536
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   537
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   538
      case 3: // compiled frame:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   539
        {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   540
          st->print(" c  ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   541
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   542
          // name
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   543
          Method* method = ((nmethod *)blob)->method();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   544
          if (method) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   545
            method->name_and_sig_as_C_string(buf, sizeof(buf));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   546
            st->print("%s ", buf);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   547
          }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   548
          else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   549
            st->print("? ");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   550
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   551
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   552
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   553
      case 4: // named frames
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   554
        {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   555
          st->print("%s ", type_name);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   556
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   557
          // name
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   558
          if (function_name)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   559
            st->print("%s", function_name);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   560
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   561
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   562
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   563
      default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   564
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   565
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   566
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   567
    st->cr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   568
    st->flush();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   569
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   570
    current_sp = current_fp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   571
    last_frame_type = frame_type;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   572
    num++;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   573
    // Check for maximum # of frames, and stop when reached.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   574
    if (max_frames > 0 && --max_frames == 0)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   575
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   576
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   577
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   578
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   579
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   580
// Convenience function for calls from the debugger.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   581
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   582
extern "C" void bt(intptr_t* start_sp,intptr_t* top_pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   583
  frame::back_trace(tty,start_sp, top_pc, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   584
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   585
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   586
extern "C" void bt_full(intptr_t* start_sp,intptr_t* top_pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   587
  frame::back_trace(tty,start_sp, top_pc, (unsigned long)(long)-1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   588
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   589
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   590
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   591
// Function for tracing a limited number of frames.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   592
// Use this one if you only need to see the "top of stack" frames.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   593
extern "C" void bt_max(intptr_t *start_sp, intptr_t *top_pc, int max_frames) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   594
  frame::back_trace(tty, start_sp, top_pc, 0, max_frames);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   595
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   596
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   597
#if !defined(PRODUCT)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   598
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   599
#define DESCRIBE_ADDRESS(name) \
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   600
  values.describe(frame_no, (intptr_t*)&ijava_state()->name, #name);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   601
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   602
void frame::describe_pd(FrameValues& values, int frame_no) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   603
  if (is_interpreted_frame()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   604
    // Describe z_ijava_state elements.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   605
    DESCRIBE_ADDRESS(method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   606
    DESCRIBE_ADDRESS(locals);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   607
    DESCRIBE_ADDRESS(monitors);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   608
    DESCRIBE_ADDRESS(cpoolCache);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   609
    DESCRIBE_ADDRESS(bcp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   610
    DESCRIBE_ADDRESS(mdx);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   611
    DESCRIBE_ADDRESS(esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   612
    DESCRIBE_ADDRESS(sender_sp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   613
    DESCRIBE_ADDRESS(top_frame_sp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   614
    DESCRIBE_ADDRESS(oop_tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   615
    DESCRIBE_ADDRESS(lresult);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   616
    DESCRIBE_ADDRESS(fresult);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   617
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   618
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   619
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 42556
diff changeset
   620
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 42556
diff changeset
   621
void frame::pd_ps() {}
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   622
#endif // !PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   623
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   624
intptr_t *frame::initial_deoptimization_info() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   625
  // Used to reset the saved FP.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   626
  return fp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   627
}