src/cpu/x86/vm/c1_MacroAssembler_x86.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/cpu/x86/vm/c1_MacroAssembler_x86.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,120 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP
    1.29 +#define CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP
    1.30 +
    1.31 +// C1_MacroAssembler contains high-level macros for C1
    1.32 +
    1.33 + private:
    1.34 +  int _rsp_offset;    // track rsp changes
    1.35 +  // initialization
    1.36 +  void pd_init() { _rsp_offset = 0; }
    1.37 +
    1.38 + public:
    1.39 +  void try_allocate(
    1.40 +    Register obj,                      // result: pointer to object after successful allocation
    1.41 +    Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
    1.42 +    int      con_size_in_bytes,        // object size in bytes if   known at compile time
    1.43 +    Register t1,                       // temp register
    1.44 +    Register t2,                       // temp register
    1.45 +    Label&   slow_case                 // continuation point if fast allocation fails
    1.46 +  );
    1.47 +
    1.48 +  void initialize_header(Register obj, Register klass, Register len, Register t1, Register t2);
    1.49 +  void initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1);
    1.50 +
    1.51 +  // locking
    1.52 +  // hdr     : must be rax, contents destroyed
    1.53 +  // obj     : must point to the object to lock, contents preserved
    1.54 +  // disp_hdr: must point to the displaced header location, contents preserved
    1.55 +  // scratch : scratch register, contents destroyed
    1.56 +  // returns code offset at which to add null check debug information
    1.57 +  int lock_object  (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case);
    1.58 +
    1.59 +  // unlocking
    1.60 +  // hdr     : contents destroyed
    1.61 +  // obj     : must point to the object to lock, contents preserved
    1.62 +  // disp_hdr: must be eax & must point to the displaced header location, contents destroyed
    1.63 +  void unlock_object(Register swap, Register obj, Register lock, Label& slow_case);
    1.64 +
    1.65 +  void initialize_object(
    1.66 +    Register obj,                      // result: pointer to object after successful allocation
    1.67 +    Register klass,                    // object klass
    1.68 +    Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
    1.69 +    int      con_size_in_bytes,        // object size in bytes if   known at compile time
    1.70 +    Register t1,                       // temp register
    1.71 +    Register t2                        // temp register
    1.72 +  );
    1.73 +
    1.74 +  // allocation of fixed-size objects
    1.75 +  // (can also be used to allocate fixed-size arrays, by setting
    1.76 +  // hdr_size correctly and storing the array length afterwards)
    1.77 +  // obj        : must be rax, will contain pointer to allocated object
    1.78 +  // t1, t2     : scratch registers - contents destroyed
    1.79 +  // header_size: size of object header in words
    1.80 +  // object_size: total size of object in words
    1.81 +  // slow_case  : exit to slow case implementation if fast allocation fails
    1.82 +  void allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case);
    1.83 +
    1.84 +  enum {
    1.85 +    max_array_allocation_length = 0x00FFFFFF
    1.86 +  };
    1.87 +
    1.88 +  // allocation of arrays
    1.89 +  // obj        : must be rax, will contain pointer to allocated object
    1.90 +  // len        : array length in number of elements
    1.91 +  // t          : scratch register - contents destroyed
    1.92 +  // header_size: size of object header in words
    1.93 +  // f          : element scale factor
    1.94 +  // slow_case  : exit to slow case implementation if fast allocation fails
    1.95 +  void allocate_array(Register obj, Register len, Register t, Register t2, int header_size, Address::ScaleFactor f, Register klass, Label& slow_case);
    1.96 +
    1.97 +  int  rsp_offset() const { return _rsp_offset; }
    1.98 +  void set_rsp_offset(int n) { _rsp_offset = n; }
    1.99 +
   1.100 +  // Note: NEVER push values directly, but only through following push_xxx functions;
   1.101 +  //       This helps us to track the rsp changes compared to the entry rsp (->_rsp_offset)
   1.102 +
   1.103 +  void push_jint (jint i)     { _rsp_offset++; push(i); }
   1.104 +  void push_oop  (jobject o)  { _rsp_offset++; pushoop(o); }
   1.105 +  // Seems to always be in wordSize
   1.106 +  void push_addr (Address a)  { _rsp_offset++; pushptr(a); }
   1.107 +  void push_reg  (Register r) { _rsp_offset++; push(r); }
   1.108 +  void pop_reg   (Register r) { _rsp_offset--; pop(r); assert(_rsp_offset >= 0, "stack offset underflow"); }
   1.109 +
   1.110 +  void dec_stack (int nof_words) {
   1.111 +    _rsp_offset -= nof_words;
   1.112 +    assert(_rsp_offset >= 0, "stack offset underflow");
   1.113 +    addptr(rsp, wordSize * nof_words);
   1.114 +  }
   1.115 +
   1.116 +  void dec_stack_after_call (int nof_words) {
   1.117 +    _rsp_offset -= nof_words;
   1.118 +    assert(_rsp_offset >= 0, "stack offset underflow");
   1.119 +  }
   1.120 +
   1.121 +  void invalidate_registers(bool inv_rax, bool inv_rbx, bool inv_rcx, bool inv_rdx, bool inv_rsi, bool inv_rdi) PRODUCT_RETURN;
   1.122 +
   1.123 +#endif // CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP

mercurial