0N/A/*
2171N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_RUNTIME_STUBROUTINES_HPP
1879N/A#define SHARE_VM_RUNTIME_STUBROUTINES_HPP
1879N/A
1879N/A#include "code/codeBlob.hpp"
1879N/A#include "memory/allocation.hpp"
1879N/A#include "runtime/frame.hpp"
1879N/A#include "runtime/mutexLocker.hpp"
1879N/A#include "runtime/stubCodeGenerator.hpp"
1879N/A#include "utilities/top.hpp"
1879N/A#ifdef TARGET_ARCH_x86
1879N/A# include "nativeInst_x86.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_sparc
1879N/A# include "nativeInst_sparc.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_zero
1879N/A# include "nativeInst_zero.hpp"
1879N/A#endif
2073N/A#ifdef TARGET_ARCH_arm
2073N/A# include "nativeInst_arm.hpp"
2073N/A#endif
2073N/A#ifdef TARGET_ARCH_ppc
2073N/A# include "nativeInst_ppc.hpp"
2073N/A#endif
1879N/A
0N/A// StubRoutines provides entry points to assembly routines used by
0N/A// compiled code and the run-time system. Platform-specific entry
0N/A// points are defined in the platform-specific inner class.
0N/A//
0N/A// Class scheme:
0N/A//
0N/A// platform-independent platform-dependent
0N/A//
0N/A// stubRoutines.hpp <-- included -- stubRoutines_<arch>.hpp
0N/A// ^ ^
0N/A// | |
0N/A// implements implements
0N/A// | |
0N/A// | |
0N/A// stubRoutines.cpp stubRoutines_<arch>.cpp
0N/A// stubRoutines_<os_family>.cpp stubGenerator_<arch>.cpp
0N/A// stubRoutines_<os_arch>.cpp
0N/A//
0N/A// Note 1: The important thing is a clean decoupling between stub
0N/A// entry points (interfacing to the whole vm; i.e., 1-to-n
0N/A// relationship) and stub generators (interfacing only to
0N/A// the entry points implementation; i.e., 1-to-1 relationship).
0N/A// This significantly simplifies changes in the generator
0N/A// structure since the rest of the vm is not affected.
0N/A//
0N/A// Note 2: stubGenerator_<arch>.cpp contains a minimal portion of
0N/A// machine-independent code; namely the generator calls of
0N/A// the generator functions that are used platform-independently.
0N/A// However, it comes with the advantage of having a 1-file
0N/A// implementation of the generator. It should be fairly easy
0N/A// to change, should it become a problem later.
0N/A//
0N/A// Scheme for adding a new entry point:
0N/A//
0N/A// 1. determine if it's a platform-dependent or independent entry point
0N/A// a) if platform independent: make subsequent changes in the independent files
0N/A// b) if platform dependent: make subsequent changes in the dependent files
0N/A// 2. add a private instance variable holding the entry point address
0N/A// 3. add a public accessor function to the instance variable
0N/A// 4. implement the corresponding generator function in the platform-dependent
0N/A// stubGenerator_<arch>.cpp file and call the function in generate_all() of that file
0N/A
0N/A
0N/Aclass StubRoutines: AllStatic {
0N/A
0N/A public:
0N/A enum platform_independent_constants {
0N/A max_size_of_parameters = 256 // max. parameter size supported by megamorphic lookups
0N/A };
0N/A
0N/A // Dependencies
0N/A friend class StubGenerator;
1879N/A#ifdef TARGET_ARCH_MODEL_x86_32
1879N/A# include "stubRoutines_x86_32.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_x86_64
1879N/A# include "stubRoutines_x86_64.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_sparc
1879N/A# include "stubRoutines_sparc.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_zero
1879N/A# include "stubRoutines_zero.hpp"
1879N/A#endif
2073N/A#ifdef TARGET_ARCH_MODEL_arm
2073N/A# include "stubRoutines_arm.hpp"
2073N/A#endif
2073N/A#ifdef TARGET_ARCH_MODEL_ppc
2073N/A# include "stubRoutines_ppc.hpp"
2073N/A#endif
1879N/A
0N/A
0N/A static jint _verify_oop_count;
0N/A static address _verify_oop_subroutine_entry;
0N/A
0N/A static address _call_stub_return_address; // the return PC, when returning to a call stub
0N/A static address _call_stub_entry;
0N/A static address _forward_exception_entry;
0N/A static address _catch_exception_entry;
0N/A static address _throw_AbstractMethodError_entry;
16N/A static address _throw_IncompatibleClassChangeError_entry;
0N/A static address _throw_NullPointerException_at_call_entry;
0N/A static address _throw_StackOverflowError_entry;
0N/A static address _handler_for_unsafe_access_entry;
0N/A
0N/A static address _atomic_xchg_entry;
0N/A static address _atomic_xchg_ptr_entry;
0N/A static address _atomic_store_entry;
0N/A static address _atomic_store_ptr_entry;
0N/A static address _atomic_cmpxchg_entry;
0N/A static address _atomic_cmpxchg_ptr_entry;
0N/A static address _atomic_cmpxchg_long_entry;
0N/A static address _atomic_add_entry;
0N/A static address _atomic_add_ptr_entry;
0N/A static address _fence_entry;
0N/A static address _d2i_wrapper;
0N/A static address _d2l_wrapper;
0N/A
0N/A static jint _fpu_cntrl_wrd_std;
0N/A static jint _fpu_cntrl_wrd_24;
0N/A static jint _fpu_cntrl_wrd_64;
0N/A static jint _fpu_cntrl_wrd_trunc;
0N/A static jint _mxcsr_std;
0N/A static jint _fpu_subnormal_bias1[3];
0N/A static jint _fpu_subnormal_bias2[3];
0N/A
0N/A static BufferBlob* _code1; // code buffer for initial routines
0N/A static BufferBlob* _code2; // code buffer for all other routines
0N/A
0N/A // Leaf routines which implement arraycopy and their addresses
0N/A // arraycopy operands aligned on element type boundary
0N/A static address _jbyte_arraycopy;
0N/A static address _jshort_arraycopy;
0N/A static address _jint_arraycopy;
0N/A static address _jlong_arraycopy;
2171N/A static address _oop_arraycopy, _oop_arraycopy_uninit;
0N/A static address _jbyte_disjoint_arraycopy;
0N/A static address _jshort_disjoint_arraycopy;
0N/A static address _jint_disjoint_arraycopy;
0N/A static address _jlong_disjoint_arraycopy;
2171N/A static address _oop_disjoint_arraycopy, _oop_disjoint_arraycopy_uninit;
0N/A
0N/A // arraycopy operands aligned on zero'th element boundary
0N/A // These are identical to the ones aligned aligned on an
0N/A // element type boundary, except that they assume that both
0N/A // source and destination are HeapWord aligned.
0N/A static address _arrayof_jbyte_arraycopy;
0N/A static address _arrayof_jshort_arraycopy;
0N/A static address _arrayof_jint_arraycopy;
0N/A static address _arrayof_jlong_arraycopy;
2171N/A static address _arrayof_oop_arraycopy, _arrayof_oop_arraycopy_uninit;
0N/A static address _arrayof_jbyte_disjoint_arraycopy;
0N/A static address _arrayof_jshort_disjoint_arraycopy;
0N/A static address _arrayof_jint_disjoint_arraycopy;
0N/A static address _arrayof_jlong_disjoint_arraycopy;
2171N/A static address _arrayof_oop_disjoint_arraycopy, _arrayof_oop_disjoint_arraycopy_uninit;
0N/A
0N/A // these are recommended but optional:
2171N/A static address _checkcast_arraycopy, _checkcast_arraycopy_uninit;
0N/A static address _unsafe_arraycopy;
0N/A static address _generic_arraycopy;
0N/A
1683N/A static address _jbyte_fill;
1683N/A static address _jshort_fill;
1683N/A static address _jint_fill;
1683N/A static address _arrayof_jbyte_fill;
1683N/A static address _arrayof_jshort_fill;
1683N/A static address _arrayof_jint_fill;
1683N/A
2726N/A // zero heap space aligned to jlong (8 bytes)
2726N/A static address _zero_aligned_words;
2726N/A
4056N/A static address _aescrypt_encryptBlock;
4056N/A static address _aescrypt_decryptBlock;
4056N/A static address _cipherBlockChaining_encryptAESCrypt;
4056N/A static address _cipherBlockChaining_decryptAESCrypt;
4056N/A
1174N/A // These are versions of the java.lang.Math methods which perform
1174N/A // the same operations as the intrinsic version. They are used for
1174N/A // constant folding in the compiler to ensure equivalence. If the
1174N/A // intrinsic version returns the same result as the strict version
1174N/A // then they can be set to the appropriate function from
1174N/A // SharedRuntime.
1174N/A static double (*_intrinsic_log)(double);
1174N/A static double (*_intrinsic_log10)(double);
1174N/A static double (*_intrinsic_exp)(double);
1174N/A static double (*_intrinsic_pow)(double, double);
1174N/A static double (*_intrinsic_sin)(double);
1174N/A static double (*_intrinsic_cos)(double);
1174N/A static double (*_intrinsic_tan)(double);
1174N/A
0N/A public:
0N/A // Initialization/Testing
0N/A static void initialize1(); // must happen before universe::genesis
0N/A static void initialize2(); // must happen after universe::genesis
0N/A
4141N/A static bool is_stub_code(address addr) { return contains(addr); }
4141N/A
0N/A static bool contains(address addr) {
0N/A return
0N/A (_code1 != NULL && _code1->blob_contains(addr)) ||
0N/A (_code2 != NULL && _code2->blob_contains(addr)) ;
0N/A }
0N/A
3932N/A static CodeBlob* code1() { return _code1; }
3932N/A static CodeBlob* code2() { return _code2; }
3932N/A
0N/A // Debugging
0N/A static jint verify_oop_count() { return _verify_oop_count; }
0N/A static jint* verify_oop_count_addr() { return &_verify_oop_count; }
0N/A // a subroutine for debugging the GC
0N/A static address verify_oop_subroutine_entry_address() { return (address)&_verify_oop_subroutine_entry; }
0N/A
0N/A static address catch_exception_entry() { return _catch_exception_entry; }
0N/A
0N/A // Calls to Java
0N/A typedef void (*CallStub)(
0N/A address link,
0N/A intptr_t* result,
0N/A BasicType result_type,
0N/A methodOopDesc* method,
0N/A address entry_point,
0N/A intptr_t* parameters,
0N/A int size_of_parameters,
0N/A TRAPS
0N/A );
0N/A
0N/A static CallStub call_stub() { return CAST_TO_FN_PTR(CallStub, _call_stub_entry); }
0N/A
0N/A // Exceptions
0N/A static address forward_exception_entry() { return _forward_exception_entry; }
0N/A // Implicit exceptions
0N/A static address throw_AbstractMethodError_entry() { return _throw_AbstractMethodError_entry; }
16N/A static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; }
0N/A static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; }
0N/A static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }
0N/A
0N/A // Exceptions during unsafe access - should throw Java exception rather
0N/A // than crash.
0N/A static address handler_for_unsafe_access() { return _handler_for_unsafe_access_entry; }
0N/A
0N/A static address atomic_xchg_entry() { return _atomic_xchg_entry; }
0N/A static address atomic_xchg_ptr_entry() { return _atomic_xchg_ptr_entry; }
0N/A static address atomic_store_entry() { return _atomic_store_entry; }
0N/A static address atomic_store_ptr_entry() { return _atomic_store_ptr_entry; }
0N/A static address atomic_cmpxchg_entry() { return _atomic_cmpxchg_entry; }
0N/A static address atomic_cmpxchg_ptr_entry() { return _atomic_cmpxchg_ptr_entry; }
0N/A static address atomic_cmpxchg_long_entry() { return _atomic_cmpxchg_long_entry; }
0N/A static address atomic_add_entry() { return _atomic_add_entry; }
0N/A static address atomic_add_ptr_entry() { return _atomic_add_ptr_entry; }
0N/A static address fence_entry() { return _fence_entry; }
0N/A
0N/A static address d2i_wrapper() { return _d2i_wrapper; }
0N/A static address d2l_wrapper() { return _d2l_wrapper; }
0N/A static jint fpu_cntrl_wrd_std() { return _fpu_cntrl_wrd_std; }
0N/A static address addr_fpu_cntrl_wrd_std() { return (address)&_fpu_cntrl_wrd_std; }
0N/A static address addr_fpu_cntrl_wrd_24() { return (address)&_fpu_cntrl_wrd_24; }
0N/A static address addr_fpu_cntrl_wrd_64() { return (address)&_fpu_cntrl_wrd_64; }
0N/A static address addr_fpu_cntrl_wrd_trunc() { return (address)&_fpu_cntrl_wrd_trunc; }
0N/A static address addr_mxcsr_std() { return (address)&_mxcsr_std; }
0N/A static address addr_fpu_subnormal_bias1() { return (address)&_fpu_subnormal_bias1; }
0N/A static address addr_fpu_subnormal_bias2() { return (address)&_fpu_subnormal_bias2; }
0N/A
0N/A
2293N/A static address select_arraycopy_function(BasicType t, bool aligned, bool disjoint, const char* &name, bool dest_uninitialized);
2293N/A
0N/A static address jbyte_arraycopy() { return _jbyte_arraycopy; }
0N/A static address jshort_arraycopy() { return _jshort_arraycopy; }
0N/A static address jint_arraycopy() { return _jint_arraycopy; }
0N/A static address jlong_arraycopy() { return _jlong_arraycopy; }
2171N/A static address oop_arraycopy(bool dest_uninitialized = false) {
2171N/A return dest_uninitialized ? _oop_arraycopy_uninit : _oop_arraycopy;
2171N/A }
0N/A static address jbyte_disjoint_arraycopy() { return _jbyte_disjoint_arraycopy; }
0N/A static address jshort_disjoint_arraycopy() { return _jshort_disjoint_arraycopy; }
0N/A static address jint_disjoint_arraycopy() { return _jint_disjoint_arraycopy; }
0N/A static address jlong_disjoint_arraycopy() { return _jlong_disjoint_arraycopy; }
2171N/A static address oop_disjoint_arraycopy(bool dest_uninitialized = false) {
2171N/A return dest_uninitialized ? _oop_disjoint_arraycopy_uninit : _oop_disjoint_arraycopy;
2171N/A }
0N/A
0N/A static address arrayof_jbyte_arraycopy() { return _arrayof_jbyte_arraycopy; }
0N/A static address arrayof_jshort_arraycopy() { return _arrayof_jshort_arraycopy; }
0N/A static address arrayof_jint_arraycopy() { return _arrayof_jint_arraycopy; }
0N/A static address arrayof_jlong_arraycopy() { return _arrayof_jlong_arraycopy; }
2171N/A static address arrayof_oop_arraycopy(bool dest_uninitialized = false) {
2171N/A return dest_uninitialized ? _arrayof_oop_arraycopy_uninit : _arrayof_oop_arraycopy;
2171N/A }
0N/A
0N/A static address arrayof_jbyte_disjoint_arraycopy() { return _arrayof_jbyte_disjoint_arraycopy; }
0N/A static address arrayof_jshort_disjoint_arraycopy() { return _arrayof_jshort_disjoint_arraycopy; }
0N/A static address arrayof_jint_disjoint_arraycopy() { return _arrayof_jint_disjoint_arraycopy; }
0N/A static address arrayof_jlong_disjoint_arraycopy() { return _arrayof_jlong_disjoint_arraycopy; }
2171N/A static address arrayof_oop_disjoint_arraycopy(bool dest_uninitialized = false) {
2171N/A return dest_uninitialized ? _arrayof_oop_disjoint_arraycopy_uninit : _arrayof_oop_disjoint_arraycopy;
2171N/A }
0N/A
2171N/A static address checkcast_arraycopy(bool dest_uninitialized = false) {
2171N/A return dest_uninitialized ? _checkcast_arraycopy_uninit : _checkcast_arraycopy;
2171N/A }
0N/A static address unsafe_arraycopy() { return _unsafe_arraycopy; }
0N/A static address generic_arraycopy() { return _generic_arraycopy; }
0N/A
1683N/A static address jbyte_fill() { return _jbyte_fill; }
1683N/A static address jshort_fill() { return _jshort_fill; }
1683N/A static address jint_fill() { return _jint_fill; }
1683N/A static address arrayof_jbyte_fill() { return _arrayof_jbyte_fill; }
1683N/A static address arrayof_jshort_fill() { return _arrayof_jshort_fill; }
1683N/A static address arrayof_jint_fill() { return _arrayof_jint_fill; }
1683N/A
4056N/A static address aescrypt_encryptBlock() { return _aescrypt_encryptBlock; }
4056N/A static address aescrypt_decryptBlock() { return _aescrypt_decryptBlock; }
4056N/A static address cipherBlockChaining_encryptAESCrypt() { return _cipherBlockChaining_encryptAESCrypt; }
4056N/A static address cipherBlockChaining_decryptAESCrypt() { return _cipherBlockChaining_decryptAESCrypt; }
4056N/A
1683N/A static address select_fill_function(BasicType t, bool aligned, const char* &name);
1683N/A
2726N/A static address zero_aligned_words() { return _zero_aligned_words; }
1683N/A
1174N/A static double intrinsic_log(double d) {
1174N/A assert(_intrinsic_log != NULL, "must be defined");
1174N/A return _intrinsic_log(d);
1174N/A }
1174N/A static double intrinsic_log10(double d) {
1174N/A assert(_intrinsic_log != NULL, "must be defined");
1174N/A return _intrinsic_log10(d);
1174N/A }
1174N/A static double intrinsic_exp(double d) {
1174N/A assert(_intrinsic_exp != NULL, "must be defined");
1174N/A return _intrinsic_exp(d);
1174N/A }
1174N/A static double intrinsic_pow(double d, double d2) {
1174N/A assert(_intrinsic_pow != NULL, "must be defined");
1174N/A return _intrinsic_pow(d, d2);
1174N/A }
1174N/A static double intrinsic_sin(double d) {
1174N/A assert(_intrinsic_sin != NULL, "must be defined");
1174N/A return _intrinsic_sin(d);
1174N/A }
1174N/A static double intrinsic_cos(double d) {
1174N/A assert(_intrinsic_cos != NULL, "must be defined");
1174N/A return _intrinsic_cos(d);
1174N/A }
1174N/A static double intrinsic_tan(double d) {
1174N/A assert(_intrinsic_tan != NULL, "must be defined");
1174N/A return _intrinsic_tan(d);
1174N/A }
1174N/A
0N/A //
0N/A // Default versions of the above arraycopy functions for platforms which do
0N/A // not have specialized versions
0N/A //
2171N/A static void jbyte_copy (jbyte* src, jbyte* dest, size_t count);
2171N/A static void jshort_copy (jshort* src, jshort* dest, size_t count);
2171N/A static void jint_copy (jint* src, jint* dest, size_t count);
2171N/A static void jlong_copy (jlong* src, jlong* dest, size_t count);
2171N/A static void oop_copy (oop* src, oop* dest, size_t count);
2171N/A static void oop_copy_uninit(oop* src, oop* dest, size_t count);
0N/A
2171N/A static void arrayof_jbyte_copy (HeapWord* src, HeapWord* dest, size_t count);
2171N/A static void arrayof_jshort_copy (HeapWord* src, HeapWord* dest, size_t count);
2171N/A static void arrayof_jint_copy (HeapWord* src, HeapWord* dest, size_t count);
2171N/A static void arrayof_jlong_copy (HeapWord* src, HeapWord* dest, size_t count);
2171N/A static void arrayof_oop_copy (HeapWord* src, HeapWord* dest, size_t count);
2171N/A static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP