hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp
author duke
Wed, 05 Jul 2017 20:10:48 +0200
changeset 27963 88d7c7c376e9
parent 25950 b5c40ed1d349
child 33089 f4e956ed8b43
child 33148 68fa8b6c4340
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23203
diff changeset
     2
 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4478
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4478
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4478
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13728
diff changeset
    26
#include "asm/macroAssembler.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "interpreter/bytecodeHistogram.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "interpreter/interpreterGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "interpreter/interpreterRuntime.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    31
#include "interpreter/interp_masm.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "interpreter/templateTable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "oops/arrayOop.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    34
#include "oops/methodData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    35
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "prims/jvmtiThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "prims/methodHandles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "runtime/arguments.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
#include "runtime/deoptimization.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    42
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    43
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    44
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    45
#include "runtime/synchronizer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    46
#include "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    47
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    48
#include "utilities/debug.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    49
#ifdef COMPILER1
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    50
#include "c1/c1_Runtime1.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    51
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23203
diff changeset
    55
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // rbx: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // r14: pointer to locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // c_rarg3: first stack arg - wordSize
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    64
  __ mov(c_rarg3, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // adjust rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    66
  __ subptr(rsp, 4 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  __ call_VM(noreg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
             CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
                              InterpreterRuntime::slow_signature_handler),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
             rbx, r14, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // rax: result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // Stack layout:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // rsp: 3 integer or float args (if static first is unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  //      1 float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  //        return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  //        stack args
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  //        garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  //        expression stack bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  //        bcp (NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  //        ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // Do FP first so we can use c_rarg3 as temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    XMMRegister floatreg = as_XMMRegister(i+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    Label isfloatordouble, isdouble, next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    __ testl(c_rarg3, 1 << (i*2));      // Float or Double?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    __ jcc(Assembler::notZero, isfloatordouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    // Do Int register here
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    switch ( i ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      case 0:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    97
        __ movl(rscratch1, Address(rbx, Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
        __ testl(rscratch1, JVM_ACC_STATIC);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    99
        __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      case 1:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   102
        __ movptr(c_rarg2, Address(rsp, wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      case 2:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   105
        __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    __ jmp (next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    __ bind(isfloatordouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    __ testl(c_rarg3, 1 << ((i*2)+1));     // Double?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    __ jcc(Assembler::notZero, isdouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
// Do Float Here
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    __ movflt(floatreg, Address(rsp, i * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    __ jmp(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// Do Double here
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    __ bind(isdouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    __ movdbl(floatreg, Address(rsp, i * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    __ bind(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // restore rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   130
  __ addptr(rsp, 4 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // rbx: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // r14: pointer to locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // c_rarg3: first stack arg - wordSize
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   143
  __ mov(c_rarg3, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // adjust rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   145
  __ subptr(rsp, 14 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  __ call_VM(noreg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
             CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                              InterpreterRuntime::slow_signature_handler),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
             rbx, r14, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // rax: result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Stack layout:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // rsp: 5 integer args (if static first is unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  //      1 float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  //      8 double args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  //        return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  //        stack args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  //        garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  //        expression stack bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  //        bcp (NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  //        ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  // Do FP first so we can use c_rarg3 as temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    const XMMRegister r = as_XMMRegister(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    Label d, done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    __ testl(c_rarg3, 1 << i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    __ jcc(Assembler::notZero, d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    __ movflt(r, Address(rsp, (6 + i) * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    __ jmp(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    __ bind(d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    __ movdbl(r, Address(rsp, (6 + i) * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    __ bind(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  // Now handle integrals.  Only do c_rarg1 if not static.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   182
  __ movl(c_rarg3, Address(rbx, Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  __ testl(c_rarg3, JVM_ACC_STATIC);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   184
  __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   186
  __ movptr(c_rarg2, Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   187
  __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   188
  __ movptr(c_rarg4, Address(rsp, 3 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   189
  __ movptr(c_rarg5, Address(rsp, 4 * wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // restore rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   192
  __ addptr(rsp, 14 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
// Various method entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   205
address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   206
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   207
  // rbx,: Method*
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   208
  // rcx: scratrch
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   209
  // r13: sender sp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // These don't need a safepoint check because they aren't virtually
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  // callable. We won't enter these intrinsics from compiled code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // If in the future we added an intrinsic which was virtually callable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // we'd have to worry about how to safepoint so that this code is used.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // mathematical functions inlined by compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // (interpreter must provide identical implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  // in order to avoid monotonicity bugs when switching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // from interpreter to compiler in the middle of some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // computation)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   225
  //
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   226
  // stack: [ ret adr ] <-- rsp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   227
  //        [ lo(arg) ]
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   228
  //        [ hi(arg) ]
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   229
  //
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  //       native methods. Interpreter::method_kind(...) does a check for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  //       native methods first before checking for intrinsic methods and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  //       thus will never select this entry point. Make sure it is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  //       called accidentally since the SharedRuntime entry points will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  //       not work for JDK 1.2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  // We no longer need to check for JDK 1.2 since it's EOL'ed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // The following check existed in pre 1.6 implementation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  //    if (Universe::is_jdk12x_version()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  //      __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  // Universe::is_jdk12x_version() always returns false since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // the JDK version is not yet determined when this method is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // This method is called during interpreter_init() whereas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // JDK version is only determined when universe2_init() is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  //       java methods.  Interpreter::method_kind(...) will select
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  //       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
   251
  // get argument
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   253
  if (kind == Interpreter::java_lang_math_sqrt) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   254
    __ sqrtsd(xmm0, Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   255
  } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   256
    __ fld_d(Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   257
    switch (kind) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   258
      case Interpreter::java_lang_math_sin :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   259
          __ trigfunc('s');
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   260
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   261
      case Interpreter::java_lang_math_cos :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   262
          __ trigfunc('c');
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   263
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   264
      case Interpreter::java_lang_math_tan :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   265
          __ trigfunc('t');
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   266
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   267
      case Interpreter::java_lang_math_abs:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   268
          __ fabs();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   269
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   270
      case Interpreter::java_lang_math_log:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   271
          __ flog();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   272
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   273
      case Interpreter::java_lang_math_log10:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   274
          __ flog10();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   275
          break;
12739
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   276
      case Interpreter::java_lang_math_pow:
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   277
          __ fld_d(Address(rsp, 3*wordSize)); // second argument (one
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   278
                                              // empty stack slot)
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   279
          __ pow_with_fallback(0);
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   280
          break;
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   281
      case Interpreter::java_lang_math_exp:
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   282
          __ exp_with_fallback(0);
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   283
           break;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   284
      default                              :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   285
          ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   286
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   287
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   288
    // return double result in xmm0 for interpreter and compilers.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   289
    __ subptr(rsp, 2*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   290
    // Round to 64bit precision
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   291
    __ fstp_d(Address(rsp, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   292
    __ movdbl(xmm0, Address(rsp, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   293
    __ addptr(rsp, 2*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   294
  }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   295
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   296
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   297
  __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   298
  __ mov(rsp, r13);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  // the days we had adapter frames. When we deoptimize a situation where a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  // compiled caller calls a compiled caller will have registers it expects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  // to survive the call to the callee. If we deoptimize the callee the only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  // way we can restore these registers is to have the oldest interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // frame that we create restore these values. That is what this routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // will accomplish.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  // At the moment we have modified c2 to not have any callee save registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  // so this problem does not exist and this routine is just a place holder.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  assert(f->is_interpreted_frame(), "must be interpreted");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
}