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