hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp
author coleenp
Tue, 22 Dec 2015 11:11:29 -0500
changeset 35214 d86005e0b4c2
parent 34651 07b1cc0f6040
child 35232 76aed99c0ddd
permissions -rw-r--r--
8074457: Remove the non-Zero CPP Interpreter Summary: Remove cppInterpreter assembly files and reorganize InterpreterGenerator includes Reviewed-by: goetz, bdelsart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents: 33465
diff changeset
     2
 * Copyright (c) 2003, 2015, 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/interpreterRuntime.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    30
#include "interpreter/interp_masm.hpp"
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
    31
#include "interpreter/templateInterpreterGenerator.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/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    42
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    43
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    44
#include "runtime/synchronizer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    45
#include "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    46
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    47
#include "utilities/debug.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    48
#ifdef COMPILER1
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    49
#include "c1/c1_Runtime1.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    50
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // rbx: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // r14: pointer to locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // c_rarg3: first stack arg - wordSize
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    61
  __ mov(c_rarg3, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // adjust rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    63
  __ subptr(rsp, 4 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  __ call_VM(noreg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
             CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
                              InterpreterRuntime::slow_signature_handler),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
             rbx, r14, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // rax: result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // Stack layout:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // rsp: 3 integer or float args (if static first is unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  //      1 float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  //        return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  //        stack args
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  //        garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  //        expression stack bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  //        bcp (NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  //        ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // Do FP first so we can use c_rarg3 as temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    XMMRegister floatreg = as_XMMRegister(i+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    Label isfloatordouble, isdouble, next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    __ testl(c_rarg3, 1 << (i*2));      // Float or Double?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    __ jcc(Assembler::notZero, isfloatordouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    // Do Int register here
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    switch ( i ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      case 0:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    94
        __ movl(rscratch1, Address(rbx, Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
        __ testl(rscratch1, JVM_ACC_STATIC);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    96
        __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      case 1:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    99
        __ movptr(c_rarg2, Address(rsp, wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      case 2:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   102
        __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    __ jmp (next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    __ bind(isfloatordouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    __ testl(c_rarg3, 1 << ((i*2)+1));     // Double?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    __ jcc(Assembler::notZero, isdouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// Do Float Here
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    __ movflt(floatreg, Address(rsp, i * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    __ jmp(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
// Do Double here
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    __ bind(isdouble);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    __ movdbl(floatreg, Address(rsp, i * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    __ bind(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // restore rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   127
  __ addptr(rsp, 4 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // rbx: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // r14: pointer to locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // c_rarg3: first stack arg - wordSize
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   140
  __ mov(c_rarg3, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // adjust rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   142
  __ subptr(rsp, 14 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  __ call_VM(noreg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
             CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
                              InterpreterRuntime::slow_signature_handler),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
             rbx, r14, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // rax: result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // Stack layout:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // rsp: 5 integer args (if static first is unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  //      1 float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  //      8 double args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  //        return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  //        stack args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  //        garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  //        expression stack bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  //        bcp (NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  //        ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  // Do FP first so we can use c_rarg3 as temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    const XMMRegister r = as_XMMRegister(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    Label d, done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    __ testl(c_rarg3, 1 << i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    __ jcc(Assembler::notZero, d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    __ movflt(r, Address(rsp, (6 + i) * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    __ jmp(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    __ bind(d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    __ movdbl(r, Address(rsp, (6 + i) * wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    __ bind(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  // 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
   179
  __ movl(c_rarg3, Address(rbx, Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  __ testl(c_rarg3, JVM_ACC_STATIC);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   181
  __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   183
  __ movptr(c_rarg2, Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   184
  __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   185
  __ movptr(c_rarg4, Address(rsp, 3 * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   186
  __ movptr(c_rarg5, Address(rsp, 4 * wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  // restore rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   189
  __ addptr(rsp, 14 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
// Various method entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
   202
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   203
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   204
  // rbx,: Method*
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   205
  // rcx: scratrch
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   206
  // r13: sender sp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // These don't need a safepoint check because they aren't virtually
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // callable. We won't enter these intrinsics from compiled code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  // If in the future we added an intrinsic which was virtually callable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // we'd have to worry about how to safepoint so that this code is used.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // mathematical functions inlined by compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // (interpreter must provide identical implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  // in order to avoid monotonicity bugs when switching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // from interpreter to compiler in the middle of some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // computation)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   222
  //
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   223
  // stack: [ ret adr ] <-- rsp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   224
  //        [ lo(arg) ]
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   225
  //        [ hi(arg) ]
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   226
  //
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  //       native methods. Interpreter::method_kind(...) does a check for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  //       native methods first before checking for intrinsic methods and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  //       thus will never select this entry point. Make sure it is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  //       called accidentally since the SharedRuntime entry points will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  //       not work for JDK 1.2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  // We no longer need to check for JDK 1.2 since it's EOL'ed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // The following check existed in pre 1.6 implementation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  //    if (Universe::is_jdk12x_version()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  //      __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // Universe::is_jdk12x_version() always returns false since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // the JDK version is not yet determined when this method is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // This method is called during interpreter_init() whereas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  // JDK version is only determined when universe2_init() is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  //       java methods.  Interpreter::method_kind(...) will select
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  //       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
   248
  // get argument
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   250
  if (kind == Interpreter::java_lang_math_sqrt) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   251
    __ sqrtsd(xmm0, Address(rsp, wordSize));
33089
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   252
  } else if (kind == Interpreter::java_lang_math_exp) {
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   253
    __ movdbl(xmm0, Address(rsp, wordSize));
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   254
    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
33465
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33155
diff changeset
   255
  } else if (kind == Interpreter::java_lang_math_log) {
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33155
diff changeset
   256
    __ movdbl(xmm0, Address(rsp, wordSize));
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33155
diff changeset
   257
    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   258
  } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   259
    __ fld_d(Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   260
    switch (kind) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   261
      case Interpreter::java_lang_math_sin :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   262
          __ trigfunc('s');
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_cos :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   265
          __ trigfunc('c');
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_tan :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   268
          __ trigfunc('t');
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_abs:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   271
          __ fabs();
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;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   281
      default                              :
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   282
          ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   283
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   284
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   285
    // return double result in xmm0 for interpreter and compilers.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   286
    __ subptr(rsp, 2*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   287
    // Round to 64bit precision
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   288
    __ fstp_d(Address(rsp, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   289
    __ movdbl(xmm0, Address(rsp, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   290
    __ addptr(rsp, 2*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   291
  }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   292
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   293
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   294
  __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   295
  __ mov(rsp, r13);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
}