hotspot/src/cpu/sparc/vm/vtableStubs_sparc.cpp
author kvn
Thu, 21 Jul 2011 11:25:07 -0700
changeset 10252 0981ce1c3eef
parent 7397 5b173b4ca846
child 11190 d561d41f241a
permissions -rw-r--r--
7063628: Use cbcond on T4 Summary: Add new short branch instruction to Hotspot sparc assembler. Reviewed-by: never, twisti, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2571
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2571
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2571
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "asm/assembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "assembler_sparc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "code/vtableStubs.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "interp_masm_sparc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "memory/resourceArea.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "oops/instanceKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "oops/klassVtable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "vmreg_sparc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#ifdef COMPILER2
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "opto/runtime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// machine-dependent part of VtableStubs: create vtableStub of correct size and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// initialize its code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
#define __ masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
extern "C" void bad_compiled_vtable_index(JavaThread* thread, oopDesc* receiver, int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// Used by compiler only; may use only caller saved, non-argument registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// NOTE:  %%%% if any change is made to this stub make sure that the function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//             pd_code_size_limit is changed to ensure the correct size for VtableStub
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  const int sparc_code_length = VtableStub::pd_code_size_limit(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  VtableStub* s = new(sparc_code_length) VtableStub(true, vtable_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  CodeBuffer cb(s->entry_point(), sparc_code_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  MacroAssembler* masm = new MacroAssembler(&cb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  if (CountCompiledCalls) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2533
diff changeset
    62
    __ inc_counter(SharedRuntime::nof_megamorphic_calls_addr(), G5, G3_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
#endif /* PRODUCT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // get receiver klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  address npe_addr = __ pc();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
    70
  __ load_klass(O0, G3_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // set methodOop (in case of interpreted method), and destination address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  int entry_offset = instanceKlass::vtable_start_offset() + vtable_index*vtableEntry::size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  if (DebugVtables) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    // check offset vs vtable length
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    __ ld(G3_scratch, instanceKlass::vtable_length_offset()*wordSize, G5);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 7397
diff changeset
    79
    __ cmp_and_br_short(G5, vtable_index*vtableEntry::size(), Assembler::greaterUnsigned, Assembler::pt, L);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    __ set(vtable_index, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), O0, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  int v_off = entry_offset*wordSize + vtableEntry::method_offset_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  if( __ is_simm13(v_off) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    __ ld_ptr(G3, v_off, G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    __ set(v_off,G5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    __ ld_ptr(G3, G5, G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  if (DebugVtables) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    Label L;
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 7397
diff changeset
    96
    __ br_notnull_short(G5_method, Assembler::pt, L);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    __ stop("Vtable entry is ZERO");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  address ame_addr = __ pc();  // if the vtable entry is null, the method is abstract
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
                               // NOTE: for vtable dispatches, the vtable entry will never be null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  __ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // jump to target (either compiled code or c2iadapter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  __ JMP(G3_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // load methodOop (in case we call c2iadapter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  masm->flush();
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   113
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   114
  if (PrintMiscellaneous && (WizardMode || Verbose)) {
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   115
    tty->print_cr("vtable #%d at "PTR_FORMAT"[%d] left over: %d",
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   116
                  vtable_index, s->entry_point(),
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   117
                  (int)(s->code_end() - s->entry_point()),
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   118
                  (int)(s->code_end() - __ pc()));
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   119
  }
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   120
  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
2533
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   121
  // shut the door on sizing bugs
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   122
  int slop = 2*BytesPerInstWord;  // 32-bit offset is this much larger than a 13-bit one
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   123
  assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for sethi;add");
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   124
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  s->set_exception_points(npe_addr, ame_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  return s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
// NOTE:  %%%% if any change is made to this stub make sure that the function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
//             pd_code_size_limit is changed to ensure the correct size for VtableStub
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   132
VtableStub* VtableStubs::create_itable_stub(int itable_index) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  const int sparc_code_length = VtableStub::pd_code_size_limit(false);
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   134
  VtableStub* s = new(sparc_code_length) VtableStub(false, itable_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  CodeBuffer cb(s->entry_point(), sparc_code_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  MacroAssembler* masm = new MacroAssembler(&cb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  Register G3_klassOop = G3_scratch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  Register G5_interface = G5;  // Passed in as an argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  Label search;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  // Entry arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  //  G5_interface: Interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  //  O0:           Receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // get receiver klass (also an implicit null-check)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  address npe_addr = __ pc();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   150
  __ load_klass(O0, G3_klassOop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  __ verify_oop(G3_klassOop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Push a new window to get some temp registers.  This chops the head of all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // my 64-bit %o registers in the LION build, but this is OK because no longs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // are passed in the %o registers.  Instead, longs are passed in G1 and G4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // and so those registers are not available here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  __ save(SP,-frame::register_save_words*wordSize,SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  if (CountCompiledCalls) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2533
diff changeset
   161
    __ inc_counter(SharedRuntime::nof_megamorphic_calls_addr(), L0, L1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
#endif /* PRODUCT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   165
  Label throw_icce;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   167
  Register L5_method = L5;
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   168
  __ lookup_interface_method(// inputs: rec. class, interface, itable index
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   169
                             G3_klassOop, G5_interface, itable_index,
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   170
                             // outputs: method, scan temp. reg
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   171
                             L5_method, L2, L3,
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   172
                             throw_icce);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  if (DebugVtables) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    Label L01;
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 7397
diff changeset
   177
    __ br_notnull_short(L5_method, Assembler::pt, L01);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    __ stop("methodOop is null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    __ bind(L01);
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   180
    __ verify_oop(L5_method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // If the following load is through a NULL pointer, we'll take an OS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // exception that should translate into an AbstractMethodError.  We need the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // window count to be correct at that time.
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   187
  __ restore(L5_method, 0, G5_method);
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   188
  // Restore registers *before* the AME point.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  address ame_addr = __ pc();   // if the vtable entry is null, the method is abstract
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  __ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // G5_method:  methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  // O0:         Receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  // G3_scratch: entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  __ JMP(G3_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   199
  __ bind(throw_icce);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2533
diff changeset
   200
  AddressLiteral icce(StubRoutines::throw_IncompatibleClassChangeError_entry());
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2533
diff changeset
   201
  __ jump_to(icce, G3_scratch);
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   202
  __ delayed()->restore();
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   203
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  masm->flush();
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   205
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   206
  if (PrintMiscellaneous && (WizardMode || Verbose)) {
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   207
    tty->print_cr("itable #%d at "PTR_FORMAT"[%d] left over: %d",
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   208
                  itable_index, s->entry_point(),
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   209
                  (int)(s->code_end() - s->entry_point()),
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   210
                  (int)(s->code_end() - __ pc()));
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   211
  }
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   212
  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
2533
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   213
  // shut the door on sizing bugs
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   214
  int slop = 2*BytesPerInstWord;  // 32-bit offset is this much larger than a 13-bit one
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   215
  assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for sethi;add");
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
   216
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  s->set_exception_points(npe_addr, ame_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  return s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
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
   223
  if (TraceJumps || DebugVtables || CountCompiledCalls || VerifyOops) return 1000;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    const int slop = 2*BytesPerInstWord; // sethi;add  (needed for long offsets)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    if (is_vtable_stub) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   227
      // ld;ld;ld,jmp,nop
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   228
      const int basic = 5*BytesPerInstWord +
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 2149
diff changeset
   229
                        // shift;add for load_klass (only shift with zero heap based)
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 2149
diff changeset
   230
                        (UseCompressedOops ?
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 2149
diff changeset
   231
                         ((Universe::narrow_oop_base() == NULL) ? BytesPerInstWord : 2*BytesPerInstWord) : 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      return basic + slop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    } else {
2149
3d362637b307 6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents: 670
diff changeset
   234
      const int basic = (28 LP64_ONLY(+ 6)) * BytesPerInstWord +
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 2149
diff changeset
   235
                        // shift;add for load_klass (only shift with zero heap based)
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 2149
diff changeset
   236
                        (UseCompressedOops ?
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 2149
diff changeset
   237
                         ((Universe::narrow_oop_base() == NULL) ? BytesPerInstWord : 2*BytesPerInstWord) : 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      return (basic + slop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  }
2533
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   241
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   242
  // In order to tune these parameters, run the JVM with VM options
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   243
  // +PrintMiscellaneous and +WizardMode to see information about
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   244
  // actual itable stubs.  Look for lines like this:
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   245
  //   itable #1 at 0x5551212[116] left over: 8
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   246
  // Reduce the constants so that the "left over" number is 8
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   247
  // Do not aim at a left-over number of zero, because a very
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   248
  // large vtable or itable offset (> 4K) will require an extra
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   249
  // sethi/or pair of instructions.
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   250
  //
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   251
  // The JVM98 app. _202_jess has a megamorphic interface call.
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   252
  // The itable code looks like this:
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   253
  // Decoding VtableStub itbl[1]@16
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   254
  //   ld  [ %o0 + 4 ], %g3
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   255
  //   save  %sp, -64, %sp
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   256
  //   ld  [ %g3 + 0xe8 ], %l2
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   257
  //   sll  %l2, 2, %l2
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   258
  //   add  %l2, 0x134, %l2
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   259
  //   and  %l2, -8, %l2        ! NOT_LP64 only
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   260
  //   add  %g3, %l2, %l2
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   261
  //   add  %g3, 4, %g3
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   262
  //   ld  [ %l2 ], %l5
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   263
  //   brz,pn   %l5, throw_icce
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   264
  //   cmp  %l5, %g5
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   265
  //   be  %icc, success
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   266
  //   add  %l2, 8, %l2
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   267
  // loop:
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   268
  //   ld  [ %l2 ], %l5
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   269
  //   brz,pn   %l5, throw_icce
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   270
  //   cmp  %l5, %g5
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   271
  //   bne,pn   %icc, loop
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   272
  //   add  %l2, 8, %l2
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   273
  // success:
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   274
  //   ld  [ %l2 + -4 ], %l2
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   275
  //   ld  [ %g3 + %l2 ], %l5
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   276
  //   restore  %l5, 0, %g5
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   277
  //   ld  [ %g5 + 0x44 ], %g3
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   278
  //   jmp  %g3
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   279
  //   nop
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   280
  // throw_icce:
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   281
  //   sethi  %hi(throw_ICCE_entry), %g3
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   282
  //   ! 5 more instructions here, LP64_ONLY
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   283
  //   jmp  %g3 + %lo(throw_ICCE_entry)
9aa50ba9a67f 6827505: sizing logic for vtable and itable stubs needs self-check
jrose
parents: 2254
diff changeset
   284
  //   restore
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
int VtableStub::pd_code_alignment() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // UltraSPARC cache line size is 8 instructions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  const unsigned int icache_line_size = 32;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  return icache_line_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
}