/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_CODE_COMPILEDIC_HPP
#define SHARE_VM_CODE_COMPILEDIC_HPP
#include "interpreter/linkResolver.hpp"
#include "oops/compiledICHolderKlass.hpp"
#include "oops/compiledICHolderOop.hpp"
#include "oops/klassOop.hpp"
#ifdef TARGET_ARCH_x86
# include "nativeInst_x86.hpp"
#endif
#ifdef TARGET_ARCH_sparc
# include "nativeInst_sparc.hpp"
#endif
#ifdef TARGET_ARCH_zero
# include "nativeInst_zero.hpp"
#endif
#ifdef TARGET_ARCH_arm
# include "nativeInst_arm.hpp"
#endif
#ifdef TARGET_ARCH_ppc
# include "nativeInst_ppc.hpp"
#endif
//-----------------------------------------------------------------------------
// The CompiledIC represents a compiled inline cache.
//
// In order to make patching of the inline cache MT-safe, we only allow the following
// transitions (when not at a safepoint):
//
//
// [1] --<-- Clean -->--- [1]
// / (null) \
// / \ /-<-\
// / [2] \ / \
// Interpreted ---------> Monomorphic | [3]
// (compiledICHolderOop) (klassOop) |
// \ / \ /
// [4] \ / [4] \->-/
// \->- Megamorphic -<-/
// (methodOop)
//
// The text in paranteses () refere to the value of the inline cache receiver (mov instruction)
//
// The numbers in square brackets refere to the kind of transition:
// [1]: Initial fixup. Receiver it found from debug information
// [2]: Compilation of a method
// [3]: Recompilation of a method (note: only entry is changed. The klassOop must stay the same)
// [4]: Inline cache miss. We go directly to megamorphic call.
//
// The class automatically inserts transition stubs (using the InlineCacheBuffer) when an MT-unsafe
// transition is made to a stub.
//
class CompiledIC;
class CompiledICInfo {
friend class CompiledIC;
private:
public:
};
friend class InlineCacheBuffer;
friend class ICStub;
private:
// low-level inline-cache manipulation. Cannot be accessed directly, since it might not be MT-safe
// to change an inline-cache. These changes the underlying inline-cache directly. They *newer* make
// changes to a transition stub.
// Reads the location of the transition stub. This will fail with an assertion, if no transition stub is
// associated with the inline cache.
address stub_address() const;
bool is_in_transition_state() const; // Use InlineCacheBuffer
public:
// conversion (machine PC to CompiledIC*)
// Return the cached_oop/destination associated with this inline cache. If the cache currently points
// to a transition stub, it will read the values from the transition stub.
oop cached_oop() const;
address ic_destination() const;
// State
bool is_clean() const;
bool is_megamorphic() const;
bool is_call_to_compiled() const;
bool is_call_to_interpreted() const;
// MT-safe patching of inline caches. Note: Only safe to call is_xxx when holding the CompiledIC_ock
// so you are guaranteed that no patching takes place. The same goes for verify.
//
// Note: We do not provide any direct access to the stub code, to prevent parts of the code
// to manipulate the inline cache in MT-unsafe ways.
//
// They all takes a TRAP argument, since they can cause a GC if the inline-cache buffer is full.
//
void set_to_clean(); // Can only be called during a safepoint operation
// Location
// Misc
};
return c_ic;
}
return c_ic;
}
return c_ic;
}
//-----------------------------------------------------------------------------
// The CompiledStaticCall represents a call to a static method in the compiled
//
// Transition diagram of a static call site is somewhat simpler than for an inlined cache:
//
//
// -----<----- Clean ----->-----
// / \
// / \
// compilled code <------------> interpreted code
//
// Clean: Calls directly to runtime method for fixup
// Compiled code: Calls directly to compiled code
// Interpreted code: Calls to stub that set methodOop reference
//
//
class CompiledStaticCall;
class StaticCallInfo {
private:
friend class CompiledStaticCall;
public:
};
friend class CompiledIC;
// Also used by CompiledIC
bool is_optimized_virtual();
public:
// State
bool is_clean() const;
bool is_call_to_compiled() const;
bool is_call_to_interpreted() const;
// Clean static call (will force resolving on next use)
void set_to_clean();
// Set state. The entry must be the same, as computed by compute_entry.
// Computation and setting is split up, since the actions are separate during
// a OptoRuntime::resolve_xxx.
// Compute entry point given a method
// Stub support
// Misc.
};
return st;
}
return st;
}
}
#endif // SHARE_VM_CODE_COMPILEDIC_HPP