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

aoqi@1 1 /*
aoqi@1 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
aoqi@1 3 * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved.
aoqi@1 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@1 5 *
aoqi@1 6 * This code is free software; you can redistribute it and/or modify it
aoqi@1 7 * under the terms of the GNU General Public License version 2 only, as
aoqi@1 8 * published by the Free Software Foundation.
aoqi@1 9 *
aoqi@1 10 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@1 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@1 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@1 13 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@1 14 * accompanied this code).
aoqi@1 15 *
aoqi@1 16 * You should have received a copy of the GNU General Public License version
aoqi@1 17 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@1 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@1 19 *
aoqi@1 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@1 21 * or visit www.oracle.com if you need additional information or have any
aoqi@1 22 * questions.
aoqi@1 23 *
aoqi@1 24 */
aoqi@1 25
aoqi@1 26 #ifndef CPU_MIPS_VM_C1_MACROASSEMBLER_MIPS_HPP
aoqi@1 27 #define CPU_MIPS_VM_C1_MACROASSEMBLER_MIPS_HPP
aoqi@1 28
aoqi@1 29 // C1_MacroAssembler contains high-level macros for C1
aoqi@1 30
aoqi@6880 31 private:
aoqi@6880 32 int _sp_offset; // track sp changes
aoqi@6880 33 // initialization
aoqi@6880 34 void pd_init() { _sp_offset = 0; }
aoqi@1 35
aoqi@6880 36 public:
aoqi@6880 37 void try_allocate(
aoqi@6880 38 Register obj, // result: pointer to object after successful allocation
aoqi@6880 39 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
aoqi@6880 40 int con_size_in_bytes, // object size in bytes if known at compile time
aoqi@6880 41 Register t1, // temp register
aoqi@6880 42 Register t2, // temp register
aoqi@6880 43 Label& slow_case // continuation point if fast allocation fails
aoqi@6880 44 );
aoqi@1 45
aoqi@6880 46 void initialize_header(Register obj, Register klass, Register len, Register t1, Register t2);
aoqi@6880 47 void initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1);
aoqi@1 48
aoqi@6880 49 // locking
aoqi@6880 50 // hdr : must be rax, contents destroyed
aoqi@6880 51 // obj : must point to the object to lock, contents preserved
aoqi@6880 52 // disp_hdr: must point to the displaced header location, contents preserved
aoqi@6880 53 // scratch : scratch register, contents destroyed
aoqi@6880 54 // returns code offset at which to add null check debug information
aoqi@6880 55 int lock_object (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case);
aoqi@1 56
aoqi@6880 57 // unlocking
aoqi@6880 58 // hdr : contents destroyed
aoqi@6880 59 // obj : must point to the object to lock, contents preserved
aoqi@6880 60 // disp_hdr: must be eax & must point to the displaced header location, contents destroyed
aoqi@6880 61 void unlock_object(Register swap, Register obj, Register lock, Label& slow_case);
aoqi@1 62
aoqi@6880 63 void initialize_object(
aoqi@6880 64 Register obj, // result: pointer to object after successful allocation
aoqi@6880 65 Register klass, // object klass
aoqi@6880 66 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
aoqi@6880 67 int con_size_in_bytes, // object size in bytes if known at compile time
aoqi@6880 68 Register t1, // temp register
aoqi@6880 69 Register t2 // temp register
aoqi@6880 70 );
aoqi@1 71
aoqi@6880 72 // allocation of fixed-size objects
aoqi@6880 73 // (can also be used to allocate fixed-size arrays, by setting
aoqi@6880 74 // hdr_size correctly and storing the array length afterwards)
aoqi@6880 75 // obj : must be rax, will contain pointer to allocated object
aoqi@6880 76 // t1, t2 : scratch registers - contents destroyed
aoqi@6880 77 // header_size: size of object header in words
aoqi@6880 78 // object_size: total size of object in words
aoqi@6880 79 // slow_case : exit to slow case implementation if fast allocation fails
aoqi@6880 80 void allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case);
aoqi@1 81
aoqi@6880 82 enum {
aoqi@6880 83 max_array_allocation_length = 0x00FFFFFF
aoqi@6880 84 };
aoqi@1 85
aoqi@6880 86 // allocation of arrays
aoqi@6880 87 // obj : must be rax, will contain pointer to allocated object
aoqi@6880 88 // len : array length in number of elements
aoqi@6880 89 // t : scratch register - contents destroyed
aoqi@6880 90 // header_size: size of object header in words
aoqi@6880 91 // f : element scale factor
aoqi@6880 92 // slow_case : exit to slow case implementation if fast allocation fails
aoqi@6880 93 void allocate_array(Register obj, Register len, Register t1, Register t2, Register t3, int header_size, int scale, Register klass, Label& slow_case);
aoqi@1 94
aoqi@6880 95 int sp_offset() const { return _sp_offset; }
aoqi@6880 96 void set_sp_offset(int n) { _sp_offset = n; }
aoqi@1 97
aoqi@6880 98 // Note: NEVER push values directly, but only through following push_xxx functions;
aoqi@6880 99 // This helps us to track the rsp changes compared to the entry rsp (->_sp_offset)
aoqi@1 100
aoqi@6880 101 void push_jint (jint i) { _sp_offset++; move(AT, (int)i); push(AT); }
aoqi@1 102 #ifdef _LP64
aoqi@6880 103 void push_oop (jobject o) { ShouldNotReachHere(); _sp_offset++; li(AT, (long)o); push(AT);}
aoqi@1 104 #else
aoqi@6880 105 void push_oop (jobject o) { ShouldNotReachHere(); _sp_offset++; move(AT, (int)o); push(AT);}
aoqi@1 106 #endif
aoqi@6880 107 // Seems to always be in wordSize
aoqi@6880 108 void push_addr (Address a) { _sp_offset++; addi(AT, a.base(), a.disp()); push(AT);}
aoqi@6880 109 void push_reg (Register r) { _sp_offset++; push(r); }
aoqi@6880 110 void pop_reg (Register r) { _sp_offset--; pop(r); assert(_sp_offset >= 0, "stack offset underflow"); }
aoqi@6880 111 void super_pop(Register r) {MacroAssembler::pop(r);}
aoqi@1 112
aoqi@6880 113 void dec_stack (int nof_words) {
aoqi@6880 114 _sp_offset -= nof_words;
aoqi@6880 115 assert(_sp_offset >= 0, "stack offset underflow");
aoqi@6880 116 addi(SP, SP, wordSize * nof_words);
aoqi@6880 117 }
aoqi@1 118
aoqi@6880 119 void dec_stack_after_call (int nof_words) {
aoqi@6880 120 _sp_offset -= nof_words;
aoqi@6880 121 assert(_sp_offset >= 0, "stack offset underflow");
aoqi@6880 122 }
aoqi@1 123
aoqi@6880 124 void invalidate_registers(bool inv_rax, bool inv_rbx, bool inv_rcx, bool inv_rdx, bool inv_rsi, bool inv_rdi) PRODUCT_RETURN;
aoqi@1 125
aoqi@1 126 #endif // CPU_MIPS_VM_C1_MACROASSEMBLER_MIPS_HPP

mercurial