0N/A/*
1879N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP
1879N/A#define CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP
1879N/A
0N/A// C1_MacroAssembler contains high-level macros for C1
0N/A
0N/A private:
0N/A int _rsp_offset; // track rsp changes
0N/A // initialization
0N/A void pd_init() { _rsp_offset = 0; }
0N/A
0N/A public:
0N/A void try_allocate(
0N/A Register obj, // result: pointer to object after successful allocation
0N/A Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
0N/A int con_size_in_bytes, // object size in bytes if known at compile time
0N/A Register t1, // temp register
0N/A Register t2, // temp register
0N/A Label& slow_case // continuation point if fast allocation fails
0N/A );
0N/A
0N/A void initialize_header(Register obj, Register klass, Register len, Register t1, Register t2);
0N/A void initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1);
0N/A
0N/A // locking
0N/A // hdr : must be rax, contents destroyed
0N/A // obj : must point to the object to lock, contents preserved
0N/A // disp_hdr: must point to the displaced header location, contents preserved
0N/A // scratch : scratch register, contents destroyed
0N/A // returns code offset at which to add null check debug information
0N/A int lock_object (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case);
0N/A
0N/A // unlocking
0N/A // hdr : contents destroyed
0N/A // obj : must point to the object to lock, contents preserved
0N/A // disp_hdr: must be eax & must point to the displaced header location, contents destroyed
0N/A void unlock_object(Register swap, Register obj, Register lock, Label& slow_case);
0N/A
0N/A void initialize_object(
0N/A Register obj, // result: pointer to object after successful allocation
0N/A Register klass, // object klass
0N/A Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
0N/A int con_size_in_bytes, // object size in bytes if known at compile time
0N/A Register t1, // temp register
0N/A Register t2 // temp register
0N/A );
0N/A
0N/A // allocation of fixed-size objects
0N/A // (can also be used to allocate fixed-size arrays, by setting
0N/A // hdr_size correctly and storing the array length afterwards)
0N/A // obj : must be rax, will contain pointer to allocated object
0N/A // t1, t2 : scratch registers - contents destroyed
0N/A // header_size: size of object header in words
0N/A // object_size: total size of object in words
0N/A // slow_case : exit to slow case implementation if fast allocation fails
0N/A void allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case);
0N/A
0N/A enum {
0N/A max_array_allocation_length = 0x00FFFFFF
0N/A };
0N/A
0N/A // allocation of arrays
0N/A // obj : must be rax, will contain pointer to allocated object
0N/A // len : array length in number of elements
0N/A // t : scratch register - contents destroyed
0N/A // header_size: size of object header in words
0N/A // f : element scale factor
0N/A // slow_case : exit to slow case implementation if fast allocation fails
0N/A void allocate_array(Register obj, Register len, Register t, Register t2, int header_size, Address::ScaleFactor f, Register klass, Label& slow_case);
0N/A
0N/A int rsp_offset() const { return _rsp_offset; }
0N/A void set_rsp_offset(int n) { _rsp_offset = n; }
0N/A
0N/A // Note: NEVER push values directly, but only through following push_xxx functions;
0N/A // This helps us to track the rsp changes compared to the entry rsp (->_rsp_offset)
0N/A
304N/A void push_jint (jint i) { _rsp_offset++; push(i); }
0N/A void push_oop (jobject o) { _rsp_offset++; pushoop(o); }
304N/A // Seems to always be in wordSize
304N/A void push_addr (Address a) { _rsp_offset++; pushptr(a); }
304N/A void push_reg (Register r) { _rsp_offset++; push(r); }
304N/A void pop_reg (Register r) { _rsp_offset--; pop(r); assert(_rsp_offset >= 0, "stack offset underflow"); }
0N/A
0N/A void dec_stack (int nof_words) {
0N/A _rsp_offset -= nof_words;
0N/A assert(_rsp_offset >= 0, "stack offset underflow");
304N/A addptr(rsp, wordSize * nof_words);
0N/A }
0N/A
0N/A void dec_stack_after_call (int nof_words) {
0N/A _rsp_offset -= nof_words;
0N/A assert(_rsp_offset >= 0, "stack offset underflow");
0N/A }
0N/A
0N/A void invalidate_registers(bool inv_rax, bool inv_rbx, bool inv_rcx, bool inv_rdx, bool inv_rsi, bool inv_rdi) PRODUCT_RETURN;
1879N/A
1879N/A#endif // CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP