src/hotspot/cpu/arm/vtableStubs_arm.cpp
author dholmes
Tue, 05 Nov 2019 18:42:10 -0500
changeset 58942 5db99b3d6023
parent 52351 0ecb4e520110
permissions -rw-r--r--
8233599: ARM32 Build failed due to 8232050 missing an include Reviewed-by: dholmes Contributed-by: Markus Knetschke <markus.knetschke@gmail.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     1
/*
58942
5db99b3d6023 8233599: ARM32 Build failed due to 8232050 missing an include
dholmes
parents: 52351
diff changeset
     2
 * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     4
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     7
 * published by the Free Software Foundation.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     8
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    13
 * accompanied this code).
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    14
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    18
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    21
 * questions.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    22
 *
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    23
 */
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    24
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    25
#include "precompiled.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    26
#include "asm/assembler.hpp"
50380
bec342339138 8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents: 49368
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    28
#include "assembler_arm.inline.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    29
#include "code/vtableStubs.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    30
#include "interp_masm_arm.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    31
#include "memory/resourceArea.hpp"
48557
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
    32
#include "oops/compiledICHolder.hpp"
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    33
#include "oops/instanceKlass.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    34
#include "oops/klassVtable.hpp"
58942
5db99b3d6023 8233599: ARM32 Build failed due to 8232050 missing an include
dholmes
parents: 52351
diff changeset
    35
#include "oops/klass.inline.hpp"
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    36
#include "runtime/sharedRuntime.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    37
#include "vmreg_arm.inline.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    38
#ifdef COMPILER2
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    39
#include "opto/runtime.hpp"
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    40
#endif
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    41
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    42
// machine-dependent part of VtableStubs: create VtableStub of correct size and
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    43
// initialize its code
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    44
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    45
#define __ masm->
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    46
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    47
#ifndef PRODUCT
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    48
extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index);
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    49
#endif
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    50
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    51
VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    52
  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    53
  const int stub_code_length = code_size_limit(true);
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    54
  VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    55
  // Can be NULL if there is no free space in the code cache.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    56
  if (s == NULL) {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    57
    return NULL;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    58
  }
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    59
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    60
  // Count unused bytes in instruction sequences of variable size.
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    61
  // We add them to the computed buffer size in order to avoid
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    62
  // overflow in subsequently generated stubs.
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    63
  address   start_pc;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    64
  int       slop_bytes = 0;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    65
  int       slop_delta = 0;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    66
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    67
  ResourceMark    rm;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    68
  CodeBuffer      cb(s->entry_point(), stub_code_length);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    69
  MacroAssembler* masm = new MacroAssembler(&cb);
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    70
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    71
#if (!defined(PRODUCT) && defined(COMPILER2))
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    72
  if (CountCompiledCalls) {
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    73
    // Implementation required?
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    74
  }
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    75
#endif
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    76
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    77
  assert(VtableStub::receiver_location() == R0->as_VMReg(), "receiver expected in R0");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    78
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    79
  const Register tmp = Rtemp; // Rtemp OK, should be free at call sites
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    80
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    81
  address npe_addr = __ pc();
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    82
  __ load_klass(tmp, R0);
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    83
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    84
#ifndef PRODUCT
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    85
  if (DebugVtables) {
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    86
    // Implementation required?
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    87
  }
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    88
#endif
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    89
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    90
  start_pc = __ pc();
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    91
  { // lookup virtual method
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    92
    int entry_offset = in_bytes(Klass::vtable_start_offset()) + vtable_index * vtableEntry::size_in_bytes();
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    93
    int method_offset = vtableEntry::method_offset_in_bytes() + entry_offset;
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
    94
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    95
    assert ((method_offset & (wordSize - 1)) == 0, "offset should be aligned");
52351
0ecb4e520110 8209093: JEP 340: One AArch64 Port, Not Two
bobv
parents: 51618
diff changeset
    96
    int offset_mask = 0xfff;
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    97
    if (method_offset & ~offset_mask) {
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    98
      __ add(tmp, tmp, method_offset & ~offset_mask);
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
    99
    }
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   100
    __ ldr(Rmethod, Address(tmp, method_offset & offset_mask));
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   101
  }
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   102
  slop_delta  = 8 - (int)(__ pc() - start_pc);
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   103
  slop_bytes += slop_delta;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   104
  assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   105
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   106
#ifndef PRODUCT
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   107
  if (DebugVtables) {
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   108
    // Implementation required?
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   109
  }
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   110
#endif
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   111
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   112
  address ame_addr = __ pc();
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   113
  __ ldr(PC, Address(Rmethod, Method::from_compiled_offset()));
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   114
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   115
  masm->flush();
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   116
  bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   117
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   118
  return s;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   119
}
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   120
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   121
VtableStub* VtableStubs::create_itable_stub(int itable_index) {
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   122
  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   123
  const int stub_code_length = code_size_limit(false);
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   124
  VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   125
  // Can be NULL if there is no free space in the code cache.
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   126
  if (s == NULL) {
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   127
    return NULL;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   128
  }
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   129
  // Count unused bytes in instruction sequences of variable size.
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   130
  // We add them to the computed buffer size in order to avoid
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   131
  // overflow in subsequently generated stubs.
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   132
  address   start_pc;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   133
  int       slop_bytes = 0;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   134
  int       slop_delta = 0;
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   135
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   136
  ResourceMark    rm;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   137
  CodeBuffer      cb(s->entry_point(), stub_code_length);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   138
  MacroAssembler* masm = new MacroAssembler(&cb);
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   139
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   140
#if (!defined(PRODUCT) && defined(COMPILER2))
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   141
  if (CountCompiledCalls) {
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   142
    // Implementation required?
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   143
  }
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   144
#endif
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   145
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   146
  assert(VtableStub::receiver_location() == R0->as_VMReg(), "receiver expected in R0");
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   147
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   148
  // R0-R3 / R0-R7 registers hold the arguments and cannot be spoiled
52351
0ecb4e520110 8209093: JEP 340: One AArch64 Port, Not Two
bobv
parents: 51618
diff changeset
   149
  const Register Rclass  = R4;
0ecb4e520110 8209093: JEP 340: One AArch64 Port, Not Two
bobv
parents: 51618
diff changeset
   150
  const Register Rintf   = R5;
0ecb4e520110 8209093: JEP 340: One AArch64 Port, Not Two
bobv
parents: 51618
diff changeset
   151
  const Register Rscan   = R6;
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   152
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   153
  Label L_no_such_interface;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   154
48557
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   155
  assert_different_registers(Ricklass, Rclass, Rintf, Rscan, Rtemp);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   156
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   157
  start_pc = __ pc();
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   158
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   159
  // get receiver klass (also an implicit null-check)
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   160
  address npe_addr = __ pc();
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   161
  __ load_klass(Rclass, R0);
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   162
48557
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   163
  // Receiver subtype check against REFC.
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   164
  __ ldr(Rintf, Address(Ricklass, CompiledICHolder::holder_klass_offset()));
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   165
  __ lookup_interface_method(// inputs: rec. class, interface, itable index
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   166
                             Rclass, Rintf, noreg,
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   167
                             // outputs: temp reg1, temp reg2
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   168
                             noreg, Rscan, Rtemp,
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   169
                             L_no_such_interface);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   170
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   171
  const ptrdiff_t  typecheckSize = __ pc() - start_pc;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   172
  start_pc = __ pc();
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   173
48557
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   174
  // Get Method* and entry point for compiler
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   175
  __ ldr(Rintf, Address(Ricklass, CompiledICHolder::holder_metadata_offset()));
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   176
  __ lookup_interface_method(// inputs: rec. class, interface, itable index
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   177
                             Rclass, Rintf, itable_index,
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   178
                             // outputs: temp reg1, temp reg2, temp reg3
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   179
                             Rmethod, Rscan, Rtemp,
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   180
                             L_no_such_interface);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   181
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   182
  const ptrdiff_t lookupSize = __ pc() - start_pc;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   183
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   184
  // Reduce "estimate" such that "padding" does not drop below 8.
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   185
  const ptrdiff_t estimate = 140;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   186
  const ptrdiff_t codesize = typecheckSize + lookupSize;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   187
  slop_delta  = (int)(estimate - codesize);
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   188
  slop_bytes += slop_delta;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   189
  assert(slop_delta >= 0, "itable #%d: Code size estimate (%d) for lookup_interface_method too small, required: %d", itable_index, (int)estimate, (int)codesize);
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   190
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   191
#ifndef PRODUCT
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   192
  if (DebugVtables) {
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   193
    // Implementation required?
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   194
  }
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   195
#endif
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   196
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   197
  address ame_addr = __ pc();
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   198
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   199
  __ ldr(PC, Address(Rmethod, Method::from_compiled_offset()));
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   200
48557
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   201
  __ bind(L_no_such_interface);
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48557
diff changeset
   202
  // Handle IncompatibleClassChangeError in itable stubs.
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48557
diff changeset
   203
  // More detailed error message.
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48557
diff changeset
   204
  // We force resolving of the call site by jumping to the "handle
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48557
diff changeset
   205
  // wrong method" stub, and so let the interpreter runtime do all the
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48557
diff changeset
   206
  // dirty work.
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48557
diff changeset
   207
  assert(SharedRuntime::get_handle_wrong_method_stub() != NULL, "check initialization order");
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 48557
diff changeset
   208
  __ jump(SharedRuntime::get_handle_wrong_method_stub(), relocInfo::runtime_call_type, Rtemp);
48557
2e867226b914 8174962: Better interface invocations
vlivanov
parents: 47216
diff changeset
   209
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   210
  masm->flush();
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   211
  bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, 0);
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   212
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   213
  return s;
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   214
}
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   215
51618
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   216
int VtableStub::pd_code_alignment() {
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   217
  // ARM32 cache line size is not an architected constant. We just align on word size.
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   218
  const unsigned int icache_line_size = wordSize;
54b344d9dd4e 8207343: Automate vtable/itable stub size calculation
lucy
parents: 50380
diff changeset
   219
  return icache_line_size;
42664
29142a56c193 8168503: JEP 297: Unified arm32/arm64 Port
bobv
parents:
diff changeset
   220
}