src/share/vm/runtime/rframe.cpp

Thu, 24 May 2018 20:03:11 +0800

author
aoqi
date
Thu, 24 May 2018 20:03:11 +0800
changeset 8868
91ddc23482a4
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Increase MaxHeapSize for better performance on MIPS

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "interpreter/interpreter.hpp"
aoqi@0 27 #include "oops/oop.inline.hpp"
aoqi@0 28 #include "oops/symbol.hpp"
aoqi@0 29 #include "runtime/frame.inline.hpp"
aoqi@0 30 #include "runtime/rframe.hpp"
aoqi@0 31 #include "runtime/vframe.hpp"
aoqi@0 32 #include "runtime/vframe_hp.hpp"
aoqi@0 33
aoqi@0 34
aoqi@0 35 static RFrame*const noCaller = (RFrame*) 0x1; // no caller (i.e., initial frame)
aoqi@0 36 static RFrame*const noCallerYet = (RFrame*) 0x0; // caller not yet computed
aoqi@0 37
aoqi@0 38 RFrame::RFrame(frame fr, JavaThread* thread, RFrame*const callee) :
aoqi@0 39 _fr(fr), _thread(thread), _callee(callee), _num(callee ? callee->num() + 1 : 0) {
aoqi@0 40 _caller = (RFrame*)noCallerYet;
aoqi@0 41 _invocations = 0;
aoqi@0 42 _distance = 0;
aoqi@0 43 }
aoqi@0 44
aoqi@0 45 void RFrame::set_distance(int d) {
aoqi@0 46 assert(is_compiled() || d >= 0, "should be positive");
aoqi@0 47 _distance = d;
aoqi@0 48 }
aoqi@0 49
aoqi@0 50 InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee)
aoqi@0 51 : RFrame(fr, thread, callee) {
aoqi@0 52 RegisterMap map(thread, false);
aoqi@0 53 _vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread));
aoqi@0 54 _method = methodHandle(thread, _vf->method());
aoqi@0 55 assert( _vf->is_interpreted_frame(), "must be interpreted");
aoqi@0 56 init();
aoqi@0 57 }
aoqi@0 58
aoqi@0 59 InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, methodHandle m)
aoqi@0 60 : RFrame(fr, thread, NULL) {
aoqi@0 61 RegisterMap map(thread, false);
aoqi@0 62 _vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread));
aoqi@0 63 _method = m;
aoqi@0 64
aoqi@0 65 assert( _vf->is_interpreted_frame(), "must be interpreted");
aoqi@0 66 init();
aoqi@0 67 }
aoqi@0 68
aoqi@0 69 CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread, RFrame*const callee)
aoqi@0 70 : RFrame(fr, thread, callee) {
aoqi@0 71 init();
aoqi@0 72 }
aoqi@0 73
aoqi@0 74 CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread)
aoqi@0 75 : RFrame(fr, thread, NULL) {
aoqi@0 76 init();
aoqi@0 77 }
aoqi@0 78
aoqi@0 79 DeoptimizedRFrame::DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const callee)
aoqi@0 80 : InterpretedRFrame(fr, thread, callee) {}
aoqi@0 81
aoqi@0 82 RFrame* RFrame::new_RFrame(frame fr, JavaThread* thread, RFrame*const callee) {
aoqi@0 83 RFrame* rf;
aoqi@0 84 int dist = callee ? callee->distance() : -1;
aoqi@0 85 if (fr.is_interpreted_frame()) {
aoqi@0 86 rf = new InterpretedRFrame(fr, thread, callee);
aoqi@0 87 dist++;
aoqi@0 88 } else if (fr.is_compiled_frame()) {
aoqi@0 89 // Even deopted frames look compiled because the deopt
aoqi@0 90 // is invisible until it happens.
aoqi@0 91 rf = new CompiledRFrame(fr, thread, callee);
aoqi@0 92 } else {
aoqi@0 93 assert(false, "Unhandled frame type");
aoqi@0 94 }
aoqi@0 95 rf->set_distance(dist);
aoqi@0 96 rf->init();
aoqi@0 97 return rf;
aoqi@0 98 }
aoqi@0 99
aoqi@0 100 RFrame* RFrame::caller() {
aoqi@0 101 if (_caller != noCallerYet) return (_caller == noCaller) ? NULL : _caller; // already computed caller
aoqi@0 102
aoqi@0 103 // caller not yet computed; do it now
aoqi@0 104 if (_fr.is_first_java_frame()) {
aoqi@0 105 _caller = (RFrame*)noCaller;
aoqi@0 106 return NULL;
aoqi@0 107 }
aoqi@0 108
aoqi@0 109 RegisterMap map(_thread, false);
aoqi@0 110 frame sender = _fr.real_sender(&map);
aoqi@0 111 if (sender.is_java_frame()) {
aoqi@0 112 _caller = new_RFrame(sender, thread(), this);
aoqi@0 113 return _caller;
aoqi@0 114 }
aoqi@0 115
aoqi@0 116 // Real caller is not java related
aoqi@0 117 _caller = (RFrame*)noCaller;
aoqi@0 118 return NULL;
aoqi@0 119 }
aoqi@0 120
aoqi@0 121 int InterpretedRFrame::cost() const {
aoqi@0 122 return _method->code_size(); // fix this
aoqi@0 123 //return _method->estimated_inline_cost(_receiverKlass);
aoqi@0 124 }
aoqi@0 125
aoqi@0 126 int CompiledRFrame::cost() const {
aoqi@0 127 nmethod* nm = top_method()->code();
aoqi@0 128 if (nm != NULL) {
aoqi@0 129 return nm->insts_size();
aoqi@0 130 } else {
aoqi@0 131 return top_method()->code_size();
aoqi@0 132 }
aoqi@0 133 }
aoqi@0 134
aoqi@0 135 void CompiledRFrame::init() {
aoqi@0 136 RegisterMap map(thread(), false);
aoqi@0 137 vframe* vf = vframe::new_vframe(&_fr, &map, thread());
aoqi@0 138 assert(vf->is_compiled_frame(), "must be compiled");
aoqi@0 139 _nm = compiledVFrame::cast(vf)->code();
aoqi@0 140 vf = vf->top();
aoqi@0 141 _vf = javaVFrame::cast(vf);
aoqi@0 142 _method = methodHandle(thread(), CodeCache::find_nmethod(_fr.pc())->method());
aoqi@0 143 assert(_method(), "should have found a method");
aoqi@0 144 #ifndef PRODUCT
aoqi@0 145 _invocations = _method->compiled_invocation_count();
aoqi@0 146 #endif
aoqi@0 147 }
aoqi@0 148
aoqi@0 149 void InterpretedRFrame::init() {
aoqi@0 150 _invocations = _method->invocation_count() + _method->backedge_count();
aoqi@0 151 }
aoqi@0 152
aoqi@0 153 void RFrame::print(const char* kind) {
aoqi@0 154 #ifndef PRODUCT
aoqi@0 155 #ifdef COMPILER2
aoqi@0 156 int cnt = top_method()->interpreter_invocation_count();
aoqi@0 157 #else
aoqi@0 158 int cnt = top_method()->invocation_count();
aoqi@0 159 #endif
aoqi@0 160 tty->print("%3d %s ", _num, is_interpreted() ? "I" : "C");
aoqi@0 161 top_method()->print_short_name(tty);
aoqi@0 162 tty->print_cr(": inv=%5d(%d) cst=%4d", _invocations, cnt, cost());
aoqi@0 163 #endif
aoqi@0 164 }
aoqi@0 165
aoqi@0 166 void CompiledRFrame::print() {
aoqi@0 167 RFrame::print("comp");
aoqi@0 168 }
aoqi@0 169
aoqi@0 170 void InterpretedRFrame::print() {
aoqi@0 171 RFrame::print("int.");
aoqi@0 172 }
aoqi@0 173
aoqi@0 174 void DeoptimizedRFrame::print() {
aoqi@0 175 RFrame::print("deopt.");
aoqi@0 176 }

mercurial