src/hotspot/share/classfile/stackMapFrame.hpp
author lfoltan
Mon, 21 Oct 2019 13:13:16 -0400
changeset 58722 cba8afa5cfed
parent 53244 9807daeb47c4
permissions -rw-r--r--
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently Summary: Increase the use of type signature constants instead of hard coded characters within the JVM. Reviewed-by: coleenp, dholmes, fparain Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53108
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53108
diff changeset
    25
#ifndef SHARE_CLASSFILE_STACKMAPFRAME_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53108
diff changeset
    26
#define SHARE_CLASSFILE_STACKMAPFRAME_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "classfile/verificationType.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "classfile/verifier.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13476
diff changeset
    30
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "runtime/handles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "runtime/signature.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "utilities/exceptions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// A StackMapFrame represents one frame in the stack map attribute.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    37
class TypeContext;
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    38
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  FLAG_THIS_UNINIT = 0x01
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class StackMapFrame : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  int32_t _offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // See comment in StackMapTable about _frame_count about why these
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // fields are int32_t instead of u2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  int32_t _locals_size;  // number of valid type elements in _locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  int32_t _stack_size;   // number of valid type elements in _stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    52
  int32_t _stack_mark;   // Records the size of the stack prior to an
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    53
                         // instruction modification, to allow rewinding
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    54
                         // when/if an error occurs.
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    55
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  int32_t _max_locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  int32_t _max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  u1 _flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  VerificationType* _locals; // local variable type array
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  VerificationType* _stack;  // operand stack type array
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  ClassVerifier* _verifier;  // the verifier verifying this method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
52436
2090b60c5e26 8213487: [BACKOUT] 8213414 Fix incorrect copy constructors in hotspot
dcubed
parents: 52434
diff changeset
    65
  StackMapFrame(const StackMapFrame& cp) :
53108
e90315ae8aa9 8213481: [REDO] Fix incorrect copy constructors in hotspot
kbarrett
parents: 52436
diff changeset
    66
      ResourceObj(cp),
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    67
      _offset(cp._offset), _locals_size(cp._locals_size),
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    68
      _stack_size(cp._stack_size), _stack_mark(cp._stack_mark),
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    69
      _max_locals(cp._max_locals), _max_stack(cp._max_stack),
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    70
      _flags(cp._flags) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    71
    _locals = NEW_RESOURCE_ARRAY(VerificationType, _max_locals);
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    72
    for (int i = 0; i < _max_locals; ++i) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    73
      if (i < _locals_size) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    74
        _locals[i] = cp._locals[i];
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    75
      } else {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    76
        _locals[i] = VerificationType::bogus_type();
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    77
      }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    78
    }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    79
    int ss = MAX2(_stack_size, _stack_mark);
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    80
    _stack = NEW_RESOURCE_ARRAY(VerificationType, _max_stack);
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    81
    for (int i = 0; i < _max_stack; ++i) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    82
      if (i < ss) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    83
        _stack[i] = cp._stack[i];
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    84
      } else {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    85
        _stack[i] = VerificationType::bogus_type();
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    86
      }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    87
    }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    88
    _verifier = NULL;
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    89
  }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
    90
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // constructors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // This constructor is used by the type checker to allocate frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // in type state, which have _max_locals and _max_stack array elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // in _locals and _stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  StackMapFrame(u2 max_locals, u2 max_stack, ClassVerifier* verifier);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // This constructor is used to initialize stackmap frames in stackmap table,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // which have _locals_size and _stack_size array elements in _locals and _stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  StackMapFrame(int32_t offset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
                u1 flags,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
                u2 locals_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
                u2 stack_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
                u2 max_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
                u2 max_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
                VerificationType* locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
                VerificationType* stack,
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 47216
diff changeset
   109
                ClassVerifier* v) : _offset(offset),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
                                    _locals_size(locals_size),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
                                    _stack_size(stack_size),
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   112
                                    _stack_mark(-1),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
                                    _max_locals(max_locals),
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 47216
diff changeset
   114
                                    _max_stack(max_stack),  _flags(flags),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
                                    _locals(locals), _stack(stack),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
                                    _verifier(v) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   118
  static StackMapFrame* copy(StackMapFrame* smf) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   119
    return new StackMapFrame(*smf);
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   120
  }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   121
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  inline void set_offset(int32_t offset)      { _offset = offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  inline void set_verifier(ClassVerifier* v)  { _verifier = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  inline void set_flags(u1 flags)             { _flags = flags; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  inline void set_locals_size(u2 locals_size) { _locals_size = locals_size; }
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   126
  inline void set_stack_size(u2 stack_size)   { _stack_size = _stack_mark = stack_size; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  inline void clear_stack()                   { _stack_size = 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  inline int32_t offset()   const             { return _offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  inline ClassVerifier* verifier() const      { return _verifier; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  inline u1 flags() const                     { return _flags; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  inline int32_t locals_size() const          { return _locals_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  inline VerificationType* locals() const     { return _locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  inline int32_t stack_size() const           { return _stack_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  inline VerificationType* stack() const      { return _stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  inline int32_t max_locals() const           { return _max_locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  inline int32_t max_stack() const            { return _max_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  inline bool flag_this_uninit() const        { return _flags & FLAG_THIS_UNINIT; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Set locals and stack types to bogus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  inline void reset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    int32_t i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    for (i = 0; i < _max_locals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      _locals[i] = VerificationType::bogus_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    for (i = 0; i < _max_stack; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      _stack[i] = VerificationType::bogus_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // Return a StackMapFrame with the same local variable array and empty stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // Stack array is allocate with unused one element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  StackMapFrame* frame_in_exception_handler(u1 flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // Set local variable type array based on m's signature.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  VerificationType set_locals_from_arg(
35194
7151995ee79e 8144256: compiler/uncommontrap/TestStackBangRbp.java crashes VM on Solaris
coleenp
parents: 27022
diff changeset
   156
    const methodHandle& m, VerificationType thisKlass, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // Search local variable type array and stack type array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // Set every element with type of old_object to new_object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  void initialize_object(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    VerificationType old_object, VerificationType new_object);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // Copy local variable type array in src into this local variable type array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  void copy_locals(const StackMapFrame* src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // Copy stack type array in src into this stack type array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  void copy_stack(const StackMapFrame* src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  // Return true if this stack map frame is assignable to target.
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   170
  bool is_assignable_to(
43179
06ccf3bfd0a3 8167104: Additional class construction refinements
hseigel
parents: 35194
diff changeset
   171
      const StackMapFrame* target, ErrorContext* ctx, TRAPS) const;
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   172
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   173
  inline void set_mark() {
17006
b9bfa72b7dda 7104565: trim jprt build targets
drchase
parents: 15466
diff changeset
   174
#ifdef ASSERT
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   175
    // Put bogus type to indicate it's no longer valid.
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   176
    if (_stack_mark != -1) {
15466
39edb6ef27d1 8007475: Memory stomp with UseMallocOnly
simonis
parents: 13728
diff changeset
   177
      for (int i = _stack_mark - 1; i >= _stack_size; --i) {
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   178
        _stack[i] = VerificationType::bogus_type();
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   179
      }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   180
    }
17006
b9bfa72b7dda 7104565: trim jprt build targets
drchase
parents: 15466
diff changeset
   181
#endif // def ASSERT
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   182
    _stack_mark = _stack_size;
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   183
  }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   184
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   185
  // Used when an error occurs and we want to reset the stack to the state
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   186
  // it was before operands were popped off.
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   187
  void restore() {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   188
    if (_stack_mark != -1) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   189
      _stack_size = _stack_mark;
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   190
    }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   191
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Push type into stack type array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  inline void push_stack(VerificationType type, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    assert(!type.is_check(), "Must be a real type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    if (_stack_size >= _max_stack) {
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   197
      verifier()->verify_error(
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   198
          ErrorContext::stack_overflow(_offset, this),
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   199
          "Operand stack overflow");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    _stack[_stack_size++] = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  inline void push_stack_2(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      VerificationType type1, VerificationType type2, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    assert(type1.is_long() || type1.is_double(), "must be long/double");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    assert(type2.is_long2() || type2.is_double2(), "must be long/double_2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    if (_stack_size >= _max_stack - 1) {
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   210
      verifier()->verify_error(
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   211
          ErrorContext::stack_overflow(_offset, this),
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   212
          "Operand stack overflow");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    _stack[_stack_size++] = type1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    _stack[_stack_size++] = type2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  // Pop and return the top type on stack without verifying.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  inline VerificationType pop_stack(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    if (_stack_size <= 0) {
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   222
      verifier()->verify_error(
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   223
          ErrorContext::stack_underflow(_offset, this),
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   224
          "Operand stack underflow");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      return VerificationType::bogus_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    VerificationType top = _stack[--_stack_size];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    return top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // Pop and return the top type on stack type array after verifying it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  // is assignable to type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  inline VerificationType pop_stack(VerificationType type, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    if (_stack_size != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
      VerificationType top = _stack[_stack_size - 1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      bool subtype = type.is_assignable_from(
27022
2db6fe33afc2 8036533: Method for correct defaults
hseigel
parents: 25900
diff changeset
   237
        top, verifier(), false, CHECK_(VerificationType::bogus_type()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      if (subtype) {
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   239
        --_stack_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        return top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    return pop_stack_ex(type, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  inline void pop_stack_2(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
      VerificationType type1, VerificationType type2, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    assert(type1.is_long2() || type1.is_double2(), "must be long/double");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    assert(type2.is_long() || type2.is_double(), "must be long/double_2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    if (_stack_size >= 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
      VerificationType top1 = _stack[_stack_size - 1];
27022
2db6fe33afc2 8036533: Method for correct defaults
hseigel
parents: 25900
diff changeset
   252
      bool subtype1 = type1.is_assignable_from(top1, verifier(), false, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
      VerificationType top2 = _stack[_stack_size - 2];
27022
2db6fe33afc2 8036533: Method for correct defaults
hseigel
parents: 25900
diff changeset
   254
      bool subtype2 = type2.is_assignable_from(top2, verifier(), false, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      if (subtype1 && subtype2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        _stack_size -= 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    pop_stack_ex(type1, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    pop_stack_ex(type2, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   264
  VerificationType local_at(int index) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   265
    return _locals[index];
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   266
  }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   267
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   268
  VerificationType stack_at(int index) {
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   269
    return _stack[index];
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   270
  }
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   271
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  // Uncommon case that throws exceptions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  VerificationType pop_stack_ex(VerificationType type, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // Return the type at index in local variable array after verifying
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // it is assignable to type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  VerificationType get_local(int32_t index, VerificationType type, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  // For long/double.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  void get_local_2(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    int32_t index, VerificationType type1, VerificationType type2, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // Set element at index in local variable array to type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  void set_local(int32_t index, VerificationType type, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // For long/double.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  void set_local_2(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    int32_t index, VerificationType type1, VerificationType type2, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // Private auxiliary method used only in is_assignable_to(StackMapFrame).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // Returns true if src is assignable to target.
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   290
  int is_assignable_to(
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    VerificationType* src, VerificationType* target, int32_t len, TRAPS) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
13476
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   293
  TypeOrigin stack_top_ctx();
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   294
471200fb94fd 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 9133
diff changeset
   295
  void print_on(outputStream* str) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   297
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53108
diff changeset
   298
#endif // SHARE_CLASSFILE_STACKMAPFRAME_HPP