1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2016 SAP SE. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_S390_VM_REGISTERSAVER_S390_HPP
  27 #define CPU_S390_VM_REGISTERSAVER_S390_HPP
  28 
  29 class RegisterSaver {
  30   // Used for saving volatile registers.
  31 
  32   // Class declaration moved to separate file to make it available elsewhere.
  33   // Implementation remains in sharedRuntime_s390.cpp
  34 
  35  public:
  36 
  37   // Set of registers to be saved.
  38   typedef enum {
  39     all_registers,
  40     all_registers_except_r2,
  41     all_integer_registers,
  42     all_volatile_registers, // According to ABI calling convention.
  43     arg_registers
  44   } RegisterSet;
  45 
  46   // Boolean flags to force only argument registers to be saved.
  47   static int live_reg_save_size(RegisterSet reg_set);
  48   static int live_reg_frame_size(RegisterSet reg_set);
  49   // Specify the register that should be stored as the return pc in the current frame.
  50   static OopMap* save_live_registers(MacroAssembler* masm, RegisterSet reg_set, Register return_pc = Z_R14);
  51   static void restore_live_registers(MacroAssembler* masm, RegisterSet reg_set);
  52 
  53   // Generate the OopMap (again, regs where saved before).
  54   static OopMap* generate_oop_map(MacroAssembler* masm, RegisterSet reg_set);
  55 
  56   // During deoptimization only the result register need to be restored
  57   // all the other values have already been extracted.
  58   static void restore_result_registers(MacroAssembler* masm);
  59 
  60   // Constants and data structures:
  61 
  62   typedef enum {
  63     int_reg           = 0,
  64     float_reg         = 1,
  65     excluded_reg      = 2,  // Not saved/restored.
  66   } RegisterType;
  67 
  68   typedef enum {
  69     reg_size          = 8,
  70     half_reg_size     = reg_size / 2,
  71   } RegisterConstants;
  72 
  73   // Remember type, number, and VMReg.
  74   typedef struct {
  75     RegisterType        reg_type;
  76     int                 reg_num;
  77     VMReg               vmreg;
  78   } LiveRegType;
  79 
  80 };
  81 
  82 #endif // CPU_S390_VM_REGISTERSAVER_S390_HPP