src/hotspot/share/runtime/vframe_hp.cpp
author mbaesken
Tue, 05 Feb 2019 17:40:15 +0100
changeset 53730 1d942423516c
parent 53065 2f41e4935c34
child 57758 91a758925be7
permissions -rw-r--r--
8218136: minor hotspot adjustments for xlclang++ from xlc16 on AIX Reviewed-by: dholmes, goetz, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 48607
diff changeset
     2
 * Copyright (c) 1997, 2018, 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"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 13728
diff changeset
    26
#include "classfile/javaClasses.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "code/codeCache.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "code/debugInfoRec.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "code/nmethod.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "code/pcDesc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "code/scopeDesc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "interpreter/oopMapCache.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "oops/instanceKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "runtime/basicLock.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 48607
diff changeset
    37
#include "runtime/frame.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "runtime/monitorChunk.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "runtime/signature.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    42
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    43
#include "runtime/vframe_hp.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    44
#ifdef COMPILER2
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    45
#include "opto/matcher.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    46
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// ------------- compiledVFrame --------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
StackValueCollection* compiledVFrame::locals() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // Natives has no scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  if (scope() == NULL) return new StackValueCollection(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  GrowableArray<ScopeValue*>*  scv_list = scope()->locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  if (scv_list == NULL) return new StackValueCollection(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // scv_list is the list of ScopeValues describing the JVM stack state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // There is one scv_list entry for every JVM stack state in use.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  int length = scv_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  StackValueCollection* result = new StackValueCollection(length);
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    61
  for (int i = 0; i < length; i++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    62
    result->add(create_stack_value(scv_list->at(i)));
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    63
  }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    64
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    65
  // Replace the original values with any stores that have been
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    66
  // performed through compiledVFrame::update_locals.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  if (list != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    // In real life this never happens or is typically a single element search
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    for (int i = 0; i < list->length(); i++) {
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    71
      if (list->at(i)->matches(this)) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    72
        list->at(i)->update_locals(result);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
void compiledVFrame::set_locals(StackValueCollection* values) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  fatal("Should use update_local for each local update");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
void compiledVFrame::update_local(BasicType type, int index, jvalue value) {
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    88
  assert(index >= 0 && index < method()->max_locals(), "out of bounds");
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    89
  update_deferred_value(type, index, value);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    90
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    92
void compiledVFrame::update_stack(BasicType type, int index, jvalue value) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    93
  assert(index >= 0 && index < method()->max_stack(), "out of bounds");
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    94
  update_deferred_value(type, index + method()->max_locals(), value);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    95
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    97
void compiledVFrame::update_monitor(int index, MonitorInfo* val) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    98
  assert(index >= 0, "out of bounds");
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
    99
  jvalue value;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   100
  value.l = (jobject) val->owner();
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   101
  update_deferred_value(T_OBJECT, index + method()->max_locals() + method()->max_stack(), value);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   102
}
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   103
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   104
void compiledVFrame::update_deferred_value(BasicType type, int index, jvalue value) {
52457
6954394aa33a 8212928: Assertion too strict in compiledVFrame::update_deferred_value on SPARC
kvn
parents: 49480
diff changeset
   105
  assert(fr().is_deoptimized_frame() || thread()->must_deopt_id() == fr().id(),
6954394aa33a 8212928: Assertion too strict in compiledVFrame::update_deferred_value on SPARC
kvn
parents: 49480
diff changeset
   106
         "frame must be scheduled for deoptimization");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals();
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   108
  jvmtiDeferredLocalVariableSet* locals = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  if (deferred != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    // See if this vframe has already had locals with deferred writes
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   111
    for (int f = 0; f < deferred->length(); f++ ) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
      if (deferred->at(f)->matches(this)) {
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   113
        locals = deferred->at(f);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   114
        break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    // No matching vframe must push a new vframe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    // No deferred updates pending for this thread.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    // allocate in C heap
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7444
diff changeset
   121
    deferred =  new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariableSet*> (1, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    thread()->set_deferred_locals(deferred);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  }
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   124
  if (locals == NULL) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   125
    locals = new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id(), vframe_id());
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   126
    deferred->push(locals);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   127
    assert(locals->id() == fr().id(), "Huh? Must match");
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   128
  }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   129
  locals->set_value_at(index, type, value);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
StackValueCollection* compiledVFrame::expressions() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // Natives has no scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  if (scope() == NULL) return new StackValueCollection(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  GrowableArray<ScopeValue*>*  scv_list = scope()->expressions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  if (scv_list == NULL) return new StackValueCollection(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // scv_list is the list of ScopeValues describing the JVM stack state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // There is one scv_list entry for every JVM stack state in use.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  int length = scv_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  StackValueCollection* result = new StackValueCollection(length);
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   142
  for (int i = 0; i < length; i++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   143
    result->add(create_stack_value(scv_list->at(i)));
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   144
  }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   145
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   146
  // Replace the original values with any stores that have been
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   147
  // performed through compiledVFrame::update_stack.
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   148
  GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   149
  if (list != NULL ) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   150
    // In real life this never happens or is typically a single element search
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   151
    for (int i = 0; i < list->length(); i++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   152
      if (list->at(i)->matches(this)) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   153
        list->at(i)->update_stack(result);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   154
        break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   155
      }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   156
    }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   157
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
// The implementation of the following two methods was factorized into the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
// class StackValue because it is also used from within deoptimization.cpp for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
// rematerialization and relocking of non-escaping objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
StackValue *compiledVFrame::create_stack_value(ScopeValue *sv) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  return StackValue::create_stack_value(&_fr, register_map(), sv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
BasicLock* compiledVFrame::resolve_monitor_lock(Location location) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  return StackValue::resolve_monitor_lock(&_fr, location);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
GrowableArray<MonitorInfo*>* compiledVFrame::monitors() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // Natives has no scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  if (scope() == NULL) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   179
    CompiledMethod* nm = code();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   180
    Method* method = nm->method();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   181
    assert(method->is_native() || nm->is_aot(), "Expect a native method or precompiled method");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    if (!method->is_synchronized()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
      return new GrowableArray<MonitorInfo*>(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    // This monitor is really only needed for UseBiasedLocking, but
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    // return it in all cases for now as it might be useful for stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    // traces and tools as well
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    GrowableArray<MonitorInfo*> *monitors = new GrowableArray<MonitorInfo*>(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    // Casting away const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    frame& fr = (frame&) _fr;
7444
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7397
diff changeset
   191
    MonitorInfo* info = new MonitorInfo(
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7397
diff changeset
   192
        fr.get_native_receiver(), fr.get_native_monitor(), false, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    monitors->push(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    return monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  GrowableArray<MonitorValue*>* monitors = scope()->monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  if (monitors == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    return new GrowableArray<MonitorInfo*>(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(monitors->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  for (int index = 0; index < monitors->length(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    MonitorValue* mv = monitors->at(index);
3171
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   203
    ScopeValue*   ov = mv->owner();
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   204
    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
   205
    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
   206
      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
   207
      // Put klass for scalar replaced object.
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   208
      ScopeValue* kv = ((ObjectValue *)ov)->klass();
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   209
      assert(kv->is_constant_oop(), "klass should be oop constant for scalar replaced object");
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   210
      Handle k(Thread::current(), ((ConstantOopReadValue*)kv)->value()());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   211
      assert(java_lang_Class::is_instance(k()), "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   212
      result->push(new MonitorInfo(k(), resolve_monitor_lock(mv->basic_lock()),
3171
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   213
                                   mv->eliminated(), true));
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   214
    } else {
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   215
      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
   216
                                   mv->eliminated(), false));
aa289b22b577 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 670
diff changeset
   217
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  }
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   219
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   220
  // Replace the original values with any stores that have been
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   221
  // performed through compiledVFrame::update_monitors.
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   222
  GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   223
  if (list != NULL ) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   224
    // In real life this never happens or is typically a single element search
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   225
    for (int i = 0; i < list->length(); i++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   226
      if (list->at(i)->matches(this)) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   227
        list->at(i)->update_monitors(result);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   228
        break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   229
      }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   230
    }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   231
  }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   232
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   237
compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, CompiledMethod* nm)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
: javaVFrame(fr, reg_map, thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  _scope  = NULL;
43484
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   240
  _vframe_id = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // Compiled method (native stub or Java code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // native wrappers have no scope data, it is implied
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   243
  if (!nm->is_compiled() || !nm->as_compiled_method()->is_native_method()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   244
      _scope  = nm->scope_desc_at(_fr.pc());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
43484
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   248
compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope, int vframe_id)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
: javaVFrame(fr, reg_map, thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  _scope  = scope;
43484
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   251
  _vframe_id = vframe_id;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  guarantee(_scope != NULL, "scope must be present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
53065
2f41e4935c34 8215205: javaVFrame much slower than vframeStream
dlong
parents: 52457
diff changeset
   255
compiledVFrame* compiledVFrame::at_scope(int decode_offset, int vframe_id) {
2f41e4935c34 8215205: javaVFrame much slower than vframeStream
dlong
parents: 52457
diff changeset
   256
  if (scope()->decode_offset() != decode_offset) {
2f41e4935c34 8215205: javaVFrame much slower than vframeStream
dlong
parents: 52457
diff changeset
   257
    ScopeDesc* scope = this->scope()->at_offset(decode_offset);
2f41e4935c34 8215205: javaVFrame much slower than vframeStream
dlong
parents: 52457
diff changeset
   258
    return new compiledVFrame(frame_pointer(), register_map(), thread(), scope, vframe_id);
2f41e4935c34 8215205: javaVFrame much slower than vframeStream
dlong
parents: 52457
diff changeset
   259
  }
2f41e4935c34 8215205: javaVFrame much slower than vframeStream
dlong
parents: 52457
diff changeset
   260
  assert(_vframe_id == vframe_id, "wrong frame id");
2f41e4935c34 8215205: javaVFrame much slower than vframeStream
dlong
parents: 52457
diff changeset
   261
  return this;
2f41e4935c34 8215205: javaVFrame much slower than vframeStream
dlong
parents: 52457
diff changeset
   262
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
bool compiledVFrame::is_top() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  // FIX IT: Remove this when new native stubs are in place
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  if (scope() == NULL) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  return scope()->is_top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   271
CompiledMethod* compiledVFrame::code() const {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   272
  return CodeCache::find_compiled(_fr.pc());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   276
Method* compiledVFrame::method() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  if (scope() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    // native nmethods have no scope the method is implied
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   279
    nmethod* nm = code()->as_nmethod();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    assert(nm->is_native_method(), "must be native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    return nm->method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   283
  return scope()->method();
1
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::bci() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  int raw = raw_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  return raw == SynchronizationEntryBCI ? 0 : raw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
int compiledVFrame::raw_bci() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  if (scope() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    // native nmethods have no scope the method/bci is implied
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   296
    nmethod* nm = code()->as_nmethod();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    assert(nm->is_native_method(), "must be native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  return scope()->bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   303
bool compiledVFrame::should_reexecute() const {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   304
  if (scope() == NULL) {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   305
    // native nmethods have no scope the method/bci is implied
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   306
    nmethod* nm = code()->as_nmethod();
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   307
    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
   308
    return false;
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   309
  }
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   310
  return scope()->should_reexecute();
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   311
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
vframe* compiledVFrame::sender() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  const frame f = fr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  if (scope() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    // native nmethods have no scope the method/bci is implied
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 29081
diff changeset
   317
    nmethod* nm = code()->as_nmethod();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    assert(nm->is_native_method(), "must be native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    return vframe::sender();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    return scope()->is_top()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
      ? vframe::sender()
43484
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   323
      : new compiledVFrame(&f, register_map(), thread(), scope()->sender(), vframe_id() + 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
43484
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   327
jvmtiDeferredLocalVariableSet::jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id, int vframe_id) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  _method = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  _bci = bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  _id = id;
43484
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   331
  _vframe_id = vframe_id;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  // Alway will need at least one, must be on C heap
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7444
diff changeset
   333
  _locals = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariable*> (1, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
jvmtiDeferredLocalVariableSet::~jvmtiDeferredLocalVariableSet() {
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   337
  for (int i = 0; i < _locals->length(); i++ ) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    delete _locals->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  // Free growableArray and c heap for elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  delete _locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   344
bool jvmtiDeferredLocalVariableSet::matches(const vframe* vf) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  if (!vf->is_compiled_frame()) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  compiledVFrame* cvf = (compiledVFrame*)vf;
43484
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   347
  if (cvf->fr().id() == id() && cvf->vframe_id() == vframe_id()) {
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   348
    assert(cvf->method() == method() && cvf->bci() == bci(), "must agree");
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   349
    return true;
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   350
  }
9c95dd31d0da 8173309: jvmtiDeferredLocalVariableSet may update the wrong frame
never
parents: 42650
diff changeset
   351
  return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   354
void jvmtiDeferredLocalVariableSet::set_value_at(int idx, BasicType type, jvalue val) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   355
  for (int i = 0; i < _locals->length(); i++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   356
    if (_locals->at(i)->index() == idx) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   357
      assert(_locals->at(i)->type() == type, "Wrong type");
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   358
      _locals->at(i)->set_value(val);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  }
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   362
  _locals->push(new jvmtiDeferredLocalVariable(idx, type, val));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   365
void jvmtiDeferredLocalVariableSet::update_value(StackValueCollection* locals, BasicType type, int index, jvalue value) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   366
  switch (type) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   367
    case T_BOOLEAN:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   368
      locals->set_int_at(index, value.z);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   369
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   370
    case T_CHAR:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   371
      locals->set_int_at(index, value.c);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   372
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   373
    case T_FLOAT:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   374
      locals->set_float_at(index, value.f);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   375
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   376
    case T_DOUBLE:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   377
      locals->set_double_at(index, value.d);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   378
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   379
    case T_BYTE:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   380
      locals->set_int_at(index, value.b);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   381
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   382
    case T_SHORT:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   383
      locals->set_int_at(index, value.s);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   384
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   385
    case T_INT:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   386
      locals->set_int_at(index, value.i);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   387
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   388
    case T_LONG:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   389
      locals->set_long_at(index, value.j);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   390
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   391
    case T_OBJECT:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   392
      {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   393
        Handle obj(Thread::current(), (oop)value.l);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   394
        locals->set_obj_at(index, obj);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   395
      }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   396
      break;
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   397
    default:
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   398
      ShouldNotReachHere();
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   399
  }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   400
}
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   401
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   402
void jvmtiDeferredLocalVariableSet::update_locals(StackValueCollection* locals) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   403
  for (int l = 0; l < _locals->length(); l ++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   404
    jvmtiDeferredLocalVariable* val = _locals->at(l);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   405
    if (val->index() >= 0 && val->index() < method()->max_locals()) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   406
      update_value(locals, val->type(), val->index(), val->value());
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   407
    }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   408
  }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   409
}
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   410
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   411
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   412
void jvmtiDeferredLocalVariableSet::update_stack(StackValueCollection* expressions) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   413
  for (int l = 0; l < _locals->length(); l ++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   414
    jvmtiDeferredLocalVariable* val = _locals->at(l);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   415
    if (val->index() >= method()->max_locals() && val->index() < method()->max_locals() + method()->max_stack()) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   416
      update_value(expressions, val->type(), val->index() - method()->max_locals(), val->value());
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   417
    }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   418
  }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   419
}
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   420
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   421
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   422
void jvmtiDeferredLocalVariableSet::update_monitors(GrowableArray<MonitorInfo*>* monitors) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   423
  for (int l = 0; l < _locals->length(); l ++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   424
    jvmtiDeferredLocalVariable* val = _locals->at(l);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   425
    if (val->index() >= method()->max_locals() + method()->max_stack()) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   426
      int lock_index = val->index() - (method()->max_locals() + method()->max_stack());
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   427
      MonitorInfo* info = monitors->at(lock_index);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   428
      MonitorInfo* new_info = new MonitorInfo((oopDesc*)val->value().l, info->lock(), info->eliminated(), info->owner_is_scalar_replaced());
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   429
      monitors->at_put(lock_index, new_info);
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   430
    }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   431
  }
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   432
}
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   433
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   434
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
void jvmtiDeferredLocalVariableSet::oops_do(OopClosure* f) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   436
  // The Method* is on the stack so a live activation keeps it alive
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   437
  // either by mirror in interpreter or code in compiled code.
48607
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   438
  for (int i = 0; i < _locals->length(); i++) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   439
    if (_locals->at(i)->type() == T_OBJECT) {
7fc3d62481ba 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 47216
diff changeset
   440
      f->do_oop(_locals->at(i)->oop_addr());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
jvmtiDeferredLocalVariable::jvmtiDeferredLocalVariable(int index, BasicType type, jvalue value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  _index = index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  _type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  _value = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
void compiledVFrame::verify() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
#endif // PRODUCT