src/share/vm/code/location.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6706829 Sdiff src/share/vm/code

src/share/vm/code/location.hpp

Print this page


   1 /*
   2  * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *
  23  */
  24 
  25 // A Location describes a concrete machine variable location
  26 // (such as integer or floating point register or a stack-held
  27 // variable). Used when generating debug-information for nmethods.
  28 //
  29 // Encoding:
  30 //
  31 // bits:
  32 //  Where:  [15]
  33 //  Type:   [14..12]
  34 //  Offset: [11..0]
  35 
  36 class Location VALUE_OBJ_CLASS_SPEC {
  37   friend class VMStructs;
  38  public:
  39   enum Where {
  40     on_stack,
  41     in_register
  42   };
  43 
  44   enum Type {

  45     normal,                     // Ints, floats, double halves
  46     oop,                        // Oop (please GC me!)
  47     int_in_long,                // Integer held in long register
  48     lng,                        // Long held in one register
  49     float_in_dbl,               // Float held in double register
  50     dbl,                        // Double held in one register
  51     addr,                       // JSR return address
  52     invalid                     // Invalid location
  53   };
  54 
  55 
  56  private:
  57   enum {
  58     OFFSET_MASK  = (jchar) 0x0FFF,
  59     OFFSET_SHIFT = 0,
  60     TYPE_MASK    = (jchar) 0x7000,
  61     TYPE_SHIFT   = 12,
  62     WHERE_MASK   = (jchar) 0x8000,
  63     WHERE_SHIFT  = 15
  64   };
  65 
  66   uint16_t _value;
  67 
  68   // Create a bit-packed Location
  69   Location(Where where_, Type type_, unsigned offset_) {
  70     set(where_, type_, offset_);
  71     assert( where () == where_ , "" );
  72     assert( type  () == type_  , "" );
  73     assert( offset() == offset_, "" );
  74   }
  75 
  76   inline void set(Where where_, Type type_, unsigned offset_) {
  77     _value = (uint16_t) ((where_  << WHERE_SHIFT) |
  78                          (type_   << TYPE_SHIFT)  |
  79                          ((offset_ << OFFSET_SHIFT) & OFFSET_MASK));
  80   }
  81 
  82  public:
  83 
  84   // Stack location Factory.  Offset is 4-byte aligned; remove low bits
  85   static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }
  86   // Register location Factory
  87   static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }
  88   // Default constructor
  89   Location() { set(on_stack,invalid,(unsigned) -1); }
  90 
  91   // Bit field accessors
  92   Where where()  const { return (Where)       ((_value & WHERE_MASK)  >> WHERE_SHIFT);}
  93   Type  type()   const { return (Type)        ((_value & TYPE_MASK)   >> TYPE_SHIFT); }
  94   unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }
  95 
  96   // Accessors
  97   bool is_register() const    { return where() == in_register; }
  98   bool is_stack() const       { return where() == on_stack;    }
  99 
 100   int stack_offset() const    { assert(where() == on_stack,    "wrong Where"); return offset()<<LogBytesPerInt; }
 101   int register_number() const { assert(where() == in_register, "wrong Where"); return offset()   ; }
 102 
 103   VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset())   ; }
 104 
 105   // Printing
 106   void print_on(outputStream* st) const;
 107 
 108   // Serialization of debugging information
 109   Location(DebugInfoReadStream* stream);
   1 /*
   2  * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *
  23  */
  24 
  25 // A Location describes a concrete machine variable location
  26 // (such as integer or floating point register or a stack-held
  27 // variable). Used when generating debug-information for nmethods.
  28 //
  29 // Encoding:
  30 //
  31 // bits (use low bits for best compression):
  32 //  Type:   [3..0]
  33 //  Where:  [4]
  34 //  Offset: [31..5]
  35 
  36 class Location VALUE_OBJ_CLASS_SPEC {
  37   friend class VMStructs;
  38  public:
  39   enum Where {
  40     on_stack,
  41     in_register
  42   };
  43 
  44   enum Type {
  45     invalid,                    // Invalid location
  46     normal,                     // Ints, floats, double halves
  47     oop,                        // Oop (please GC me!)
  48     int_in_long,                // Integer held in long register
  49     lng,                        // Long held in one register
  50     float_in_dbl,               // Float held in double register
  51     dbl,                        // Double held in one register
  52     addr,                       // JSR return address
  53     narrowoop                   // Narrow Oop (please GC me!)
  54   };
  55 
  56 
  57  private:
  58   enum {
  59     TYPE_MASK    = (juint) 0x0F,
  60     TYPE_SHIFT   = 0,
  61     WHERE_MASK   = (juint) 0x10,
  62     WHERE_SHIFT  = 4,
  63     OFFSET_MASK  = (juint) 0xFFFFFFE0,
  64     OFFSET_SHIFT = 5
  65   };
  66 
  67   juint _value;
  68 
  69   // Create a bit-packed Location
  70   Location(Where where_, Type type_, unsigned offset_) {
  71     set(where_, type_, offset_);
  72     assert( where () == where_ , "" );
  73     assert( type  () == type_  , "" );
  74     assert( offset() == offset_, "" );
  75   }
  76 
  77   inline void set(Where where_, Type type_, unsigned offset_) {
  78     _value = (juint) ((where_  << WHERE_SHIFT) |
  79                       (type_   << TYPE_SHIFT)  |
  80                       ((offset_ << OFFSET_SHIFT) & OFFSET_MASK));
  81   }
  82 
  83  public:
  84 
  85   // Stack location Factory.  Offset is 4-byte aligned; remove low bits
  86   static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }
  87   // Register location Factory
  88   static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }
  89   // Default constructor
  90   Location() { set(on_stack,invalid,0); }
  91 
  92   // Bit field accessors
  93   Where where()  const { return (Where)       ((_value & WHERE_MASK)  >> WHERE_SHIFT);}
  94   Type  type()   const { return (Type)        ((_value & TYPE_MASK)   >> TYPE_SHIFT); }
  95   unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }
  96 
  97   // Accessors
  98   bool is_register() const    { return where() == in_register; }
  99   bool is_stack() const       { return where() == on_stack;    }
 100 
 101   int stack_offset() const    { assert(where() == on_stack,    "wrong Where"); return offset()<<LogBytesPerInt; }
 102   int register_number() const { assert(where() == in_register, "wrong Where"); return offset()   ; }
 103 
 104   VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset())   ; }
 105 
 106   // Printing
 107   void print_on(outputStream* st) const;
 108 
 109   // Serialization of debugging information
 110   Location(DebugInfoReadStream* stream);
src/share/vm/code/location.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File