hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp
author trims
Thu, 12 Mar 2009 18:16:36 -0700
changeset 2154 72a9b7284ccf
parent 2105 347008ce7984
child 2259 d3c946e7f127
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
2105
347008ce7984 6814575: Update copyright year
xdono
parents: 1909
diff changeset
     2
 * Copyright 1999-2009 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_c1_Runtime1_x86.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// Implementation of StubAssembler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address entry, int args_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  // setup registers
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    33
  const Register thread = NOT_LP64(rdi) LP64_ONLY(r15_thread); // is callee-saved register (Visual C++ calling conventions)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  assert(!(oop_result1->is_valid() || oop_result2->is_valid()) || oop_result1 != oop_result2, "registers must be different");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  assert(oop_result1 != thread && oop_result2 != thread, "registers must be different");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  assert(args_size >= 0, "illegal args_size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    38
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    39
  mov(c_rarg0, thread);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    40
  set_num_rt_args(0); // Nothing on stack
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    41
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  set_num_rt_args(1 + args_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // push java thread (becomes first argument of C function)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  get_thread(thread);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    46
  push(thread);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    47
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  set_last_Java_frame(thread, noreg, rbp, NULL);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    50
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // do the call
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  call(RuntimeAddress(entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  int call_offset = offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // verify callee-saved register
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  guarantee(thread != rax, "change this code");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    57
  push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    get_thread(rax);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    60
    cmpptr(thread, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    int3();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    stop("StubAssembler::call_RT: rdi not callee saved?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    66
  pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  reset_last_Java_frame(thread, true, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // discard thread and arguments
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    71
  NOT_LP64(addptr(rsp, num_rt_args()*BytesPerWord));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // check for pending exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  { Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    75
    cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    // exception pending => remove activation and forward to exception handler
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    78
    movptr(rax, Address(thread, Thread::pending_exception_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    // make sure that the vm_results are cleared
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    if (oop_result1->is_valid()) {
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
    81
      movptr(Address(thread, JavaThread::vm_result_offset()), NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    if (oop_result2->is_valid()) {
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
    84
      movptr(Address(thread, JavaThread::vm_result_2_offset()), NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    if (frame_size() == no_frame_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    } else if (_stub_id == Runtime1::forward_exception_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      jump(RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // get oop results if there are any and reset the values in the thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  if (oop_result1->is_valid()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    98
    movptr(oop_result1, Address(thread, JavaThread::vm_result_offset()));
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
    99
    movptr(Address(thread, JavaThread::vm_result_offset()), NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    verify_oop(oop_result1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  if (oop_result2->is_valid()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   103
    movptr(oop_result2, Address(thread, JavaThread::vm_result_2_offset()));
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
   104
    movptr(Address(thread, JavaThread::vm_result_2_offset()), NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    verify_oop(oop_result2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  return call_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address entry, Register arg1) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   112
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   113
  mov(c_rarg1, arg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   114
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   115
  push(arg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   116
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  return call_RT(oop_result1, oop_result2, entry, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address entry, Register arg1, Register arg2) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   122
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   123
  if (c_rarg1 == arg2) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   124
    if (c_rarg2 == arg1) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   125
      xchgq(arg1, arg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   126
    } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   127
      mov(c_rarg2, arg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   128
      mov(c_rarg1, arg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   129
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   130
  } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   131
    mov(c_rarg1, arg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   132
    mov(c_rarg2, arg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   133
  }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   134
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   135
  push(arg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   136
  push(arg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   137
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  return call_RT(oop_result1, oop_result2, entry, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address entry, Register arg1, Register arg2, Register arg3) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   143
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   144
  // if there is any conflict use the stack
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   145
  if (arg1 == c_rarg2 || arg1 == c_rarg3 ||
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   146
      arg2 == c_rarg1 || arg1 == c_rarg3 ||
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   147
      arg3 == c_rarg1 || arg1 == c_rarg2) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   148
    push(arg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   149
    push(arg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   150
    push(arg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   151
    pop(c_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   152
    pop(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   153
    pop(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   154
  } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   155
    mov(c_rarg1, arg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   156
    mov(c_rarg2, arg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   157
    mov(c_rarg3, arg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   158
  }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   159
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   160
  push(arg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   161
  push(arg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   162
  push(arg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   163
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  return call_RT(oop_result1, oop_result2, entry, 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
// Implementation of StubFrame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
class StubFrame: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  StubAssembler* _sasm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  void load_argument(int offset_in_words, Register reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  ~StubFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
#define __ _sasm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
StubFrame::StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  _sasm = sasm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  __ set_info(name, must_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  __ enter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
// load parameters that were stored with LIR_Assembler::store_parameter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
// Note: offsets for store_parameter and load_argument must match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
void StubFrame::load_argument(int offset_in_words, Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // rbp, + 0: link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  //     + 1: return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  //     + 2: argument with offset 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  //     + 3: argument with offset 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  //     + 4: ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   199
  __ movptr(reg, Address(rbp, (offset_in_words + 2) * BytesPerWord));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
StubFrame::~StubFrame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
#undef __
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
// Implementation of Runtime1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
#define __ sasm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   215
const int float_regs_as_doubles_size_in_slots = pd_nof_fpu_regs_frame_map * 2;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   216
const int xmm_regs_as_doubles_size_in_slots = FrameMap::nof_xmm_regs * 2;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
// Stack layout for saving/restoring  all the registers needed during a runtime
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
// call (this includes deoptimization)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
// Note: note that users of this frame may well have arguments to some runtime
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
// while these values are on the stack. These positions neglect those arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
// but the code in save_live_registers will take the argument count into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
// account.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
//
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   225
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   226
  #define SLOT2(x) x,
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   227
  #define SLOT_PER_WORD 2
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   228
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   229
  #define SLOT2(x)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   230
  #define SLOT_PER_WORD 1
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   231
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   232
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
enum reg_save_layout {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   234
  // 64bit needs to keep stack 16 byte aligned. So we add some alignment dummies to make that
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   235
  // happen and will assert if the stack size we create is misaligned
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   236
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   237
  align_dummy_0, align_dummy_1,
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   238
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   239
  dummy1, SLOT2(dummy1H)                                                                    // 0, 4
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   240
  dummy2, SLOT2(dummy2H)                                                                    // 8, 12
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // Two temps to be used as needed by users of save/restore callee registers
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   242
  temp_2_off, SLOT2(temp_2H_off)                                                            // 16, 20
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   243
  temp_1_off, SLOT2(temp_1H_off)                                                            // 24, 28
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   244
  xmm_regs_as_doubles_off,                                                                  // 32
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   245
  float_regs_as_doubles_off = xmm_regs_as_doubles_off + xmm_regs_as_doubles_size_in_slots,  // 160
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   246
  fpu_state_off = float_regs_as_doubles_off + float_regs_as_doubles_size_in_slots,          // 224
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   247
  // fpu_state_end_off is exclusive
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   248
  fpu_state_end_off = fpu_state_off + (FPUStateSizeInWords / SLOT_PER_WORD),                // 352
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   249
  marker = fpu_state_end_off, SLOT2(markerH)                                                // 352, 356
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   250
  extra_space_offset,                                                                       // 360
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   251
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   252
  r15_off = extra_space_offset, r15H_off,                                                   // 360, 364
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   253
  r14_off, r14H_off,                                                                        // 368, 372
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   254
  r13_off, r13H_off,                                                                        // 376, 380
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   255
  r12_off, r12H_off,                                                                        // 384, 388
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   256
  r11_off, r11H_off,                                                                        // 392, 396
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   257
  r10_off, r10H_off,                                                                        // 400, 404
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   258
  r9_off, r9H_off,                                                                          // 408, 412
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   259
  r8_off, r8H_off,                                                                          // 416, 420
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   260
  rdi_off, rdiH_off,                                                                        // 424, 428
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   261
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  rdi_off = extra_space_offset,
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   263
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   264
  rsi_off, SLOT2(rsiH_off)                                                                  // 432, 436
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   265
  rbp_off, SLOT2(rbpH_off)                                                                  // 440, 444
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   266
  rsp_off, SLOT2(rspH_off)                                                                  // 448, 452
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   267
  rbx_off, SLOT2(rbxH_off)                                                                  // 456, 460
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   268
  rdx_off, SLOT2(rdxH_off)                                                                  // 464, 468
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   269
  rcx_off, SLOT2(rcxH_off)                                                                  // 472, 476
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   270
  rax_off, SLOT2(raxH_off)                                                                  // 480, 484
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   271
  saved_rbp_off, SLOT2(saved_rbpH_off)                                                      // 488, 492
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   272
  return_off, SLOT2(returnH_off)                                                            // 496, 500
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   273
  reg_save_frame_size,  // As noted: neglects any parameters to runtime                     // 504
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   274
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   275
#ifdef _WIN64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   276
  c_rarg0_off = rcx_off,
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   277
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   278
  c_rarg0_off = rdi_off,
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   279
#endif // WIN64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  // equates
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  // illegal instruction handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  continue_dest_off = temp_1_off,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // deoptimization equates
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  fp0_off = float_regs_as_doubles_off, // slot for java float/double return value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  xmm0_off = xmm_regs_as_doubles_off,  // slot for java float/double return value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  deopt_type = temp_2_off,             // slot for type of deopt in progress
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  ret_type = temp_1_off                // slot for return type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
// Save off registers which might be killed by calls into the runtime.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
// Tries to smart of about FP registers.  In particular we separate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
// saving and describing the FPU registers for deoptimization since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
// have to save the FPU registers twice if we describe them and on P4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
// saving FPU registers which don't contain anything appears
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
// expensive.  The deopt blob is the only thing which needs to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
// describe FPU registers.  In all other cases it should be sufficient
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
// to simply save their current value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
                                bool save_fpu_registers = true) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   306
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   307
  // In 64bit all the args are in regs so there are no additional stack slots
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   308
  LP64_ONLY(num_rt_args = 0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   309
  LP64_ONLY(assert((reg_save_frame_size * VMRegImpl::stack_slot_size) % 16 == 0, "must be 16 byte aligned");)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   310
  int frame_size_in_slots = reg_save_frame_size + num_rt_args; // args + thread
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   311
  sasm->set_frame_size(frame_size_in_slots / VMRegImpl::slots_per_word );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // record saved value locations in an OopMap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  // locations are offsets from sp after runtime call; num_rt_args is number of arguments in call, including thread
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   315
  OopMap* map = new OopMap(frame_size_in_slots, 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  map->set_callee_saved(VMRegImpl::stack2reg(rax_off + num_rt_args), rax->as_VMReg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  map->set_callee_saved(VMRegImpl::stack2reg(rcx_off + num_rt_args), rcx->as_VMReg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  map->set_callee_saved(VMRegImpl::stack2reg(rdx_off + num_rt_args), rdx->as_VMReg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  map->set_callee_saved(VMRegImpl::stack2reg(rbx_off + num_rt_args), rbx->as_VMReg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  map->set_callee_saved(VMRegImpl::stack2reg(rsi_off + num_rt_args), rsi->as_VMReg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  map->set_callee_saved(VMRegImpl::stack2reg(rdi_off + num_rt_args), rdi->as_VMReg());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   322
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   323
  map->set_callee_saved(VMRegImpl::stack2reg(r8_off + num_rt_args),  r8->as_VMReg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   324
  map->set_callee_saved(VMRegImpl::stack2reg(r9_off + num_rt_args),  r9->as_VMReg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   325
  map->set_callee_saved(VMRegImpl::stack2reg(r10_off + num_rt_args), r10->as_VMReg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   326
  map->set_callee_saved(VMRegImpl::stack2reg(r11_off + num_rt_args), r11->as_VMReg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   327
  map->set_callee_saved(VMRegImpl::stack2reg(r12_off + num_rt_args), r12->as_VMReg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   328
  map->set_callee_saved(VMRegImpl::stack2reg(r13_off + num_rt_args), r13->as_VMReg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   329
  map->set_callee_saved(VMRegImpl::stack2reg(r14_off + num_rt_args), r14->as_VMReg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   330
  map->set_callee_saved(VMRegImpl::stack2reg(r15_off + num_rt_args), r15->as_VMReg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   331
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   332
  // This is stupid but needed.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   333
  map->set_callee_saved(VMRegImpl::stack2reg(raxH_off + num_rt_args), rax->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   334
  map->set_callee_saved(VMRegImpl::stack2reg(rcxH_off + num_rt_args), rcx->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   335
  map->set_callee_saved(VMRegImpl::stack2reg(rdxH_off + num_rt_args), rdx->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   336
  map->set_callee_saved(VMRegImpl::stack2reg(rbxH_off + num_rt_args), rbx->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   337
  map->set_callee_saved(VMRegImpl::stack2reg(rsiH_off + num_rt_args), rsi->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   338
  map->set_callee_saved(VMRegImpl::stack2reg(rdiH_off + num_rt_args), rdi->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   339
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   340
  map->set_callee_saved(VMRegImpl::stack2reg(r8H_off + num_rt_args),  r8->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   341
  map->set_callee_saved(VMRegImpl::stack2reg(r9H_off + num_rt_args),  r9->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   342
  map->set_callee_saved(VMRegImpl::stack2reg(r10H_off + num_rt_args), r10->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   343
  map->set_callee_saved(VMRegImpl::stack2reg(r11H_off + num_rt_args), r11->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   344
  map->set_callee_saved(VMRegImpl::stack2reg(r12H_off + num_rt_args), r12->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   345
  map->set_callee_saved(VMRegImpl::stack2reg(r13H_off + num_rt_args), r13->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   346
  map->set_callee_saved(VMRegImpl::stack2reg(r14H_off + num_rt_args), r14->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   347
  map->set_callee_saved(VMRegImpl::stack2reg(r15H_off + num_rt_args), r15->as_VMReg()->next());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   348
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  if (save_fpu_registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    if (UseSSE < 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      int fpu_off = float_regs_as_doubles_off;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
      for (int n = 0; n < FrameMap::nof_fpu_regs; n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
        VMReg fpu_name_0 = FrameMap::fpu_regname(n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        map->set_callee_saved(VMRegImpl::stack2reg(fpu_off +     num_rt_args), fpu_name_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
        // %%% This is really a waste but we'll keep things as they were for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
        if (true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
          map->set_callee_saved(VMRegImpl::stack2reg(fpu_off + 1 + num_rt_args), fpu_name_0->next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        fpu_off += 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
      assert(fpu_off == fpu_state_off, "incorrect number of fpu stack slots");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    if (UseSSE >= 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
      int xmm_off = xmm_regs_as_doubles_off;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
      for (int n = 0; n < FrameMap::nof_xmm_regs; n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
        VMReg xmm_name_0 = as_XMMRegister(n)->as_VMReg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
        map->set_callee_saved(VMRegImpl::stack2reg(xmm_off +     num_rt_args), xmm_name_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        // %%% This is really a waste but we'll keep things as they were for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
        if (true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
          map->set_callee_saved(VMRegImpl::stack2reg(xmm_off + 1 + num_rt_args), xmm_name_0->next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
        xmm_off += 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      assert(xmm_off == float_regs_as_doubles_off, "incorrect number of xmm registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    } else if (UseSSE == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
      int xmm_off = xmm_regs_as_doubles_off;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
      for (int n = 0; n < FrameMap::nof_xmm_regs; n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
        VMReg xmm_name_0 = as_XMMRegister(n)->as_VMReg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
        map->set_callee_saved(VMRegImpl::stack2reg(xmm_off +     num_rt_args), xmm_name_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
        xmm_off += 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
      assert(xmm_off == float_regs_as_doubles_off, "incorrect number of xmm registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  return map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
static OopMap* save_live_registers(StubAssembler* sasm, int num_rt_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
                                   bool save_fpu_registers = true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  __ block_comment("save_live_registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   396
  // 64bit passes the args in regs to the c++ runtime
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   397
  int frame_size_in_slots = reg_save_frame_size NOT_LP64(+ num_rt_args); // args + thread
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // frame_size = round_to(frame_size, 4);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   399
  sasm->set_frame_size(frame_size_in_slots / VMRegImpl::slots_per_word );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   401
  __ pusha();         // integer registers
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  // assert(float_regs_as_doubles_off % 2 == 0, "misaligned offset");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  // assert(xmm_regs_as_doubles_off % 2 == 0, "misaligned offset");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   406
  __ subptr(rsp, extra_space_offset * VMRegImpl::stack_slot_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
#ifdef ASSERT
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   409
  __ movptr(Address(rsp, marker * VMRegImpl::stack_slot_size), (int32_t)0xfeedbeef);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  if (save_fpu_registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    if (UseSSE < 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
      // save FPU stack
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   415
      __ fnsave(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
      __ fwait();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      Label ok;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   420
      __ cmpw(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size), StubRoutines::fpu_cntrl_wrd_std());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
      __ jccb(Assembler::equal, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
      __ stop("corrupted control word detected");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      __ bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
      // Reset the control word to guard against exceptions being unmasked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
      // since fstp_d can cause FPU stack underflow exceptions.  Write it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
      // into the on stack copy and then reload that to make sure that the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      // current and future values are correct.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   430
      __ movw(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size), StubRoutines::fpu_cntrl_wrd_std());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   431
      __ frstor(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
      // Save the FPU registers in de-opt-able form
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   434
      __ fstp_d(Address(rsp, float_regs_as_doubles_off * VMRegImpl::stack_slot_size +  0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   435
      __ fstp_d(Address(rsp, float_regs_as_doubles_off * VMRegImpl::stack_slot_size +  8));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   436
      __ fstp_d(Address(rsp, float_regs_as_doubles_off * VMRegImpl::stack_slot_size + 16));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   437
      __ fstp_d(Address(rsp, float_regs_as_doubles_off * VMRegImpl::stack_slot_size + 24));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   438
      __ fstp_d(Address(rsp, float_regs_as_doubles_off * VMRegImpl::stack_slot_size + 32));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   439
      __ fstp_d(Address(rsp, float_regs_as_doubles_off * VMRegImpl::stack_slot_size + 40));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   440
      __ fstp_d(Address(rsp, float_regs_as_doubles_off * VMRegImpl::stack_slot_size + 48));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   441
      __ fstp_d(Address(rsp, float_regs_as_doubles_off * VMRegImpl::stack_slot_size + 56));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    if (UseSSE >= 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
      // save XMM registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
      // XMM registers can contain float or double values, but this is not known here,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      // so always save them as doubles.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      // note that float values are _not_ converted automatically, so for float values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      // the second word contains only garbage data.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   450
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size +  0), xmm0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   451
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size +  8), xmm1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   452
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 16), xmm2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   453
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 24), xmm3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   454
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 32), xmm4);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   455
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 40), xmm5);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   456
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 48), xmm6);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   457
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 56), xmm7);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   458
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   459
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 64), xmm8);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   460
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 72), xmm9);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   461
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 80), xmm10);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   462
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 88), xmm11);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   463
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 96), xmm12);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   464
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 104), xmm13);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   465
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 112), xmm14);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   466
      __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 120), xmm15);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   467
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    } else if (UseSSE == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
      // save XMM registers as float because double not supported without SSE2
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   470
      __ movflt(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size +  0), xmm0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   471
      __ movflt(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size +  8), xmm1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   472
      __ movflt(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 16), xmm2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   473
      __ movflt(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 24), xmm3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   474
      __ movflt(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 32), xmm4);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   475
      __ movflt(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 40), xmm5);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   476
      __ movflt(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 48), xmm6);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   477
      __ movflt(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 56), xmm7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  // FPU stack must be empty now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  __ verify_FPU(0, "save_live_registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  return generate_oop_map(sasm, num_rt_args, save_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
static void restore_fpu(StubAssembler* sasm, bool restore_fpu_registers = true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  if (restore_fpu_registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
    if (UseSSE >= 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
      // restore XMM registers
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   492
      __ movdbl(xmm0, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size +  0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   493
      __ movdbl(xmm1, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size +  8));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   494
      __ movdbl(xmm2, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 16));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   495
      __ movdbl(xmm3, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 24));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   496
      __ movdbl(xmm4, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 32));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   497
      __ movdbl(xmm5, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 40));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   498
      __ movdbl(xmm6, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 48));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   499
      __ movdbl(xmm7, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 56));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   500
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   501
      __ movdbl(xmm8, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 64));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   502
      __ movdbl(xmm9, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 72));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   503
      __ movdbl(xmm10, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 80));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   504
      __ movdbl(xmm11, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 88));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   505
      __ movdbl(xmm12, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 96));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   506
      __ movdbl(xmm13, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 104));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   507
      __ movdbl(xmm14, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 112));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   508
      __ movdbl(xmm15, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 120));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   509
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    } else if (UseSSE == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
      // restore XMM registers
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   512
      __ movflt(xmm0, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size +  0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   513
      __ movflt(xmm1, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size +  8));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   514
      __ movflt(xmm2, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 16));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   515
      __ movflt(xmm3, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 24));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   516
      __ movflt(xmm4, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 32));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   517
      __ movflt(xmm5, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 40));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   518
      __ movflt(xmm6, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 48));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   519
      __ movflt(xmm7, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 56));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    if (UseSSE < 2) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   523
      __ frstor(Address(rsp, fpu_state_off * VMRegImpl::stack_slot_size));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
      // check that FPU stack is really empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      __ verify_FPU(0, "restore_live_registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    // check that FPU stack is really empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    __ verify_FPU(0, "restore_live_registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
    Label ok;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   537
    __ cmpptr(Address(rsp, marker * VMRegImpl::stack_slot_size), (int32_t)0xfeedbeef);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    __ jcc(Assembler::equal, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    __ stop("bad offsets in frame");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    __ bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   542
#endif // ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   544
  __ addptr(rsp, extra_space_offset * VMRegImpl::stack_slot_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  __ block_comment("restore_live_registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  restore_fpu(sasm, restore_fpu_registers);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   552
  __ popa();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
static void restore_live_registers_except_rax(StubAssembler* sasm, bool restore_fpu_registers = true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  __ block_comment("restore_live_registers_except_rax");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  restore_fpu(sasm, restore_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   561
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   562
  __ movptr(r15, Address(rsp, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   563
  __ movptr(r14, Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   564
  __ movptr(r13, Address(rsp, 2 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   565
  __ movptr(r12, Address(rsp, 3 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   566
  __ movptr(r11, Address(rsp, 4 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   567
  __ movptr(r10, Address(rsp, 5 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   568
  __ movptr(r9,  Address(rsp, 6 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   569
  __ movptr(r8,  Address(rsp, 7 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   570
  __ movptr(rdi, Address(rsp, 8 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   571
  __ movptr(rsi, Address(rsp, 9 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   572
  __ movptr(rbp, Address(rsp, 10 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   573
  // skip rsp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   574
  __ movptr(rbx, Address(rsp, 12 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   575
  __ movptr(rdx, Address(rsp, 13 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   576
  __ movptr(rcx, Address(rsp, 14 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   577
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   578
  __ addptr(rsp, 16 * wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   579
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   580
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   581
  __ pop(rdi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   582
  __ pop(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   583
  __ pop(rbp);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   584
  __ pop(rbx); // skip this value
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   585
  __ pop(rbx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   586
  __ pop(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   587
  __ pop(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   588
  __ addptr(rsp, BytesPerWord);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   589
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
void Runtime1::initialize_pd() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  // nothing to do
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
// target: the entry point of the method that creates and posts the exception oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
// has_argument: true if the exception needs an argument (passed on stack because registers must be preserved)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  // preserve all registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  int num_rt_args = has_argument ? 2 : 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  OopMap* oop_map = save_live_registers(sasm, num_rt_args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  // now all registers are saved and can be used freely
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  // verify that no old value is used accidentally
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  __ invalidate_registers(true, true, true, true, true, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  // registers used by this stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  const Register temp_reg = rbx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  // load argument for exception that is passed as an argument into the stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  if (has_argument) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   615
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   616
    __ movptr(c_rarg1, Address(rbp, 2*BytesPerWord));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   617
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   618
    __ movptr(temp_reg, Address(rbp, 2*BytesPerWord));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   619
    __ push(temp_reg);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   620
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  int call_offset = __ call_RT(noreg, noreg, target, num_rt_args - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  OopMapSet* oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  oop_maps->add_gc_map(call_offset, oop_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
  __ stop("should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  return oop_maps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
void Runtime1::generate_handle_exception(StubAssembler *sasm, OopMapSet* oop_maps, OopMap* oop_map, bool save_fpu_registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  // incoming parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
  const Register exception_oop = rax;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  const Register exception_pc = rdx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  // other registers used in this stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  const Register real_return_addr = rbx;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   639
  const Register thread = NOT_LP64(rdi) LP64_ONLY(r15_thread);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  __ block_comment("generate_handle_exception");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
#ifdef TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  // C2 can leave the fpu stack dirty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
  if (UseSSE < 2 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
    __ empty_FPU_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
#endif // TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  // verify that only rax, and rdx is valid at this time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  __ invalidate_registers(false, true, true, false, true, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  // verify that rax, contains a valid exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  __ verify_not_null_oop(exception_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  // load address of JavaThread object for thread-local data
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   656
  NOT_LP64(__ get_thread(thread);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  // check that fields in JavaThread for exception oop and issuing pc are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  // empty before writing to them
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  Label oop_empty;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   662
  __ cmpptr(Address(thread, JavaThread::exception_oop_offset()), (int32_t) NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  __ jcc(Assembler::equal, oop_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
  __ stop("exception oop already set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  __ bind(oop_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  Label pc_empty;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   668
  __ cmpptr(Address(thread, JavaThread::exception_pc_offset()), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  __ jcc(Assembler::equal, pc_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  __ stop("exception pc already set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  __ bind(pc_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  // save exception oop and issuing pc into JavaThread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  // (exception handler will load it from here)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   676
  __ movptr(Address(thread, JavaThread::exception_oop_offset()), exception_oop);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   677
  __ movptr(Address(thread, JavaThread::exception_pc_offset()), exception_pc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
  // save real return address (pc that called this stub)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   680
  __ movptr(real_return_addr, Address(rbp, 1*BytesPerWord));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   681
  __ movptr(Address(rsp, temp_1_off * VMRegImpl::stack_slot_size), real_return_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  // patch throwing pc into return address (has bci & oop map)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   684
  __ movptr(Address(rbp, 1*BytesPerWord), exception_pc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  // compute the exception handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  // the exception oop and the throwing pc are read from the fields in JavaThread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  oop_maps->add_gc_map(call_offset, oop_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  // rax,: handler address or NULL if no handler exists
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  //      will be the deopt blob if nmethod was deoptimized while we looked up
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
  //      handler regardless of whether handler existed in the nmethod.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  // only rax, is valid at this time, all other registers have been destroyed by the runtime call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  __ invalidate_registers(false, true, true, true, true, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  // Do we have an exception handler in the nmethod?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  Label no_handler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
  Label done;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   701
  __ testptr(rax, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  __ jcc(Assembler::zero, no_handler);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  // exception handler found
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  // patch the return address -> the stub will directly return to the exception handler
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   706
  __ movptr(Address(rbp, 1*BytesPerWord), rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  // restore registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  restore_live_registers(sasm, save_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  // return to exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  __ bind(no_handler);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  // no exception handler found in this method, so the exception is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  // forwarded to the caller (using the unwind code of the nmethod)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  // there is no need to restore the registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  // restore the real return address that was saved before the RT-call
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   721
  __ movptr(real_return_addr, Address(rsp, temp_1_off * VMRegImpl::stack_slot_size));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   722
  __ movptr(Address(rbp, 1*BytesPerWord), real_return_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  // load address of JavaThread object for thread-local data
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   725
  NOT_LP64(__ get_thread(thread);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  // restore exception oop into rax, (convention for unwind code)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   727
  __ movptr(exception_oop, Address(thread, JavaThread::exception_oop_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  // clear exception fields in JavaThread because they are no longer needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  // (fields must be cleared because they are processed by GC otherwise)
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
   731
  __ movptr(Address(thread, JavaThread::exception_oop_offset()), NULL_WORD);
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
   732
  __ movptr(Address(thread, JavaThread::exception_pc_offset()), NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  // pop the stub frame off
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  generate_unwind_exception(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  __ stop("should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
void Runtime1::generate_unwind_exception(StubAssembler *sasm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  // incoming parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
  const Register exception_oop = rax;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
  // other registers used in this stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  const Register exception_pc = rdx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
  const Register handler_addr = rbx;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   748
  const Register thread = NOT_LP64(rdi) LP64_ONLY(r15_thread);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  // verify that only rax, is valid at this time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
  __ invalidate_registers(false, true, true, true, true, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  // check that fields in JavaThread for exception oop and issuing pc are empty
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   755
  NOT_LP64(__ get_thread(thread);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  Label oop_empty;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   757
  __ cmpptr(Address(thread, JavaThread::exception_oop_offset()), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
  __ jcc(Assembler::equal, oop_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  __ stop("exception oop must be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  __ bind(oop_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  Label pc_empty;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   763
  __ cmpptr(Address(thread, JavaThread::exception_pc_offset()), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  __ jcc(Assembler::equal, pc_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  __ stop("exception pc must be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
  __ bind(pc_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
  // clear the FPU stack in case any FPU results are left behind
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  __ empty_FPU_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  // leave activation of nmethod
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
  // store return address (is on top of stack after leave)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   775
  __ movptr(exception_pc, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  __ verify_oop(exception_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  // save exception oop from rax, to stack before call
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   780
  __ push(exception_oop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  // search the exception handler address of the caller (using the return address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), exception_pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  // rax,: exception handler address of the caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  // only rax, is valid at this time, all other registers have been destroyed by the call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  __ invalidate_registers(false, true, true, true, true, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
  // move result of call into correct register
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   790
  __ movptr(handler_addr, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
  // restore exception oop in rax, (required convention of exception handler)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   793
  __ pop(exception_oop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
  __ verify_oop(exception_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
  // get throwing pc (= return address).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
  // rdx has been destroyed by the call, so it must be set again
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
  // the pop is also necessary to simulate the effect of a ret(0)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   800
  __ pop(exception_pc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
  // verify that that there is really a valid exception in rax,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  __ verify_not_null_oop(exception_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
  // continue at exception handler (return address removed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  // note: do *not* remove arguments when unwinding the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
  //       activation since the caller assumes having
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  //       all arguments on the stack when entering the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  //       runtime to determine the exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  //       (GC happens at call site with arguments!)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
  // rax,: exception oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  // rdx: throwing pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  // rbx,: exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
  __ jmp(handler_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
  // use the maximum number of runtime-arguments here because it is difficult to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
  // distinguish each RT-Call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
  // Note: This number affects also the RT-Call in generate_handle_exception because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  //       the oop-map is shared for all calls.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  const int num_rt_args = 2;  // thread + dummy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
  assert(deopt_blob != NULL, "deoptimization blob must have been created");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  OopMap* oop_map = save_live_registers(sasm, num_rt_args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   830
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   831
  const Register thread = r15_thread;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   832
  // No need to worry about dummy
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   833
  __ mov(c_rarg0, thread);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   834
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   835
  __ push(rax); // push dummy
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
  const Register thread = rdi; // is callee-saved register (Visual C++ calling conventions)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  // push java thread (becomes first argument of C function)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
  __ get_thread(thread);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   840
  __ push(thread);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   841
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  __ set_last_Java_frame(thread, noreg, rbp, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
  // do the call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  __ call(RuntimeAddress(target));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  OopMapSet* oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  oop_maps->add_gc_map(__ offset(), oop_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  // verify callee-saved register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  guarantee(thread != rax, "change this code");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   850
  __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
    __ get_thread(rax);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   853
    __ cmpptr(thread, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
    __ jcc(Assembler::equal, L);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   855
    __ stop("StubAssembler::call_RT: rdi/r15 not callee saved?");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   858
  __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  __ reset_last_Java_frame(thread, true, false);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   861
#ifndef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   862
  __ pop(rcx); // discard thread arg
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   863
  __ pop(rcx); // discard dummy
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   864
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
  // check for pending exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
  { Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   868
    __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
    __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
    // exception pending => remove activation and forward to exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   872
    __ testptr(rax, rax);                                   // have we deoptimized?
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
    __ jump_cc(Assembler::equal,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
               RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
    // the deopt blob expects exceptions in the special fields of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
    // JavaThread, so copy and clear pending exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
    // load and clear pending exception
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   880
    __ movptr(rax, Address(thread, Thread::pending_exception_offset()));
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
   881
    __ movptr(Address(thread, Thread::pending_exception_offset()), NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
    // check that there is really a valid exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
    __ verify_not_null_oop(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
    // load throwing pc: this is the return address of the stub
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   887
    __ movptr(rdx, Address(rsp, return_off * VMRegImpl::stack_slot_size));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
    // check that fields in JavaThread for exception oop and issuing pc are empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
    Label oop_empty;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   892
    __ cmpptr(Address(thread, JavaThread::exception_oop_offset()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
    __ jcc(Assembler::equal, oop_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
    __ stop("exception oop must be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
    __ bind(oop_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
    Label pc_empty;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   898
    __ cmpptr(Address(thread, JavaThread::exception_pc_offset()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
    __ jcc(Assembler::equal, pc_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
    __ stop("exception pc must be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
    __ bind(pc_empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
    // store exception oop and throwing pc to JavaThread
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   905
    __ movptr(Address(thread, JavaThread::exception_oop_offset()), rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   906
    __ movptr(Address(thread, JavaThread::exception_pc_offset()), rdx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
    restore_live_registers(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    __ leave();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   911
    __ addptr(rsp, BytesPerWord);  // remove return address from stack
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
    // Forward the exception directly to deopt blob. We can blow no
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
    // registers and must leave throwing pc on the stack.  A patch may
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
    // have values live in registers so the entry point with the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
    // exception in tls.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
    __ jump(RuntimeAddress(deopt_blob->unpack_with_exception_in_tls()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
  // Runtime will return true if the nmethod has been deoptimized during
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  // the patching process. In that case we must do a deopt reexecute instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  Label reexecuteEntry, cont;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   928
  __ testptr(rax, rax);                                 // have we deoptimized?
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  __ jcc(Assembler::equal, cont);                       // no
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
  // Will reexecute. Proper return address is already on the stack we just restore
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
  // registers, pop all of our frame but the return address and jump to the deopt blob
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
  restore_live_registers(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  __ jump(RuntimeAddress(deopt_blob->unpack_with_reexecution()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  __ bind(cont);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  restore_live_registers(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  return oop_maps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
  // for better readability
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  const bool must_gc_arguments = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
  const bool dont_gc_arguments = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
  // default value; overwritten for some optimized stubs that are called from methods that do not use the fpu
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
  bool save_fpu_registers = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
  // stub code & info for the different stubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
  OopMapSet* oop_maps = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  switch (id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
    case forward_exception_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
        // we're handling an exception in the context of a compiled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
        // frame.  The registers have been saved in the standard
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
        // places.  Perform an exception lookup in the caller and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
        // dispatch to the handler if found.  Otherwise unwind and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
        // dispatch to the callers exception handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   967
        const Register thread = NOT_LP64(rdi) LP64_ONLY(r15_thread);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
        const Register exception_oop = rax;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
        const Register exception_pc = rdx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
        // load pending exception oop into rax,
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   972
        __ movptr(exception_oop, Address(thread, Thread::pending_exception_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
        // clear pending exception
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
   974
        __ movptr(Address(thread, Thread::pending_exception_offset()), NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
        // load issuing PC (the return address for this stub) into rdx
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   977
        __ movptr(exception_pc, Address(rbp, 1*BytesPerWord));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
        // make sure that the vm_results are cleared (may be unnecessary)
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
   980
        __ movptr(Address(thread, JavaThread::vm_result_offset()), NULL_WORD);
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1412
diff changeset
   981
        __ movptr(Address(thread, JavaThread::vm_result_2_offset()), NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
        // verify that that there is really a valid exception in rax,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
        __ verify_not_null_oop(exception_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
        OopMap* oop_map = generate_oop_map(sasm, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
        generate_handle_exception(sasm, oop_maps, oop_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
        __ stop("should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
    case new_instance_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
    case fast_new_instance_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
    case fast_new_instance_init_check_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
        Register klass = rdx; // Incoming
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
        Register obj   = rax; // Result
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
        if (id == new_instance_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
          __ set_info("new_instance", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
        } else if (id == fast_new_instance_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
          __ set_info("fast new_instance", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
          assert(id == fast_new_instance_init_check_id, "bad StubID");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
          __ set_info("fast new_instance init check", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
        if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
            UseTLAB && FastTLABRefill) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
          Label slow_path;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
          Register obj_size = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
          Register t1       = rbx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
          Register t2       = rsi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
          assert_different_registers(klass, obj, obj_size, t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1018
          __ push(rdi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1019
          __ push(rbx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
          if (id == fast_new_instance_init_check_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
            // make sure the klass is initialized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
            __ cmpl(Address(klass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)), instanceKlass::fully_initialized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
            __ jcc(Assembler::notEqual, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
          // assert object can be fast path allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
          {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
            Label ok, not_ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
            __ movl(obj_size, Address(klass, Klass::layout_helper_offset_in_bytes() + sizeof(oopDesc)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
            __ cmpl(obj_size, 0);  // make sure it's an instance (LH > 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
            __ jcc(Assembler::lessEqual, not_ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
            __ testl(obj_size, Klass::_lh_instance_slow_path_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
            __ jcc(Assembler::zero, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
            __ bind(not_ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
            __ stop("assert(can be fast path allocated)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
            __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
            __ bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
          // if we got here then the TLAB allocation failed, so try
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
          // refilling the TLAB or allocating directly from eden.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
          Label retry_tlab, try_eden;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
          __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
          __ bind(retry_tlab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1050
          // get the instance size (size is postive so movl is fine for 64bit)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
          __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
          __ tlab_allocate(obj, obj_size, 0, t1, t2, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
          __ initialize_object(obj, klass, obj_size, 0, t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
          __ verify_oop(obj);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1055
          __ pop(rbx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1056
          __ pop(rdi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
          __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
          __ bind(try_eden);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1060
          // get the instance size (size is postive so movl is fine for 64bit)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
          __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
          __ eden_allocate(obj, obj_size, 0, t1, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
          __ initialize_object(obj, klass, obj_size, 0, t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
          __ verify_oop(obj);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1065
          __ pop(rbx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1066
          __ pop(rdi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
          __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
          __ bind(slow_path);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1070
          __ pop(rbx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1071
          __ pop(rdi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
        __ enter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
        OopMap* map = save_live_registers(sasm, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
        int call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_instance), klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
        oop_maps->add_gc_map(call_offset, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
        restore_live_registers_except_rax(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
        __ verify_oop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
        __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
        __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
        // rax,: new instance
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
#ifdef TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
    case counter_overflow_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
        Register bci = rax;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
        __ enter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
        OopMap* map = save_live_registers(sasm, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
        // Retrieve bci
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
        __ movl(bci, Address(rbp, 2*BytesPerWord));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, counter_overflow), bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
        oop_maps->add_gc_map(call_offset, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
        restore_live_registers(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
        __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
        __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
#endif // TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
    case new_type_array_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
    case new_object_array_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
        Register length   = rbx; // Incoming
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
        Register klass    = rdx; // Incoming
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
        Register obj      = rax; // Result
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
        if (id == new_type_array_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
          __ set_info("new_type_array", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
          __ set_info("new_object_array", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
        // assert object type is really an array of the proper kind
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
          Label ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
          Register t0 = obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
          __ movl(t0, Address(klass, Klass::layout_helper_offset_in_bytes() + sizeof(oopDesc)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
          __ sarl(t0, Klass::_lh_array_tag_shift);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
          int tag = ((id == new_type_array_id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
                     ? Klass::_lh_array_tag_type_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
                     : Klass::_lh_array_tag_obj_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
          __ cmpl(t0, tag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
          __ jcc(Assembler::equal, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
          __ stop("assert(is an array klass)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
          __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
          __ bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
        if (UseTLAB && FastTLABRefill) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
          Register arr_size = rsi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
          Register t1       = rcx;  // must be rcx for use as shift count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
          Register t2       = rdi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
          Label slow_path;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
          assert_different_registers(length, klass, obj, arr_size, t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
          // check that array length is small enough for fast path.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
          __ cmpl(length, C1_MacroAssembler::max_array_allocation_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
          __ jcc(Assembler::above, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
          // if we got here then the TLAB allocation failed, so try
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
          // refilling the TLAB or allocating directly from eden.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
          Label retry_tlab, try_eden;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
          __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx, & rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
          __ bind(retry_tlab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
          // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F))
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1157
          // since size is postive movl does right thing on 64bit
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
          __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1159
          // since size is postive movl does right thing on 64bit
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
          __ movl(arr_size, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
          assert(t1 == rcx, "fixed register usage");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1162
          __ shlptr(arr_size /* by t1=rcx, mod 32 */);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1163
          __ shrptr(t1, Klass::_lh_header_size_shift);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1164
          __ andptr(t1, Klass::_lh_header_size_mask);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1165
          __ addptr(arr_size, t1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1166
          __ addptr(arr_size, MinObjAlignmentInBytesMask); // align up
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1167
          __ andptr(arr_size, ~MinObjAlignmentInBytesMask);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
          __ tlab_allocate(obj, arr_size, 0, t1, t2, slow_path);  // preserves arr_size
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
          __ initialize_header(obj, klass, length, t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
          __ movb(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes() + (Klass::_lh_header_size_shift / BitsPerByte)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
          assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
          assert(Klass::_lh_header_size_mask <= 0xFF, "bytewise");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1175
          __ andptr(t1, Klass::_lh_header_size_mask);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1176
          __ subptr(arr_size, t1);  // body length
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1177
          __ addptr(t1, obj);       // body start
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
          __ initialize_body(t1, arr_size, 0, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
          __ verify_oop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
          __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
          __ bind(try_eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
          // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F))
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1184
          // since size is postive movl does right thing on 64bit
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
          __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1186
          // since size is postive movl does right thing on 64bit
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
          __ movl(arr_size, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
          assert(t1 == rcx, "fixed register usage");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1189
          __ shlptr(arr_size /* by t1=rcx, mod 32 */);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1190
          __ shrptr(t1, Klass::_lh_header_size_shift);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1191
          __ andptr(t1, Klass::_lh_header_size_mask);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1192
          __ addptr(arr_size, t1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1193
          __ addptr(arr_size, MinObjAlignmentInBytesMask); // align up
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1194
          __ andptr(arr_size, ~MinObjAlignmentInBytesMask);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
          __ eden_allocate(obj, arr_size, 0, t1, slow_path);  // preserves arr_size
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
          __ initialize_header(obj, klass, length, t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
          __ movb(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes() + (Klass::_lh_header_size_shift / BitsPerByte)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
          assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
          assert(Klass::_lh_header_size_mask <= 0xFF, "bytewise");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1202
          __ andptr(t1, Klass::_lh_header_size_mask);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1203
          __ subptr(arr_size, t1);  // body length
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1204
          __ addptr(t1, obj);       // body start
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
          __ initialize_body(t1, arr_size, 0, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
          __ verify_oop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
          __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
          __ bind(slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
        __ enter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
        OopMap* map = save_live_registers(sasm, 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
        int call_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
        if (id == new_type_array_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
          call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_type_array), klass, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
          call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_object_array), klass, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
        oop_maps->add_gc_map(call_offset, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
        restore_live_registers_except_rax(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
        __ verify_oop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
        __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
        __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
        // rax,: new array
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
    case new_multi_array_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
      { StubFrame f(sasm, "new_multi_array", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
        // rax,: klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
        // rbx,: rank
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
        // rcx: address of 1st dimension
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
        OopMap* map = save_live_registers(sasm, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
        int call_offset = __ call_RT(rax, noreg, CAST_FROM_FN_PTR(address, new_multi_array), rax, rbx, rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
        oop_maps->add_gc_map(call_offset, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
        restore_live_registers_except_rax(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
        // rax,: new multi array
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
        __ verify_oop(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
    case register_finalizer_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
        __ set_info("register_finalizer", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1254
        // This is called via call_runtime so the arguments
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1255
        // will be place in C abi locations
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1256
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1257
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1258
        __ verify_oop(c_rarg0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1259
        __ mov(rax, c_rarg0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1260
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
        // The object is passed on the stack and we haven't pushed a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
        // frame yet so it's one work away from top of stack.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1263
        __ movptr(rax, Address(rsp, 1 * BytesPerWord));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
        __ verify_oop(rax);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1265
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
        // load the klass and check the has finalizer flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
        Label register_finalizer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
        Register t = rsi;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1270
        __ movptr(t, Address(rax, oopDesc::klass_offset_in_bytes()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
        __ movl(t, Address(t, Klass::access_flags_offset_in_bytes() + sizeof(oopDesc)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
        __ testl(t, JVM_ACC_HAS_FINALIZER);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
        __ jcc(Assembler::notZero, register_finalizer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
        __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
        __ bind(register_finalizer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
        __ enter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
        OopMap* oop_map = save_live_registers(sasm, 2 /*num_rt_args */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
        int call_offset = __ call_RT(noreg, noreg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
                                     CAST_FROM_FN_PTR(address, SharedRuntime::register_finalizer), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
        oop_maps->add_gc_map(call_offset, oop_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
        // Now restore all the live registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
        restore_live_registers(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
        __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
        __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
    case throw_range_check_failed_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
      { StubFrame f(sasm, "range_check_failed", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
    case throw_index_exception_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
      { StubFrame f(sasm, "index_range_check_failed", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
    case throw_div0_exception_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
      { StubFrame f(sasm, "throw_div0_exception", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
    case throw_null_pointer_exception_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
      { StubFrame f(sasm, "throw_null_pointer_exception", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
    case handle_exception_nofpu_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
      save_fpu_registers = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
      // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
    case handle_exception_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
      { StubFrame f(sasm, "handle_exception", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
        OopMap* oop_map = save_live_registers(sasm, 1, save_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
        generate_handle_exception(sasm, oop_maps, oop_map, save_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
    case unwind_exception_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
      { __ set_info("unwind_exception", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
        // note: no stubframe since we are about to leave the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
        //       activation and we are calling a leaf VM function only.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
        generate_unwind_exception(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
    case throw_array_store_exception_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
      { StubFrame f(sasm, "throw_array_store_exception", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
        // tos + 0: link
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
        //     + 1: return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
    case throw_class_cast_exception_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
      { StubFrame f(sasm, "throw_class_cast_exception", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
    case throw_incompatible_class_change_error_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
      { StubFrame f(sasm, "throw_incompatible_class_cast_exception", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
    case slow_subtype_check_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
        enum layout {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1358
          rax_off, SLOT2(raxH_off)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1359
          rcx_off, SLOT2(rcxH_off)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1360
          rsi_off, SLOT2(rsiH_off)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1361
          rdi_off, SLOT2(rdiH_off)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1362
          // saved_rbp_off, SLOT2(saved_rbpH_off)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1363
          return_off, SLOT2(returnH_off)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1364
          sub_off, SLOT2(subH_off)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1365
          super_off, SLOT2(superH_off)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
          framesize
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
        };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
        __ set_info("slow_subtype_check", dont_gc_arguments);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1370
        __ push(rdi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1371
        __ push(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1372
        __ push(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1373
        __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1375
        // This is called by pushing args and not with C abi
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1376
        __ movptr(rsi, Address(rsp, (super_off) * VMRegImpl::stack_slot_size)); // super
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1377
        __ movptr(rax, Address(rsp, (sub_off  ) * VMRegImpl::stack_slot_size)); // sub
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1378
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1379
        __ movptr(rdi,Address(rsi,sizeof(oopDesc) + Klass::secondary_supers_offset_in_bytes()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1380
        // since size is postive movl does right thing on 64bit
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1381
        __ movl(rcx, Address(rdi, arrayOopDesc::length_offset_in_bytes()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1382
        __ addptr(rdi, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
        Label miss;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
        __ repne_scan();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
        __ jcc(Assembler::notEqual, miss);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1387
        __ movptr(Address(rsi,sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes()), rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1388
        __ movptr(Address(rsp, (super_off) * VMRegImpl::stack_slot_size), 1); // result
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1389
        __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1390
        __ pop(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1391
        __ pop(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1392
        __ pop(rdi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
        __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
        __ bind(miss);
1909
952b42dad1fc 6795913: A few remaining wrong casts need to be fixed for building hotspot successfully on Mac OS.
xlu
parents: 1888
diff changeset
  1396
        __ movptr(Address(rsp, (super_off) * VMRegImpl::stack_slot_size), NULL_WORD); // result
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1397
        __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1398
        __ pop(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1399
        __ pop(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1400
        __ pop(rdi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
        __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
    case monitorenter_nofpu_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
      save_fpu_registers = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
      // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
    case monitorenter_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
        StubFrame f(sasm, "monitorenter", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
        OopMap* map = save_live_registers(sasm, 3, save_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1413
        // Called with store_parameter and not C abi
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1414
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
        f.load_argument(1, rax); // rax,: object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
        f.load_argument(0, rbx); // rbx,: lock address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), rax, rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
        oop_maps->add_gc_map(call_offset, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
        restore_live_registers(sasm, save_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
    case monitorexit_nofpu_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
      save_fpu_registers = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
      // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
    case monitorexit_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
        StubFrame f(sasm, "monitorexit", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
        OopMap* map = save_live_registers(sasm, 2, save_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1434
        // Called with store_parameter and not C abi
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1435
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
        f.load_argument(0, rax); // rax,: lock address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
        // note: really a leaf routine but must setup last java sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
        //       => use call_RT for now (speed can be improved by
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
        //       doing last java sp setup manually)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
        oop_maps->add_gc_map(call_offset, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
        restore_live_registers(sasm, save_fpu_registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
    case access_field_patching_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
      { StubFrame f(sasm, "access_field_patching", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
        // we should set up register map
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
        oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
    case load_klass_patching_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
      { StubFrame f(sasm, "load_klass_patching", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
        // we should set up register map
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
        oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
    case jvmti_exception_throw_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
      { // rax,: exception oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
        StubFrame f(sasm, "jvmti_exception_throw", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
        // Preserve all registers across this potentially blocking call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
        const int num_rt_args = 2;  // thread, exception oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
        OopMap* map = save_live_registers(sasm, num_rt_args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, Runtime1::post_jvmti_exception_throw), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
        oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
        oop_maps->add_gc_map(call_offset, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
        restore_live_registers(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
    case dtrace_object_alloc_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
      { // rax,: object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
        StubFrame f(sasm, "dtrace_object_alloc", dont_gc_arguments);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
        // we can't gc here so skip the oopmap but make sure that all
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
        // the live registers get saved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
        save_live_registers(sasm, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1484
        __ NOT_LP64(push(rax)) LP64_ONLY(mov(c_rarg0, rax));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc)));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1486
        NOT_LP64(__ pop(rax));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
        restore_live_registers(sasm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
    case fpu2long_stub_id:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
        // rax, and rdx are destroyed, but should be free since the result is returned there
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
        // preserve rsi,ecx
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1496
        __ push(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1497
        __ push(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1498
        LP64_ONLY(__ push(rdx);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
        // check for NaN
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
        Label return0, do_return, return_min_jlong, do_convert;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1503
        Address value_high_word(rsp, wordSize + 4);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1504
        Address value_low_word(rsp, wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1505
        Address result_high_word(rsp, 3*wordSize + 4);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1506
        Address result_low_word(rsp, 3*wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1508
        __ subptr(rsp, 32);                    // more than enough on 32bit
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
        __ fst_d(value_low_word);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
        __ movl(rax, value_high_word);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
        __ andl(rax, 0x7ff00000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
        __ cmpl(rax, 0x7ff00000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
        __ jcc(Assembler::notEqual, do_convert);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
        __ movl(rax, value_high_word);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
        __ andl(rax, 0xfffff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
        __ orl(rax, value_low_word);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
        __ jcc(Assembler::notZero, return0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
        __ bind(do_convert);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
        __ fnstcw(Address(rsp, 0));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1521
        __ movzwl(rax, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
        __ orl(rax, 0xc00);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
        __ movw(Address(rsp, 2), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
        __ fldcw(Address(rsp, 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
        __ fwait();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
        __ fistp_d(result_low_word);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
        __ fldcw(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
        __ fwait();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1529
        // This gets the entire long in rax on 64bit
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1530
        __ movptr(rax, result_low_word);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1531
        // testing of high bits
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
        __ movl(rdx, result_high_word);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1533
        __ mov(rcx, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
        // What the heck is the point of the next instruction???
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
        __ xorl(rcx, 0x0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
        __ movl(rsi, 0x80000000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
        __ xorl(rsi, rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
        __ orl(rcx, rsi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
        __ jcc(Assembler::notEqual, do_return);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
        __ fldz();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
        __ fcomp_d(value_low_word);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
        __ fnstsw_ax();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1543
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1544
        __ testl(rax, 0x4100);  // ZF & CF == 0
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1545
        __ jcc(Assembler::equal, return_min_jlong);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1546
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
        __ sahf();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
        __ jcc(Assembler::above, return_min_jlong);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1549
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
        // return max_jlong
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1551
#ifndef _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
        __ movl(rdx, 0x7fffffff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
        __ movl(rax, 0xffffffff);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1554
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1555
        __ mov64(rax, CONST64(0x7fffffffffffffff));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1556
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
        __ jmp(do_return);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
        __ bind(return_min_jlong);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1560
#ifndef _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
        __ movl(rdx, 0x80000000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
        __ xorl(rax, rax);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1563
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1564
        __ mov64(rax, CONST64(0x8000000000000000));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1565
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
        __ jmp(do_return);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
        __ bind(return0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
        __ fpop();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1570
#ifndef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1571
        __ xorptr(rdx,rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1572
        __ xorptr(rax,rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1573
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1574
        __ xorptr(rax, rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1575
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1577
        __ bind(do_return);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1578
        __ addptr(rsp, 32);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1579
        LP64_ONLY(__ pop(rdx);)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1580
        __ pop(rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1581
        __ pop(rsi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
        __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1586
#ifndef SERIALGC
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1587
    case g1_pre_barrier_slow_id:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1588
      {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1589
        StubFrame f(sasm, "g1_pre_barrier", dont_gc_arguments);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1590
        // arg0 : previous value of memory
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1591
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1592
        BarrierSet* bs = Universe::heap()->barrier_set();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1593
        if (bs->kind() != BarrierSet::G1SATBCTLogging) {
1394
apetrusenko
parents: 1066 1374
diff changeset
  1594
          __ movptr(rax, (int)id);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1595
          __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1596
          __ should_not_reach_here();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1597
          break;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1598
        }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1599
1394
apetrusenko
parents: 1066 1374
diff changeset
  1600
        __ push(rax);
apetrusenko
parents: 1066 1374
diff changeset
  1601
        __ push(rdx);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1602
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1603
        const Register pre_val = rax;
1394
apetrusenko
parents: 1066 1374
diff changeset
  1604
        const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1605
        const Register tmp = rdx;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1606
1394
apetrusenko
parents: 1066 1374
diff changeset
  1607
        NOT_LP64(__ get_thread(thread);)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1608
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1609
        Address in_progress(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1610
                                             PtrQueue::byte_offset_of_active()));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1611
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1612
        Address queue_index(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1613
                                             PtrQueue::byte_offset_of_index()));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1614
        Address buffer(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1615
                                        PtrQueue::byte_offset_of_buf()));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1616
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1617
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1618
        Label done;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1619
        Label runtime;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1620
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1621
        // Can we store original value in the thread's buffer?
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1622
1394
apetrusenko
parents: 1066 1374
diff changeset
  1623
        LP64_ONLY(__ movslq(tmp, queue_index);)
apetrusenko
parents: 1066 1374
diff changeset
  1624
#ifdef _LP64
apetrusenko
parents: 1066 1374
diff changeset
  1625
        __ cmpq(tmp, 0);
apetrusenko
parents: 1066 1374
diff changeset
  1626
#else
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1627
        __ cmpl(queue_index, 0);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1628
#endif
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1629
        __ jcc(Assembler::equal, runtime);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1630
#ifdef _LP64
apetrusenko
parents: 1066 1374
diff changeset
  1631
        __ subq(tmp, wordSize);
apetrusenko
parents: 1066 1374
diff changeset
  1632
        __ movl(queue_index, tmp);
apetrusenko
parents: 1066 1374
diff changeset
  1633
        __ addq(tmp, buffer);
apetrusenko
parents: 1066 1374
diff changeset
  1634
#else
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1635
        __ subl(queue_index, wordSize);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1636
        __ movl(tmp, buffer);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1637
        __ addl(tmp, queue_index);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1638
#endif
apetrusenko
parents: 1066 1374
diff changeset
  1639
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1640
        // prev_val (rax)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1641
        f.load_argument(0, pre_val);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1642
        __ movptr(Address(tmp, 0), pre_val);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1643
        __ jmp(done);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1644
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1645
        __ bind(runtime);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1646
        // load the pre-value
1394
apetrusenko
parents: 1066 1374
diff changeset
  1647
        __ push(rcx);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1648
        f.load_argument(0, rcx);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1649
        __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), rcx, thread);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1650
        __ pop(rcx);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1651
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1652
        __ bind(done);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1653
        __ pop(rdx);
apetrusenko
parents: 1066 1374
diff changeset
  1654
        __ pop(rax);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1655
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1656
      break;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1657
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1658
    case g1_post_barrier_slow_id:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1659
      {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1660
        StubFrame f(sasm, "g1_post_barrier", dont_gc_arguments);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1661
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1662
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1663
        // arg0: store_address
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1664
        Address store_addr(rbp, 2*BytesPerWord);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1665
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1666
        BarrierSet* bs = Universe::heap()->barrier_set();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1667
        CardTableModRefBS* ct = (CardTableModRefBS*)bs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1668
        Label done;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1669
        Label runtime;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1670
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1671
        // At this point we know new_value is non-NULL and the new_value crosses regsion.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1672
        // Must check to see if card is already dirty
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1673
1394
apetrusenko
parents: 1066 1374
diff changeset
  1674
        const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1675
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1676
        Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1677
                                             PtrQueue::byte_offset_of_index()));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1678
        Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1679
                                        PtrQueue::byte_offset_of_buf()));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1680
1394
apetrusenko
parents: 1066 1374
diff changeset
  1681
        __ push(rax);
apetrusenko
parents: 1066 1374
diff changeset
  1682
        __ push(rdx);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1683
1394
apetrusenko
parents: 1066 1374
diff changeset
  1684
        NOT_LP64(__ get_thread(thread);)
apetrusenko
parents: 1066 1374
diff changeset
  1685
        ExternalAddress cardtable((address)ct->byte_map_base);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1686
        assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1687
1394
apetrusenko
parents: 1066 1374
diff changeset
  1688
        const Register card_addr = rdx;
apetrusenko
parents: 1066 1374
diff changeset
  1689
#ifdef _LP64
apetrusenko
parents: 1066 1374
diff changeset
  1690
        const Register tmp = rscratch1;
apetrusenko
parents: 1066 1374
diff changeset
  1691
        f.load_argument(0, card_addr);
apetrusenko
parents: 1066 1374
diff changeset
  1692
        __ shrq(card_addr, CardTableModRefBS::card_shift);
apetrusenko
parents: 1066 1374
diff changeset
  1693
        __ lea(tmp, cardtable);
apetrusenko
parents: 1066 1374
diff changeset
  1694
        // get the address of the card
apetrusenko
parents: 1066 1374
diff changeset
  1695
        __ addq(card_addr, tmp);
apetrusenko
parents: 1066 1374
diff changeset
  1696
#else
apetrusenko
parents: 1066 1374
diff changeset
  1697
        const Register card_index = rdx;
apetrusenko
parents: 1066 1374
diff changeset
  1698
        f.load_argument(0, card_index);
apetrusenko
parents: 1066 1374
diff changeset
  1699
        __ shrl(card_index, CardTableModRefBS::card_shift);
apetrusenko
parents: 1066 1374
diff changeset
  1700
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1701
        Address index(noreg, card_index, Address::times_1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1702
        __ leal(card_addr, __ as_Address(ArrayAddress(cardtable, index)));
1394
apetrusenko
parents: 1066 1374
diff changeset
  1703
#endif
apetrusenko
parents: 1066 1374
diff changeset
  1704
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1705
        __ cmpb(Address(card_addr, 0), 0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1706
        __ jcc(Assembler::equal, done);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1707
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1708
        // storing region crossing non-NULL, card is clean.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1709
        // dirty card and log.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1710
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1711
        __ movb(Address(card_addr, 0), 0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1712
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1713
        __ cmpl(queue_index, 0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1714
        __ jcc(Assembler::equal, runtime);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1715
        __ subl(queue_index, wordSize);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1716
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1717
        const Register buffer_addr = rbx;
1394
apetrusenko
parents: 1066 1374
diff changeset
  1718
        __ push(rbx);
apetrusenko
parents: 1066 1374
diff changeset
  1719
apetrusenko
parents: 1066 1374
diff changeset
  1720
        __ movptr(buffer_addr, buffer);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1721
1394
apetrusenko
parents: 1066 1374
diff changeset
  1722
#ifdef _LP64
apetrusenko
parents: 1066 1374
diff changeset
  1723
        __ movslq(rscratch1, queue_index);
apetrusenko
parents: 1066 1374
diff changeset
  1724
        __ addptr(buffer_addr, rscratch1);
apetrusenko
parents: 1066 1374
diff changeset
  1725
#else
apetrusenko
parents: 1066 1374
diff changeset
  1726
        __ addptr(buffer_addr, queue_index);
apetrusenko
parents: 1066 1374
diff changeset
  1727
#endif
apetrusenko
parents: 1066 1374
diff changeset
  1728
        __ movptr(Address(buffer_addr, 0), card_addr);
apetrusenko
parents: 1066 1374
diff changeset
  1729
apetrusenko
parents: 1066 1374
diff changeset
  1730
        __ pop(rbx);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1731
        __ jmp(done);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1732
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1733
        __ bind(runtime);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1734
        NOT_LP64(__ push(rcx);)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1735
        __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1736
        NOT_LP64(__ pop(rcx);)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1737
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1738
        __ bind(done);
1394
apetrusenko
parents: 1066 1374
diff changeset
  1739
        __ pop(rdx);
apetrusenko
parents: 1066 1374
diff changeset
  1740
        __ pop(rax);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1741
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1742
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1743
      break;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1744
#endif // !SERIALGC
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1745
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
      { StubFrame f(sasm, "unimplemented entry", dont_gc_arguments);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1748
        __ movptr(rax, (int)id);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
        __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
        __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
  return oop_maps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
#undef __