1 /*
   2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, Red Hat Inc. 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 // This file is a derivative work resulting from (and including) modifications
  26 // made by Azul Systems, Inc.  The dates of such changes are 2013-2016.
  27 // Copyright 2013-2016 Azul Systems, Inc.  All Rights Reserved.
  28 //
  29 // Please contact Azul Systems, 385 Moffett Park Drive, Suite 115, Sunnyvale,
  30 // CA 94089 USA or visit www.azul.com if you need additional information or
  31 // have any questions.
  32 
  33 #ifndef CPU_AARCH32_VM_C1_MACROASSEMBLER_AARCH32_HPP
  34 #define CPU_AARCH32_VM_C1_MACROASSEMBLER_AARCH32_HPP
  35 
  36 // C1_MacroAssembler contains high-level macros for C1
  37 
  38  private:
  39   int _rsp_offset;    // track rsp changes
  40   // initialization
  41   void pd_init() { _rsp_offset = 0; }
  42 
  43 void zero_memory(Register addr, Register len, Register t1);
  44 
  45  public:
  46   void try_allocate(
  47     Register obj,                      // result: pointer to object after successful allocation
  48     Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
  49     int      con_size_in_bytes,        // object size in bytes if   known at compile time
  50     Register t1,                       // temp register
  51     Register t2,                       // temp register
  52     Label&   slow_case                 // continuation point if fast allocation fails
  53   );
  54 
  55   void initialize_header(Register obj, Register klass, Register len, Register t1, Register t2);
  56   void initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1);
  57 
  58   void float_cmp(bool is_float, int unordered_result,
  59                  FloatRegister f0, FloatRegister f1,
  60                  Register result);
  61 
  62   // locking
  63   // hdr     : must be r0, contents destroyed
  64   // obj     : must point to the object to lock, contents preserved
  65   // disp_hdr: must point to the displaced header location, contents preserved
  66   // scratch : scratch register, contents destroyed
  67   // returns code offset at which to add null check debug information
  68   int lock_object  (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case);
  69 
  70   // unlocking
  71   // hdr     : contents destroyed
  72   // obj     : must point to the object to lock, contents preserved
  73   // disp_hdr: must be r0 & must point to the displaced header location, contents destroyed
  74   void unlock_object(Register swap, Register obj, Register lock, Label& slow_case);
  75 
  76   void initialize_object(
  77     Register obj,                      // result: pointer to object after successful allocation
  78     Register klass,                    // object klass
  79     Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
  80     int      con_size_in_bytes,        // object size in bytes if   known at compile time
  81     Register t1,                       // temp register
  82     Register t2                        // temp register
  83   );
  84 
  85   // allocation of fixed-size objects
  86   // (can also be used to allocate fixed-size arrays, by setting
  87   // hdr_size correctly and storing the array length afterwards)
  88   // obj        : will contain pointer to allocated object
  89   // t1, t2     : scratch registers - contents destroyed
  90   // header_size: size of object header in words
  91   // object_size: total size of object in words
  92   // slow_case  : exit to slow case implementation if fast allocation fails
  93   void allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case);
  94 
  95   enum {
  96     max_array_allocation_length = 0x00FFFFFF
  97   };
  98 
  99   // allocation of arrays
 100   // obj        : will contain pointer to allocated object
 101   // len        : array length in number of elements
 102   // t          : scratch register - contents destroyed
 103   // header_size: size of object header in words
 104   // f          : element scale factor
 105   // slow_case  : exit to slow case implementation if fast allocation fails
 106   void allocate_array(Register obj, Register len, Register t, Register t2, int header_size, int f, Register klass, Label& slow_case);
 107 
 108   int  rsp_offset() const { return _rsp_offset; }
 109   void set_rsp_offset(int n) { _rsp_offset = n; }
 110 
 111   void invalidate_registers(bool inv_r0, bool inv_r2, bool inv_r3) PRODUCT_RETURN;
 112 
 113   void patchable_load(Register reg, address addr);
 114 
 115 #endif // CPU_AARCH32_VM_C1_MACROASSEMBLER_AARCH32_HPP