hotspot/src/share/vm/code/scopeDesc.hpp
author cfang
Thu, 20 Aug 2009 12:42:57 -0700
changeset 3686 69c1b5228547
parent 3600 27aa4477d039
child 4894 8a76fd3d098d
permissions -rw-r--r--
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit Summary: use PcDesc to keep record of the reexecute bit instead of using DebugInfoStreams Reviewed-by: kvn, never, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
3686
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
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
// SimpleScopeDesc is used when all you need to extract from
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// a given pc,nmethod pair is a methodOop and a bci. This is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// quite a bit faster than allocating a full ScopeDesc, but
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// very limited in abilities.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class SimpleScopeDesc : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  methodOop _method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  int _bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  SimpleScopeDesc(nmethod* code,address pc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    PcDesc* pc_desc = code->pc_desc_at(pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    assert(pc_desc != NULL, "Must be able to find matching PcDesc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    int ignore_sender = buffer.read_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    _method           = methodOop(buffer.read_oop());
3686
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    42
    _bci              = buffer.read_bci();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  methodOop method() { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  int bci() { return _bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// ScopeDescs contain the information that makes source-level debugging of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// nmethods possible; each scopeDesc describes a method activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class ScopeDesc : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Constructor
3686
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    55
  ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // Calls above, giving default value of "serialized_null" to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // "obj_decode_offset" argument.  (We don't use a default argument to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // avoid a .hpp-.hpp dependency.)
3686
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    60
  ScopeDesc(const nmethod* code, int decode_offset, bool reexecute);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // JVM state
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 1
diff changeset
    63
  methodHandle method()   const { return _method; }
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 1
diff changeset
    64
  int          bci()      const { return _bci;    }
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 1
diff changeset
    65
  bool should_reexecute() const { return _reexecute; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  GrowableArray<ScopeValue*>*   locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  GrowableArray<ScopeValue*>*   expressions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  GrowableArray<MonitorValue*>* monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  GrowableArray<ScopeValue*>*   objects();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // Stack walking, returns NULL if this is the outer most scope.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  ScopeDesc* sender() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Returns where the scope was decoded
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  int decode_offset() const { return _decode_offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // Tells whether sender() returns NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  bool is_top() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // Tells whether sd is equal to this
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  bool is_equal(ScopeDesc* sd) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // Alternative constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  ScopeDesc(const ScopeDesc* parent);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // JVM state
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  methodHandle  _method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  int           _bci;
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 1
diff changeset
    90
  bool          _reexecute;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Decoding offsets
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  int _decode_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  int _sender_decode_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  int _locals_decode_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  int _expressions_decode_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  int _monitors_decode_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Object pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  GrowableArray<ScopeValue*>* _objects;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // Nmethod information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  const nmethod* _code;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // Decoding operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  void decode_body();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  GrowableArray<ScopeValue*>* decode_scope_values(int decode_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  GrowableArray<MonitorValue*>* decode_monitor_values(int decode_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  GrowableArray<ScopeValue*>* decode_object_values(int decode_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  DebugInfoReadStream* stream_at(int decode_offset) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Printing support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  void print_on(outputStream* st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  void print_on(outputStream* st, PcDesc* pd) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  void print_value_on(outputStream* st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
};