src/share/vm/code/vmreg.hpp

Print this page
rev 6670 : 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
Reviewed-by: lfoltan, coleenp, dholmes
   1 /*
   2  * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CODE_VMREG_HPP
  26 #define SHARE_VM_CODE_VMREG_HPP
  27 

  28 #include "memory/allocation.hpp"
  29 #include "utilities/globalDefinitions.hpp"
  30 #include "asm/register.hpp"
  31 
  32 #ifdef COMPILER2
  33 #include "opto/adlcVMDeps.hpp"
  34 #include "utilities/ostream.hpp"
  35 #ifdef TARGET_ARCH_MODEL_x86_32
  36 # include "adfiles/adGlobals_x86_32.hpp"
  37 #endif
  38 #ifdef TARGET_ARCH_MODEL_x86_64
  39 # include "adfiles/adGlobals_x86_64.hpp"
  40 #endif
  41 #ifdef TARGET_ARCH_MODEL_sparc
  42 # include "adfiles/adGlobals_sparc.hpp"
  43 #endif
  44 #ifdef TARGET_ARCH_MODEL_zero
  45 # include "adfiles/adGlobals_zero.hpp"
  46 #endif
  47 #ifdef TARGET_ARCH_MODEL_arm
  48 # include "adfiles/adGlobals_arm.hpp"
  49 #endif
  50 #ifdef TARGET_ARCH_MODEL_ppc_32
  51 # include "adfiles/adGlobals_ppc_32.hpp"
  52 #endif
  53 #ifdef TARGET_ARCH_MODEL_ppc_64
  54 # include "adfiles/adGlobals_ppc_64.hpp"
  55 #endif
  56 #endif
  57 
  58 //------------------------------VMReg------------------------------------------
  59 // The VM uses 'unwarped' stack slots; the compiler uses 'warped' stack slots.
  60 // Register numbers below VMRegImpl::stack0 are the same for both.  Register
  61 // numbers above stack0 are either warped (in the compiler) or unwarped
  62 // (in the VM).  Unwarped numbers represent stack indices, offsets from
  63 // the current stack pointer.  Warped numbers are required during compilation
  64 // when we do not yet know how big the frame will be.
  65 
  66 class VMRegImpl;
  67 typedef VMRegImpl* VMReg;
  68 
  69 class VMRegImpl {
  70 // friend class OopMap;
  71 friend class VMStructs;
  72 friend class OptoReg;
  73 // friend class Location;
  74 private:
  75   enum {


  90 
  91   const char*  name() {
  92     if (is_reg()) {
  93       return regName[value()];
  94     } else if (!is_valid()) {
  95       return "BAD";
  96     } else {
  97       // shouldn't really be called with stack
  98       return "STACKED REG";
  99     }
 100   }
 101   static VMReg Bad() { return (VMReg) (intptr_t) BAD_REG; }
 102   bool is_valid() const { return ((intptr_t) this) != BAD_REG; }
 103   bool is_stack() const { return (intptr_t) this >= (intptr_t) stack0; }
 104   bool is_reg()   const { return is_valid() && !is_stack(); }
 105 
 106   // A concrete register is a value that returns true for is_reg() and is
 107   // also a register you could use in the assembler. On machines with
 108   // 64bit registers only one half of the VMReg (and OptoReg) is considered
 109   // concrete.
 110   bool is_concrete();
 111 
 112   // VMRegs are 4 bytes wide on all platforms
 113   static const int stack_slot_size;
 114   static const int slots_per_word;
 115 
 116 
 117   // This really ought to check that the register is "real" in the sense that
 118   // we don't try and get the VMReg number of a physical register that doesn't
 119   // have an expressible part. That would be pd specific code
 120   VMReg next() {
 121     assert((is_reg() && value() < stack0->value() - 1) || is_stack(), "must be");
 122     return (VMReg)(intptr_t)(value() + 1);
 123   }
 124   VMReg next(int i) {
 125     assert((is_reg() && value() < stack0->value() - i) || is_stack(), "must be");
 126     return (VMReg)(intptr_t)(value() + i);
 127   }
 128   VMReg prev() {
 129     assert((is_stack() && value() > stack0->value()) || (is_reg() && value() != 0), "must be");
 130     return (VMReg)(intptr_t)(value() - 1);


   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CODE_VMREG_HPP
  26 #define SHARE_VM_CODE_VMREG_HPP
  27 
  28 #include "asm/register.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "utilities/globalDefinitions.hpp"

  31 
  32 #ifdef COMPILER2
  33 #include "opto/adlcVMDeps.hpp"
  34 #include "utilities/ostream.hpp"





















  35 #endif
  36 
  37 //------------------------------VMReg------------------------------------------
  38 // The VM uses 'unwarped' stack slots; the compiler uses 'warped' stack slots.
  39 // Register numbers below VMRegImpl::stack0 are the same for both.  Register
  40 // numbers above stack0 are either warped (in the compiler) or unwarped
  41 // (in the VM).  Unwarped numbers represent stack indices, offsets from
  42 // the current stack pointer.  Warped numbers are required during compilation
  43 // when we do not yet know how big the frame will be.
  44 
  45 class VMRegImpl;
  46 typedef VMRegImpl* VMReg;
  47 
  48 class VMRegImpl {
  49 // friend class OopMap;
  50 friend class VMStructs;
  51 friend class OptoReg;
  52 // friend class Location;
  53 private:
  54   enum {


  69 
  70   const char*  name() {
  71     if (is_reg()) {
  72       return regName[value()];
  73     } else if (!is_valid()) {
  74       return "BAD";
  75     } else {
  76       // shouldn't really be called with stack
  77       return "STACKED REG";
  78     }
  79   }
  80   static VMReg Bad() { return (VMReg) (intptr_t) BAD_REG; }
  81   bool is_valid() const { return ((intptr_t) this) != BAD_REG; }
  82   bool is_stack() const { return (intptr_t) this >= (intptr_t) stack0; }
  83   bool is_reg()   const { return is_valid() && !is_stack(); }
  84 
  85   // A concrete register is a value that returns true for is_reg() and is
  86   // also a register you could use in the assembler. On machines with
  87   // 64bit registers only one half of the VMReg (and OptoReg) is considered
  88   // concrete.
  89   //  bool is_concrete();
  90 
  91   // VMRegs are 4 bytes wide on all platforms
  92   static const int stack_slot_size;
  93   static const int slots_per_word;
  94 
  95 
  96   // This really ought to check that the register is "real" in the sense that
  97   // we don't try and get the VMReg number of a physical register that doesn't
  98   // have an expressible part. That would be pd specific code
  99   VMReg next() {
 100     assert((is_reg() && value() < stack0->value() - 1) || is_stack(), "must be");
 101     return (VMReg)(intptr_t)(value() + 1);
 102   }
 103   VMReg next(int i) {
 104     assert((is_reg() && value() < stack0->value() - i) || is_stack(), "must be");
 105     return (VMReg)(intptr_t)(value() + i);
 106   }
 107   VMReg prev() {
 108     assert((is_stack() && value() > stack0->value()) || (is_reg() && value() != 0), "must be");
 109     return (VMReg)(intptr_t)(value() - 1);