hotspot/src/share/vm/runtime/vframe_hp.cpp
author kamg
Thu, 09 Dec 2010 15:04:26 -0500
changeset 7444 be338e543a57
parent 7397 5b173b4ca846
child 13195 be27e1b6a4b9
permissions -rw-r--r--
7004582: Add GetThisObject() function to JVMTI 1.2 Summary: Add 'GetThisObject' function Reviewed-by: never, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, 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: 3603
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3603
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: 3603
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "code/codeCache.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "code/debugInfoRec.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "code/nmethod.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "code/pcDesc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "code/scopeDesc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "interpreter/oopMapCache.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "oops/instanceKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "runtime/basicLock.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "runtime/monitorChunk.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "runtime/signature.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
#include "runtime/vframe_hp.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    42
#ifdef COMPILER2
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    43
#include "opto/matcher.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    44
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// ------------- compiledVFrame --------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
StackValueCollection* compiledVFrame::locals() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // Natives has no scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  if (scope() == NULL) return new StackValueCollection(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  GrowableArray<ScopeValue*>*  scv_list = scope()->locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  if (scv_list == NULL) return new StackValueCollection(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // scv_list is the list of ScopeValues describing the JVM stack state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // There is one scv_list entry for every JVM stack state in use.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  int length = scv_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  StackValueCollection* result = new StackValueCollection(length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // In rare instances set_locals may have occurred in which case
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // there are local values that are not described by the ScopeValue anymore
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  GrowableArray<jvmtiDeferredLocalVariable*>* deferred = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  if (list != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    // In real life this never happens or is typically a single element search
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    for (int i = 0; i < list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
      if (list->at(i)->matches((vframe*)this)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
        deferred = list->at(i)->locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  for( int i = 0; i < length; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    result->add( create_stack_value(scv_list->at(i)) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Replace specified locals with any deferred writes that are present
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  if (deferred != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    for ( int l = 0;  l < deferred->length() ; l ++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      jvmtiDeferredLocalVariable* val = deferred->at(l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      switch (val->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
      case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        result->set_int_at(val->index(), val->value().z);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
      case T_CHAR:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
        result->set_int_at(val->index(), val->value().c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      case T_FLOAT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
        result->set_float_at(val->index(), val->value().f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      case T_DOUBLE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
        result->set_double_at(val->index(), val->value().d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      case T_BYTE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
        result->set_int_at(val->index(), val->value().b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      case T_SHORT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
        result->set_int_at(val->index(), val->value().s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
        result->set_int_at(val->index(), val->value().i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      case T_LONG:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
        result->set_long_at(val->index(), val->value().j);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
      case T_OBJECT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
          Handle obj((oop)val->value().l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
          result->set_obj_at(val->index(), obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
        ShouldNotReachHere();
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
void compiledVFrame::set_locals(StackValueCollection* values) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  fatal("Should use update_local for each local update");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
void compiledVFrame::update_local(BasicType type, int index, jvalue value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  assert(fr().is_deoptimized_frame(), "frame must be scheduled for deoptimization");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
#endif /* ASSERT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  if (deferred != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    // See if this vframe has already had locals with deferred writes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    int f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    for ( f = 0 ; f < deferred->length() ; f++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
      if (deferred->at(f)->matches(this)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
        // Matching, vframe now see if the local already had deferred write
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
        GrowableArray<jvmtiDeferredLocalVariable*>* locals = deferred->at(f)->locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
        int l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
        for (l = 0 ; l < locals->length() ; l++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
          if (locals->at(l)->index() == index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
            locals->at(l)->set_value(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
            return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
        // No matching local already present. Push a new value onto the deferred collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
        locals->push(new jvmtiDeferredLocalVariable(index, type, value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
        return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    // No matching vframe must push a new vframe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    // No deferred updates pending for this thread.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    // allocate in C heap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    deferred =  new(ResourceObj::C_HEAP) GrowableArray<jvmtiDeferredLocalVariableSet*> (1, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    thread()->set_deferred_locals(deferred);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  deferred->push(new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  assert(deferred->top()->id() == fr().id(), "Huh? Must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  deferred->top()->set_local_at(index, type, value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
StackValueCollection* compiledVFrame::expressions() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // Natives has no scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  if (scope() == NULL) return new StackValueCollection(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  GrowableArray<ScopeValue*>*  scv_list = scope()->expressions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  if (scv_list == NULL) return new StackValueCollection(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // scv_list is the list of ScopeValues describing the JVM stack state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // There is one scv_list entry for every JVM stack state in use.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  int length = scv_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  StackValueCollection* result = new StackValueCollection(length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  for( int i = 0; i < length; i++ )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    result->add( create_stack_value(scv_list->at(i)) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
// The implementation of the following two methods was factorized into the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
// class StackValue because it is also used from within deoptimization.cpp for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
// rematerialization and relocking of non-escaping objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
StackValue *compiledVFrame::create_stack_value(ScopeValue *sv) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  return StackValue::create_stack_value(&_fr, register_map(), sv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
BasicLock* compiledVFrame::resolve_monitor_lock(Location location) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  return StackValue::resolve_monitor_lock(&_fr, location);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
GrowableArray<MonitorInfo*>* compiledVFrame::monitors() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // Natives has no scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  if (scope() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    nmethod* nm = code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    methodOop method = nm->method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    assert(method->is_native(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    if (!method->is_synchronized()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
      return new GrowableArray<MonitorInfo*>(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    // This monitor is really only needed for UseBiasedLocking, but
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    // return it in all cases for now as it might be useful for stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    // traces and tools as well
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    GrowableArray<MonitorInfo*> *monitors = new GrowableArray<MonitorInfo*>(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    // Casting away const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    frame& fr = (frame&) _fr;
7444
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7397
diff changeset
   210
    MonitorInfo* info = new MonitorInfo(
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7397
diff changeset
   211
        fr.get_native_receiver(), fr.get_native_monitor(), false, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    monitors->push(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    return monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  GrowableArray<MonitorValue*>* monitors = scope()->monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  if (monitors == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    return new GrowableArray<MonitorInfo*>(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(monitors->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  for (int index = 0; index < monitors->length(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    MonitorValue* mv = monitors->at(index);
3171
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   222
    ScopeValue*   ov = mv->owner();
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   223
    StackValue *owner_sv = create_stack_value(ov); // it is an oop
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   224
    if (ov->is_object() && owner_sv->obj_is_scalar_replaced()) { // The owner object was scalar replaced
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   225
      assert(mv->eliminated(), "monitor should be eliminated for scalar replaced object");
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   226
      // Put klass for scalar replaced object.
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   227
      ScopeValue* kv = ((ObjectValue *)ov)->klass();
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   228
      assert(kv->is_constant_oop(), "klass should be oop constant for scalar replaced object");
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   229
      KlassHandle k(((ConstantOopReadValue*)kv)->value()());
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   230
      result->push(new MonitorInfo(k->as_klassOop(), resolve_monitor_lock(mv->basic_lock()),
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   231
                                   mv->eliminated(), true));
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   232
    } else {
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   233
      result->push(new MonitorInfo(owner_sv->get_obj()(), resolve_monitor_lock(mv->basic_lock()),
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   234
                                   mv->eliminated(), false));
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   235
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, nmethod* nm)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
: javaVFrame(fr, reg_map, thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  _scope  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // Compiled method (native stub or Java code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // native wrappers have no scope data, it is implied
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  if (!nm->is_native_method()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    _scope  = nm->scope_desc_at(_fr.pc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
: javaVFrame(fr, reg_map, thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  _scope  = scope;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  guarantee(_scope != NULL, "scope must be present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
bool compiledVFrame::is_top() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  // FIX IT: Remove this when new native stubs are in place
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  if (scope() == NULL) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  return scope()->is_top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
nmethod* compiledVFrame::code() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  return CodeCache::find_nmethod(_fr.pc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
methodOop compiledVFrame::method() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  if (scope() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    // native nmethods have no scope the method is implied
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    nmethod* nm = code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    assert(nm->is_native_method(), "must be native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    return nm->method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  return scope()->method()();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
int compiledVFrame::bci() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  int raw = raw_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  return raw == SynchronizationEntryBCI ? 0 : raw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
int compiledVFrame::raw_bci() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  if (scope() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    // native nmethods have no scope the method/bci is implied
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    nmethod* nm = code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    assert(nm->is_native_method(), "must be native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  return scope()->bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   297
bool compiledVFrame::should_reexecute() const {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   298
  if (scope() == NULL) {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   299
    // native nmethods have no scope the method/bci is implied
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   300
    nmethod* nm = code();
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   301
    assert(nm->is_native_method(), "must be native");
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   302
    return false;
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   303
  }
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   304
  return scope()->should_reexecute();
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   305
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
vframe* compiledVFrame::sender() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  const frame f = fr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  if (scope() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    // native nmethods have no scope the method/bci is implied
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    nmethod* nm = code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    assert(nm->is_native_method(), "must be native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    return vframe::sender();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    return scope()->is_top()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
      ? vframe::sender()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
      : new compiledVFrame(&f, register_map(), thread(), scope()->sender());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
jvmtiDeferredLocalVariableSet::jvmtiDeferredLocalVariableSet(methodOop method, int bci, intptr_t* id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  _method = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  _bci = bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  _id = id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  // Alway will need at least one, must be on C heap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  _locals = new(ResourceObj::C_HEAP) GrowableArray<jvmtiDeferredLocalVariable*> (1, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
jvmtiDeferredLocalVariableSet::~jvmtiDeferredLocalVariableSet() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  for (int i = 0; i < _locals->length() ; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    delete _locals->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // Free growableArray and c heap for elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  delete _locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
bool jvmtiDeferredLocalVariableSet::matches(vframe* vf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  if (!vf->is_compiled_frame()) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  compiledVFrame* cvf = (compiledVFrame*)vf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  return cvf->fr().id() == id() && cvf->method() == method() && cvf->bci() == bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
void jvmtiDeferredLocalVariableSet::set_local_at(int idx, BasicType type, jvalue val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  for ( i = 0 ; i < locals()->length() ; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    if ( locals()->at(i)->index() == idx) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      assert(locals()->at(i)->type() == type, "Wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      locals()->at(i)->set_value(val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  locals()->push(new jvmtiDeferredLocalVariable(idx, type, val));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
void jvmtiDeferredLocalVariableSet::oops_do(OopClosure* f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  f->do_oop((oop*) &_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  for ( int i = 0; i < locals()->length(); i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    if ( locals()->at(i)->type() == T_OBJECT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
      f->do_oop(locals()->at(i)->oop_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
jvmtiDeferredLocalVariable::jvmtiDeferredLocalVariable(int index, BasicType type, jvalue value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  _index = index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  _type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  _value = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
void compiledVFrame::verify() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
#endif // PRODUCT