Path: blob/master/src/hotspot/cpu/x86/c1_MacroAssembler_x86.hpp
41144 views
/*1* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef CPU_X86_C1_MACROASSEMBLER_X86_HPP25#define CPU_X86_C1_MACROASSEMBLER_X86_HPP2627// C1_MacroAssembler contains high-level macros for C12829private:30int _rsp_offset; // track rsp changes31// initialization32void pd_init() { _rsp_offset = 0; }3334public:35void try_allocate(36Register obj, // result: pointer to object after successful allocation37Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise38int con_size_in_bytes, // object size in bytes if known at compile time39Register t1, // temp register40Register t2, // temp register41Label& slow_case // continuation point if fast allocation fails42);4344void initialize_header(Register obj, Register klass, Register len, Register t1, Register t2);45void initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1);4647// locking48// hdr : must be rax, contents destroyed49// obj : must point to the object to lock, contents preserved50// disp_hdr: must point to the displaced header location, contents preserved51// scratch : scratch register, contents destroyed52// returns code offset at which to add null check debug information53int lock_object (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case);5455// unlocking56// hdr : contents destroyed57// obj : must point to the object to lock, contents preserved58// disp_hdr: must be eax & must point to the displaced header location, contents destroyed59void unlock_object(Register swap, Register obj, Register lock, Label& slow_case);6061void initialize_object(62Register obj, // result: pointer to object after successful allocation63Register klass, // object klass64Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise65int con_size_in_bytes, // object size in bytes if known at compile time66Register t1, // temp register67Register t2, // temp register68bool is_tlab_allocated // the object was allocated in a TLAB; relevant for the implementation of ZeroTLAB69);7071// allocation of fixed-size objects72// (can also be used to allocate fixed-size arrays, by setting73// hdr_size correctly and storing the array length afterwards)74// obj : must be rax, will contain pointer to allocated object75// t1, t2 : scratch registers - contents destroyed76// header_size: size of object header in words77// object_size: total size of object in words78// slow_case : exit to slow case implementation if fast allocation fails79void allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case);8081enum {82max_array_allocation_length = 0x00FFFFFF83};8485// allocation of arrays86// obj : must be rax, will contain pointer to allocated object87// len : array length in number of elements88// t : scratch register - contents destroyed89// header_size: size of object header in words90// f : element scale factor91// slow_case : exit to slow case implementation if fast allocation fails92void allocate_array(Register obj, Register len, Register t, Register t2, int header_size, Address::ScaleFactor f, Register klass, Label& slow_case);9394int rsp_offset() const { return _rsp_offset; }95void set_rsp_offset(int n) { _rsp_offset = n; }9697// Note: NEVER push values directly, but only through following push_xxx functions;98// This helps us to track the rsp changes compared to the entry rsp (->_rsp_offset)99100void push_jint (jint i) { _rsp_offset++; push(i); }101void push_oop (jobject o) { _rsp_offset++; pushoop(o); }102// Seems to always be in wordSize103void push_addr (Address a) { _rsp_offset++; pushptr(a); }104void push_reg (Register r) { _rsp_offset++; push(r); }105void pop_reg (Register r) { _rsp_offset--; pop(r); assert(_rsp_offset >= 0, "stack offset underflow"); }106107void dec_stack (int nof_words) {108_rsp_offset -= nof_words;109assert(_rsp_offset >= 0, "stack offset underflow");110addptr(rsp, wordSize * nof_words);111}112113void dec_stack_after_call (int nof_words) {114_rsp_offset -= nof_words;115assert(_rsp_offset >= 0, "stack offset underflow");116}117118void invalidate_registers(bool inv_rax, bool inv_rbx, bool inv_rcx, bool inv_rdx, bool inv_rsi, bool inv_rdi) PRODUCT_RETURN;119120// This platform only uses signal-based null checks. The Label is not needed.121void null_check(Register r, Label *Lnull = NULL) { MacroAssembler::null_check(r); }122123void load_parameter(int offset_in_words, Register reg);124125void save_live_registers_no_oop_map(bool save_fpu_registers);126void restore_live_registers_except_rax(bool restore_fpu_registers);127void restore_live_registers(bool restore_fpu_registers);128129#endif // CPU_X86_C1_MACROASSEMBLER_X86_HPP130131132