src/hotspot/cpu/x86/c1_MacroAssembler_x86.hpp
author eosterlund
Thu, 26 Apr 2018 20:42:43 +0200
changeset 49906 4bb58f644e4e
parent 47216 71c04702a3d5
child 50023 bdb627563075
permissions -rw-r--r--
8201543: Modularize C1 GC barriers Reviewed-by: pliden, rbackman, rkennke
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 47216
diff changeset
     2
 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1217
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1217
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1217
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// C1_MacroAssembler contains high-level macros for C1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  int _rsp_offset;    // track rsp changes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  // initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  void pd_init() { _rsp_offset = 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  void try_allocate(
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    Register obj,                      // result: pointer to object after successful allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    int      con_size_in_bytes,        // object size in bytes if   known at compile time
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    Register t1,                       // temp register
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    Register t2,                       // temp register
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    Label&   slow_case                 // continuation point if fast allocation fails
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  void initialize_header(Register obj, Register klass, Register len, Register t1, Register t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  void initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // locking
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // hdr     : must be rax, contents destroyed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // obj     : must point to the object to lock, contents preserved
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // disp_hdr: must point to the displaced header location, contents preserved
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // scratch : scratch register, contents destroyed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // returns code offset at which to add null check debug information
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  int lock_object  (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // unlocking
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // hdr     : contents destroyed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // obj     : must point to the object to lock, contents preserved
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // disp_hdr: must be eax & must point to the displaced header location, contents destroyed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  void unlock_object(Register swap, Register obj, Register lock, Label& slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  void initialize_object(
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    Register obj,                      // result: pointer to object after successful allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    Register klass,                    // object klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    int      con_size_in_bytes,        // object size in bytes if   known at compile time
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    Register t1,                       // temp register
35548
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 34220
diff changeset
    68
    Register t2,                       // temp register
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 34220
diff changeset
    69
    bool     is_tlab_allocated         // the object was allocated in a TLAB; relevant for the implementation of ZeroTLAB
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // allocation of fixed-size objects
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // (can also be used to allocate fixed-size arrays, by setting
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // hdr_size correctly and storing the array length afterwards)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // obj        : must be rax, will contain pointer to allocated object
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // t1, t2     : scratch registers - contents destroyed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // header_size: size of object header in words
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // object_size: total size of object in words
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // slow_case  : exit to slow case implementation if fast allocation fails
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  void allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    max_array_allocation_length = 0x00FFFFFF
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // allocation of arrays
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // obj        : must be rax, will contain pointer to allocated object
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // len        : array length in number of elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // t          : scratch register - contents destroyed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // header_size: size of object header in words
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  // f          : element scale factor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // slow_case  : exit to slow case implementation if fast allocation fails
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void allocate_array(Register obj, Register len, Register t, Register t2, int header_size, Address::ScaleFactor f, Register klass, Label& slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  int  rsp_offset() const { return _rsp_offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void set_rsp_offset(int n) { _rsp_offset = n; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // Note: NEVER push values directly, but only through following push_xxx functions;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  //       This helps us to track the rsp changes compared to the entry rsp (->_rsp_offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   101
  void push_jint (jint i)     { _rsp_offset++; push(i); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  void push_oop  (jobject o)  { _rsp_offset++; pushoop(o); }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   103
  // Seems to always be in wordSize
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   104
  void push_addr (Address a)  { _rsp_offset++; pushptr(a); }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   105
  void push_reg  (Register r) { _rsp_offset++; push(r); }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   106
  void pop_reg   (Register r) { _rsp_offset--; pop(r); assert(_rsp_offset >= 0, "stack offset underflow"); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  void dec_stack (int nof_words) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    _rsp_offset -= nof_words;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    assert(_rsp_offset >= 0, "stack offset underflow");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   111
    addptr(rsp, wordSize * nof_words);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  void dec_stack_after_call (int nof_words) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    _rsp_offset -= nof_words;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    assert(_rsp_offset >= 0, "stack offset underflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  void invalidate_registers(bool inv_rax, bool inv_rbx, bool inv_rcx, bool inv_rdx, bool inv_rsi, bool inv_rdi) PRODUCT_RETURN;
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   120
34220
1ba69cb5585c 8138952: C1: Distinguish between PPC32 and PPC64
mdoerr
parents: 7397
diff changeset
   121
  // This platform only uses signal-based null checks. The Label is not needed.
1ba69cb5585c 8138952: C1: Distinguish between PPC32 and PPC64
mdoerr
parents: 7397
diff changeset
   122
  void null_check(Register r, Label *Lnull = NULL) { MacroAssembler::null_check(r); }
1ba69cb5585c 8138952: C1: Distinguish between PPC32 and PPC64
mdoerr
parents: 7397
diff changeset
   123
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 47216
diff changeset
   124
  void load_parameter(int offset_in_words, Register reg);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 47216
diff changeset
   125
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 47216
diff changeset
   126
  void save_live_registers_no_oop_map(int num_rt_args, bool save_fpu_registers);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 47216
diff changeset
   127
  void restore_live_registers(bool restore_fpu_registers);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 47216
diff changeset
   128
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   129
#endif // CPU_X86_VM_C1_MACROASSEMBLER_X86_HPP