src/cpu/x86/vm/c1_MacroAssembler_x86.hpp

Wed, 15 Apr 2020 11:49:55 +0800

author
aoqi
date
Wed, 15 Apr 2020 11:49:55 +0800
changeset 9852
70aa912cebe5
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

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

mercurial