src/hotspot/share/runtime/vframeArray.cpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 54786 ebf733a324d4
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 54786
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
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: 5419
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: 6740
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    26
#include "classfile/vmSymbols.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    27
#include "code/vmreg.inline.hpp"
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
    28
#include "interpreter/bytecode.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    29
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    30
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    31
#include "memory/resourceArea.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    32
#include "oops/methodData.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    33
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    34
#include "prims/jvmtiThreadState.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49359
diff changeset
    35
#include "runtime/frame.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    36
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    37
#include "runtime/monitorChunk.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    38
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    39
#include "runtime/vframe.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    40
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    41
#include "runtime/vframe_hp.hpp"
49593
4dd58ecc9912 8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents: 49480
diff changeset
    42
#include "utilities/copy.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    43
#include "utilities/events.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    44
#ifdef COMPILER2
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    45
#include "opto/runtime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6740
diff changeset
    46
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
int vframeArrayElement:: bci(void) const { return (_bci == SynchronizationEntryBCI ? 0 : _bci); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
void vframeArrayElement::free_monitors(JavaThread* jt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  if (_monitors != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
     MonitorChunk* chunk = _monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
     _monitors = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
     jt->remove_monitor_chunk(chunk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
     delete chunk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    59
void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// Copy the information from the compiled vframe to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// interpreter frame we will be creating to replace vf
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  _method = vf->method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  _bci    = vf->raw_bci();
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
    66
  _reexecute = vf->should_reexecute();
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    67
#ifdef ASSERT
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    68
  _removed_monitors = false;
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    69
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  int index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // Get the monitors off-stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  GrowableArray<MonitorInfo*>* list = vf->monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  if (list->is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    _monitors = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    // Allocate monitor chunk
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    _monitors = new MonitorChunk(list->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    vf->thread()->add_monitor_chunk(_monitors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    // Migrate the BasicLocks from the stack to the monitor chunk
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    for (index = 0; index < list->length(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      MonitorInfo* monitor = list->at(index);
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    87
      assert(!monitor->owner_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      BasicObjectLock* dest = _monitors->at(index);
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    89
      if (monitor->owner_is_scalar_replaced()) {
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    90
        dest->set_obj(NULL);
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    91
      } else {
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    92
        assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    93
        dest->set_obj(monitor->owner());
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    94
        monitor->lock()->move_to(monitor->owner(), dest->lock());
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
    95
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Convert the vframe locals and expressions to off stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // values. Because we will not gc all oops can be converted to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // intptr_t (i.e. a stack slot) and we are fine. This is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // good since we are inside a HandleMark and the oops in our
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // collection would go away between packing them here and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // unpacking them in unpack_on_stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // First the locals go off-stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // FIXME this seems silly it creates a StackValueCollection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // in order to get the size to then copy them and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // convert the types to intptr_t size slots. Seems like it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // could do it in place... Still uses less memory than the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // old way though
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  StackValueCollection *locs = vf->locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  _locals = new StackValueCollection(locs->size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  for(index = 0; index < locs->size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    StackValue* value = locs->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    switch(value->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      case T_OBJECT:
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
   120
        assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
        // preserve object type
20282
7f9cbdf89af2 7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents: 15943
diff changeset
   122
        _locals->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
      case T_CONFLICT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
        // A dead local.  Will be initialized to null/zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
        _locals->add( new StackValue());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
      case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
        _locals->add( new StackValue(value->get_int()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // Now the expressions off-stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // Same silliness as above
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  StackValueCollection *exprs = vf->expressions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  _expressions = new StackValueCollection(exprs->size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  for(index = 0; index < exprs->size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    StackValue* value = exprs->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    switch(value->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      case T_OBJECT:
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
   145
        assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
        // preserve object type
20282
7f9cbdf89af2 7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents: 15943
diff changeset
   147
        _expressions->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      case T_CONFLICT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
        // A dead stack element.  Will be initialized to null/zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
        // This can occur when the compiler emits a state in which stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
        // elements are known to be dead (because of an imminent exception).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
        _expressions->add( new StackValue());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
      case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
        _expressions->add( new StackValue(value->get_int()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
        ShouldNotReachHere();
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
int unpack_counter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
9636
363ca5579aff 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 7913
diff changeset
   166
void vframeArrayElement::unpack_on_stack(int caller_actual_parameters,
363ca5579aff 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 7913
diff changeset
   167
                                         int callee_parameters,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
                                         int callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
                                         frame* caller,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
                                         bool is_top_frame,
15943
d830a939d985 8009761: Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
roland
parents: 15475
diff changeset
   171
                                         bool is_bottom_frame,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
                                         int exec_mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  JavaThread* thread = (JavaThread*) Thread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   175
  bool realloc_failure_exception = thread->frames_to_pop_failed_realloc() > 0;
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   176
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // Look at bci and decide on bcp and continuation pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  address bcp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // C++ interpreter doesn't need a pc since it will figure out what to do when it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // begins execution
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  address pc;
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   182
  bool use_next_mdp = false; // true if we should use the mdp associated with the next bci
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   183
                             // rather than the one associated with bcp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  if (raw_bci() == SynchronizationEntryBCI) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    // We are deoptimizing while hanging in prologue code for synchronized method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    bcp = method()->bcp_from(0); // first byte code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    pc  = Interpreter::deopt_entry(vtos, 0); // step = 0 since we don't skip current bytecode
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   188
  } else if (should_reexecute()) { //reexecute this bytecode
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   189
    assert(is_top_frame, "reexecute allowed only for the top frame");
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   190
    bcp = method()->bcp_from(bci());
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   191
    pc  = Interpreter::deopt_reexecute_entry(method(), bcp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    bcp = method()->bcp_from(bci());
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   194
    pc  = Interpreter::deopt_continue_after_entry(method(), bcp, callee_parameters, is_top_frame);
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 3171
diff changeset
   195
    use_next_mdp = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  assert(Bytecodes::is_defined(*bcp), "must be a valid bytecode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // Monitorenter and pending exceptions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  // For Compiler2, there should be no pending exception when deoptimizing at monitorenter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  // because there is no safepoint at the null pointer check (it is either handled explicitly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  // or prior to the monitorenter) and asynchronous exceptions are not made "pending" by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  // runtime interface for the slow case (see JRT_ENTRY_FOR_MONITORENTER).  If an asynchronous
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // exception was processed, the bytecode pointer would have to be extended one bytecode beyond
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // the monitorenter to place it in the proper exception range.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // For Compiler1, deoptimization can occur while throwing a NullPointerException at monitorenter,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // in which case bcp should point to the monitorenter since it is within the exception's range.
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   210
  //
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   211
  // For realloc failure exception we just pop frames, skip the guarantee.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame");
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33198
diff changeset
   214
  assert(thread->deopt_compiled_method() != NULL, "compiled method should be known");
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   215
  guarantee(realloc_failure_exception || !(thread->deopt_compiled_method()->is_compiled_by_c2() &&
6740
2bc601284215 6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents: 5883
diff changeset
   216
              *bcp == Bytecodes::_monitorenter             &&
2bc601284215 6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents: 5883
diff changeset
   217
              exec_mode == Deoptimization::Unpack_exception),
2bc601284215 6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents: 5883
diff changeset
   218
            "shouldn't get exception during monitorenter");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  int popframe_preserved_args_size_in_bytes = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  int popframe_preserved_args_size_in_words = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  if (is_top_frame) {
4896
88b4193b82b0 6925249: assert(last_sp < (intptr_t*) interpreter_frame_monitor_begin(),"bad tos")
kvn
parents: 3603
diff changeset
   223
    JvmtiThreadState *state = thread->jvmti_thread_state();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    if (JvmtiExport::can_pop_frame() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
        (thread->has_pending_popframe() || thread->popframe_forcing_deopt_reexecution())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
      if (thread->has_pending_popframe()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
        // Pop top frame after deoptimization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
#ifndef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        pc = Interpreter::remove_activation_preserving_args_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        // Do an uncommon trap type entry. c++ interpreter will know
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
        // to pop frame and preserve the args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
        pc = Interpreter::deopt_entry(vtos, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
        use_next_mdp = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
        // Reexecute invoke in top frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
        pc = Interpreter::deopt_entry(vtos, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
        use_next_mdp = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        popframe_preserved_args_size_in_bytes = in_bytes(thread->popframe_preserved_args_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
        // Note: the PopFrame-related extension of the expression stack size is done in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
        // Deoptimization::fetch_unroll_info_helper
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
        popframe_preserved_args_size_in_words = in_words(thread->popframe_preserved_args_size_in_words());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      }
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   245
    } else if (!realloc_failure_exception && JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      // Force early return from top frame after deoptimization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
#ifndef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
      pc = Interpreter::remove_activation_early_entry(state->earlyret_tos());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    } else {
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   251
      if (realloc_failure_exception && JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   252
        state->clr_earlyret_pending();
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   253
        state->set_earlyret_oop(NULL);
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   254
        state->clr_earlyret_value();
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents: 38133
diff changeset
   255
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      // Possibly override the previous pc computation of the top (youngest) frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
      switch (exec_mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      case Deoptimization::Unpack_deopt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
        // use what we've got
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
      case Deoptimization::Unpack_exception:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
        // exception is pending
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4896
diff changeset
   263
        pc = SharedRuntime::raw_exception_handler_for_return_address(thread, pc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
        // [phh] We're going to end up in some handler or other, so it doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
        // matter what mdp we point to.  See exception_handler_for_exception()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
        // in interpreterRuntime.cpp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
      case Deoptimization::Unpack_uncommon_trap:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
      case Deoptimization::Unpack_reexecute:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
        // redo last byte code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
        pc  = Interpreter::deopt_entry(vtos, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
        use_next_mdp = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  // Setup the interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  assert(method() != NULL, "method must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  int temps = expressions()->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  Interpreter::layout_activation(method(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
                                 temps + callee_parameters,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
                                 popframe_preserved_args_size_in_words,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
                                 locks,
9636
363ca5579aff 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 7913
diff changeset
   291
                                 caller_actual_parameters,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
                                 callee_parameters,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
                                 callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
                                 caller,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
                                 iframe(),
15943
d830a939d985 8009761: Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
roland
parents: 15475
diff changeset
   296
                                 is_top_frame,
d830a939d985 8009761: Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
roland
parents: 15475
diff changeset
   297
                                 is_bottom_frame);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // Update the pc in the frame object and overwrite the temporary pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // we placed in the skeletal frame now that we finally know the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // exact interpreter address we should use.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  _frame.patch_pc(thread, pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   305
  assert (!method()->is_synchronized() || locks > 0 || _removed_monitors || raw_bci() == SynchronizationEntryBCI, "synchronized methods must have monitors");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  for (int index = 0; index < locks; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    top = iframe()->previous_monitor_in_interpreter_frame(top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    BasicObjectLock* src = _monitors->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    top->set_obj(src->obj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    src->lock()->move_to(src->obj(), top->lock());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  if (ProfileInterpreter) {
25714
87fa6860b5ae 8004128: NPG: remove stackwalking in Threads::gc_prologue and gc_epilogue code
coleenp
parents: 24424
diff changeset
   315
    iframe()->interpreter_frame_set_mdp(0); // clear out the mdp.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  }
25714
87fa6860b5ae 8004128: NPG: remove stackwalking in Threads::gc_prologue and gc_epilogue code
coleenp
parents: 24424
diff changeset
   317
  iframe()->interpreter_frame_set_bcp(bcp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  if (ProfileInterpreter) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   319
    MethodData* mdo = method()->method_data();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    if (mdo != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
      int bci = iframe()->interpreter_frame_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
      if (use_next_mdp) ++bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      address mdp = mdo->bci_to_dp(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      iframe()->interpreter_frame_set_mdp(mdp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   328
  if (PrintDeoptimizationDetails) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   329
    tty->print_cr("Expressions size: %d", expressions()->size());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   330
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   331
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  // Unpack expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // If this is an intermediate frame (i.e. not top frame) then this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // only unpacks the part of the expression stack not used by callee
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  // as parameters. The callee parameters are unpacked as part of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // callee locals.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  for(i = 0; i < expressions()->size(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    StackValue *value = expressions()->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    intptr_t*   addr  = iframe()->interpreter_frame_expression_stack_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    switch(value->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
      case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
        *addr = value->get_int();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   344
#ifndef PRODUCT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   345
        if (PrintDeoptimizationDetails) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   346
          tty->print_cr("Reconstructed expression %d (INT): %d", i, (int)(*addr));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   347
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   348
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      case T_OBJECT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
        *addr = value->get_int(T_OBJECT);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   352
#ifndef PRODUCT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   353
        if (PrintDeoptimizationDetails) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   354
          tty->print("Reconstructed expression %d (OBJECT): ", i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   355
          oop o = (oop)(address)(*addr);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   356
          if (o == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   357
            tty->print_cr("NULL");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   358
          } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   359
            ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   360
            tty->print_raw_cr(o->klass()->name()->as_C_string());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   361
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   362
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   363
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
      case T_CONFLICT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
        // A dead stack slot.  Initialize to null in case it is an oop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
        *addr = NULL_WORD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  // Unpack the locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  for(i = 0; i < locals()->size(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    StackValue *value = locals()->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    intptr_t* addr  = iframe()->interpreter_frame_local_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    switch(value->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
      case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
        *addr = value->get_int();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   382
#ifndef PRODUCT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   383
        if (PrintDeoptimizationDetails) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   384
          tty->print_cr("Reconstructed local %d (INT): %d", i, (int)(*addr));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   385
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   386
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      case T_OBJECT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
        *addr = value->get_int(T_OBJECT);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   390
#ifndef PRODUCT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   391
        if (PrintDeoptimizationDetails) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   392
          tty->print("Reconstructed local %d (OBJECT): ", i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   393
          oop o = (oop)(address)(*addr);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   394
          if (o == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   395
            tty->print_cr("NULL");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   396
          } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   397
            ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   398
            tty->print_raw_cr(o->klass()->name()->as_C_string());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   399
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   400
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   401
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
      case T_CONFLICT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
        // A dead location. If it is an oop then we need a NULL to prevent GC from following it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
        *addr = NULL_WORD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  if (is_top_frame && JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    // An interpreted frame was popped but it returns to a deoptimized
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    // frame. The incoming arguments to the interpreted activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    // were preserved in thread-local storage by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    // remove_activation_preserving_args_entry in the interpreter; now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    // we put them back into the just-unpacked interpreter frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    // Note that this assumes that the locals arena grows toward lower
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    // addresses.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    if (popframe_preserved_args_size_in_words != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
      void* saved_args = thread->popframe_preserved_args();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
      assert(saved_args != NULL, "must have been saved by interpreter");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      assert(popframe_preserved_args_size_in_words <=
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 5046
diff changeset
   425
             iframe()->interpreter_frame_expression_stack_size()*Interpreter::stackElementWords,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
             "expression stack size should have been extended");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
      int top_element = iframe()->interpreter_frame_expression_stack_size()-1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      intptr_t* base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
      if (frame::interpreter_frame_expression_stack_direction() < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
        base = iframe()->interpreter_frame_expression_stack_at(top_element);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
        base = iframe()->interpreter_frame_expression_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
      }
5883
8dc4bdc132d5 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 5547
diff changeset
   435
      Copy::conjoint_jbytes(saved_args,
8dc4bdc132d5 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 5547
diff changeset
   436
                            base,
8dc4bdc132d5 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 5547
diff changeset
   437
                            popframe_preserved_args_size_in_bytes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
      thread->popframe_free_preserved_args();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
#ifndef PRODUCT
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28039
diff changeset
   443
  if (PrintDeoptimizationDetails) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    ttyLocker ttyl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    tty->print_cr("[%d Interpreted Frame]", ++unpack_counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    iframe()->print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    RegisterMap map(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    vframe* f = vframe::new_vframe(iframe(), &map, thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    f->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    tty->print_cr("locals size     %d", locals()->size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    tty->print_cr("expression size %d", expressions()->size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    method()->print_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    // method()->print_codes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  } else if (TraceDeoptimization) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    tty->print("     ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    method()->print_value();
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   460
    Bytecodes::Code code = Bytecodes::java_code_at(method(), bcp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    int bci = method()->bci_from(bcp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    tty->print(" - %s", Bytecodes::name(code));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    tty->print(" @ bci %d ", bci);
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 28039
diff changeset
   464
    tty->print_cr("sp = " PTR_FORMAT, p2i(iframe()->sp()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  // The expression stack and locals are in the resource area don't leave
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  // a dangling pointer in the vframeArray we leave around for debug
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  // purposes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  _locals = _expressions = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 20282
diff changeset
   476
int vframeArrayElement::on_stack_size(int callee_parameters,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
                                      int callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
                                      bool is_top_frame,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
                                      int popframe_extra_stack_expression_els) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  assert(method()->max_locals() == locals()->size(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  int temps = expressions()->size();
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 20282
diff changeset
   483
  return Interpreter::size_activation(method()->max_stack(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
                                      temps + callee_parameters,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
                                      popframe_extra_stack_expression_els,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
                                      locks,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
                                      callee_parameters,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
                                      callee_locals,
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 20282
diff changeset
   489
                                      is_top_frame);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49359
diff changeset
   493
intptr_t* vframeArray::unextended_sp() const {
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49359
diff changeset
   494
  return _original.unextended_sp();
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49359
diff changeset
   495
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
   498
                                   RegisterMap *reg_map, frame sender, frame caller, frame self,
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
   499
                                   bool realloc_failures) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  // Allocate the vframeArray
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  vframeArray * result = (vframeArray*) AllocateHeap(sizeof(vframeArray) + // fixed part
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
                                                     sizeof(vframeArrayElement) * (chunk->length() - 1), // variable part
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 9636
diff changeset
   504
                                                     mtCompiler);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  result->_frames = chunk->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  result->_owner_thread = thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  result->_sender = sender;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  result->_caller = caller;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  result->_original = self;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  result->set_unroll_block(NULL); // initialize it
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
   511
  result->fill_in(thread, frame_size, chunk, reg_map, realloc_failures);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
void vframeArray::fill_in(JavaThread* thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
                          int frame_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
                          GrowableArray<compiledVFrame*>* chunk,
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
   518
                          const RegisterMap *reg_map,
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
   519
                          bool realloc_failures) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  // Set owner first, it is used when adding monitor chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  _frame_size = frame_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  for(int i = 0; i < chunk->length(); i++) {
28039
bf5a8340bf8a 6898462: The escape analysis with G1 cause crash assertion src/share/vm/runtime/vframeArray.cpp:94
roland
parents: 25717
diff changeset
   524
    element(i)->fill_in(chunk->at(i), realloc_failures);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  // Copy registers for callee-saved registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  if (reg_map != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
    for(int i = 0; i < RegisterMap::reg_count; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
      // The register map has one entry for every int (32-bit value), so
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
      // 64-bit physical registers have two entries in the map, one for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
      // each half.  Ignore the high halves of 64-bit registers, just like
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
      // frame::oopmapreg_to_location does.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
      //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
      // [phh] FIXME: this is a temporary hack!  This code *should* work
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
      // correctly w/o this hack, possibly by changing RegisterMap::pd_location
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
      // in frame_amd64.cpp and the values of the phantom high half registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
      // in amd64.ad.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
      //      if (VMReg::Name(i) < SharedInfo::stack0 && is_even(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
        intptr_t* src = (intptr_t*) reg_map->location(VMRegImpl::as_VMReg(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
        _callee_registers[i] = src != NULL ? *src : NULL_WORD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
        //      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
        //      jint* src = (jint*) reg_map->location(VMReg::Name(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
        //      _callee_registers[i] = src != NULL ? *src : NULL_WORD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
        //      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
      jint* src = (jint*) reg_map->location(VMRegImpl::as_VMReg(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
      _callee_registers[i] = src != NULL ? *src : NULL_WORD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
      if (src == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
        set_location_valid(i, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
        set_location_valid(i, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
        jint* dst = (jint*) register_location(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
        *dst = *src;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
9636
363ca5579aff 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 7913
diff changeset
   562
void vframeArray::unpack_to_stack(frame &unpack_frame, int exec_mode, int caller_actual_parameters) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  // stack picture
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  //   unpack_frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  //   [new interpreter frames ] (frames are skeletal but walkable)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  //   caller_frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  //  This routine fills in the missing data for the skeletal interpreter frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  //  in the above picture.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  // Find the skeletal interpreter frames to unpack into
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   572
  JavaThread* THREAD = JavaThread::current();
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   573
  RegisterMap map(THREAD, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  // Get the youngest frame we will unpack (last to be unpacked)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  frame me = unpack_frame.sender(&map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  int index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  for (index = 0; index < frames(); index++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    *element(index)->iframe() = me;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    // Get the caller frame (possibly skeletal)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    me = me.sender(&map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   583
  // Do the unpacking of interpreter frames; the frame at index 0 represents the top activation, so it has no callee
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   584
  // Unpack the frames from the oldest (frames() -1) to the youngest (0)
15943
d830a939d985 8009761: Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
roland
parents: 15475
diff changeset
   585
  frame* caller_frame = &me;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  for (index = frames() - 1; index >= 0 ; index--) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   587
    vframeArrayElement* elem = element(index);  // caller
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   588
    int callee_parameters, callee_locals;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   589
    if (index == 0) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   590
      callee_parameters = callee_locals = 0;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   591
    } else {
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 54786
diff changeset
   592
      methodHandle caller(THREAD, elem->method());
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 54786
diff changeset
   593
      methodHandle callee(THREAD, element(index - 1)->method());
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   594
      Bytecode_invoke inv(caller, elem->bci());
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   595
      // invokedynamic instructions don't have a class but obviously don't have a MemberName appendix.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   596
      // NOTE:  Use machinery here that avoids resolving of any kind.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   597
      const bool has_member_arg =
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   598
          !inv.is_invokedynamic() && MethodHandles::has_member_arg(inv.klass(), inv.name());
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   599
      callee_parameters = callee->size_of_parameters() + (has_member_arg ? 1 : 0);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   600
      callee_locals     = callee->max_locals();
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   601
    }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   602
    elem->unpack_on_stack(caller_actual_parameters,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   603
                          callee_parameters,
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   604
                          callee_locals,
15943
d830a939d985 8009761: Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
roland
parents: 15475
diff changeset
   605
                          caller_frame,
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   606
                          index == 0,
15943
d830a939d985 8009761: Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
roland
parents: 15475
diff changeset
   607
                          index == frames() - 1,
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   608
                          exec_mode);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
    if (index == frames() - 1) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13195
diff changeset
   610
      Deoptimization::unwind_callee_save_values(elem->iframe(), this);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
    }
15943
d830a939d985 8009761: Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
roland
parents: 15475
diff changeset
   612
    caller_frame = elem->iframe();
9636
363ca5579aff 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 7913
diff changeset
   613
    caller_actual_parameters = callee_parameters;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  deallocate_monitor_chunks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
void vframeArray::deallocate_monitor_chunks() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  JavaThread* jt = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  for (int index = 0; index < frames(); index++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
     element(index)->free_monitors(jt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
bool vframeArray::structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  if (owner_thread() != thread) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  int index = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
#if 0 // FIXME can't do this comparison
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  // Compare only within vframe array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
  for (deoptimizedVFrame* vf = deoptimizedVFrame::cast(vframe_at(first_index())); vf; vf = vf->deoptimized_sender_or_null()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
    if (index >= chunk->length() || !vf->structural_compare(chunk->at(index))) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
    index++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  if (index != chunk->length()) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
address vframeArray::register_location(int i) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  assert(0 <= i && i < RegisterMap::reg_count, "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  return (address) & _callee_registers[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
// Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
// Note: we cannot have print_on as const, as we allocate inside the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
void vframeArray::print_on_2(outputStream* st)  {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 28039
diff changeset
   657
  st->print_cr(" - sp: " INTPTR_FORMAT, p2i(sp()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  st->print(" - thread: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  Thread::current()->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  st->print_cr(" - frame size: %d", frame_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  for (int index = 0; index < frames() ; index++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    element(index)->print(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
void vframeArrayElement::print(outputStream* st) {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 28039
diff changeset
   667
  st->print_cr(" - interpreter_frame -> sp: " INTPTR_FORMAT, p2i(iframe()->sp()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
void vframeArray::print_value_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  st->print_cr("vframeArray [%d] ", frames());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
#endif