nameDesc.hpp

Go to the documentation of this file.
00001 /* Copyright 1994, LongView Technologies L.L.C. $Revision: 1.12 $ */
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 #ifdef DELTA_COMPILER
00025 
00026 // A NameDesc describes the source-level value of a name in some Delta scope
00027 // (e.g. an argument, local, or expression stack entry).  NameDescs are usually
00028 // stored in the zone as part of the debugging information.
00029 
00030 class NameDesc: public PrintableResourceObj {
00031   // are ResourceObj because some are created on-the-fly
00032  public:
00033   virtual bool isLocation() const       { return false; }
00034   virtual bool isValue() const          { return false; }
00035   virtual bool isBlockValue() const     { return false; }
00036   virtual bool isMemoizedBlock() const  { return false; }
00037   virtual bool isIllegal() const        { return false; }
00038 
00039   virtual bool hasLocation() const      { return false; }
00040   virtual Location location() const     { SubclassResponsibility(); return unAllocated; }
00041   virtual oop value(const frame* f = NULL) const { SubclassResponsibility(); return NULL; } 
00042   
00043   virtual bool verify()                 { return true; }
00044   virtual void print()                  = 0;
00045 
00046   virtual bool equal(NameDesc* other) const { return false; }
00047 
00048   int offset;
00049 };
00050 
00051 // something stored at a location
00052 struct LocationNameDesc: public NameDesc {
00053   Location _loc;
00054 
00055   LocationNameDesc(Location loc) {
00056     _loc = loc; 
00057   }
00058 
00059   bool isLocation() const       { return true; }
00060   Location location() const     { return _loc; }
00061   bool hasLocation() const      { return true; }
00062 
00063   bool equal(NameDesc* other) const; 
00064   
00065   void print();
00066 };
00067 
00068 // a run-time constant
00069 struct ValueNameDesc: public NameDesc {
00070   oop _v;
00071 
00072   ValueNameDesc(oop v) {
00073     _v = v;
00074   }
00075   
00076   bool isValue() const { return true; }
00077   
00078   oop value(const frame* f = NULL) const { return _v; }
00079 
00080   bool equal(NameDesc* other) const; 
00081 
00082   void print();
00083 };
00084 
00085 // a block closure "constant", i.e., a block that has been optimized away
00086 struct BlockValueNameDesc: public NameDesc {
00087   methodOop  _block_method;
00088   ScopeDesc* _parent_scope;
00089   
00090   BlockValueNameDesc(methodOop block_method, ScopeDesc* parent_scope) {
00091     _block_method = block_method;
00092     _parent_scope = parent_scope;
00093   }
00094 
00095   bool isBlockValue() const     { return true; }
00096   
00097   // Returns a blockClosureOop
00098   // There are two cases:
00099   // 1. During deoptmization, 
00100   //      where the contextOop referred by the block must be canonicalized
00101   //      to preserve language semantics.
00102   // 2. Normal operation (use during stack tracing etc.), 
00103   //      where contextOop canonicalization is not needed.     
00104   oop value(const frame* f = NULL) const;
00105 
00106   methodOop block_method() const  { return _block_method; }
00107   ScopeDesc* parent_scope() const { return _parent_scope; }
00108 
00109   bool equal(NameDesc* other) const; 
00110   
00111   void print();
00112 };
00113 
00114 // a block closure that may or may not be created at runtime, so location l 
00115 // contains either the real block or a dummy block
00116 struct MemoizedBlockNameDesc: public NameDesc {
00117   Location   _loc;
00118   methodOop  _block_method;
00119   ScopeDesc* _parent_scope;
00120 
00121   MemoizedBlockNameDesc(Location loc, methodOop block_method, ScopeDesc* parent_scope) {
00122     _loc          = loc;
00123     _block_method = block_method;
00124     _parent_scope = parent_scope;
00125   }
00126 
00127   bool isMemoizedBlock() const          { return true; }
00128   
00129   Location location() const             { return _loc; }
00130   methodOop block_method() const        { return _block_method; }
00131   ScopeDesc* parent_scope() const       { return _parent_scope; }
00132   static oop uncreatedBlockValue()      { return smiOop_zero; }
00133 
00134   bool hasLocation() const              { return true; }
00135   oop value(const frame* f = NULL) const;
00136 
00137   bool equal(NameDesc* other) const; 
00138   
00139   void print();
00140 };
00141 
00142 struct IllegalNameDesc: public NameDesc {
00143 
00144   IllegalNameDesc() {}
00145   bool isIllegal() const        { return true; }
00146 
00147   bool equal(NameDesc* other) const; 
00148   
00149   void print();
00150 };
00151 
00152 #endif

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