src/cpu/mips/vm/c1_MacroAssembler_mips.hpp

Tue, 26 Jul 2016 17:06:17 +0800

author
fujie
date
Tue, 26 Jul 2016 17:06:17 +0800
changeset 41
d885f8d65c58
parent 1
2d8a650513c2
child 6880
52ea28d233d2
permissions
-rw-r--r--

Add multiply word to GPR instruction (mul) in MIPS assembler.

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

mercurial