duke@435: /* duke@435: * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: // StubRoutines provides entry points to assembly routines used by duke@435: // compiled code and the run-time system. Platform-specific entry duke@435: // points are defined in the platform-specific inner class. duke@435: // duke@435: // Class scheme: duke@435: // duke@435: // platform-independent platform-dependent duke@435: // duke@435: // stubRoutines.hpp <-- included -- stubRoutines_.hpp duke@435: // ^ ^ duke@435: // | | duke@435: // implements implements duke@435: // | | duke@435: // | | duke@435: // stubRoutines.cpp stubRoutines_.cpp duke@435: // stubRoutines_.cpp stubGenerator_.cpp duke@435: // stubRoutines_.cpp duke@435: // duke@435: // Note 1: The important thing is a clean decoupling between stub duke@435: // entry points (interfacing to the whole vm; i.e., 1-to-n duke@435: // relationship) and stub generators (interfacing only to duke@435: // the entry points implementation; i.e., 1-to-1 relationship). duke@435: // This significantly simplifies changes in the generator duke@435: // structure since the rest of the vm is not affected. duke@435: // duke@435: // Note 2: stubGenerator_.cpp contains a minimal portion of duke@435: // machine-independent code; namely the generator calls of duke@435: // the generator functions that are used platform-independently. duke@435: // However, it comes with the advantage of having a 1-file duke@435: // implementation of the generator. It should be fairly easy duke@435: // to change, should it become a problem later. duke@435: // duke@435: // Scheme for adding a new entry point: duke@435: // duke@435: // 1. determine if it's a platform-dependent or independent entry point duke@435: // a) if platform independent: make subsequent changes in the independent files duke@435: // b) if platform dependent: make subsequent changes in the dependent files duke@435: // 2. add a private instance variable holding the entry point address duke@435: // 3. add a public accessor function to the instance variable duke@435: // 4. implement the corresponding generator function in the platform-dependent duke@435: // stubGenerator_.cpp file and call the function in generate_all() of that file duke@435: duke@435: duke@435: class StubRoutines: AllStatic { duke@435: duke@435: public: duke@435: enum platform_independent_constants { duke@435: max_size_of_parameters = 256 // max. parameter size supported by megamorphic lookups duke@435: }; duke@435: duke@435: // Dependencies duke@435: friend class StubGenerator; duke@435: #include "incls/_stubRoutines_pd.hpp.incl" // machine-specific parts duke@435: duke@435: static jint _verify_oop_count; duke@435: static address _verify_oop_subroutine_entry; duke@435: duke@435: static address _call_stub_return_address; // the return PC, when returning to a call stub duke@435: static address _call_stub_entry; duke@435: static address _forward_exception_entry; duke@435: static address _catch_exception_entry; duke@435: static address _throw_AbstractMethodError_entry; dcubed@451: static address _throw_IncompatibleClassChangeError_entry; duke@435: static address _throw_ArithmeticException_entry; duke@435: static address _throw_NullPointerException_entry; duke@435: static address _throw_NullPointerException_at_call_entry; duke@435: static address _throw_StackOverflowError_entry; duke@435: static address _handler_for_unsafe_access_entry; duke@435: duke@435: static address _atomic_xchg_entry; duke@435: static address _atomic_xchg_ptr_entry; duke@435: static address _atomic_store_entry; duke@435: static address _atomic_store_ptr_entry; duke@435: static address _atomic_cmpxchg_entry; duke@435: static address _atomic_cmpxchg_ptr_entry; duke@435: static address _atomic_cmpxchg_long_entry; duke@435: static address _atomic_add_entry; duke@435: static address _atomic_add_ptr_entry; duke@435: static address _fence_entry; duke@435: static address _d2i_wrapper; duke@435: static address _d2l_wrapper; duke@435: duke@435: static jint _fpu_cntrl_wrd_std; duke@435: static jint _fpu_cntrl_wrd_24; duke@435: static jint _fpu_cntrl_wrd_64; duke@435: static jint _fpu_cntrl_wrd_trunc; duke@435: static jint _mxcsr_std; duke@435: static jint _fpu_subnormal_bias1[3]; duke@435: static jint _fpu_subnormal_bias2[3]; duke@435: duke@435: static BufferBlob* _code1; // code buffer for initial routines duke@435: static BufferBlob* _code2; // code buffer for all other routines duke@435: duke@435: // Leaf routines which implement arraycopy and their addresses duke@435: // arraycopy operands aligned on element type boundary duke@435: static address _jbyte_arraycopy; duke@435: static address _jshort_arraycopy; duke@435: static address _jint_arraycopy; duke@435: static address _jlong_arraycopy; duke@435: static address _oop_arraycopy; duke@435: static address _jbyte_disjoint_arraycopy; duke@435: static address _jshort_disjoint_arraycopy; duke@435: static address _jint_disjoint_arraycopy; duke@435: static address _jlong_disjoint_arraycopy; duke@435: static address _oop_disjoint_arraycopy; duke@435: duke@435: // arraycopy operands aligned on zero'th element boundary duke@435: // These are identical to the ones aligned aligned on an duke@435: // element type boundary, except that they assume that both duke@435: // source and destination are HeapWord aligned. duke@435: static address _arrayof_jbyte_arraycopy; duke@435: static address _arrayof_jshort_arraycopy; duke@435: static address _arrayof_jint_arraycopy; duke@435: static address _arrayof_jlong_arraycopy; duke@435: static address _arrayof_oop_arraycopy; duke@435: static address _arrayof_jbyte_disjoint_arraycopy; duke@435: static address _arrayof_jshort_disjoint_arraycopy; duke@435: static address _arrayof_jint_disjoint_arraycopy; duke@435: static address _arrayof_jlong_disjoint_arraycopy; duke@435: static address _arrayof_oop_disjoint_arraycopy; duke@435: duke@435: // these are recommended but optional: duke@435: static address _checkcast_arraycopy; duke@435: static address _unsafe_arraycopy; duke@435: static address _generic_arraycopy; duke@435: duke@435: public: duke@435: // Initialization/Testing duke@435: static void initialize1(); // must happen before universe::genesis duke@435: static void initialize2(); // must happen after universe::genesis duke@435: duke@435: static bool contains(address addr) { duke@435: return duke@435: (_code1 != NULL && _code1->blob_contains(addr)) || duke@435: (_code2 != NULL && _code2->blob_contains(addr)) ; duke@435: } duke@435: duke@435: // Debugging duke@435: static jint verify_oop_count() { return _verify_oop_count; } duke@435: static jint* verify_oop_count_addr() { return &_verify_oop_count; } duke@435: // a subroutine for debugging the GC duke@435: static address verify_oop_subroutine_entry_address() { return (address)&_verify_oop_subroutine_entry; } duke@435: duke@435: static address catch_exception_entry() { return _catch_exception_entry; } duke@435: duke@435: // Calls to Java duke@435: typedef void (*CallStub)( duke@435: address link, duke@435: intptr_t* result, duke@435: BasicType result_type, duke@435: methodOopDesc* method, duke@435: address entry_point, duke@435: intptr_t* parameters, duke@435: int size_of_parameters, duke@435: TRAPS duke@435: ); duke@435: duke@435: static CallStub call_stub() { return CAST_TO_FN_PTR(CallStub, _call_stub_entry); } duke@435: duke@435: // Exceptions duke@435: static address forward_exception_entry() { return _forward_exception_entry; } duke@435: // Implicit exceptions duke@435: static address throw_AbstractMethodError_entry() { return _throw_AbstractMethodError_entry; } dcubed@451: static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; } duke@435: static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; } duke@435: static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; } duke@435: static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; } duke@435: static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; } duke@435: duke@435: // Exceptions during unsafe access - should throw Java exception rather duke@435: // than crash. duke@435: static address handler_for_unsafe_access() { return _handler_for_unsafe_access_entry; } duke@435: duke@435: static address atomic_xchg_entry() { return _atomic_xchg_entry; } duke@435: static address atomic_xchg_ptr_entry() { return _atomic_xchg_ptr_entry; } duke@435: static address atomic_store_entry() { return _atomic_store_entry; } duke@435: static address atomic_store_ptr_entry() { return _atomic_store_ptr_entry; } duke@435: static address atomic_cmpxchg_entry() { return _atomic_cmpxchg_entry; } duke@435: static address atomic_cmpxchg_ptr_entry() { return _atomic_cmpxchg_ptr_entry; } duke@435: static address atomic_cmpxchg_long_entry() { return _atomic_cmpxchg_long_entry; } duke@435: static address atomic_add_entry() { return _atomic_add_entry; } duke@435: static address atomic_add_ptr_entry() { return _atomic_add_ptr_entry; } duke@435: static address fence_entry() { return _fence_entry; } duke@435: duke@435: static address d2i_wrapper() { return _d2i_wrapper; } duke@435: static address d2l_wrapper() { return _d2l_wrapper; } duke@435: static jint fpu_cntrl_wrd_std() { return _fpu_cntrl_wrd_std; } duke@435: static address addr_fpu_cntrl_wrd_std() { return (address)&_fpu_cntrl_wrd_std; } duke@435: static address addr_fpu_cntrl_wrd_24() { return (address)&_fpu_cntrl_wrd_24; } duke@435: static address addr_fpu_cntrl_wrd_64() { return (address)&_fpu_cntrl_wrd_64; } duke@435: static address addr_fpu_cntrl_wrd_trunc() { return (address)&_fpu_cntrl_wrd_trunc; } duke@435: static address addr_mxcsr_std() { return (address)&_mxcsr_std; } duke@435: static address addr_fpu_subnormal_bias1() { return (address)&_fpu_subnormal_bias1; } duke@435: static address addr_fpu_subnormal_bias2() { return (address)&_fpu_subnormal_bias2; } duke@435: duke@435: duke@435: static address jbyte_arraycopy() { return _jbyte_arraycopy; } duke@435: static address jshort_arraycopy() { return _jshort_arraycopy; } duke@435: static address jint_arraycopy() { return _jint_arraycopy; } duke@435: static address jlong_arraycopy() { return _jlong_arraycopy; } duke@435: static address oop_arraycopy() { return _oop_arraycopy; } duke@435: static address jbyte_disjoint_arraycopy() { return _jbyte_disjoint_arraycopy; } duke@435: static address jshort_disjoint_arraycopy() { return _jshort_disjoint_arraycopy; } duke@435: static address jint_disjoint_arraycopy() { return _jint_disjoint_arraycopy; } duke@435: static address jlong_disjoint_arraycopy() { return _jlong_disjoint_arraycopy; } duke@435: static address oop_disjoint_arraycopy() { return _oop_disjoint_arraycopy; } duke@435: duke@435: static address arrayof_jbyte_arraycopy() { return _arrayof_jbyte_arraycopy; } duke@435: static address arrayof_jshort_arraycopy() { return _arrayof_jshort_arraycopy; } duke@435: static address arrayof_jint_arraycopy() { return _arrayof_jint_arraycopy; } duke@435: static address arrayof_jlong_arraycopy() { return _arrayof_jlong_arraycopy; } duke@435: static address arrayof_oop_arraycopy() { return _arrayof_oop_arraycopy; } duke@435: duke@435: static address arrayof_jbyte_disjoint_arraycopy() { return _arrayof_jbyte_disjoint_arraycopy; } duke@435: static address arrayof_jshort_disjoint_arraycopy() { return _arrayof_jshort_disjoint_arraycopy; } duke@435: static address arrayof_jint_disjoint_arraycopy() { return _arrayof_jint_disjoint_arraycopy; } duke@435: static address arrayof_jlong_disjoint_arraycopy() { return _arrayof_jlong_disjoint_arraycopy; } duke@435: static address arrayof_oop_disjoint_arraycopy() { return _arrayof_oop_disjoint_arraycopy; } duke@435: duke@435: static address checkcast_arraycopy() { return _checkcast_arraycopy; } duke@435: static address unsafe_arraycopy() { return _unsafe_arraycopy; } duke@435: static address generic_arraycopy() { return _generic_arraycopy; } duke@435: duke@435: // duke@435: // Default versions of the above arraycopy functions for platforms which do duke@435: // not have specialized versions duke@435: // duke@435: static void jbyte_copy (jbyte* src, jbyte* dest, size_t count); duke@435: static void jshort_copy(jshort* src, jshort* dest, size_t count); duke@435: static void jint_copy (jint* src, jint* dest, size_t count); duke@435: static void jlong_copy (jlong* src, jlong* dest, size_t count); duke@435: static void oop_copy (oop* src, oop* dest, size_t count); duke@435: duke@435: static void arrayof_jbyte_copy (HeapWord* src, HeapWord* dest, size_t count); duke@435: static void arrayof_jshort_copy(HeapWord* src, HeapWord* dest, size_t count); duke@435: static void arrayof_jint_copy (HeapWord* src, HeapWord* dest, size_t count); duke@435: static void arrayof_jlong_copy (HeapWord* src, HeapWord* dest, size_t count); duke@435: static void arrayof_oop_copy (HeapWord* src, HeapWord* dest, size_t count); duke@435: };