hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp
author jrose
Wed, 08 Apr 2009 10:56:49 -0700
changeset 2534 08dac9ce0cd7
parent 1066 717c3345024f
child 4478 c3a8af0fc6b0
permissions -rw-r--r--
6655638: dynamic languages need method handles Summary: initial implementation, with known omissions (x86/64, sparc, compiler optim., c-oops, C++ interp.) Reviewed-by: kvn, twisti, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
     2
 * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_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
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    38
  __ mov(c_rarg3, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  // adjust rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    40
  __ subptr(rsp, 4 * wordSize);
1
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);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    73
        __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
      case 1:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    76
        __ movptr(c_rarg2, Address(rsp, wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      case 2:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    79
        __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
1
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
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   104
  __ addptr(rsp, 4 * wordSize);
1
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
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   117
  __ mov(c_rarg3, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // adjust rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   119
  __ subptr(rsp, 14 * wordSize);
1
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);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   158
  __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   160
  __ movptr(c_rarg2, Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   161
  __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   162
  __ movptr(c_rarg4, Address(rsp, 3 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   163
  __ movptr(c_rarg5, Address(rsp, 4 * wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // restore rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   166
  __ addptr(rsp, 14 * wordSize);
1
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
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   179
address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   180
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   181
  // rbx,: methodOop
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   182
  // rcx: scratrch
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   183
  // r13: sender sp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // These don't need a safepoint check because they aren't virtually
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // callable. We won't enter these intrinsics from compiled code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // If in the future we added an intrinsic which was virtually callable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // we'd have to worry about how to safepoint so that this code is used.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  // mathematical functions inlined by compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  // (interpreter must provide identical implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // in order to avoid monotonicity bugs when switching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // from interpreter to compiler in the middle of some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // computation)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   199
  //
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   200
  // stack: [ ret adr ] <-- rsp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   201
  //        [ lo(arg) ]
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   202
  //        [ hi(arg) ]
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   203
  //
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  //       native methods. Interpreter::method_kind(...) does a check for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  //       native methods first before checking for intrinsic methods and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  //       thus will never select this entry point. Make sure it is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  //       called accidentally since the SharedRuntime entry points will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  //       not work for JDK 1.2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // We no longer need to check for JDK 1.2 since it's EOL'ed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // The following check existed in pre 1.6 implementation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  //    if (Universe::is_jdk12x_version()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  //      __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // Universe::is_jdk12x_version() always returns false since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // the JDK version is not yet determined when this method is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  // This method is called during interpreter_init() whereas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // JDK version is only determined when universe2_init() is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  //       java methods.  Interpreter::method_kind(...) will select
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  //       this entry point for the corresponding methods in JDK 1.3.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   225
  // get argument
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   227
  if (kind == Interpreter::java_lang_math_sqrt) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   228
    __ sqrtsd(xmm0, Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   229
  } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   230
    __ fld_d(Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   231
    switch (kind) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   232
      case Interpreter::java_lang_math_sin :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   233
          __ trigfunc('s');
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   234
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   235
      case Interpreter::java_lang_math_cos :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   236
          __ trigfunc('c');
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   237
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   238
      case Interpreter::java_lang_math_tan :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   239
          __ trigfunc('t');
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   240
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   241
      case Interpreter::java_lang_math_abs:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   242
          __ fabs();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   243
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   244
      case Interpreter::java_lang_math_log:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   245
          __ flog();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   246
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   247
      case Interpreter::java_lang_math_log10:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   248
          __ flog10();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   249
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   250
      default                              :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   251
          ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   252
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   253
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   254
    // return double result in xmm0 for interpreter and compilers.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   255
    __ subptr(rsp, 2*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   256
    // Round to 64bit precision
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   257
    __ fstp_d(Address(rsp, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   258
    __ movdbl(xmm0, Address(rsp, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   259
    __ addptr(rsp, 2*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   260
  }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   261
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   262
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   263
  __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   264
  __ mov(rsp, r13);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
// Abstract method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
// Attempt to execute abstract method. Throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
address InterpreterGenerator::generate_abstract_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  // rbx: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // r13: sender SP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  // abstract method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  // remove return address. Not really needed, since exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  // handling throws away expression stack
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   282
  __ pop(rbx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // adjust stack to what a normal return would do
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   285
  __ mov(rsp, r13);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  __ call_VM(noreg, CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
                             InterpreterRuntime::throw_AbstractMethodError));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // the call_VM checks for exception, so we should never return here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   297
// Method handle invoker
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   298
// Dispatch a method of the form java.dyn.MethodHandles::invoke(...)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   299
address InterpreterGenerator::generate_method_handle_entry(void) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   300
  if (!EnableMethodHandles) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   301
    return generate_abstract_entry();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   302
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   303
  return generate_abstract_entry(); //6815692//
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   304
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   305
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1066
diff changeset
   306
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
// Empty method, generate a very fast return.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
address InterpreterGenerator::generate_empty_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  // rbx: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // r13: sender sp must set sp to this value on return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  if (!UseFastEmptyMethods) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  // If we need a safepoint check, generate full interpreter entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  Label slow_path;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
           SafepointSynchronize::_not_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  __ jcc(Assembler::notEqual, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  // do nothing for empty methods (do not even increment invocation counter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  // Code: _return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  // _return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  // return w/o popping parameters
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   329
  __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   330
  __ mov(rsp, r13);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  __ bind(slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  (void) generate_normal_entry(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
// This method tells the deoptimizer how big an interpreted frame must be:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
int AbstractInterpreter::size_activation(methodOop method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
                                         int tempcount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
                                         int popframe_extra_args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
                                         int moncount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
                                         int callee_param_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
                                         int callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
                                         bool is_top_frame) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  return layout_activation(method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
                           tempcount, popframe_extra_args, moncount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
                           callee_param_count, callee_locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
                           (frame*) NULL, (frame*) NULL, is_top_frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  // the days we had adapter frames. When we deoptimize a situation where a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  // compiled caller calls a compiled caller will have registers it expects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  // to survive the call to the callee. If we deoptimize the callee the only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  // way we can restore these registers is to have the oldest interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  // frame that we create restore these values. That is what this routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  // will accomplish.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  // At the moment we have modified c2 to not have any callee save registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  // so this problem does not exist and this routine is just a place holder.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  assert(f->is_interpreted_frame(), "must be interpreted");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
}