00001 /* Copyright 1994 - 1996, LongView Technologies, L.L.C. $Revision: 1.49 $ */ 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 class Interpreter: AllStatic { 00026 private: 00027 static bool _is_initialized; // true if Interpreter has been initialized 00028 static char* _code_begin_addr; // the first byte of the interpreter's code 00029 static char* _code_end_addr; // the first byte after the interpreter's code 00030 static int* _invocation_counter_addr;// the address of the invocation counter (used in method entry code) 00031 static char* _redo_send_entry; // entry point to redo an interpreted send that called a zombie nmethod 00032 00033 // Run-time routines 00034 static void trace_bytecode(); 00035 static void wrong_eax(); // called in debug mode only 00036 static void wrong_ebx(); // called in debug mode only 00037 static void wrong_esp(); // called in debug mode only 00038 static void wrong_obj(); // called in debug mode only 00039 static void wrong_primitive_result(); // called in debug mode only 00040 00041 // Floats 00042 static doubleOop oopify_FloatValue(); 00043 00044 public: 00045 // Note: The variable below has been introduced for debugging only: It seems that sometimes a nmethod 00046 // is called from the interpreter (last time it was via a megamorphic self send) that is invalid, 00047 // i.e., the nmethod reports a cache miss by calling the lookup routines. In order to backtrack 00048 // called entry point is stored. Remove this variable if the bug has been found! (gri 7-24-96) 00049 static char* _last_native_called; // last nmethod entry point called by the interpreter 00050 00051 static bool contains(char* pc); // true if pc is within interpreter code; false otherwise 00052 00053 // Properties of the interpreter code (depends on defines in the assembler code) 00054 static bool is_optimized(); 00055 static bool can_trace_bytecodes(); 00056 static bool can_trace_sends(); 00057 static bool has_assertions(); 00058 static bool has_stack_checks(); 00059 static bool has_timers(); 00060 00061 static void print_code_status(); 00062 00063 // Loops 00064 static void loop_counter_overflow(); // this routine gets called when the loop counter overflows 00065 static int loop_counter(); // the number of loop iterations since the last reset 00066 static void reset_loop_counter(); // resets the loop counter to 0 00067 static int loop_counter_limit(); // the loop counter limit 00068 static void set_loop_counter_limit(int limit); 00069 00070 // Invocation counters 00071 static void set_invocation_counter_limit(int new_limit); // set invocation limit 00072 static int get_invocation_counter_limit(); // return invocation limit 00073 00074 // entry points 00075 static char* redo_send_entry() { return _redo_send_entry; } 00076 00077 // Initialization 00078 static bool is_initialized() { return _is_initialized; } 00079 static void init(); 00080 00081 friend class InterpreterGenerator; 00082 };