hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp
author coleenp
Sun, 13 Apr 2008 17:43:42 -0400
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
permissions -rw-r--r--
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
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 2003-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_x86_64.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  // rbx: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  // r14: pointer to locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  // c_rarg3: first stack arg - wordSize
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  __ movq(c_rarg3, rsp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  // adjust rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  __ subq(rsp, 4 * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  __ call_VM(noreg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
             CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
                              InterpreterRuntime::slow_signature_handler),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
             rbx, r14, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // rax: result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // Stack layout:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // rsp: 3 integer or float args (if static first is unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  //      1 float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  //        return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  //        stack args
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  //        garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  //        expression stack bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  //        bcp (NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  //        ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Do FP first so we can use c_rarg3 as temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    XMMRegister floatreg = as_XMMRegister(i+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    Label isfloatordouble, isdouble, next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    __ testl(c_rarg3, 1 << (i*2));      // Float or Double?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    __ jcc(Assembler::notZero, isfloatordouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    // Do Int register here
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    switch ( i ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
      case 0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        __ movl(rscratch1, Address(rbx, methodOopDesc::access_flags_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
        __ testl(rscratch1, JVM_ACC_STATIC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        __ cmovq(Assembler::zero, c_rarg1, Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
      case 1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        __ movq(c_rarg2, Address(rsp, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      case 2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
        __ movq(c_rarg3, Address(rsp, 2 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    __ jmp (next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    __ bind(isfloatordouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    __ testl(c_rarg3, 1 << ((i*2)+1));     // Double?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    __ jcc(Assembler::notZero, isdouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
// Do Float Here
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    __ movflt(floatreg, Address(rsp, i * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    __ jmp(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
// Do Double here
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    __ bind(isdouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    __ movdbl(floatreg, Address(rsp, i * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    __ bind(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // restore rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  __ addq(rsp, 4 * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // rbx: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // r14: pointer to locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // c_rarg3: first stack arg - wordSize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  __ movq(c_rarg3, rsp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // adjust rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  __ subq(rsp, 14 * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  __ call_VM(noreg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
             CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
                              InterpreterRuntime::slow_signature_handler),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
             rbx, r14, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // rax: result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Stack layout:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // rsp: 5 integer args (if static first is unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  //      1 float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  //      8 double args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  //        return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  //        stack args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  //        garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  //        expression stack bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  //        bcp (NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  //        ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Do FP first so we can use c_rarg3 as temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    const XMMRegister r = as_XMMRegister(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    Label d, done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    __ testl(c_rarg3, 1 << i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    __ jcc(Assembler::notZero, d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    __ movflt(r, Address(rsp, (6 + i) * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    __ jmp(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    __ bind(d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    __ movdbl(r, Address(rsp, (6 + i) * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    __ bind(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Now handle integrals.  Only do c_rarg1 if not static.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  __ movl(c_rarg3, Address(rbx, methodOopDesc::access_flags_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  __ testl(c_rarg3, JVM_ACC_STATIC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  __ cmovq(Assembler::zero, c_rarg1, Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  __ movq(c_rarg2, Address(rsp, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  __ movq(c_rarg3, Address(rsp, 2 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  __ movq(c_rarg4, Address(rsp, 3 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  __ movq(c_rarg5, Address(rsp, 4 * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // restore rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  __ addq(rsp, 14 * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
// Various method entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
address InterpreterGenerator::generate_math_entry(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  AbstractInterpreter::MethodKind kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  // rbx: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  assert(kind == Interpreter::java_lang_math_sqrt,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
         "Other intrinsics are not special");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // These don't need a safepoint check because they aren't virtually
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // callable. We won't enter these intrinsics from compiled code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // If in the future we added an intrinsic which was virtually callable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // we'd have to worry about how to safepoint so that this code is used.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  // mathematical functions inlined by compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // (interpreter must provide identical implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // in order to avoid monotonicity bugs when switching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // from interpreter to compiler in the middle of some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // computation)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  //       native methods. Interpreter::method_kind(...) does a check for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  //       native methods first before checking for intrinsic methods and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  //       thus will never select this entry point. Make sure it is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  //       called accidentally since the SharedRuntime entry points will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  //       not work for JDK 1.2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // We no longer need to check for JDK 1.2 since it's EOL'ed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // The following check existed in pre 1.6 implementation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  //    if (Universe::is_jdk12x_version()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  //      __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // Universe::is_jdk12x_version() always returns false since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  // the JDK version is not yet determined when this method is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // This method is called during interpreter_init() whereas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  // JDK version is only determined when universe2_init() is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  //       java methods.  Interpreter::method_kind(...) will select
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  //       this entry point for the corresponding methods in JDK 1.3.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  __ sqrtsd(xmm0, Address(rsp, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  __ popq(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  __ movq(rsp, r13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
// Abstract method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
// Attempt to execute abstract method. Throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
address InterpreterGenerator::generate_abstract_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  // rbx: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  // r13: sender SP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // abstract method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // remove return address. Not really needed, since exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // handling throws away expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  __ popq(rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // adjust stack to what a normal return would do
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  __ movq(rsp, r13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  // throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  __ call_VM(noreg, CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
                             InterpreterRuntime::throw_AbstractMethodError));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  // the call_VM checks for exception, so we should never return here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
// Empty method, generate a very fast return.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
address InterpreterGenerator::generate_empty_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // rbx: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // r13: sender sp must set sp to this value on return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  if (!UseFastEmptyMethods) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  // If we need a safepoint check, generate full interpreter entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  Label slow_path;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
           SafepointSynchronize::_not_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  __ jcc(Assembler::notEqual, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // do nothing for empty methods (do not even increment invocation counter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // Code: _return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // _return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  // return w/o popping parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  __ popq(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  __ movq(rsp, r13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  __ bind(slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  (void) generate_normal_entry(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// Call an accessor method (assuming it is resolved, otherwise drop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
// into vanilla (slow path) entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
address InterpreterGenerator::generate_accessor_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  // rbx: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // r13: senderSP must preserver for slow path, set SP to it on fast path
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  Label xreturn_path;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // do fastpath for resolved accessor methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  if (UseFastAccessorMethods) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    //       thereof; parameter size = 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    // Note: We can only use this code if the getfield has been resolved
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    //       and if we don't have a null-pointer exception => check for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    //       these conditions first and use slow path if necessary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    Label slow_path;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    // If we need a safepoint check, generate full interpreter entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
             SafepointSynchronize::_not_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    __ jcc(Assembler::notEqual, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    // rbx: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    __ movq(rax, Address(rsp, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    // check if local 0 != NULL and read field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    __ testq(rax, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
    __ jcc(Assembler::zero, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    __ movq(rdi, Address(rbx, methodOopDesc::constants_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    // read first instruction word and extract bytecode @ 1 and index @ 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    __ movq(rdx, Address(rbx, methodOopDesc::const_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    __ movl(rdx, Address(rdx, constMethodOopDesc::codes_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    // Shift codes right to get the index on the right.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    // The bytecode fetched looks like <index><0xb4><0x2a>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    __ shrl(rdx, 2 * BitsPerByte);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    __ movq(rdi, Address(rdi, constantPoolOopDesc::cache_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    // rax: local 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    // rbx: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    // rdx: constant pool cache index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    // rdi: constant pool cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    // check if getfield has been resolved and read constant pool cache entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    // check the validity of the cache entry by testing whether _indices field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    // contains Bytecode::_getfield in b1 byte.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
    assert(in_words(ConstantPoolCacheEntry::size()) == 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
           "adjust shift below");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    __ movl(rcx,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
            Address(rdi,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
                    rdx,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
                    Address::times_8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
                    constantPoolCacheOopDesc::base_offset() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
                    ConstantPoolCacheEntry::indices_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    __ shrl(rcx, 2 * BitsPerByte);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    __ andl(rcx, 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    __ cmpl(rcx, Bytecodes::_getfield);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    __ jcc(Assembler::notEqual, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    // Note: constant pool entry is not valid before bytecode is resolved
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    __ movq(rcx,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
            Address(rdi,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
                    rdx,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
                    Address::times_8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
                    constantPoolCacheOopDesc::base_offset() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
                    ConstantPoolCacheEntry::f2_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    // edx: flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    __ movl(rdx,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
            Address(rdi,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
                    rdx,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
                    Address::times_8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
                    constantPoolCacheOopDesc::base_offset() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
                    ConstantPoolCacheEntry::flags_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    Label notObj, notInt, notByte, notShort;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    const Address field_address(rax, rcx, Address::times_1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    // Need to differentiate between igetfield, agetfield, bgetfield etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    // because they are different sizes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    // Use the type from the constant pool cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    __ shrl(rdx, ConstantPoolCacheEntry::tosBits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    // Make sure we don't need to mask edx for tosBits after the above shift
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    ConstantPoolCacheEntry::verify_tosBits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    __ cmpl(rdx, atos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
    __ jcc(Assembler::notEqual, notObj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    // atos
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   378
    __ load_heap_oop(rax, field_address);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    __ jmp(xreturn_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    __ bind(notObj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    __ cmpl(rdx, itos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
    __ jcc(Assembler::notEqual, notInt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
    // itos
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    __ movl(rax, field_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    __ jmp(xreturn_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
    __ bind(notInt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    __ cmpl(rdx, btos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
    __ jcc(Assembler::notEqual, notByte);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
    // btos
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
    __ load_signed_byte(rax, field_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
    __ jmp(xreturn_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    __ bind(notByte);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    __ cmpl(rdx, stos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    __ jcc(Assembler::notEqual, notShort);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    // stos
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    __ load_signed_word(rax, field_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    __ jmp(xreturn_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
    __ bind(notShort);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
    Label okay;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    __ cmpl(rdx, ctos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    __ jcc(Assembler::equal, okay);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    __ stop("what type is this?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    __ bind(okay);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
    // ctos
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    __ load_unsigned_word(rax, field_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    __ bind(xreturn_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    // _ireturn/_areturn
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    __ popq(rdi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    __ movq(rsp, r13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    __ jmp(rdi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    // generate a vanilla interpreter entry as the slow path
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    __ bind(slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    (void) generate_normal_entry(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    (void) generate_normal_entry(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
// This method tells the deoptimizer how big an interpreted frame must be:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
int AbstractInterpreter::size_activation(methodOop method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
                                         int tempcount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
                                         int popframe_extra_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
                                         int moncount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
                                         int callee_param_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
                                         int callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
                                         bool is_top_frame) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  return layout_activation(method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
                           tempcount, popframe_extra_args, moncount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
                           callee_param_count, callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
                           (frame*) NULL, (frame*) NULL, is_top_frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  // the days we had adapter frames. When we deoptimize a situation where a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  // compiled caller calls a compiled caller will have registers it expects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  // to survive the call to the callee. If we deoptimize the callee the only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  // way we can restore these registers is to have the oldest interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  // frame that we create restore these values. That is what this routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  // will accomplish.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // At the moment we have modified c2 to not have any callee save registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  // so this problem does not exist and this routine is just a place holder.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  assert(f->is_interpreted_frame(), "must be interpreted");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
}