Tue, 24 Jul 2012 10:51:00 -0700
7023639: JSR 292 method handle invocation needs a fast path for compiled code
6984705: JSR 292 method handle creation should not go through JNI
Summary: remove assembly code for JDK 7 chained method handles
Reviewed-by: jrose, twisti, kvn, mhaupt
Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_RUNTIME_RFRAME_HPP |
stefank@2314 | 26 | #define SHARE_VM_RUNTIME_RFRAME_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/allocation.hpp" |
stefank@2314 | 29 | #include "runtime/frame.inline.hpp" |
stefank@2314 | 30 | |
duke@435 | 31 | // rframes ("recompiler frames") decorate stack frames with some extra information |
duke@435 | 32 | // needed by the recompiler. The recompiler views the stack (at the time of recompilation) |
duke@435 | 33 | // as a list of rframes. |
duke@435 | 34 | |
duke@435 | 35 | class RFrame : public ResourceObj { |
duke@435 | 36 | protected: |
duke@435 | 37 | const frame _fr; // my frame |
duke@435 | 38 | JavaThread* const _thread; // thread where frame resides. |
duke@435 | 39 | RFrame* _caller; // caller / callee rframes (or NULL) |
duke@435 | 40 | RFrame*const _callee; |
duke@435 | 41 | const int _num; // stack frame number (0 = most recent) |
duke@435 | 42 | int _invocations; // current invocation estimate (for this frame) |
duke@435 | 43 | // (i.e., how often was this frame called) |
duke@435 | 44 | int _distance; // recompilation search "distance" (measured in # of interpreted frames) |
duke@435 | 45 | |
duke@435 | 46 | RFrame(frame fr, JavaThread* thread, RFrame*const callee); |
duke@435 | 47 | virtual void init() = 0; // compute invocations, loopDepth, etc. |
duke@435 | 48 | void print(const char* name); |
duke@435 | 49 | |
duke@435 | 50 | public: |
duke@435 | 51 | |
duke@435 | 52 | static RFrame* new_RFrame(frame fr, JavaThread* thread, RFrame*const callee); |
duke@435 | 53 | |
duke@435 | 54 | virtual bool is_interpreted() const { return false; } |
duke@435 | 55 | virtual bool is_compiled() const { return false; } |
duke@435 | 56 | int distance() const { return _distance; } |
duke@435 | 57 | void set_distance(int d); |
duke@435 | 58 | int invocations() const { return _invocations; } |
duke@435 | 59 | int num() const { return _num; } |
duke@435 | 60 | frame fr() const { return _fr; } |
duke@435 | 61 | JavaThread* thread() const { return _thread; } |
duke@435 | 62 | virtual int cost() const = 0; // estimated inlining cost (size) |
duke@435 | 63 | virtual methodHandle top_method() const = 0; |
duke@435 | 64 | virtual javaVFrame* top_vframe() const = 0; |
duke@435 | 65 | virtual nmethod* nm() const { ShouldNotCallThis(); return NULL; } |
duke@435 | 66 | |
duke@435 | 67 | RFrame* caller(); |
duke@435 | 68 | RFrame* callee() const { return _callee; } |
duke@435 | 69 | RFrame* parent() const; // rframe containing lexical scope (if any) |
duke@435 | 70 | virtual void print() = 0; |
duke@435 | 71 | |
duke@435 | 72 | static int computeSends(methodOop m); |
duke@435 | 73 | static int computeSends(nmethod* nm); |
duke@435 | 74 | static int computeCumulSends(methodOop m); |
duke@435 | 75 | static int computeCumulSends(nmethod* nm); |
duke@435 | 76 | }; |
duke@435 | 77 | |
duke@435 | 78 | class CompiledRFrame : public RFrame { // frame containing a compiled method |
duke@435 | 79 | protected: |
duke@435 | 80 | nmethod* _nm; |
duke@435 | 81 | javaVFrame* _vf; // top vframe; may be NULL (for most recent frame) |
duke@435 | 82 | methodHandle _method; // top method |
duke@435 | 83 | |
duke@435 | 84 | CompiledRFrame(frame fr, JavaThread* thread, RFrame*const callee); |
duke@435 | 85 | void init(); |
duke@435 | 86 | friend class RFrame; |
duke@435 | 87 | |
duke@435 | 88 | public: |
duke@435 | 89 | CompiledRFrame(frame fr, JavaThread* thread); // for nmethod triggering its counter (callee == NULL) |
duke@435 | 90 | bool is_compiled() const { return true; } |
duke@435 | 91 | methodHandle top_method() const { return _method; } |
duke@435 | 92 | javaVFrame* top_vframe() const { return _vf; } |
duke@435 | 93 | nmethod* nm() const { return _nm; } |
duke@435 | 94 | int cost() const; |
duke@435 | 95 | void print(); |
duke@435 | 96 | }; |
duke@435 | 97 | |
duke@435 | 98 | class InterpretedRFrame : public RFrame { // interpreter frame |
duke@435 | 99 | protected: |
duke@435 | 100 | javaVFrame* _vf; // may be NULL (for most recent frame) |
duke@435 | 101 | methodHandle _method; |
duke@435 | 102 | |
duke@435 | 103 | InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee); |
duke@435 | 104 | void init(); |
duke@435 | 105 | friend class RFrame; |
duke@435 | 106 | |
duke@435 | 107 | public: |
duke@435 | 108 | InterpretedRFrame(frame fr, JavaThread* thread, methodHandle m); // constructor for method triggering its invocation counter |
duke@435 | 109 | bool is_interpreted() const { return true; } |
duke@435 | 110 | methodHandle top_method() const { return _method; } |
duke@435 | 111 | javaVFrame* top_vframe() const { return _vf; } |
duke@435 | 112 | int cost() const; |
duke@435 | 113 | void print(); |
duke@435 | 114 | }; |
duke@435 | 115 | |
duke@435 | 116 | // treat deoptimized frames as interpreted |
duke@435 | 117 | class DeoptimizedRFrame : public InterpretedRFrame { |
duke@435 | 118 | protected: |
duke@435 | 119 | DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const callee); |
duke@435 | 120 | friend class RFrame; |
duke@435 | 121 | public: |
duke@435 | 122 | void print(); |
duke@435 | 123 | }; |
stefank@2314 | 124 | |
stefank@2314 | 125 | #endif // SHARE_VM_RUNTIME_RFRAME_HPP |