hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp
author twisti
Fri, 13 Feb 2009 09:09:35 -0800
changeset 2031 24e034f56dcb
parent 1 489c9b5090e2
child 2534 08dac9ce0cd7
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
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
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/_interpreter_sparc.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// Generation of Interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// The InterpreterGenerator generates the interpreter into Interpreter::_code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//----------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
int AbstractInterpreter::BasicType_as_index(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    case T_BOOLEAN: i = 0; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    case T_CHAR   : i = 1; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    case T_BYTE   : i = 2; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    case T_SHORT  : i = 3; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    case T_INT    : i = 4; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    case T_LONG   : i = 5; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    case T_VOID   : i = 6; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    case T_FLOAT  : i = 7; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    case T_DOUBLE : i = 8; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    case T_OBJECT : i = 9; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    case T_ARRAY  : i = 9; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  return i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
#ifndef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  Argument argv(0, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // We are in the jni transition frame. Save the last_java_frame corresponding to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // outer interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  __ set_last_Java_frame(FP, noreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // make sure the interpreter frame we've pushed has a valid return pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  __ mov(O7, I7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  __ mov(Lmethod, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  __ mov(Llocals, G4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  __ save_frame(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  __ mov(G2_thread, L7_thread_cache);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  __ add(argv.address_in_frame(), O3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  __ mov(G2_thread, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  __ mov(G3_scratch, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  __ delayed()->mov(G4_scratch, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  __ mov(L7_thread_cache, G2_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  __ reset_last_Java_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // load the register arguments (the C code packed them as varargs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  for (Argument ldarg = argv.successor(); ldarg.is_register(); ldarg = ldarg.successor()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  __ ret();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  __ delayed()->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
     restore(O0, 0, Lscratch);  // caller's Lscratch gets the result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
// LP64 passes floating point arguments in F1, F3, F5, etc. instead of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// O0, O1, O2 etc..
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
// Doubles are passed in D0, D2, D4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// We store the signature of the first 16 arguments in the first argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// slot because it will be overwritten prior to calling the native
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
// function, with the pointer to the JNIEnv.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
// If LP64 there can be up to 16 floating point arguments in registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// or 6 integer registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    non_float  = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    float_sig  = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    double_sig = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    sig_mask   = 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  Argument argv(0, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // We are in the jni transition frame. Save the last_java_frame corresponding to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // outer interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  __ set_last_Java_frame(FP, noreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // make sure the interpreter frame we've pushed has a valid return pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  __ mov(O7, I7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  __ mov(Lmethod, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  __ mov(Llocals, G4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  __ save_frame(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  __ mov(G2_thread, L7_thread_cache);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  __ add(argv.address_in_frame(), O3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  __ mov(G2_thread, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  __ mov(G3_scratch, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  __ delayed()->mov(G4_scratch, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  __ mov(L7_thread_cache, G2_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  __ reset_last_Java_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // load the register arguments (the C code packed them as varargs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  Address Sig = argv.address_in_frame();        // Argument 0 holds the signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  __ ld_ptr( Sig, G3_scratch );                   // Get register argument signature word into G3_scratch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  __ mov( G3_scratch, G4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  __ srl( G4_scratch, 2, G4_scratch);             // Skip Arg 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  Label done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  for (Argument ldarg = argv.successor(); ldarg.is_float_register(); ldarg = ldarg.successor()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    Label NonFloatArg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    Label LoadFloatArg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    Label LoadDoubleArg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    Label NextArg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    Address a = ldarg.address_in_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    __ andcc(G4_scratch, sig_mask, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    __ br(Assembler::zero, false, Assembler::pt, NonFloatArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    __ cmp(G3_scratch, float_sig );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    __ br(Assembler::equal, false, Assembler::pt, LoadFloatArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    __ cmp(G3_scratch, double_sig );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    __ br(Assembler::equal, false, Assembler::pt, LoadDoubleArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    __ bind(NonFloatArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    // There are only 6 integer register arguments!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    if ( ldarg.is_register() )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
      __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    // Optimization, see if there are any more args and get out prior to checking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    // all 16 float registers.  My guess is that this is rare.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    // If is_register is false, then we are done the first six integer args.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
      __ tst(G4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
      __ brx(Assembler::zero, false, Assembler::pt, done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
      __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    __ ba(false, NextArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    __ delayed()->srl( G4_scratch, 2, G4_scratch );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    __ bind(LoadFloatArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    __ ldf( FloatRegisterImpl::S, a, ldarg.as_float_register(), 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    __ ba(false, NextArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    __ delayed()->srl( G4_scratch, 2, G4_scratch );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    __ bind(LoadDoubleArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    __ ldf( FloatRegisterImpl::D, a, ldarg.as_double_register() );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    __ ba(false, NextArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    __ delayed()->srl( G4_scratch, 2, G4_scratch );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    __ bind(NextArg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  __ bind(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  __ ret();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  __ delayed()->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
     restore(O0, 0, Lscratch);  // caller's Lscratch gets the result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
void InterpreterGenerator::generate_counter_overflow(Label& Lcontinue) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  // Generate code to initiate compilation on the counter overflow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  // InterpreterRuntime::frequency_counter_overflow takes two arguments,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // the first indicates if the counter overflow occurs at a backwards branch (NULL bcp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // and the second is only used when the first is true.  We pass zero for both.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // The call returns the address of the verified entry point for the method or NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // if the compilation did not complete (either went background or bailed out).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  __ set((int)false, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), O2, O2, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  // returns verified_entry_point or NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // we ignore it in any case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  __ ba(false, Lcontinue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
// End of helpers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
// Various method entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
// Abstract method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
// Attempt to execute abstract method. Throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
address InterpreterGenerator::generate_abstract_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  // abstract method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // the call_VM checks for exception, so we should never return here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
//----------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
// Entry points & stack frame layout
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
// Here we generate the various kind of entries into the interpreter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
// The two main entry type are generic bytecode methods and native call method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
// These both come in synchronized and non-synchronized versions but the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
// frame layout they create is very similar. The other method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
// types are really just special purpose entries that are really entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
// and interpretation all in one. These are for trivial methods like
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
// accessor, empty, or special math methods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
// When control flow reaches any of the entry types for the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
// the following holds ->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
// C2 Calling Conventions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
// The entry code below assumes that the following registers are set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
// when coming in:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
//    G5_method: holds the methodOop of the method to call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
//    Lesp:    points to the TOS of the callers expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
//             after having pushed all the parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
// The entry code does the following to setup an interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
//   pop parameters from the callers stack by adjusting Lesp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
//   set O0 to Lesp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
//   compute X = (max_locals - num_parameters)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
//   bump SP up by X to accomadate the extra locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
//   compute X = max_expression_stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
//               + vm_local_words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
//               + 16 words of register save area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
//   save frame doing a save sp, -X, sp growing towards lower addresses
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
//   set Lbcp, Lmethod, LcpoolCache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
//   set Llocals to i0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
//   set Lmonitors to FP - rounded_vm_local_words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
//   set Lesp to Lmonitors - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
//  The frame has now been setup to do the rest of the entry code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
// Try this optimization:  Most method entries could live in a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
// "one size fits all" stack frame without all the dynamic size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
// calculations.  It might be profitable to do all this calculation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// statically and approximately for "small enough" methods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
//-----------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
// C1 Calling conventions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
// Upon method entry, the following registers are setup:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
// g2 G2_thread: current thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// g5 G5_method: method to activate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// g4 Gargs  : pointer to last argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
// Stack:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
// +---------------+ <--- sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
// : reg save area :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
// +---------------+ <--- sp + 0x40
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
// : extra 7 slots :      note: these slots are not really needed for the interpreter (fix later)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
// +---------------+ <--- sp + 0x5c
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
// :     free      :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
// +---------------+ <--- Gargs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
// :   arguments   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
// +---------------+
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
// AFTER FRAME HAS BEEN SETUP for method interpretation the stack looks like:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
// +---------------+ <--- sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
// : reg save area :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
// +---------------+ <--- sp + 0x40
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
// : extra 7 slots :      note: these slots are not really needed for the interpreter (fix later)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
// +---------------+ <--- sp + 0x5c
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
// :               :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
// |               | <--- Lesp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
// +---------------+ <--- Lmonitors (fp - 0x18)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
// |   VM locals   |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
// +---------------+ <--- fp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
// : reg save area :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
// +---------------+ <--- fp + 0x40
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
// : extra 7 slots :      note: these slots are not really needed for the interpreter (fix later)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
// +---------------+ <--- fp + 0x5c
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
// :     free      :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
// +---------------+
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
// : nonarg locals :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
// +---------------+
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
// :   arguments   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
// |               | <--- Llocals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
// +---------------+ <--- Gargs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
// |               |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
address AbstractInterpreterGenerator::generate_method_entry(AbstractInterpreter::MethodKind kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  // determine code generation flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  bool synchronized = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  address entry_point = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    case Interpreter::zerolocals             :                                                                             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    case Interpreter::zerolocals_synchronized: synchronized = true;                                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    case Interpreter::native                 : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(false);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    case Interpreter::native_synchronized    : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(true);   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    case Interpreter::empty                  : entry_point = ((InterpreterGenerator*)this)->generate_empty_entry();        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    case Interpreter::accessor               : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry();     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    case Interpreter::abstract               : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry();     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    case Interpreter::java_lang_math_sin     :                                                                             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    case Interpreter::java_lang_math_cos     :                                                                             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    case Interpreter::java_lang_math_tan     :                                                                             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    case Interpreter::java_lang_math_sqrt    :                                                                             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    case Interpreter::java_lang_math_abs     :                                                                             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    case Interpreter::java_lang_math_log     :                                                                             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    case Interpreter::java_lang_math_log10   :                                                                             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    default                                  : ShouldNotReachHere();                                                       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  if (entry_point) return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  return ((InterpreterGenerator*)this)->generate_normal_entry(synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
// This method tells the deoptimizer how big an interpreted frame must be:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
int AbstractInterpreter::size_activation(methodOop method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
                                         int tempcount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
                                         int popframe_extra_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
                                         int moncount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
                                         int callee_param_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
                                         int callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
                                         bool is_top_frame) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  return layout_activation(method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
                           tempcount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
                           popframe_extra_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
                           moncount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
                           callee_param_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
                           callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
                           (frame*)NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
                           (frame*)NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
                           is_top_frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  // the days we had adapter frames. When we deoptimize a situation where a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  // compiled caller calls a compiled caller will have registers it expects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  // to survive the call to the callee. If we deoptimize the callee the only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  // way we can restore these registers is to have the oldest interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  // frame that we create restore these values. That is what this routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // will accomplish.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // At the moment we have modified c2 to not have any callee save registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // so this problem does not exist and this routine is just a place holder.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  assert(f->is_interpreted_frame(), "must be interpreted");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
//----------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
// Exceptions