stubRoutines.hpp

Go to the documentation of this file.
00001 /* Copyright 1994 - 1996 LongView Technologies L.L.C. $Revision: 1.19 $ */
00002 /* Copyright (c) 2006, Sun Microsystems, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
00006 following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
00010           disclaimer in the documentation and/or other materials provided with the distribution.
00011     * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 
00012           from this software without specific prior written permission.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00020 
00021 
00022 */
00023 
00024 
00025 // StubRoutines contains a set of little assembly run-time routines.
00026 // Instead of relying on an assembler, these routines are generated
00027 // during system initialization.
00028 // Note: The stubroutines are *outside* of the interpreter code.
00029 //
00030 // Steps to add a new stub routine:
00031 //
00032 // 1. add a new entry point (class variable)
00033 // 2. add the corresponding entry point accessor (class method)
00034 // 3. implement the stub code generator
00035 // 4. call the generator in init()
00036 
00037 class StubRoutines: AllStatic {
00038  private:
00039   enum { _code_size = 2000 };                   // simply increase if too small (assembler will crash if too small)
00040   static bool _is_initialized;                  // true if StubRoutines has been initialized
00041   static char _code[_code_size];                // the code buffer for the stub routines
00042 
00043   // add entry points here
00044   static char* _ic_normal_lookup_entry;
00045   static char* _ic_super_lookup_entry;
00046   static char* _zombie_nmethod_entry;
00047   static char* _zombie_block_nmethod_entry;
00048   static char* _megamorphic_ic_entry;
00049   static char* _compile_block_entry;
00050   static char* _continue_NLR_entry;
00051   static char* _call_sync_DLL_entry;
00052   static char* _call_async_DLL_entry;
00053   static char* _lookup_sync_DLL_entry;
00054   static char* _lookup_async_DLL_entry;
00055   static char* _recompile_stub_entry;
00056   static char* _used_uncommon_trap_entry;
00057   static char* _unused_uncommon_trap_entry;
00058   static char* _verify_context_chain_entry;
00059   static char* _deoptimize_block_entry;
00060   static char* _call_inspector_entry;
00061 
00062   static char* _PIC_stub_entries[];
00063   static char* _allocate_entries[];
00064 
00065   
00066   // add tracing routines here
00067   static void trace_DLL_call_1(dll_func function, oop* last_argument, int nof_arguments);
00068   static void trace_DLL_call_2(int result);
00069   static void wrong_DLL_call();
00070 
00071 
00072   // add generators here
00073   static char* generate_ic_lookup(MacroAssembler* masm, char* lookup_routine_entry);
00074   static char* generate_call_DLL(MacroAssembler* masm, bool async);
00075   static char* generate_lookup_DLL(MacroAssembler* masm, bool async);
00076   
00077   static char* generate_ic_normal_lookup        (MacroAssembler* masm);
00078   static char* generate_ic_super_lookup         (MacroAssembler* masm);
00079   static char* generate_zombie_nmethod          (MacroAssembler* masm);
00080   static char* generate_zombie_block_nmethod    (MacroAssembler* masm);
00081   static char* generate_megamorphic_ic          (MacroAssembler* masm);
00082   static char* generate_compile_block           (MacroAssembler* masm);
00083   static char* generate_continue_NLR            (MacroAssembler* masm);
00084   static char* generate_call_sync_DLL           (MacroAssembler* masm)  { return generate_call_DLL  (masm, false); }
00085   static char* generate_call_async_DLL          (MacroAssembler* masm)  { return generate_call_DLL  (masm, true ); }
00086   static char* generate_lookup_sync_DLL         (MacroAssembler* masm)  { return generate_lookup_DLL(masm, false); }
00087   static char* generate_lookup_async_DLL        (MacroAssembler* masm)  { return generate_lookup_DLL(masm, true ); }
00088   static char* generate_recompile_stub          (MacroAssembler* masm);
00089   static char* generate_uncommon_trap           (MacroAssembler* masm);
00090   static char* generate_verify_context_chain    (MacroAssembler* masm);
00091   static char* generate_deoptimize_block        (MacroAssembler* masm);
00092   static char* generate_call_inspector          (MacroAssembler* masm);
00093 
00094   static char* generate_PIC_stub                (MacroAssembler* masm, int pic_size     );
00095   static char* generate_allocate                (MacroAssembler* masm, int size         );
00096 
00097 
00098   // helpers for generation
00099   static char* generate(MacroAssembler* masm, char* title, char* gen(MacroAssembler*));
00100   static char* generate(MacroAssembler* masm, char* title, char* gen(MacroAssembler*, int argument), int argument);
00101 
00102  public:
00103   // add entry point accessors here
00104   static char* ic_normal_lookup_entry()         { return _ic_normal_lookup_entry; }
00105   static char* ic_super_lookup_entry()          { return _ic_super_lookup_entry; }
00106   static char* zombie_nmethod_entry()           { return _zombie_nmethod_entry; }
00107   static char* zombie_block_nmethod_entry()     { return _zombie_block_nmethod_entry; }
00108   static char* megamorphic_ic_entry()           { return _megamorphic_ic_entry; }
00109   static char* compile_block_entry()            { return _compile_block_entry; }
00110   static char* continue_NLR_entry()             { return _continue_NLR_entry; }
00111   static char* call_DLL_entry(bool async)       { return async ? _call_async_DLL_entry   : _call_sync_DLL_entry; }
00112   static char* lookup_DLL_entry(bool async)     { return async ? _lookup_async_DLL_entry : _lookup_sync_DLL_entry; }
00113   static char* recompile_stub_entry()           { return _recompile_stub_entry; }
00114   static char* used_uncommon_trap_entry()       { return _used_uncommon_trap_entry; }
00115   static char* unused_uncommon_trap_entry()     { return _unused_uncommon_trap_entry; }
00116   static char* verify_context_chain()           { return _verify_context_chain_entry; }
00117   static char* deoptimize_block_entry()         { return _deoptimize_block_entry; }
00118   static char* call_inspector_entry()           { return _call_inspector_entry; }
00119 
00120   static char* PIC_stub_entry(int pic_size);    // PIC interpreter stubs: pic_size is the number of entries
00121   static char* allocate_entry(int size);        // allocation of memOops: size is words in addition to header
00122 
00123   // Support for profiling
00124   static bool contains(char* pc)                { return (_code <= pc) && (pc < &_code[_code_size]); }
00125 
00126   static void init();                           // must be called in system initialization phase
00127 };

Generated on Mon Oct 9 13:37:28 2006 for Strongtalk VM by  doxygen 1.4.7