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