inliningdb.hpp

Go to the documentation of this file.
00001 /* Copyright 1996, LongView Technologies L.L.C. $Revision: 1.8 $ */
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 // Interface to the inlining database
00025 
00026 class InliningDatabaseKey;
00027 
00028 class InliningDatabase : AllStatic {
00029  private:
00030   // Helper functions to compute file path when filing out.
00031   static char* selector_string(symbolOop selector);
00032   static char* method_string(methodOop method);
00033   static char* klass_string(klassOop klass);
00034 
00035   // Read the scope structure from a stream
00036   static RScope* file_in_from(FILE* stream);
00037 
00038   // Helper functions when iterating over zone.
00039   static int      local_number_of_nmethods_written;
00040   static void     local_file_out_all(nmethod* nm);
00041   static klassOop local_klass;
00042   static void     local_file_out_klass(nmethod* nm);
00043 
00044   // Returns the file name for the two keys and creates the necessary directories 
00045   static char* compute_file_name(LookupKey* outer, LookupKey* inner, bool create_directories);
00046 
00047   // Returns the file name for the index file
00048   static char* index_file_name();
00049 
00050   static char* _directory;
00051 
00052   static outputStream* index_st;
00053   static InliningDatabaseKey* table;
00054   static unsigned int table_size;      // Size of table power of 2
00055   static unsigned int table_size_mask; // nthMask(table_size)
00056   static unsigned int table_no;        // Number of elements in the table
00057  public:
00058   // Accessor for the root of the database
00059   static char* default_directory();
00060   static void  set_directory(char* dir);
00061   static char* directory();
00062 
00063   // Writes the inlining structure for all compiled code.
00064   // Returns the number of written inlining structures. 
00065   static int file_out_all();
00066 
00067   // Writes the inlining structure for compiled method.
00068   // Returns whether the information was written.
00069   static bool file_out(nmethod* nm, outputStream* index_st = NULL);
00070 
00071   // Writes the inlining structure for all compiled methods with a
00072   // specific receiver klass, returns the number of written structures. 
00073   static int file_out(klassOop klass);
00074 
00075   // Reads the inlining structure from file_name.
00076   // Returns NULL if the attempt failed.
00077   static RScope* file_in(char* file_name);
00078 
00079   // Reads the inlining structure for receiver_class/selector.
00080   // Returns NULL if the attempt failed.
00081   static RScope* file_in(LookupKey* outer, LookupKey* inner = NULL);
00082 
00083   // Converts a string into a mangled name that is a valid filename
00084   // on the running platform.
00085   static char* mangle_name(char *str);
00086 
00087   // Converts a mangled string back to the orignal sting. 
00088   static char* unmangle_name(char* str);
00089 
00090   // the lookup table
00091   static void    reset_lookup_table();
00092   static void    add_lookup_entry(LookupKey* outer,  LookupKey* inner = NULL);
00093   static bool    lookup(LookupKey* outer, LookupKey* inner = NULL);
00094   static RScope* lookup_and_remove(LookupKey* outer, LookupKey* inner = NULL);
00095   static RScope* select_and_remove(bool* end_of_table); // For background compilation
00096 
00097   // Index file
00098   static void load_index_file();
00099 
00100   // Iterates through all oops stored in the inlining database
00101   static void oops_do(void f(oop*));
00102  private:
00103   static void allocate_table(unsigned int size);
00104   static inline unsigned int index_for(LookupKey* outer, LookupKey* inner);
00105   static inline unsigned int next_index(unsigned int index);
00106 };

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