hotspot/src/cpu/sparc/vm/vtableStubs_sparc.cpp
author twisti
Fri, 13 Feb 2009 09:09:35 -0800
changeset 2031 24e034f56dcb
parent 670 ddf3e9583f2f
child 2149 3d362637b307
permissions -rw-r--r--
6800154: Add comments to long_by_long_mulhi() for better understandability Summary: This patch adds a comment pointing to the Hacker's Delight version of the algorithm plus a verbatim copy of it. Furthermore it adds inline comments. Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 360
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_vtableStubs_sparc.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// machine-dependent part of VtableStubs: create vtableStub of correct size and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// initialize its code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
#define __ masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
extern "C" void bad_compiled_vtable_index(JavaThread* thread, oopDesc* receiver, int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// Used by compiler only; may use only caller saved, non-argument registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// NOTE:  %%%% if any change is made to this stub make sure that the function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//             pd_code_size_limit is changed to ensure the correct size for VtableStub
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  const int sparc_code_length = VtableStub::pd_code_size_limit(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  VtableStub* s = new(sparc_code_length) VtableStub(true, vtable_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  CodeBuffer cb(s->entry_point(), sparc_code_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  MacroAssembler* masm = new MacroAssembler(&cb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  if (CountCompiledCalls) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    Address ctr(G5, SharedRuntime::nof_megamorphic_calls_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    __ sethi(ctr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    __ ld(ctr, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    __ inc(G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    __ st(G3_scratch, ctr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
#endif /* PRODUCT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // get receiver klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  address npe_addr = __ pc();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
    63
  __ load_klass(O0, G3_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // set methodOop (in case of interpreted method), and destination address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  int entry_offset = instanceKlass::vtable_start_offset() + vtable_index*vtableEntry::size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  if (DebugVtables) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    // check offset vs vtable length
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    __ ld(G3_scratch, instanceKlass::vtable_length_offset()*wordSize, G5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    __ cmp(G5, vtable_index*vtableEntry::size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    __ br(Assembler::greaterUnsigned, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    __ set(vtable_index, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), O0, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  int v_off = entry_offset*wordSize + vtableEntry::method_offset_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  if( __ is_simm13(v_off) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    __ ld_ptr(G3, v_off, G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    __ set(v_off,G5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    __ ld_ptr(G3, G5, G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  if (DebugVtables) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    __ br_notnull(G5_method, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    __ stop("Vtable entry is ZERO");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  address ame_addr = __ pc();  // if the vtable entry is null, the method is abstract
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
                               // NOTE: for vtable dispatches, the vtable entry will never be null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  __ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // jump to target (either compiled code or c2iadapter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  __ JMP(G3_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // load methodOop (in case we call c2iadapter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  masm->flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  s->set_exception_points(npe_addr, ame_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  return s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// NOTE:  %%%% if any change is made to this stub make sure that the function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
//             pd_code_size_limit is changed to ensure the correct size for VtableStub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
VtableStub* VtableStubs::create_itable_stub(int vtable_index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  const int sparc_code_length = VtableStub::pd_code_size_limit(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  VtableStub* s = new(sparc_code_length) VtableStub(false, vtable_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  CodeBuffer cb(s->entry_point(), sparc_code_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  MacroAssembler* masm = new MacroAssembler(&cb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  Register G3_klassOop = G3_scratch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  Register G5_interface = G5;  // Passed in as an argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  Label search;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Entry arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  //  G5_interface: Interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  //  O0:           Receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // get receiver klass (also an implicit null-check)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  address npe_addr = __ pc();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   134
  __ load_klass(O0, G3_klassOop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  __ verify_oop(G3_klassOop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // Push a new window to get some temp registers.  This chops the head of all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // my 64-bit %o registers in the LION build, but this is OK because no longs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // are passed in the %o registers.  Instead, longs are passed in G1 and G4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // and so those registers are not available here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  __ save(SP,-frame::register_save_words*wordSize,SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  Register I0_receiver = I0;    // Location of receiver after save
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  if (CountCompiledCalls) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    Address ctr(L0, SharedRuntime::nof_megamorphic_calls_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    __ sethi(ctr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    __ ld(ctr, L1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    __ inc(L1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    __ st(L1, ctr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
#endif /* PRODUCT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // load start of itable entries into L0 register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  const int base = instanceKlass::vtable_start_offset() * wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  __ ld(Address(G3_klassOop, 0, instanceKlass::vtable_length_offset() * wordSize), L0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // %%% Could store the aligned, prescaled offset in the klassoop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  __ sll(L0, exact_log2(vtableEntry::size() * wordSize), L0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // see code for instanceKlass::start_of_itable!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  const int vtable_alignment = align_object_offset(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  assert(vtable_alignment == 1 || vtable_alignment == 2, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  const int odd_bit = vtableEntry::size() * wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  if (vtable_alignment == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    __ and3(L0, odd_bit, L1);   // isolate the odd bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  __ add(G3_klassOop, L0, L0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  if (vtable_alignment == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    __ add(L0, L1, L0);         // double the odd bit, to align up
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // Loop over all itable entries until desired interfaceOop (G5_interface) found
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  __ bind(search);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  // %%%% Could load both offset and interface in one ldx, if they were
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // in the opposite order.  This would save a load.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  __ ld_ptr(L0, base + itableOffsetEntry::interface_offset_in_bytes(), L1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   179
  // If the entry is NULL then we've reached the end of the table
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   180
  // without finding the expected interface, so throw an exception
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   181
  Label throw_icce;
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   182
  __ bpr(Assembler::rc_z, false, Assembler::pn, L1, throw_icce);
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   183
  __ delayed()->cmp(G5_interface, L1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  __ brx(Assembler::notEqual, true, Assembler::pn, search);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  __ delayed()->add(L0, itableOffsetEntry::size() * wordSize, L0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // entry found and L0 points to it, move offset of vtable for interface into L0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  __ ld(L0, base + itableOffsetEntry::offset_offset_in_bytes(), L0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // Compute itableMethodEntry and get methodOop(G5_method) and entrypoint(L0) for compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  const int method_offset = (itableMethodEntry::size() * wordSize * vtable_index) + itableMethodEntry::method_offset_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  __ add(G3_klassOop, L0, L1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  __ ld_ptr(L1, method_offset, G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  if (DebugVtables) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    Label L01;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    __ ld_ptr(L1, method_offset, G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    __ bpr(Assembler::rc_nz, false, Assembler::pt, G5_method, L01);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    __ stop("methodOop is null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    __ bind(L01);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    __ verify_oop(G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // If the following load is through a NULL pointer, we'll take an OS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // exception that should translate into an AbstractMethodError.  We need the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // window count to be correct at that time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  __ restore();                 // Restore registers BEFORE the AME point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  address ame_addr = __ pc();   // if the vtable entry is null, the method is abstract
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  __ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // G5_method:  methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  // O0:         Receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // G3_scratch: entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  __ JMP(G3_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   221
  __ bind(throw_icce);
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   222
  Address icce(G3_scratch, StubRoutines::throw_IncompatibleClassChangeError_entry());
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   223
  __ jump_to(icce, 0);
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   224
  __ delayed()->restore();
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   225
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  masm->flush();
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   227
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   228
  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   229
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  s->set_exception_points(npe_addr, ame_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  return s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   236
  if (TraceJumps || DebugVtables || CountCompiledCalls || VerifyOops) return 1000;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    const int slop = 2*BytesPerInstWord; // sethi;add  (needed for long offsets)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    if (is_vtable_stub) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   240
      // ld;ld;ld,jmp,nop
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   241
      const int basic = 5*BytesPerInstWord +
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   242
                        // shift;add for load_klass
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   243
                        (UseCompressedOops ? 2*BytesPerInstWord : 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      return basic + slop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    } else {
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   246
      // save, ld, ld, sll, and, add, add, ld, cmp, br, add, ld, add, ld, ld, jmp, restore, sethi, jmpl, restore
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   247
      const int basic = (20 LP64_ONLY(+ 6)) * BytesPerInstWord +
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   248
                        // shift;add for load_klass
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   249
                        (UseCompressedOops ? 2*BytesPerInstWord : 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      return (basic + slop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
int VtableStub::pd_code_alignment() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  // UltraSPARC cache line size is 8 instructions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  const unsigned int icache_line_size = 32;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  return icache_line_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}