src/hotspot/cpu/x86/compiledIC_x86.cpp
author goetz
Fri, 19 Jan 2018 17:01:34 +0100
changeset 48807 fd8ccb37fce9
parent 48487 abf1d797e380
child 51996 84743156e780
permissions -rw-r--r--
8195776: [x86,sparc] A row of minor fixes and enhancements. Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
     1
/*
48807
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 48487
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
     4
 *
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
     7
 * published by the Free Software Foundation.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
     8
 *
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    13
 * accompanied this code).
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    14
 *
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    18
 *
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    21
 * questions.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    22
 *
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    23
 */
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    24
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    25
#include "precompiled.hpp"
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    26
#include "asm/macroAssembler.inline.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    27
#include "code/codeCache.hpp"
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    28
#include "code/compiledIC.hpp"
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    29
#include "code/icBuffer.hpp"
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    30
#include "code/nmethod.hpp"
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    31
#include "memory/resourceArea.hpp"
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    32
#include "runtime/mutexLocker.hpp"
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    33
#include "runtime/safepoint.hpp"
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    34
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    35
// ----------------------------------------------------------------------------
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    36
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
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) {
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    39
  // Stub is fixed up when the corresponding call is converted from
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    40
  // calling compiled code to calling interpreted code.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    41
  // movq rbx, 0
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    42
  // jmp -5 # to self
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
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
  }
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    47
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    48
  // Note that the code buffer's insts_mark is always relative to insts.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    49
  // That's why we must use the macroassembler to generate a stub.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    50
  MacroAssembler _masm(&cbuf);
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    51
32082
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 25359
diff changeset
    52
  address base = __ start_a_stub(to_interp_stub_size());
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 25359
diff changeset
    53
  if (base == NULL) {
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 25359
diff changeset
    54
    return NULL;  // CodeBuffer::expand failed.
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 25359
diff changeset
    55
  }
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    56
  // Static stub relocation stores the instruction address of the call.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    57
  __ relocate(static_stub_Relocation::spec(mark, false), Assembler::imm_operand);
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    58
  // Static stub relocation also tags the Method* in the code-stream.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    59
  __ mov_metadata(rbx, (Metadata*) NULL);  // Method is zapped till fixup time.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    60
  // This is recognized as unresolved by relocs/nativeinst/ic code.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    61
  __ jump(RuntimeAddress(__ pc()));
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    62
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
    63
  assert(__ pc() - base <= to_interp_stub_size(), "wrong stub size");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
    64
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    65
  // Update current stubs pointer and restore insts_end.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    66
  __ end_a_stub();
32082
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 25359
diff changeset
    67
  return base;
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    68
}
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    69
#undef __
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    70
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    71
int CompiledStaticCall::to_interp_stub_size() {
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    72
  return NOT_LP64(10)    // movl; jmp
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    73
         LP64_ONLY(15);  // movq (1+1+8); jmp (1+4)
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    74
}
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    75
48487
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    76
int CompiledStaticCall::to_trampoline_stub_size() {
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    77
  // x86 doesn't use trampolines.
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    78
  return 0;
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    79
}
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
    80
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    81
// Relocation entries for call stub, compiled java to interpreter.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    82
int CompiledStaticCall::reloc_to_interp_stub() {
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    83
  return 4; // 3 in emit_to_interp_stub + 1 in emit_call
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    84
}
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
    85
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    86
#if INCLUDE_AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    87
#define __ _masm.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    88
void CompiledStaticCall::emit_to_aot_stub(CodeBuffer &cbuf, address mark) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    89
  if (!UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    90
    return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    91
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    92
  // Stub is fixed up when the corresponding call is converted from
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    93
  // calling compiled code to calling aot code.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    94
  // movq rax, imm64_aot_code_address
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    95
  // jmp  rax
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    96
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    97
  if (mark == NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    98
    mark = cbuf.insts_mark();  // Get mark within main instrs section.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
    99
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   100
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   101
  // Note that the code buffer's insts_mark is always relative to insts.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   102
  // That's why we must use the macroassembler to generate a stub.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   103
  MacroAssembler _masm(&cbuf);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   104
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   105
  address base =
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   106
  __ start_a_stub(to_aot_stub_size());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   107
  guarantee(base != NULL, "out of space");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   108
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   109
  // Static stub relocation stores the instruction address of the call.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   110
  __ relocate(static_stub_Relocation::spec(mark, true /* is_aot */), Assembler::imm_operand);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   111
  // Load destination AOT code address.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   112
#ifdef _LP64
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   113
  __ mov64(rax, CONST64(0));  // address is zapped till fixup time.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   114
#else
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   115
  __ movl(rax, 0);  // address is zapped till fixup time.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   116
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   117
  // This is recognized as unresolved by relocs/nativeinst/ic code.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   118
  __ jmp(rax);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   119
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   120
  assert(__ pc() - base <= to_aot_stub_size(), "wrong stub size");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   121
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   122
  // Update current stubs pointer and restore insts_end.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   123
  __ end_a_stub();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   124
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   125
#undef __
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   126
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   127
int CompiledStaticCall::to_aot_stub_size() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   128
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   129
    return NOT_LP64(7)    // movl; jmp
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   130
           LP64_ONLY(12);  // movq (1+1+8); jmp (2)
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   131
  } else {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   132
    return 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   133
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   134
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   135
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   136
// Relocation entries for call stub, compiled java to aot.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   137
int CompiledStaticCall::reloc_to_aot_stub() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   138
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   139
    return 2; // 1 in emit_to_aot_stub + 1 in emit_call
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   140
  } else {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   141
    return 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   142
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   143
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   144
#endif // INCLUDE_AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   145
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   146
void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, address entry) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   147
  address stub = find_stub(false /* is_aot */);
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   148
  guarantee(stub != NULL, "stub not found");
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   149
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   150
  if (TraceICs) {
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   151
    ResourceMark rm;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   152
    tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17094
diff changeset
   153
                  p2i(instruction_address()),
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   154
                  callee->name_and_sig_as_C_string());
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   155
  }
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   156
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   157
  // Creation also verifies the object.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   158
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   159
  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   160
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
   161
#ifdef ASSERT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
   162
  // read the value once
48807
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 48487
diff changeset
   163
  volatile intptr_t data = method_holder->data();
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 48487
diff changeset
   164
  volatile address destination = jump->jump_destination();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
   165
  assert(data == 0 || data == (intptr_t)callee(),
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   166
         "a) MT-unsafe modification of inline cache");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
   167
  assert(destination == (address)-1 || destination == entry,
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   168
         "b) MT-unsafe modification of inline cache");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
   169
#endif
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   170
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   171
  // Update stub.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   172
  method_holder->set_data((intptr_t)callee());
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   173
  jump->set_jump_destination(entry);
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   174
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   175
  // Update jump to call.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   176
  set_destination_mt_safe(stub);
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   177
}
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   178
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   179
void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   180
  assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call");
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   181
  // Reset stub.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   182
  address stub = static_stub->addr();
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   183
  assert(stub != NULL, "stub not found");
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   184
  // Creation also verifies the object.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   185
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   186
  method_holder->set_data(0);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   187
  if (!static_stub->is_aot()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   188
    NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   189
    jump->set_jump_destination((address)-1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   190
  }
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   191
}
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   192
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32082
diff changeset
   193
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   194
//-----------------------------------------------------------------------------
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   195
// Non-product mode code
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   196
#ifndef PRODUCT
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   197
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   198
void CompiledDirectStaticCall::verify() {
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   199
  // Verify call.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   200
  _call->verify();
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   201
  if (os::is_MP()) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   202
    _call->verify_alignment();
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   203
  }
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   204
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   205
#ifdef ASSERT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   206
  CodeBlob *cb = CodeCache::find_blob_unsafe((address) _call);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   207
  assert(cb && !cb->is_aot(), "CompiledDirectStaticCall cannot be used on AOTCompiledMethod");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   208
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   209
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   210
  // Verify stub.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38035
diff changeset
   211
  address stub = find_stub(false /* is_aot */);
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   212
  assert(stub != NULL, "no stub found for static call");
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   213
  // Creation also verifies the object.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   214
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   215
  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   216
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   217
  // Verify state.
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   218
  assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   219
}
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
diff changeset
   220
#endif // !PRODUCT