src/share/vm/code/location.hpp

Wed, 09 Apr 2008 15:10:22 -0700

author
rasbold
date
Wed, 09 Apr 2008 15:10:22 -0700
changeset 544
9f4457a14b58
parent 435
a61af66fc99e
child 766
cecd8eb4e0ca
permissions
-rw-r--r--

Merge

     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  */
    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]
    36 class Location VALUE_OBJ_CLASS_SPEC {
    37   friend class VMStructs;
    38  public:
    39   enum Where {
    40     on_stack,
    41     in_register
    42   };
    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   };
    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   };
    66   uint16_t _value;
    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   }
    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   }
    82  public:
    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); }
    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); }
    96   // Accessors
    97   bool is_register() const    { return where() == in_register; }
    98   bool is_stack() const       { return where() == on_stack;    }
   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()   ; }
   103   VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset())   ; }
   105   // Printing
   106   void print_on(outputStream* st) const;
   108   // Serialization of debugging information
   109   Location(DebugInfoReadStream* stream);
   110   void write_on(DebugInfoWriteStream* stream);
   112   // check
   113   static bool legal_offset_in_bytes(int offset_in_bytes);
   114 };

mercurial