src/hotspot/share/runtime/rframe.cpp
author hseigel
Mon, 05 Mar 2018 10:29:23 -0500
changeset 49340 4e82736053ae
parent 47799 1772ebf07d1f
permissions -rw-r--r--
8191102: Incorrect include file use in classLoader.hpp Summary: Move appropriate methods to <fiile>.inline.hpp files. Create <file>.inline.hpp files when needed. Reviewed-by: coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 47799
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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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: 6418
diff changeset
    25
#include "precompiled.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 8921
diff changeset
    26
#include "code/codeCache.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    27
#include "interpreter/interpreter.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 47799
diff changeset
    28
#include "oops/method.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    29
#include "oops/oop.inline.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    30
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    31
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    32
#include "runtime/rframe.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    33
#include "runtime/vframe.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    34
#include "runtime/vframe_hp.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
static RFrame*const  noCaller    = (RFrame*) 0x1;               // no caller (i.e., initial frame)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
static RFrame*const  noCallerYet = (RFrame*) 0x0;               // caller not yet computed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
RFrame::RFrame(frame fr, JavaThread* thread, RFrame*const callee) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  _fr(fr), _thread(thread), _callee(callee), _num(callee ? callee->num() + 1 : 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  _caller = (RFrame*)noCallerYet;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  _invocations = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  _distance = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
void RFrame::set_distance(int d) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  assert(is_compiled() || d >= 0, "should be positive");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  _distance = d;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
: RFrame(fr, thread, callee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  RegisterMap map(thread, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  _vf     = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread));
31521
f57b2ce43484 8079775: Java 9-fastdebug ia32 Error: Unimplemented with "-XX:CompilationPolicyChoice=1 -XX:-TieredCompilation" options
iveresov
parents: 25715
diff changeset
    56
  _method = _vf->method();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  assert(   _vf->is_interpreted_frame(), "must be interpreted");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
31521
f57b2ce43484 8079775: Java 9-fastdebug ia32 Error: Unimplemented with "-XX:CompilationPolicyChoice=1 -XX:-TieredCompilation" options
iveresov
parents: 25715
diff changeset
    61
InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, Method* m)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
: RFrame(fr, thread, NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  RegisterMap map(thread, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  _vf     = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  _method = m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  assert(   _vf->is_interpreted_frame(),  "must be interpreted");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread, RFrame*const  callee)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
: RFrame(fr, thread, callee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
: RFrame(fr, thread, NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
DeoptimizedRFrame::DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const  callee)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
: InterpretedRFrame(fr, thread, callee) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
RFrame* RFrame::new_RFrame(frame fr, JavaThread* thread, RFrame*const  callee) {
31851
ec2f9350c499 8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents: 31521
diff changeset
    85
  RFrame* rf = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  int dist = callee ? callee->distance() : -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  if (fr.is_interpreted_frame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    rf = new InterpretedRFrame(fr, thread, callee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    dist++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  } else if (fr.is_compiled_frame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    // Even deopted frames look compiled because the deopt
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    // is invisible until it happens.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    rf = new CompiledRFrame(fr, thread, callee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    assert(false, "Unhandled frame type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  }
31851
ec2f9350c499 8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents: 31521
diff changeset
    97
  if (rf != NULL) {
ec2f9350c499 8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents: 31521
diff changeset
    98
    rf->set_distance(dist);
ec2f9350c499 8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents: 31521
diff changeset
    99
    rf->init();
ec2f9350c499 8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents: 31521
diff changeset
   100
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  return rf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
RFrame* RFrame::caller() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  if (_caller != noCallerYet) return (_caller == noCaller) ? NULL : _caller;    // already computed caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // caller not yet computed; do it now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  if (_fr.is_first_java_frame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    _caller = (RFrame*)noCaller;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  RegisterMap map(_thread, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  frame sender = _fr.real_sender(&map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  if (sender.is_java_frame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    _caller = new_RFrame(sender, thread(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    return _caller;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Real caller is not java related
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  _caller = (RFrame*)noCaller;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
int InterpretedRFrame::cost() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  return _method->code_size();    // fix this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  //return _method->estimated_inline_cost(_receiverKlass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
int CompiledRFrame::cost() const {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33160
diff changeset
   131
  CompiledMethod* nm = top_method()->code();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  if (nm != NULL) {
6418
6671edbd230e 6978355: renaming for 6961697
twisti
parents: 5547
diff changeset
   133
    return nm->insts_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    return top_method()->code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
void CompiledRFrame::init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  RegisterMap map(thread(), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  vframe* vf = vframe::new_vframe(&_fr, &map, thread());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  assert(vf->is_compiled_frame(), "must be compiled");
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33160
diff changeset
   143
  _nm = compiledVFrame::cast(vf)->code()->as_nmethod();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  vf = vf->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  _vf = javaVFrame::cast(vf);
31521
f57b2ce43484 8079775: Java 9-fastdebug ia32 Error: Unimplemented with "-XX:CompilationPolicyChoice=1 -XX:-TieredCompilation" options
iveresov
parents: 25715
diff changeset
   146
  _method = CodeCache::find_nmethod(_fr.pc())->method();
f57b2ce43484 8079775: Java 9-fastdebug ia32 Error: Unimplemented with "-XX:CompilationPolicyChoice=1 -XX:-TieredCompilation" options
iveresov
parents: 25715
diff changeset
   147
  assert(_method, "should have found a method");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  _invocations = _method->compiled_invocation_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
void InterpretedRFrame::init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  _invocations = _method->invocation_count() + _method->backedge_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
void RFrame::print(const char* kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
#ifndef PRODUCT
47799
1772ebf07d1f 8152470: Add COMPILER2_OR_JVMCI definition
jcm
parents: 47216
diff changeset
   159
#if COMPILER2_OR_JVMCI
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  int cnt = top_method()->interpreter_invocation_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  int cnt = top_method()->invocation_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  tty->print("%3d %s ", _num, is_interpreted() ? "I" : "C");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  top_method()->print_short_name(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  tty->print_cr(": inv=%5d(%d) cst=%4d", _invocations, cnt, cost());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
void CompiledRFrame::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  RFrame::print("comp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
void InterpretedRFrame::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  RFrame::print("int.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
void DeoptimizedRFrame::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  RFrame::print("deopt.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
}