hotspot/src/share/vm/runtime/vframeArray.hpp
author phh
Wed, 28 Oct 2009 16:25:51 -0400
changeset 4434 4b41e5b42f81
parent 3795 6227ff014cfe
child 5547 f4b087cbb361
permissions -rw-r--r--
6887571: Increase default heap config sizes Summary: Apply modification of existing server heap size ergo to all collectors except CMS. Reviewed-by: jmasa, ysr, xlu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
3795
6227ff014cfe 6884624: Update copyright year
xdono
parents: 3600
diff changeset
     2
 * Copyright 1997-2009 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// A vframeArray is an array used for momentarily storing off stack Java method activations
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// during deoptimization. Essentially it is an array of vframes where each vframe
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// data is stored off stack. This structure will never exist across a safepoint so
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// there is no need to gc any oops that are stored in the structure.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class LocalsClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class ExpressionStackClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class MonitorStackClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class MonitorArrayElement;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class StackValueCollection;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// A vframeArrayElement is an element of a vframeArray. Each element
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// represent an interpreter frame which will eventually be created.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class vframeArrayElement : public _ValueObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    frame _frame;                                                // the interpreter frame we will unpack into
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 1
diff changeset
    44
    int  _bci;                                                   // raw bci for this vframe
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 1
diff changeset
    45
    bool _reexecute;                                             // whether sould we reexecute this bytecode
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    methodOop  _method;                                          // the method for this vframe
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    MonitorChunk* _monitors;                                     // active monitors for this vframe
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    StackValueCollection* _locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    StackValueCollection* _expressions;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  frame* iframe(void)                { return &_frame; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  int bci(void) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  int raw_bci(void) const            { return _bci; }
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 1
diff changeset
    58
  bool should_reexecute(void) const  { return _reexecute; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  methodOop method(void) const       { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  MonitorChunk* monitors(void) const { return _monitors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  void free_monitors(JavaThread* jt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  StackValueCollection* locals(void) const             { return _locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  StackValueCollection* expressions(void) const        { return _expressions; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  void fill_in(compiledVFrame* vf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // Formerly part of deoptimizedVFrame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Returns the on stack word size for this frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // callee_parameters is the number of callee locals residing inside this frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  int on_stack_size(int callee_parameters,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
                    int callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
                    bool is_top_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
                    int popframe_extra_stack_expression_els) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // Unpacks the element to skeletal interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  void unpack_on_stack(int callee_parameters,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
                       int callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
                       frame* caller,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
                       bool is_top_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
                       int exec_mode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  void print(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
#endif /* PRODUCT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
// this can be a ResourceObj if we don't save the last one...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
// but it does make debugging easier even if we can't look
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
// at the data in each vframeElement
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
class vframeArray: public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // Here is what a vframeArray looks like in memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      fixed part
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
        description of the original frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
        _frames - number of vframes in this array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
        adapter info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
        callee register save area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      variable part
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
        vframeArrayElement   [ 0 ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
        ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
        vframeArrayElement   [_frames - 1]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  JavaThread*                  _owner_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  vframeArray*                 _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  frame                        _original;          // the original frame of the deoptee
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  frame                        _caller;            // caller of root frame in vframeArray
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  frame                        _sender;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  Deoptimization::UnrollBlock* _unroll_block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  int                          _frame_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  int                          _frames; // number of javavframes in the array (does not count any adapter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  intptr_t                     _callee_registers[RegisterMap::reg_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  unsigned char                _valid[RegisterMap::reg_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  vframeArrayElement           _elements[1];   // First variable section.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  void fill_in_element(int index, compiledVFrame* vf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  bool is_location_valid(int i) const        { return _valid[i] != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  void set_location_valid(int i, bool valid) { _valid[i] = valid; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // Tells whether index is within bounds.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  bool is_within_bounds(int index) const        { return 0 <= index && index < frames(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // Accessores for instance variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  int frames() const                            { return _frames;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  static vframeArray* allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                               RegisterMap* reg_map, frame sender, frame caller, frame self);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  vframeArrayElement* element(int index)        { assert(is_within_bounds(index), "Bad index"); return &_elements[index]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Allocates a new vframe in the array and fills the array with vframe information in chunk
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // Returns the owner of this vframeArray
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  JavaThread* owner_thread() const           { return _owner_thread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // Accessors for next
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  vframeArray* next() const                  { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  void set_next(vframeArray* value)          { _next = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // Accessors for sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  intptr_t* sp() const                       { return _original.sp(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  intptr_t* unextended_sp() const            { return _original.unextended_sp(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  address original_pc() const                { return _original.pc(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  frame original() const                     { return _original; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  frame caller() const                       { return _caller; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  frame sender() const                       { return _sender; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // Accessors for unroll block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  Deoptimization::UnrollBlock* unroll_block() const         { return _unroll_block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  void set_unroll_block(Deoptimization::UnrollBlock* block) { _unroll_block = block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // Returns the size of the frame that got deoptimized
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  int frame_size() const { return _frame_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // Unpack the array on the stack passed in stack interval
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  void unpack_to_stack(frame &unpack_frame, int exec_mode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Deallocates monitor chunks allocated during deoptimization.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // This should be called when the array is not used anymore.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  void deallocate_monitor_chunks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // Accessor for register map
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  address register_location(int i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  void print_on_2(outputStream* st) PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  void print_value_on(outputStream* st) const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // Comparing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  bool structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
};