src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp
author eosterlund
Thu, 01 Nov 2018 14:57:26 +0100
changeset 52384 d6dc479bcdd3
parent 51996 84743156e780
child 54440 23a04fe2aca2
permissions -rw-r--r--
8212681: Refactor IC locking to use a fine grained CompiledICLocker Reviewed-by: coleenp, rehn, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     1
/*
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 50104
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
50104
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
     3
 * Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved.
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     5
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     8
 * published by the Free Software Foundation.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     9
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    14
 * accompanied this code).
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    15
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    19
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    22
 * questions.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    23
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    24
 */
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    25
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    26
#include "precompiled.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    28
#include "code/compiledIC.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    29
#include "code/icBuffer.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    30
#include "code/nmethod.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    31
#include "memory/resourceArea.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    32
#include "runtime/mutexLocker.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    33
#include "runtime/safepoint.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    34
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    35
// ----------------------------------------------------------------------------
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    36
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    37
#define __ _masm.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
    38
address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) {
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    39
  // Stub is fixed up when the corresponding call is converted from
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    40
  // calling compiled code to calling interpreted code.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    41
  // mov rmethod, 0
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    42
  // jmp -4 # to self
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    43
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
    44
  if (mark == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
    45
    mark = cbuf.insts_mark();  // Get mark within main instrs section.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
    46
  }
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    47
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    48
  // Note that the code buffer's insts_mark is always relative to insts.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    49
  // That's why we must use the macroassembler to generate a stub.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    50
  MacroAssembler _masm(&cbuf);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    51
32082
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 29183
diff changeset
    52
  address base = __ start_a_stub(to_interp_stub_size());
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    53
  int offset = __ offset();
32082
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 29183
diff changeset
    54
  if (base == NULL) {
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 29183
diff changeset
    55
    return NULL;  // CodeBuffer::expand failed
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 29183
diff changeset
    56
  }
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    57
  // static stub relocation stores the instruction address of the call
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    58
  __ relocate(static_stub_Relocation::spec(mark));
50104
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    59
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    60
#if INCLUDE_AOT
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    61
  // Don't create a Metadata reloc if we're generating immutable PIC.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    62
  if (cbuf.immutable_PIC()) {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    63
    __ movptr(rmethod, 0);
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    64
  } else {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    65
    __ mov_metadata(rmethod, (Metadata*)NULL);
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    66
  }
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    67
#else
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    68
  __ mov_metadata(rmethod, (Metadata*)NULL);
50104
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    69
#endif
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    70
  __ movptr(rscratch1, 0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    71
  __ br(rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    72
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    73
  assert((__ offset() - offset) <= (int)to_interp_stub_size(), "stub too big");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    74
  __ end_a_stub();
32082
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 29183
diff changeset
    75
  return base;
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    76
}
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    77
#undef __
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    78
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    79
int CompiledStaticCall::to_interp_stub_size() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    80
  return 7 * NativeInstruction::instruction_size;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    81
}
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    82
48487
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    83
int CompiledStaticCall::to_trampoline_stub_size() {
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    84
  // Somewhat pessimistically, we count 3 instructions here (although
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    85
  // there are only two) because we sometimes emit an alignment nop.
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    86
  // Trampoline stubs are always word aligned.
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    87
  return 3 * NativeInstruction::instruction_size + wordSize;
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    88
}
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    89
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    90
// Relocation entries for call stub, compiled java to interpreter.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    91
int CompiledStaticCall::reloc_to_interp_stub() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    92
  return 4; // 3 in emit_to_interp_stub + 1 in emit_call
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    93
}
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    94
50104
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    95
#if INCLUDE_AOT
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    96
#define __ _masm.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    97
void CompiledStaticCall::emit_to_aot_stub(CodeBuffer &cbuf, address mark) {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    98
  if (!UseAOT) {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
    99
    return;
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   100
  }
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   101
  // Stub is fixed up when the corresponding call is converted from
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   102
  // calling compiled code to calling aot code.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   103
  // mov r, imm64_aot_code_address
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   104
  // jmp r
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   105
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   106
  if (mark == NULL) {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   107
    mark = cbuf.insts_mark();  // Get mark within main instrs section.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   108
  }
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   109
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   110
  // Note that the code buffer's insts_mark is always relative to insts.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   111
  // That's why we must use the macroassembler to generate a stub.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   112
  MacroAssembler _masm(&cbuf);
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   113
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   114
  address base =
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   115
  __ start_a_stub(to_aot_stub_size());
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   116
  guarantee(base != NULL, "out of space");
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   117
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   118
  // Static stub relocation stores the instruction address of the call.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   119
  __ relocate(static_stub_Relocation::spec(mark, true /* is_aot */));
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   120
  // Load destination AOT code address.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   121
  __ movptr(rscratch1, 0);  // address is zapped till fixup time.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   122
  // This is recognized as unresolved by relocs/nativeinst/ic code.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   123
  __ br(rscratch1);
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   124
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   125
  assert(__ pc() - base <= to_aot_stub_size(), "wrong stub size");
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   126
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   127
  // Update current stubs pointer and restore insts_end.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   128
  __ end_a_stub();
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   129
}
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   130
#undef __
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   131
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   132
int CompiledStaticCall::to_aot_stub_size() {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   133
  if (UseAOT) {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   134
    return 5 * 4;  // movz; movk; movk; movk; br
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   135
  } else {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   136
    return 0;
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   137
  }
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   138
}
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   139
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   140
// Relocation entries for call stub, compiled java to aot.
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   141
int CompiledStaticCall::reloc_to_aot_stub() {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   142
  if (UseAOT) {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   143
    return 5 * 4;  // movz; movk; movk; movk; br
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   144
  } else {
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   145
    return 0;
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   146
  }
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   147
}
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   148
#endif // INCLUDE_AOT
4ea7917929b9 8185505: AArch64: Port AOT to AArch64
aph
parents: 48487
diff changeset
   149
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38657
diff changeset
   150
void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, address entry) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38657
diff changeset
   151
  address stub = find_stub(false /* is_aot */);
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   152
  guarantee(stub != NULL, "stub not found");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   153
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   154
  if (TraceICs) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   155
    ResourceMark rm;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38657
diff changeset
   156
    tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   157
                  p2i(instruction_address()),
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   158
                  callee->name_and_sig_as_C_string());
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   159
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   160
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   161
  // Creation also verifies the object.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   162
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   163
#ifndef PRODUCT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   164
  NativeGeneralJump* jump = nativeGeneralJump_at(method_holder->next_instruction_address());
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   165
38657
3caf062361a6 8144856: fix assert in CompiledStaticCall::set_to_interpreted
jcm
parents: 38035
diff changeset
   166
  // read the value once
3caf062361a6 8144856: fix assert in CompiledStaticCall::set_to_interpreted
jcm
parents: 38035
diff changeset
   167
  volatile intptr_t data = method_holder->data();
3caf062361a6 8144856: fix assert in CompiledStaticCall::set_to_interpreted
jcm
parents: 38035
diff changeset
   168
  assert(data == 0 || data == (intptr_t)callee(),
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   169
         "a) MT-unsafe modification of inline cache");
38657
3caf062361a6 8144856: fix assert in CompiledStaticCall::set_to_interpreted
jcm
parents: 38035
diff changeset
   170
  assert(data == 0 || jump->jump_destination() == entry,
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   171
         "b) MT-unsafe modification of inline cache");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   172
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   173
  // Update stub.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   174
  method_holder->set_data((intptr_t)callee());
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   175
  NativeGeneralJump::insert_unconditional(method_holder->next_instruction_address(), entry);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   176
  ICache::invalidate_range(stub, to_interp_stub_size());
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   177
  // Update jump to call.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   178
  set_destination_mt_safe(stub);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   179
}
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   180
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38657
diff changeset
   181
void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   182
  // Reset stub.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   183
  address stub = static_stub->addr();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   184
  assert(stub != NULL, "stub not found");
52384
d6dc479bcdd3 8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents: 51996
diff changeset
   185
  assert(CompiledICLocker::is_safe(stub), "mt unsafe call");
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   186
  // Creation also verifies the object.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   187
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   188
  method_holder->set_data(0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   189
}
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   190
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   191
//-----------------------------------------------------------------------------
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   192
// Non-product mode code
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   193
#ifndef PRODUCT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   194
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38657
diff changeset
   195
void CompiledDirectStaticCall::verify() {
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   196
  // Verify call.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38657
diff changeset
   197
  _call->verify();
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 50104
diff changeset
   198
  _call->verify_alignment();
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   199
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   200
  // Verify stub.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38657
diff changeset
   201
  address stub = find_stub(false /* is_aot */);
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   202
  assert(stub != NULL, "no stub found for static call");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   203
  // Creation also verifies the object.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   204
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   205
  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   206
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   207
  // Verify state.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   208
  assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   209
}
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   210
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   211
#endif // !PRODUCT