compUtils.hpp

Go to the documentation of this file.
00001 /* Copyright 1994, LongView Technologies L.L.C. $Revision: 1.10 $ */
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 // helper functions / data structures for compiler support; e.g. compiler
00025 // parameters (inlining limits etc.)
00026 
00027 #ifdef DELTA_COMPILER
00028 
00029 // kinds of inlining limits
00030 enum InlineLimitType {
00031   NormalFnLimit,                    // "size" of normal method (see msgCost)
00032   BlockArgFnLimit,                  // size of method with block args
00033   BlockFnLimit,                     // size of block method (value, value: etc)
00034   SplitCostLimit,                   // max total cost of copied nodes
00035   NormalFnInstrLimit,               // size (instructions) of normal method
00036   BlockArgFnInstrLimit,             // ditto for method with block args
00037   BlockFnInstrLimit,                // ditto for block method
00038   NmInstrLimit,                     // desired max. nmethod size
00039   LastLimit                         // sentinel
00040 };
00041 
00042 typedef bool (*checkLocalSendFn)(symbolOop sel);
00043 enum InlineFnType {
00044   NormalFn,                 // normal method
00045   BlockArgFn,               // method with one or more block args
00046   BlockFn                   // block method (value, value: etc)
00047 };
00048 
00049 // parameters of cost function that computes space cost of inlining 
00050 // a particular method
00051 struct CostParam {          
00052   int localCost;            // local variable access / assign
00053   int cheapSendCost;        // "cheap" send (see isCheapMessage)
00054   int sendCost;             // arbitrary send
00055   int blockArgPenalty;     // penalty if non-cheap send has block arg(s)
00056   int primCallCost;         // primitive call
00057   
00058   CostParam(int l, int c, int s, int b, int p) {
00059     localCost = l; cheapSendCost = c; sendCost = s;
00060     blockArgPenalty = b; primCallCost = p;
00061   }
00062 };
00063 
00064 // The PerformanceDebugger reports info useful for finding performance bugs (e.g., 
00065 // contexts and blocks that can't be eliminated and the resons why).
00066 
00067 class PerformanceDebugger : public ResourceObj {
00068   Compiler* c;
00069   bool compileReported;       // have we already reported something for this compile?
00070   GrowableArray<BlockPReg*>* blocks;
00071   GrowableArray<char*>* reports;  // list of reports already printed (to avoid duplicates)
00072   stringStream* str;
00073   GrowableArray<InlinedScope*>* notInlinedBecauseNmethodTooBig;
00074 public:
00075   PerformanceDebugger(Compiler* c);
00076 
00077   void report_context(InlinedScope* s);                   // couldn't eliminate scope's context
00078   void report_block(Node* s, BlockPReg* blk, char* what); // couldn't eliminate block
00079   void report_toobig(InlinedScope* s);                    // nmethod getting too big
00080   void report_uncommon(bool reoptimizing);                // uncommon recompile  
00081   void report_prim_failure(primitive_desc* pd);           // failure not uncommon
00082   void finish_reporting();
00083 private:
00084   void report_compile();
00085   void start_report();
00086   void stop_report();
00087   friend class Reporter;
00088 };
00089 
00090 #endif

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