src/hotspot/share/interpreter/bytecodeUtils.hpp
author goetz
Wed, 10 Apr 2019 08:26:23 +0200
branchJEP-8220715-NPE_messages
changeset 57319 aa400d41ebd6
parent 57271 1735d39dbff9
permissions -rw-r--r--
Print methods in Java syntax. Simplify computing the message Summary: Cleanup test: arrange according to messages and topics. Add test cases.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57271
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     1
/*
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     3
 * Copyright (c) 2019 SAP SE. All rights reserved.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     5
 *
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
     9
 *
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    14
 * accompanied this code).
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    15
 *
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    19
 *
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    22
 * questions.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    23
 *
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    24
 */
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    25
57319
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
    26
#ifndef SHARE_INTERPRETER_BYTECODEUTILS_HPP
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
    27
#define SHARE_INTERPRETER_BYTECODEUTILS_HPP
57271
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    28
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    29
#include "memory/allocation.hpp"
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    30
#include "oops/method.hpp"
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    31
#include "utilities/growableArray.hpp"
57319
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
    32
#include "utilities/globalDefinitions.hpp"
57271
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    33
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    34
class TrackingStack;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    35
class TrackingStackCreator;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    36
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    37
// The entry of TrackingStack.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    38
class TrackingStackEntry {
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    39
 private:
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    40
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    41
  friend class TrackingStack;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    42
  friend class TrackingStackCreator;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    43
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    44
  // The raw entry composed of the type and the bci.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    45
  int _entry;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    46
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    47
  enum {
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    48
    SCALE = 1024 * 1024
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    49
  };
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    50
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    51
  // Merges this entry with the given one and returns the result. If
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    52
  // the bcis of the entry are different, the bci of the result will be
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    53
  // undefined. If the types are different, the result type is T_CONFLICT.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    54
  // (an exception is if one type is an array and the other is object, then
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    55
  // the result type will be T_OBJECT).
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    56
  TrackingStackEntry merge(TrackingStackEntry other);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    57
public:
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    58
  // Creates a new entry with an invalid bci and the given type.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    59
  TrackingStackEntry(BasicType type = T_CONFLICT);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    60
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    61
  // Creates a new entry with the given bci and type.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    62
  TrackingStackEntry(int bci, BasicType type);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    63
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    64
 public:
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    65
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    66
  enum {
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    67
    INVALID = SCALE - 1
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    68
  };
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    69
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    70
  // Returns the bci. If the bci is invalid, INVALID is returned.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    71
  int get_bci();
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    72
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    73
  // Returns true, if the bci is not invalid.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    74
  bool has_bci() { return get_bci() != INVALID; }
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    75
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    76
  // Returns the type of the entry.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    77
  BasicType get_type();
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    78
};
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    79
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    80
// A stack consisting of TrackingStackEntries.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    81
class TrackingStack: CHeapObj<mtInternal> {
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    82
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    83
 private:
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    84
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    85
  friend class TrackingStackCreator;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    86
  friend class TrackingStackEntry;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    87
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    88
  // The stack.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    89
  GrowableArray<TrackingStackEntry> _stack;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    90
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    91
  TrackingStack() { };
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    92
  TrackingStack(const TrackingStack &copy);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    93
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    94
  // Pushes the given entry.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    95
  void push_raw(TrackingStackEntry entry);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    96
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    97
  // Like push_raw, but if the entry is long or double, we push two.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    98
  void push(TrackingStackEntry entry);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
    99
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   100
  // Like push(entry), but using bci/type instead of entry.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   101
  void push(int bci, BasicType type);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   102
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   103
  // Pops the given number of entries.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   104
  void pop(int slots);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   105
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   106
  // Merges this with the given stack by merging all entries. The
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   107
  // size of the stacks must be the same.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   108
  void merge(TrackingStack const& other);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   109
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   110
 public:
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   111
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   112
  // Returns the size of the stack.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   113
  int get_size() const;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   114
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   115
  // Returns the entry with the given index. Top of stack is at index 0.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   116
  TrackingStackEntry get_entry(int slot);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   117
};
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   118
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   119
// Analyses the bytecodes of a method and tries to create a tracking
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   120
// stack for each bci. The tracking stack holds the bci and type of
57319
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   121
// the object on the stack. The bci (if valid) holds the bci of the
57271
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   122
// instruction, which put the entry on the stack.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   123
class TrackingStackCreator {
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   124
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   125
  // The stacks.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   126
  GrowableArray<TrackingStack*>* _stacks;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   127
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   128
  // The method.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   129
  Method* _method;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   130
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   131
  // The maximum number of entries we want to use. This is used to
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   132
  // limit the amount of memory we waste for insane methods (as they
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   133
  // appear in JCK tests).
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   134
  int _max_entries;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   135
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   136
  // The number of entries used (the sum of all entries of all stacks).
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   137
  int _nr_of_entries;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   138
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   139
  // If true, we have added at least one new stack.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   140
  bool _added_one;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   141
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   142
  // If true, we have processed all bytecodes.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   143
  bool _all_processed;
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   144
57319
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   145
  static const int _max_cause_detail;
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   146
57271
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   147
  // Merges the stack the the given bci with the given stack. If there
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   148
  // is no stack at the bci, we just put the given stack there. This
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   149
  // method doesn't takes ownership of the stack.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   150
  void merge(int bci, TrackingStack* stack);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   151
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   152
  // Processes the instruction at the given bci in the method. Returns
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   153
  // the size of the instruction.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   154
  int do_instruction(int bci);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   155
57319
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   156
  bool print_NPE_cause0(outputStream *os, int bci, int slot, int max_detail, const char *prefix = NULL);
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   157
57271
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   158
 public:
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   159
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   160
  // Creates tracking stacks for the given method (the method must be
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   161
  // rewritten already). Note that you're not allowed to use this object
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   162
  // when crossing a safepoint! If the bci is != -1, we only create the
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   163
  // stacks as far as needed to get a stack for the bci.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   164
  TrackingStackCreator(Method* method, int bci = -1);
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   165
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   166
  // Releases the resources.
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   167
  ~TrackingStackCreator();
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   168
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   169
  // Returns the number of stacks (this is the size of the method).
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   170
  int get_size() { return _stacks->length() - 1; }
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   171
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   172
  // Assuming that a NullPointerException was thrown at the given bci,
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   173
  // we return the nr of the slot holding the null reference. If this
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   174
  // NPE is created by hand, we return -2 as the slot. If there
57319
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   175
  // cannot be a NullPointerException at the bci, -1 is returned.
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   176
  int get_NPE_null_slot(int bci);
57271
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   177
57319
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   178
  // Prints a java-like expression for the bytecode that pushed
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   179
  // the value to the given slot being live at the given bci.
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   180
  // It constructs the expression recuring backwards over the
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   181
  // bytecode.
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   182
  // The TOS has the slot number 0, that below 1 and so on.
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   183
  void print_NPE_cause(outputStream *os, int bci, int slot);
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   184
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   185
  // Prints a string describing the failed action.
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   186
  void print_NPE_failedAction(outputStream *os, int bci);
57271
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   187
};
1735d39dbff9 8218628: Add detailed message to NullPointerException describing what is null.
goetz
parents:
diff changeset
   188
57319
aa400d41ebd6 Print methods in Java syntax. Simplify computing the message
goetz
parents: 57271
diff changeset
   189
#endif // SHARE_INTERPRETER_BYTECODEUTILS_HPP