src/cpu/mips/vm/c1_MacroAssembler_mips.hpp

Thu, 07 Sep 2017 09:12:16 +0800

author
aoqi
date
Thu, 07 Sep 2017 09:12:16 +0800
changeset 6880
52ea28d233d2
parent 1
2d8a650513c2
child 9459
814e9e335067
permissions
-rw-r--r--

#5745 [Code Reorganization] code cleanup and code style fix
This is a huge patch, but only code cleanup, code style fix and useless code deletion are included, for example:
tab -> two spaces, deleted spacees at the end of a line, delete useless comments.

This patch also included:
Declaration and definition of class MacroAssembler is moved from assembler_mips.h/cpp to macroAssembler_mips.h/cpp

     1 /*
     2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2015, 2016, Loongson Technology. 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  */
    26 #ifndef CPU_MIPS_VM_C1_MACROASSEMBLER_MIPS_HPP
    27 #define CPU_MIPS_VM_C1_MACROASSEMBLER_MIPS_HPP
    29 // C1_MacroAssembler contains high-level macros for C1
    31  private:
    32   int _sp_offset;    // track sp changes
    33   // initialization
    34   void pd_init() { _sp_offset = 0; }
    36  public:
    37   void try_allocate(
    38     Register obj,                      // result: pointer to object after successful allocation
    39     Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
    40     int      con_size_in_bytes,        // object size in bytes if   known at compile time
    41     Register t1,                       // temp register
    42     Register t2,                       // temp register
    43     Label&   slow_case                 // continuation point if fast allocation fails
    44   );
    46   void initialize_header(Register obj, Register klass, Register len, Register t1, Register t2);
    47   void initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1);
    49   // locking
    50   // hdr     : must be rax, contents destroyed
    51   // obj     : must point to the object to lock, contents preserved
    52   // disp_hdr: must point to the displaced header location, contents preserved
    53   // scratch : scratch register, contents destroyed
    54   // returns code offset at which to add null check debug information
    55   int lock_object  (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case);
    57   // unlocking
    58   // hdr     : contents destroyed
    59   // obj     : must point to the object to lock, contents preserved
    60   // disp_hdr: must be eax & must point to the displaced header location, contents destroyed
    61   void unlock_object(Register swap, Register obj, Register lock, Label& slow_case);
    63   void initialize_object(
    64     Register obj,                      // result: pointer to object after successful allocation
    65     Register klass,                    // object klass
    66     Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
    67     int      con_size_in_bytes,        // object size in bytes if   known at compile time
    68     Register t1,                       // temp register
    69     Register t2                        // temp register
    70   );
    72   // allocation of fixed-size objects
    73   // (can also be used to allocate fixed-size arrays, by setting
    74   // hdr_size correctly and storing the array length afterwards)
    75   // obj        : must be rax, will contain pointer to allocated object
    76   // t1, t2     : scratch registers - contents destroyed
    77   // header_size: size of object header in words
    78   // object_size: total size of object in words
    79   // slow_case  : exit to slow case implementation if fast allocation fails
    80   void allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case);
    82   enum {
    83     max_array_allocation_length = 0x00FFFFFF
    84   };
    86   // allocation of arrays
    87   // obj        : must be rax, will contain pointer to allocated object
    88   // len        : array length in number of elements
    89   // t          : scratch register - contents destroyed
    90   // header_size: size of object header in words
    91   // f          : element scale factor
    92   // slow_case  : exit to slow case implementation if fast allocation fails
    93   void allocate_array(Register obj, Register len, Register t1, Register t2, Register t3, int header_size, int scale, Register klass, Label& slow_case);
    95   int  sp_offset() const { return _sp_offset; }
    96   void set_sp_offset(int n) { _sp_offset = n; }
    98   // Note: NEVER push values directly, but only through following push_xxx functions;
    99   //       This helps us to track the rsp changes compared to the entry rsp (->_sp_offset)
   101   void push_jint (jint i)     { _sp_offset++; move(AT, (int)i); push(AT); }
   102 #ifdef _LP64
   103   void push_oop  (jobject o)  { ShouldNotReachHere(); _sp_offset++; li(AT, (long)o); push(AT);}
   104 #else
   105   void push_oop  (jobject o)  { ShouldNotReachHere(); _sp_offset++; move(AT, (int)o); push(AT);}
   106 #endif
   107   // Seems to always be in wordSize
   108   void push_addr (Address a)  { _sp_offset++; addi(AT, a.base(), a.disp()); push(AT);}
   109   void push_reg  (Register r) { _sp_offset++; push(r); }
   110   void pop_reg   (Register r) { _sp_offset--; pop(r); assert(_sp_offset >= 0, "stack offset underflow"); }
   111   void super_pop(Register r) {MacroAssembler::pop(r);}
   113   void dec_stack (int nof_words) {
   114     _sp_offset -= nof_words;
   115     assert(_sp_offset >= 0, "stack offset underflow");
   116     addi(SP, SP, wordSize * nof_words);
   117   }
   119   void dec_stack_after_call (int nof_words) {
   120     _sp_offset -= nof_words;
   121     assert(_sp_offset >= 0, "stack offset underflow");
   122   }
   124   void invalidate_registers(bool inv_rax, bool inv_rbx, bool inv_rcx, bool inv_rdx, bool inv_rsi, bool inv_rdi) PRODUCT_RETURN;
   126 #endif // CPU_MIPS_VM_C1_MACROASSEMBLER_MIPS_HPP

mercurial