hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp
author shade
Thu, 04 Feb 2016 21:44:23 +0300
changeset 35708 290a3952e434
parent 34148 6efbc7ffd767
child 35560 b3fa0a291684
permissions -rw-r--r--
8149044: jdk/internal/misc/JavaLangAccess/FormatUnsigned.java fails all platforms Summary: Remove the obsolete FormatUnsigned test. Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29189
diff changeset
     2
 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     3
 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     5
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     8
 * published by the Free Software Foundation.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     9
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    14
 * accompanied this code).
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    15
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    19
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    22
 * questions.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    23
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    24
 */
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    25
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    26
#include "precompiled.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    27
#include "asm/assembler.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    28
#include "c1/c1_CodeStubs.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    29
#include "c1/c1_Defs.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    30
#include "c1/c1_MacroAssembler.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    31
#include "c1/c1_Runtime1.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    32
#include "compiler/disassembler.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    33
#include "interpreter/interpreter.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    34
#include "nativeInst_aarch64.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    35
#include "oops/compiledICHolder.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    36
#include "oops/oop.inline.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    37
#include "prims/jvmtiExport.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    38
#include "register_aarch64.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    39
#include "runtime/sharedRuntime.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    40
#include "runtime/signature.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    41
#include "runtime/vframe.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    42
#include "runtime/vframeArray.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    43
#include "vmreg_aarch64.inline.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    44
#if INCLUDE_ALL_GCS
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29189
diff changeset
    45
#include "gc/g1/g1SATBCardTableModRefBS.hpp"
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    46
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    47
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    48
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    49
// Implementation of StubAssembler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    50
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    51
int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, int args_size) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    52
  // setup registers
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    53
  assert(!(oop_result1->is_valid() || metadata_result->is_valid()) || oop_result1 != metadata_result, "registers must be different");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    54
  assert(oop_result1 != rthread && metadata_result != rthread, "registers must be different");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    55
  assert(args_size >= 0, "illegal args_size");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    56
  bool align_stack = false;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    57
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    58
  mov(c_rarg0, rthread);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    59
  set_num_rt_args(0); // Nothing on stack
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    60
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    61
  Label retaddr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    62
  set_last_Java_frame(sp, rfp, retaddr, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    63
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    64
  // do the call
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    65
  lea(rscratch1, RuntimeAddress(entry));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    66
  blrt(rscratch1, args_size + 1, 8, 1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    67
  bind(retaddr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    68
  int call_offset = offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    69
  // verify callee-saved register
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    70
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    71
  push(r0, sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    72
  { Label L;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    73
    get_thread(r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    74
    cmp(rthread, r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    75
    br(Assembler::EQ, L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    76
    stop("StubAssembler::call_RT: rthread not callee saved?");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    77
    bind(L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    78
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    79
  pop(r0, sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    80
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    81
  reset_last_Java_frame(true, true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    82
  maybe_isb();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    83
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    84
  // check for pending exceptions
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    85
  { Label L;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    86
    // check for pending exceptions (java_thread is set upon return)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    87
    ldr(rscratch1, Address(rthread, in_bytes(Thread::pending_exception_offset())));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    88
    cbz(rscratch1, L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    89
    // exception pending => remove activation and forward to exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    90
    // make sure that the vm_results are cleared
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    91
    if (oop_result1->is_valid()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    92
      str(zr, Address(rthread, JavaThread::vm_result_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    93
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    94
    if (metadata_result->is_valid()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    95
      str(zr, Address(rthread, JavaThread::vm_result_2_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    96
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    97
    if (frame_size() == no_frame_size) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    98
      leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    99
      far_jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   100
    } else if (_stub_id == Runtime1::forward_exception_id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   101
      should_not_reach_here();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   102
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   103
      far_jump(RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   104
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   105
    bind(L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   106
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   107
  // get oop results if there are any and reset the values in the thread
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   108
  if (oop_result1->is_valid()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   109
    get_vm_result(oop_result1, rthread);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   110
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   111
  if (metadata_result->is_valid()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   112
    get_vm_result_2(metadata_result, rthread);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   113
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   114
  return call_offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   115
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   116
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   117
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   118
int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   119
  mov(c_rarg1, arg1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   120
  return call_RT(oop_result1, metadata_result, entry, 1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   121
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   122
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   123
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   124
int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   125
  if (c_rarg1 == arg2) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   126
    if (c_rarg2 == arg1) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   127
      mov(rscratch1, arg1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   128
      mov(arg1, arg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   129
      mov(arg2, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   130
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   131
      mov(c_rarg2, arg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   132
      mov(c_rarg1, arg1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   133
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   134
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   135
    mov(c_rarg1, arg1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   136
    mov(c_rarg2, arg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   137
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   138
  return call_RT(oop_result1, metadata_result, entry, 2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   139
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   140
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   141
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   142
int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2, Register arg3) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   143
  // if there is any conflict use the stack
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   144
  if (arg1 == c_rarg2 || arg1 == c_rarg3 ||
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   145
      arg2 == c_rarg1 || arg1 == c_rarg3 ||
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   146
      arg3 == c_rarg1 || arg1 == c_rarg2) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   147
    stp(arg3, arg2, Address(pre(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   148
    stp(arg1, zr, Address(pre(sp, -2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   149
    ldp(c_rarg1, zr, Address(post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   150
    ldp(c_rarg3, c_rarg2, Address(post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   151
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   152
    mov(c_rarg1, arg1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   153
    mov(c_rarg2, arg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   154
    mov(c_rarg3, arg3);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   155
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   156
  return call_RT(oop_result1, metadata_result, entry, 3);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   157
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   158
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   159
// Implementation of StubFrame
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   160
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   161
class StubFrame: public StackObj {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   162
 private:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   163
  StubAssembler* _sasm;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   164
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   165
 public:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   166
  StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   167
  void load_argument(int offset_in_words, Register reg);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   168
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   169
  ~StubFrame();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   170
};;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   171
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   172
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   173
#define __ _sasm->
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   174
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   175
StubFrame::StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   176
  _sasm = sasm;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   177
  __ set_info(name, must_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   178
  __ enter();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   179
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   180
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   181
// load parameters that were stored with LIR_Assembler::store_parameter
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   182
// Note: offsets for store_parameter and load_argument must match
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   183
void StubFrame::load_argument(int offset_in_words, Register reg) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   184
  // rbp, + 0: link
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   185
  //     + 1: return address
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   186
  //     + 2: argument with offset 0
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   187
  //     + 3: argument with offset 1
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   188
  //     + 4: ...
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   189
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   190
  __ ldr(reg, Address(rfp, (offset_in_words + 2) * BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   191
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   192
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   193
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   194
StubFrame::~StubFrame() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   195
  __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   196
  __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   197
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   198
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   199
#undef __
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   200
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   201
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   202
// Implementation of Runtime1
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   203
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   204
#define __ sasm->
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   205
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   206
const int float_regs_as_doubles_size_in_slots = pd_nof_fpu_regs_frame_map * 2;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   207
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   208
// Stack layout for saving/restoring  all the registers needed during a runtime
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   209
// call (this includes deoptimization)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   210
// Note: note that users of this frame may well have arguments to some runtime
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   211
// while these values are on the stack. These positions neglect those arguments
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   212
// but the code in save_live_registers will take the argument count into
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   213
// account.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   214
//
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   215
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   216
enum reg_save_layout {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   217
  reg_save_frame_size = 32 /* float */ + 32 /* integer */
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   218
};
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   219
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   220
// Save off registers which might be killed by calls into the runtime.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   221
// Tries to smart of about FP registers.  In particular we separate
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   222
// saving and describing the FPU registers for deoptimization since we
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   223
// have to save the FPU registers twice if we describe them.  The
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   224
// deopt blob is the only thing which needs to describe FPU registers.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   225
// In all other cases it should be sufficient to simply save their
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   226
// current value.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   227
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   228
static int cpu_reg_save_offsets[FrameMap::nof_cpu_regs];
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   229
static int fpu_reg_save_offsets[FrameMap::nof_fpu_regs];
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   230
static int reg_save_size_in_words;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   231
static int frame_size_in_bytes = -1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   232
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   233
static OopMap* generate_oop_map(StubAssembler* sasm, bool save_fpu_registers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   234
  int frame_size_in_bytes = reg_save_frame_size * BytesPerWord;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   235
  sasm->set_frame_size(frame_size_in_bytes / BytesPerWord);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   236
  int frame_size_in_slots = frame_size_in_bytes / sizeof(jint);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   237
  OopMap* oop_map = new OopMap(frame_size_in_slots, 0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   238
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   239
  for (int i = 0; i < FrameMap::nof_cpu_regs; i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   240
    Register r = as_Register(i);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   241
    if (i <= 18 && i != rscratch1->encoding() && i != rscratch2->encoding()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   242
      int sp_offset = cpu_reg_save_offsets[i];
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   243
      oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   244
                                r->as_VMReg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   245
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   246
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   247
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   248
  if (save_fpu_registers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   249
    for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   250
      FloatRegister r = as_FloatRegister(i);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   251
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   252
        int sp_offset = fpu_reg_save_offsets[i];
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   253
        oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   254
                                  r->as_VMReg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   255
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   256
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   257
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   258
  return oop_map;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   259
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   260
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   261
static OopMap* save_live_registers(StubAssembler* sasm,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   262
                                   bool save_fpu_registers = true) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   263
  __ block_comment("save_live_registers");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   264
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   265
  __ push(RegSet::range(r0, r29), sp);         // integer registers except lr & sp
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   266
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   267
  if (save_fpu_registers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   268
    for (int i = 30; i >= 0; i -= 2)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   269
      __ stpd(as_FloatRegister(i), as_FloatRegister(i+1),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   270
              Address(__ pre(sp, -2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   271
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   272
    __ add(sp, sp, -32 * wordSize);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   273
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   274
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   275
  return generate_oop_map(sasm, save_fpu_registers);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   276
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   277
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   278
static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   279
  if (restore_fpu_registers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   280
    for (int i = 0; i < 32; i += 2)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   281
      __ ldpd(as_FloatRegister(i), as_FloatRegister(i+1),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   282
              Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   283
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   284
    __ add(sp, sp, 32 * wordSize);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   285
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   286
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   287
  __ pop(RegSet::range(r0, r29), sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   288
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   289
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   290
static void restore_live_registers_except_r0(StubAssembler* sasm, bool restore_fpu_registers = true)  {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   291
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   292
  if (restore_fpu_registers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   293
    for (int i = 0; i < 32; i += 2)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   294
      __ ldpd(as_FloatRegister(i), as_FloatRegister(i+1),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   295
              Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   296
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   297
    __ add(sp, sp, 32 * wordSize);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   298
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   299
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   300
  __ ldp(zr, r1, Address(__ post(sp, 16)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   301
  __ pop(RegSet::range(r2, r29), sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   302
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   303
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   304
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   305
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   306
void Runtime1::initialize_pd() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   307
  int i;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   308
  int sp_offset = 0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   309
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   310
  // all float registers are saved explicitly
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   311
  assert(FrameMap::nof_fpu_regs == 32, "double registers not handled here");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   312
  for (i = 0; i < FrameMap::nof_fpu_regs; i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   313
    fpu_reg_save_offsets[i] = sp_offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   314
    sp_offset += 2;   // SP offsets are in halfwords
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   315
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   316
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   317
  for (i = 0; i < FrameMap::nof_cpu_regs; i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   318
    Register r = as_Register(i);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   319
    cpu_reg_save_offsets[i] = sp_offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   320
    sp_offset += 2;   // SP offsets are in halfwords
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   321
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   322
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   323
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   324
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   325
// target: the entry point of the method that creates and posts the exception oop
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   326
// has_argument: true if the exception needs an argument (passed in rscratch1)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   327
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   328
OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   329
  // make a frame and preserve the caller's caller-save registers
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   330
  OopMap* oop_map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   331
  int call_offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   332
  if (!has_argument) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   333
    call_offset = __ call_RT(noreg, noreg, target);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   334
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   335
    call_offset = __ call_RT(noreg, noreg, target, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   336
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   337
  OopMapSet* oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   338
  oop_maps->add_gc_map(call_offset, oop_map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   339
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   340
  __ should_not_reach_here();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   341
  return oop_maps;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   342
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   343
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   344
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   345
OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   346
  __ block_comment("generate_handle_exception");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   347
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   348
  // incoming parameters
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   349
  const Register exception_oop = r0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   350
  const Register exception_pc  = r3;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   351
  // other registers used in this stub
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   352
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   353
  // Save registers, if required.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   354
  OopMapSet* oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   355
  OopMap* oop_map = NULL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   356
  switch (id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   357
  case forward_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   358
    // We're handling an exception in the context of a compiled frame.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   359
    // The registers have been saved in the standard places.  Perform
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   360
    // an exception lookup in the caller and dispatch to the handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   361
    // if found.  Otherwise unwind and dispatch to the callers
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   362
    // exception handler.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   363
    oop_map = generate_oop_map(sasm, 1 /*thread*/);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   364
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   365
    // load and clear pending exception oop into r0
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   366
    __ ldr(exception_oop, Address(rthread, Thread::pending_exception_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   367
    __ str(zr, Address(rthread, Thread::pending_exception_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   368
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   369
    // load issuing PC (the return address for this stub) into r3
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   370
    __ ldr(exception_pc, Address(rfp, 1*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   371
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   372
    // make sure that the vm_results are cleared (may be unnecessary)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   373
    __ str(zr, Address(rthread, JavaThread::vm_result_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   374
    __ str(zr, Address(rthread, JavaThread::vm_result_2_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   375
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   376
  case handle_exception_nofpu_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   377
  case handle_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   378
    // At this point all registers MAY be live.
29189
9252ebf92115 8072129: [AARCH64] missing fix for 8066900
enevill
parents: 29184
diff changeset
   379
    oop_map = save_live_registers(sasm, id != handle_exception_nofpu_id);
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   380
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   381
  case handle_exception_from_callee_id: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   382
    // At this point all registers except exception oop (r0) and
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   383
    // exception pc (lr) are dead.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   384
    const int frame_size = 2 /*fp, return address*/;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   385
    oop_map = new OopMap(frame_size * VMRegImpl::slots_per_word, 0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   386
    sasm->set_frame_size(frame_size);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   387
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   388
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   389
  default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   390
    __ should_not_reach_here();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   391
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   392
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   393
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   394
  // verify that only r0 and r3 are valid at this time
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   395
  __ invalidate_registers(false, true, true, false, true, true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   396
  // verify that r0 contains a valid exception
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   397
  __ verify_not_null_oop(exception_oop);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   398
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   399
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   400
  // check that fields in JavaThread for exception oop and issuing pc are
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   401
  // empty before writing to them
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   402
  Label oop_empty;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   403
  __ ldr(rscratch1, Address(rthread, JavaThread::exception_oop_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   404
  __ cbz(rscratch1, oop_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   405
  __ stop("exception oop already set");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   406
  __ bind(oop_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   407
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   408
  Label pc_empty;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   409
  __ ldr(rscratch1, Address(rthread, JavaThread::exception_pc_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   410
  __ cbz(rscratch1, pc_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   411
  __ stop("exception pc already set");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   412
  __ bind(pc_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   413
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   414
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   415
  // save exception oop and issuing pc into JavaThread
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   416
  // (exception handler will load it from here)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   417
  __ str(exception_oop, Address(rthread, JavaThread::exception_oop_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   418
  __ str(exception_pc, Address(rthread, JavaThread::exception_pc_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   419
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   420
  // patch throwing pc into return address (has bci & oop map)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   421
  __ str(exception_pc, Address(rfp, 1*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   422
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   423
  // compute the exception handler.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   424
  // the exception oop and the throwing pc are read from the fields in JavaThread
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   425
  int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   426
  oop_maps->add_gc_map(call_offset, oop_map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   427
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   428
  // r0: handler address
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   429
  //      will be the deopt blob if nmethod was deoptimized while we looked up
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   430
  //      handler regardless of whether handler existed in the nmethod.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   431
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   432
  // only r0 is valid at this time, all other registers have been destroyed by the runtime call
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   433
  __ invalidate_registers(false, true, true, true, true, true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   434
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   435
  // patch the return address, this stub will directly return to the exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   436
  __ str(r0, Address(rfp, 1*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   437
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   438
  switch (id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   439
  case forward_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   440
  case handle_exception_nofpu_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   441
  case handle_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   442
    // Restore the registers that were saved at the beginning.
29189
9252ebf92115 8072129: [AARCH64] missing fix for 8066900
enevill
parents: 29184
diff changeset
   443
    restore_live_registers(sasm, id != handle_exception_nofpu_id);
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   444
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   445
  case handle_exception_from_callee_id:
30552
ff209a4a81b5 8079564: Use FP register as proper frame pointer in JIT compiled code on aarch64
enevill
parents: 29189
diff changeset
   446
    // Pop the return address.
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   447
    __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   448
    __ ret(lr);  // jump to exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   449
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   450
  default:  ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   451
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   452
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   453
  return oop_maps;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   454
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   455
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   456
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   457
void Runtime1::generate_unwind_exception(StubAssembler *sasm) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   458
  // incoming parameters
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   459
  const Register exception_oop = r0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   460
  // callee-saved copy of exception_oop during runtime call
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   461
  const Register exception_oop_callee_saved = r19;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   462
  // other registers used in this stub
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   463
  const Register exception_pc = r3;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   464
  const Register handler_addr = r1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   465
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   466
  // verify that only r0, is valid at this time
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   467
  __ invalidate_registers(false, true, true, true, true, true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   468
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   469
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   470
  // check that fields in JavaThread for exception oop and issuing pc are empty
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   471
  Label oop_empty;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   472
  __ ldr(rscratch1, Address(rthread, JavaThread::exception_oop_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   473
  __ cbz(rscratch1, oop_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   474
  __ stop("exception oop must be empty");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   475
  __ bind(oop_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   476
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   477
  Label pc_empty;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   478
  __ ldr(rscratch1, Address(rthread, JavaThread::exception_pc_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   479
  __ cbz(rscratch1, pc_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   480
  __ stop("exception pc must be empty");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   481
  __ bind(pc_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   482
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   483
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   484
  // Save our return address because
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   485
  // exception_handler_for_return_address will destroy it.  We also
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   486
  // save exception_oop
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   487
  __ stp(lr, exception_oop, Address(__ pre(sp, -2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   488
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   489
  // search the exception handler address of the caller (using the return address)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   490
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), rthread, lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   491
  // r0: exception handler address of the caller
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   492
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   493
  // Only R0 is valid at this time; all other registers have been
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   494
  // destroyed by the call.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   495
  __ invalidate_registers(false, true, true, true, false, true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   496
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   497
  // move result of call into correct register
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   498
  __ mov(handler_addr, r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   499
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   500
  // get throwing pc (= return address).
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   501
  // lr has been destroyed by the call
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   502
  __ ldp(lr, exception_oop, Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   503
  __ mov(r3, lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   504
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   505
  __ verify_not_null_oop(exception_oop);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   506
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   507
  // continue at exception handler (return address removed)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   508
  // note: do *not* remove arguments when unwinding the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   509
  //       activation since the caller assumes having
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   510
  //       all arguments on the stack when entering the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   511
  //       runtime to determine the exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   512
  //       (GC happens at call site with arguments!)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   513
  // r0: exception oop
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   514
  // r3: throwing pc
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   515
  // r1: exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   516
  __ br(handler_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   517
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   518
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   519
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   520
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   521
OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   522
  // use the maximum number of runtime-arguments here because it is difficult to
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   523
  // distinguish each RT-Call.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   524
  // Note: This number affects also the RT-Call in generate_handle_exception because
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   525
  //       the oop-map is shared for all calls.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   526
  DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   527
  assert(deopt_blob != NULL, "deoptimization blob must have been created");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   528
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   529
  OopMap* oop_map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   530
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   531
  __ mov(c_rarg0, rthread);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   532
  Label retaddr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   533
  __ set_last_Java_frame(sp, rfp, retaddr, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   534
  // do the call
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   535
  __ lea(rscratch1, RuntimeAddress(target));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   536
  __ blrt(rscratch1, 1, 0, 1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   537
  __ bind(retaddr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   538
  OopMapSet* oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   539
  oop_maps->add_gc_map(__ offset(), oop_map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   540
  // verify callee-saved register
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   541
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   542
  { Label L;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   543
    __ get_thread(rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   544
    __ cmp(rthread, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   545
    __ br(Assembler::EQ, L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   546
    __ stop("StubAssembler::call_RT: rthread not callee saved?");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   547
    __ bind(L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   548
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   549
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   550
  __ reset_last_Java_frame(true, false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   551
  __ maybe_isb();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   552
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   553
  // check for pending exceptions
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   554
  { Label L;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   555
    __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   556
    __ cbz(rscratch1, L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   557
    // exception pending => remove activation and forward to exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   558
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   559
    { Label L1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   560
      __ cbnz(r0, L1);                                  // have we deoptimized?
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   561
      __ far_jump(RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   562
      __ bind(L1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   563
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   564
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   565
    // the deopt blob expects exceptions in the special fields of
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   566
    // JavaThread, so copy and clear pending exception.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   567
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   568
    // load and clear pending exception
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   569
    __ ldr(r0, Address(rthread, Thread::pending_exception_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   570
    __ str(zr, Address(rthread, Thread::pending_exception_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   571
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   572
    // check that there is really a valid exception
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   573
    __ verify_not_null_oop(r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   574
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   575
    // load throwing pc: this is the return address of the stub
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   576
    __ mov(r3, lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   577
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   578
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   579
    // check that fields in JavaThread for exception oop and issuing pc are empty
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   580
    Label oop_empty;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   581
    __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   582
    __ cbz(rscratch1, oop_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   583
    __ stop("exception oop must be empty");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   584
    __ bind(oop_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   585
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   586
    Label pc_empty;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   587
    __ ldr(rscratch1, Address(rthread, JavaThread::exception_pc_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   588
    __ cbz(rscratch1, pc_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   589
    __ stop("exception pc must be empty");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   590
    __ bind(pc_empty);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   591
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   592
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   593
    // store exception oop and throwing pc to JavaThread
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   594
    __ str(r0, Address(rthread, JavaThread::exception_oop_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   595
    __ str(r3, Address(rthread, JavaThread::exception_pc_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   596
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   597
    restore_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   598
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   599
    __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   600
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   601
    // Forward the exception directly to deopt blob. We can blow no
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   602
    // registers and must leave throwing pc on the stack.  A patch may
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   603
    // have values live in registers so the entry point with the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   604
    // exception in tls.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   605
    __ far_jump(RuntimeAddress(deopt_blob->unpack_with_exception_in_tls()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   606
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   607
    __ bind(L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   608
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   609
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   610
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   611
  // Runtime will return true if the nmethod has been deoptimized during
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   612
  // the patching process. In that case we must do a deopt reexecute instead.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   613
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   614
  Label reexecuteEntry, cont;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   615
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   616
  __ cbz(r0, cont);                                 // have we deoptimized?
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   617
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   618
  // Will reexecute. Proper return address is already on the stack we just restore
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   619
  // registers, pop all of our frame but the return address and jump to the deopt blob
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   620
  restore_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   621
  __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   622
  __ far_jump(RuntimeAddress(deopt_blob->unpack_with_reexecution()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   623
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   624
  __ bind(cont);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   625
  restore_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   626
  __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   627
  __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   628
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   629
  return oop_maps;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   630
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   631
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   632
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   633
OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   634
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   635
  const Register exception_oop = r0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   636
  const Register exception_pc  = r3;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   637
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   638
  // for better readability
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   639
  const bool must_gc_arguments = true;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   640
  const bool dont_gc_arguments = false;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   641
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   642
  // default value; overwritten for some optimized stubs that are called from methods that do not use the fpu
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   643
  bool save_fpu_registers = true;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   644
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   645
  // stub code & info for the different stubs
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   646
  OopMapSet* oop_maps = NULL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   647
  OopMap* oop_map = NULL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   648
  switch (id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   649
    {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   650
    case forward_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   651
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   652
        oop_maps = generate_handle_exception(id, sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   653
        __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   654
        __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   655
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   656
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   657
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   658
    case throw_div0_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   659
      { StubFrame f(sasm, "throw_div0_exception", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   660
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   661
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   662
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   663
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   664
    case throw_null_pointer_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   665
      { StubFrame f(sasm, "throw_null_pointer_exception", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   666
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   667
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   668
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   669
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   670
    case new_instance_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   671
    case fast_new_instance_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   672
    case fast_new_instance_init_check_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   673
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   674
        Register klass = r3; // Incoming
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   675
        Register obj   = r0; // Result
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   676
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   677
        if (id == new_instance_id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   678
          __ set_info("new_instance", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   679
        } else if (id == fast_new_instance_id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   680
          __ set_info("fast new_instance", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   681
        } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   682
          assert(id == fast_new_instance_init_check_id, "bad StubID");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   683
          __ set_info("fast new_instance init check", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   684
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   685
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   686
        if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id) &&
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   687
            UseTLAB && FastTLABRefill) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   688
          Label slow_path;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   689
          Register obj_size = r2;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   690
          Register t1       = r19;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   691
          Register t2       = r4;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   692
          assert_different_registers(klass, obj, obj_size, t1, t2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   693
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   694
          __ stp(r5, r19, Address(__ pre(sp, -2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   695
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   696
          if (id == fast_new_instance_init_check_id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   697
            // make sure the klass is initialized
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   698
            __ ldrb(rscratch1, Address(klass, InstanceKlass::init_state_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   699
            __ cmpw(rscratch1, InstanceKlass::fully_initialized);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   700
            __ br(Assembler::NE, slow_path);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   701
          }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   702
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   703
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   704
          // assert object can be fast path allocated
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   705
          {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   706
            Label ok, not_ok;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   707
            __ ldrw(obj_size, Address(klass, Klass::layout_helper_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   708
            __ cmp(obj_size, 0u);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   709
            __ br(Assembler::LE, not_ok);  // make sure it's an instance (LH > 0)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   710
            __ tstw(obj_size, Klass::_lh_instance_slow_path_bit);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   711
            __ br(Assembler::EQ, ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   712
            __ bind(not_ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   713
            __ stop("assert(can be fast path allocated)");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   714
            __ should_not_reach_here();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   715
            __ bind(ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   716
          }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   717
#endif // ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   718
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   719
          // if we got here then the TLAB allocation failed, so try
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   720
          // refilling the TLAB or allocating directly from eden.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   721
          Label retry_tlab, try_eden;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   722
          __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy r3 (klass), returns r5
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   723
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   724
          __ bind(retry_tlab);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   725
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   726
          // get the instance size (size is postive so movl is fine for 64bit)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   727
          __ ldrw(obj_size, Address(klass, Klass::layout_helper_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   728
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   729
          __ tlab_allocate(obj, obj_size, 0, t1, t2, slow_path);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   730
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   731
          __ initialize_object(obj, klass, obj_size, 0, t1, t2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   732
          __ verify_oop(obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   733
          __ ldp(r5, r19, Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   734
          __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   735
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   736
          __ bind(try_eden);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   737
          // get the instance size (size is postive so movl is fine for 64bit)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   738
          __ ldrw(obj_size, Address(klass, Klass::layout_helper_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   739
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   740
          __ eden_allocate(obj, obj_size, 0, t1, slow_path);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   741
          __ incr_allocated_bytes(rthread, obj_size, 0, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   742
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   743
          __ initialize_object(obj, klass, obj_size, 0, t1, t2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   744
          __ verify_oop(obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   745
          __ ldp(r5, r19, Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   746
          __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   747
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   748
          __ bind(slow_path);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   749
          __ ldp(r5, r19, Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   750
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   751
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   752
        __ enter();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   753
        OopMap* map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   754
        int call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_instance), klass);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   755
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   756
        oop_maps->add_gc_map(call_offset, map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   757
        restore_live_registers_except_r0(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   758
        __ verify_oop(obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   759
        __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   760
        __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   761
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   762
        // r0,: new instance
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   763
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   764
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   765
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   766
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   767
    case counter_overflow_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   768
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   769
        Register bci = r0, method = r1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   770
        __ enter();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   771
        OopMap* map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   772
        // Retrieve bci
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   773
        __ ldrw(bci, Address(rfp, 2*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   774
        // And a pointer to the Method*
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   775
        __ ldr(method, Address(rfp, 3*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   776
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, counter_overflow), bci, method);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   777
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   778
        oop_maps->add_gc_map(call_offset, map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   779
        restore_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   780
        __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   781
        __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   782
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   783
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   784
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   785
    case new_type_array_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   786
    case new_object_array_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   787
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   788
        Register length   = r19; // Incoming
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   789
        Register klass    = r3; // Incoming
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   790
        Register obj      = r0; // Result
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   791
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   792
        if (id == new_type_array_id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   793
          __ set_info("new_type_array", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   794
        } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   795
          __ set_info("new_object_array", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   796
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   797
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   798
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   799
        // assert object type is really an array of the proper kind
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   800
        {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   801
          Label ok;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   802
          Register t0 = obj;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   803
          __ ldrw(t0, Address(klass, Klass::layout_helper_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   804
          __ asrw(t0, t0, Klass::_lh_array_tag_shift);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   805
          int tag = ((id == new_type_array_id)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   806
                     ? Klass::_lh_array_tag_type_value
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   807
                     : Klass::_lh_array_tag_obj_value);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   808
          __ mov(rscratch1, tag);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   809
          __ cmpw(t0, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   810
          __ br(Assembler::EQ, ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   811
          __ stop("assert(is an array klass)");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   812
          __ should_not_reach_here();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   813
          __ bind(ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   814
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   815
#endif // ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   816
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   817
        if (UseTLAB && FastTLABRefill) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   818
          Register arr_size = r4;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   819
          Register t1       = r2;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   820
          Register t2       = r5;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   821
          Label slow_path;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   822
          assert_different_registers(length, klass, obj, arr_size, t1, t2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   823
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   824
          // check that array length is small enough for fast path.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   825
          __ mov(rscratch1, C1_MacroAssembler::max_array_allocation_length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   826
          __ cmpw(length, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   827
          __ br(Assembler::HI, slow_path);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   828
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   829
          // if we got here then the TLAB allocation failed, so try
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   830
          // refilling the TLAB or allocating directly from eden.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   831
          Label retry_tlab, try_eden;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   832
          const Register thread =
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   833
            __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves r19 & r3, returns rthread
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   834
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   835
          __ bind(retry_tlab);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   836
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   837
          // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F))
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   838
          // since size is positive ldrw does right thing on 64bit
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   839
          __ ldrw(t1, Address(klass, Klass::layout_helper_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   840
          __ lslvw(arr_size, length, t1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   841
          __ ubfx(t1, t1, Klass::_lh_header_size_shift,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   842
                  exact_log2(Klass::_lh_header_size_mask + 1));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   843
          __ add(arr_size, arr_size, t1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   844
          __ add(arr_size, arr_size, MinObjAlignmentInBytesMask); // align up
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   845
          __ andr(arr_size, arr_size, ~MinObjAlignmentInBytesMask);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   846
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   847
          __ tlab_allocate(obj, arr_size, 0, t1, t2, slow_path);  // preserves arr_size
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   848
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   849
          __ initialize_header(obj, klass, length, t1, t2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   850
          __ ldrb(t1, Address(klass, in_bytes(Klass::layout_helper_offset()) + (Klass::_lh_header_size_shift / BitsPerByte)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   851
          assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   852
          assert(Klass::_lh_header_size_mask <= 0xFF, "bytewise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   853
          __ andr(t1, t1, Klass::_lh_header_size_mask);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   854
          __ sub(arr_size, arr_size, t1);  // body length
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   855
          __ add(t1, t1, obj);       // body start
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   856
          __ initialize_body(t1, arr_size, 0, t2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   857
          __ verify_oop(obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   858
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   859
          __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   860
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   861
          __ bind(try_eden);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   862
          // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F))
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   863
          // since size is positive ldrw does right thing on 64bit
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   864
          __ ldrw(t1, Address(klass, Klass::layout_helper_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   865
          // since size is postive movw does right thing on 64bit
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   866
          __ movw(arr_size, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   867
          __ lslvw(arr_size, length, t1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   868
          __ ubfx(t1, t1, Klass::_lh_header_size_shift,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   869
                  exact_log2(Klass::_lh_header_size_mask + 1));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   870
          __ add(arr_size, arr_size, t1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   871
          __ add(arr_size, arr_size, MinObjAlignmentInBytesMask); // align up
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   872
          __ andr(arr_size, arr_size, ~MinObjAlignmentInBytesMask);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   873
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   874
          __ eden_allocate(obj, arr_size, 0, t1, slow_path);  // preserves arr_size
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   875
          __ incr_allocated_bytes(thread, arr_size, 0, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   876
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   877
          __ initialize_header(obj, klass, length, t1, t2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   878
          __ ldrb(t1, Address(klass, in_bytes(Klass::layout_helper_offset()) + (Klass::_lh_header_size_shift / BitsPerByte)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   879
          assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   880
          assert(Klass::_lh_header_size_mask <= 0xFF, "bytewise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   881
          __ andr(t1, t1, Klass::_lh_header_size_mask);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   882
          __ sub(arr_size, arr_size, t1);  // body length
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   883
          __ add(t1, t1, obj);       // body start
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   884
          __ initialize_body(t1, arr_size, 0, t2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   885
          __ verify_oop(obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   886
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   887
          __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   888
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   889
          __ bind(slow_path);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   890
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   891
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   892
        __ enter();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   893
        OopMap* map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   894
        int call_offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   895
        if (id == new_type_array_id) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   896
          call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_type_array), klass, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   897
        } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   898
          call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_object_array), klass, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   899
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   900
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   901
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   902
        oop_maps->add_gc_map(call_offset, map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   903
        restore_live_registers_except_r0(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   904
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   905
        __ verify_oop(obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   906
        __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   907
        __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   908
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   909
        // r0: new array
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   910
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   911
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   912
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   913
    case new_multi_array_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   914
      { StubFrame f(sasm, "new_multi_array", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   915
        // r0,: klass
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   916
        // r19,: rank
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   917
        // r2: address of 1st dimension
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   918
        OopMap* map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   919
        __ mov(c_rarg1, r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   920
        __ mov(c_rarg3, r2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   921
        __ mov(c_rarg2, r19);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   922
        int call_offset = __ call_RT(r0, noreg, CAST_FROM_FN_PTR(address, new_multi_array), r1, r2, r3);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   923
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   924
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   925
        oop_maps->add_gc_map(call_offset, map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   926
        restore_live_registers_except_r0(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   927
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   928
        // r0,: new multi array
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   929
        __ verify_oop(r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   930
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   931
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   932
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   933
    case register_finalizer_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   934
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   935
        __ set_info("register_finalizer", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   936
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   937
        // This is called via call_runtime so the arguments
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   938
        // will be place in C abi locations
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   939
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   940
        __ verify_oop(c_rarg0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   941
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   942
        // load the klass and check the has finalizer flag
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   943
        Label register_finalizer;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   944
        Register t = r5;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   945
        __ load_klass(t, r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   946
        __ ldrw(t, Address(t, Klass::access_flags_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   947
        __ tst(t, JVM_ACC_HAS_FINALIZER);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   948
        __ br(Assembler::NE, register_finalizer);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   949
        __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   950
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   951
        __ bind(register_finalizer);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   952
        __ enter();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   953
        OopMap* oop_map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   954
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, SharedRuntime::register_finalizer), r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   955
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   956
        oop_maps->add_gc_map(call_offset, oop_map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   957
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   958
        // Now restore all the live registers
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   959
        restore_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   960
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   961
        __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   962
        __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   963
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   964
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   965
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   966
    case throw_class_cast_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   967
      { StubFrame f(sasm, "throw_class_cast_exception", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   968
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   969
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   970
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   971
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   972
    case throw_incompatible_class_change_error_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   973
      { StubFrame f(sasm, "throw_incompatible_class_cast_exception", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   974
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   975
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   976
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   977
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   978
    case slow_subtype_check_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   979
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   980
        // Typical calling sequence:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   981
        // __ push(klass_RInfo);  // object klass or other subclass
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   982
        // __ push(sup_k_RInfo);  // array element klass or other superclass
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   983
        // __ bl(slow_subtype_check);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   984
        // Note that the subclass is pushed first, and is therefore deepest.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   985
        enum layout {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   986
          r0_off, r0_off_hi,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   987
          r2_off, r2_off_hi,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   988
          r4_off, r4_off_hi,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   989
          r5_off, r5_off_hi,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   990
          sup_k_off, sup_k_off_hi,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   991
          klass_off, klass_off_hi,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   992
          framesize,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   993
          result_off = sup_k_off
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   994
        };
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   995
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   996
        __ set_info("slow_subtype_check", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   997
        __ push(RegSet::of(r0, r2, r4, r5), sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   998
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   999
        // This is called by pushing args and not with C abi
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1000
        // __ ldr(r4, Address(sp, (klass_off) * VMRegImpl::stack_slot_size)); // subclass
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1001
        // __ ldr(r0, Address(sp, (sup_k_off) * VMRegImpl::stack_slot_size)); // superclass
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1002
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1003
        __ ldp(r4, r0, Address(sp, (sup_k_off) * VMRegImpl::stack_slot_size));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1004
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1005
        Label miss;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1006
        __ check_klass_subtype_slow_path(r4, r0, r2, r5, NULL, &miss);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1007
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1008
        // fallthrough on success:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1009
        __ mov(rscratch1, 1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1010
        __ str(rscratch1, Address(sp, (result_off) * VMRegImpl::stack_slot_size)); // result
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1011
        __ pop(RegSet::of(r0, r2, r4, r5), sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1012
        __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1013
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1014
        __ bind(miss);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1015
        __ str(zr, Address(sp, (result_off) * VMRegImpl::stack_slot_size)); // result
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1016
        __ pop(RegSet::of(r0, r2, r4, r5), sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1017
        __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1018
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1019
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1020
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1021
    case monitorenter_nofpu_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1022
      save_fpu_registers = false;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1023
      // fall through
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1024
    case monitorenter_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1025
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1026
        StubFrame f(sasm, "monitorenter", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1027
        OopMap* map = save_live_registers(sasm, save_fpu_registers);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1028
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1029
        // Called with store_parameter and not C abi
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1030
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1031
        f.load_argument(1, r0); // r0,: object
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1032
        f.load_argument(0, r1); // r1,: lock address
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1033
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1034
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), r0, r1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1035
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1036
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1037
        oop_maps->add_gc_map(call_offset, map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1038
        restore_live_registers(sasm, save_fpu_registers);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1039
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1040
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1041
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1042
    case monitorexit_nofpu_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1043
      save_fpu_registers = false;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1044
      // fall through
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1045
    case monitorexit_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1046
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1047
        StubFrame f(sasm, "monitorexit", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1048
        OopMap* map = save_live_registers(sasm, save_fpu_registers);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1049
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1050
        // Called with store_parameter and not C abi
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1051
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1052
        f.load_argument(0, r0); // r0,: lock address
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1053
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1054
        // note: really a leaf routine but must setup last java sp
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1055
        //       => use call_RT for now (speed can be improved by
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1056
        //       doing last java sp setup manually)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1057
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1058
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1059
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1060
        oop_maps->add_gc_map(call_offset, map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1061
        restore_live_registers(sasm, save_fpu_registers);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1062
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1063
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1064
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1065
    case deoptimize_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1066
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1067
        StubFrame f(sasm, "deoptimize", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1068
        OopMap* oop_map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1069
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, deoptimize));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1070
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1071
        oop_maps->add_gc_map(call_offset, oop_map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1072
        restore_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1073
        DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1074
        assert(deopt_blob != NULL, "deoptimization blob must have been created");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1075
        __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1076
        __ far_jump(RuntimeAddress(deopt_blob->unpack_with_reexecution()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1077
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1078
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1079
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1080
    case throw_range_check_failed_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1081
      { StubFrame f(sasm, "range_check_failed", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1082
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1083
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1084
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1085
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1086
    case unwind_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1087
      { __ set_info("unwind_exception", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1088
        // note: no stubframe since we are about to leave the current
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1089
        //       activation and we are calling a leaf VM function only.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1090
        generate_unwind_exception(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1091
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1092
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1093
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1094
    case access_field_patching_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1095
      { StubFrame f(sasm, "access_field_patching", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1096
        // we should set up register map
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1097
        oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1098
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1099
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1100
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1101
    case load_klass_patching_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1102
      { StubFrame f(sasm, "load_klass_patching", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1103
        // we should set up register map
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1104
        oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1105
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1106
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1107
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1108
    case load_mirror_patching_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1109
      { StubFrame f(sasm, "load_mirror_patching", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1110
        // we should set up register map
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1111
        oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1112
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1113
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1114
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1115
    case load_appendix_patching_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1116
      { StubFrame f(sasm, "load_appendix_patching", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1117
        // we should set up register map
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1118
        oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1119
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1120
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1121
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1122
    case handle_exception_nofpu_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1123
    case handle_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1124
      { StubFrame f(sasm, "handle_exception", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1125
        oop_maps = generate_handle_exception(id, sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1126
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1127
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1128
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1129
    case handle_exception_from_callee_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1130
      { StubFrame f(sasm, "handle_exception_from_callee", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1131
        oop_maps = generate_handle_exception(id, sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1132
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1133
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1134
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1135
    case throw_index_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1136
      { StubFrame f(sasm, "index_range_check_failed", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1137
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1138
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1139
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1140
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1141
    case throw_array_store_exception_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1142
      { StubFrame f(sasm, "throw_array_store_exception", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1143
        // tos + 0: link
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1144
        //     + 1: return address
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1145
        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1146
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1147
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1148
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1149
#if INCLUDE_ALL_GCS
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1150
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1151
// Registers to be saved around calls to g1_wb_pre or g1_wb_post
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1152
#define G1_SAVE_REGS (RegSet::range(r0, r18) - RegSet::of(rscratch1, rscratch2))
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1153
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1154
    case g1_pre_barrier_slow_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1155
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1156
        StubFrame f(sasm, "g1_pre_barrier", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1157
        // arg0 : previous value of memory
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1158
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1159
        BarrierSet* bs = Universe::heap()->barrier_set();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1160
        if (bs->kind() != BarrierSet::G1SATBCTLogging) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1161
          __ mov(r0, (int)id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1162
          __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1163
          __ should_not_reach_here();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1164
          break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1165
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1166
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1167
        const Register pre_val = r0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1168
        const Register thread = rthread;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1169
        const Register tmp = rscratch1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1170
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1171
        Address in_progress(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 30777
diff changeset
  1172
                                             SATBMarkQueue::byte_offset_of_active()));
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1173
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1174
        Address queue_index(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 30777
diff changeset
  1175
                                             SATBMarkQueue::byte_offset_of_index()));
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1176
        Address buffer(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 30777
diff changeset
  1177
                                        SATBMarkQueue::byte_offset_of_buf()));
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1178
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1179
        Label done;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1180
        Label runtime;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1181
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1182
        // Can we store original value in the thread's buffer?
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1183
        __ ldr(tmp, queue_index);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1184
        __ cbz(tmp, runtime);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1185
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1186
        __ sub(tmp, tmp, wordSize);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1187
        __ str(tmp, queue_index);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1188
        __ ldr(rscratch2, buffer);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1189
        __ add(tmp, tmp, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1190
        f.load_argument(0, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1191
        __ str(rscratch2, Address(tmp, 0));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1192
        __ b(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1193
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1194
        __ bind(runtime);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1195
        __ push(G1_SAVE_REGS, sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1196
        f.load_argument(0, pre_val);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1197
        __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, thread);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1198
        __ pop(G1_SAVE_REGS, sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1199
        __ bind(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1200
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1201
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1202
    case g1_post_barrier_slow_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1203
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1204
        StubFrame f(sasm, "g1_post_barrier", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1205
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1206
        // arg0: store_address
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1207
        Address store_addr(rfp, 2*BytesPerWord);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1208
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1209
        BarrierSet* bs = Universe::heap()->barrier_set();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1210
        CardTableModRefBS* ct = (CardTableModRefBS*)bs;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1211
        assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1212
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1213
        Label done;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1214
        Label runtime;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1215
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1216
        // At this point we know new_value is non-NULL and the new_value crosses regions.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1217
        // Must check to see if card is already dirty
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1218
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1219
        const Register thread = rthread;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1220
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1221
        Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 30777
diff changeset
  1222
                                             DirtyCardQueue::byte_offset_of_index()));
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1223
        Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 30777
diff changeset
  1224
                                        DirtyCardQueue::byte_offset_of_buf()));
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1225
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1226
        const Register card_addr = rscratch2;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1227
        ExternalAddress cardtable((address) ct->byte_map_base);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1228
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1229
        f.load_argument(0, card_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1230
        __ lsr(card_addr, card_addr, CardTableModRefBS::card_shift);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1231
        unsigned long offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1232
        __ adrp(rscratch1, cardtable, offset);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1233
        __ add(card_addr, card_addr, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1234
        __ ldrb(rscratch1, Address(card_addr, offset));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1235
        __ cmpw(rscratch1, (int)G1SATBCardTableModRefBS::g1_young_card_val());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1236
        __ br(Assembler::EQ, done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1237
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1238
        assert((int)CardTableModRefBS::dirty_card_val() == 0, "must be 0");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1239
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1240
        __ membar(Assembler::StoreLoad);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1241
        __ ldrb(rscratch1, Address(card_addr, offset));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1242
        __ cbzw(rscratch1, done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1243
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1244
        // storing region crossing non-NULL, card is clean.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1245
        // dirty card and log.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1246
        __ strb(zr, Address(card_addr, offset));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1247
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1248
        __ ldr(rscratch1, queue_index);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1249
        __ cbz(rscratch1, runtime);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1250
        __ sub(rscratch1, rscratch1, wordSize);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1251
        __ str(rscratch1, queue_index);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1252
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1253
        const Register buffer_addr = r0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1254
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1255
        __ push(RegSet::of(r0, r1), sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1256
        __ ldr(buffer_addr, buffer);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1257
        __ str(card_addr, Address(buffer_addr, rscratch1));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1258
        __ pop(RegSet::of(r0, r1), sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1259
        __ b(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1260
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1261
        __ bind(runtime);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1262
        __ push(G1_SAVE_REGS, sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1263
        __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1264
        __ pop(G1_SAVE_REGS, sp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1265
        __ bind(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1266
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1267
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1268
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1269
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1270
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1271
    case predicate_failed_trap_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1272
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1273
        StubFrame f(sasm, "predicate_failed_trap", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1274
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1275
        OopMap* map = save_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1276
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1277
        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1278
        oop_maps = new OopMapSet();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1279
        oop_maps->add_gc_map(call_offset, map);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1280
        restore_live_registers(sasm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1281
        __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1282
        DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1283
        assert(deopt_blob != NULL, "deoptimization blob must have been created");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1284
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1285
        __ far_jump(RuntimeAddress(deopt_blob->unpack_with_reexecution()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1286
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1287
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1288
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1289
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1290
    default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1291
      { StubFrame f(sasm, "unimplemented entry", dont_gc_arguments);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1292
        __ mov(r0, (int)id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1293
        __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1294
        __ should_not_reach_here();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1295
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1296
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1297
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1298
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1299
  return oop_maps;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1300
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1301
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1302
#undef __
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1303
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1304
const char *Runtime1::pd_name_for_address(address entry) { Unimplemented(); return 0; }