src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp
author rehn
Thu, 31 Aug 2017 10:00:28 +0200
changeset 47881 0ce0ac68ace7
parent 47216 71c04702a3d5
child 51056 3ddf41505d54
permissions -rw-r--r--
8189941: Implementation JEP 312: Thread-local handshake Summary: Introduce a way to execute a callback on threads without performing a global VM safepoint. Make it both possible and cheap to stop individual threads and not just all threads or none. Reviewed-by: mdoerr, neliasso, acorn, aph, coleenp, dholmes Contributed-by: mikael.gerdin@oracle.com, erik.osterlund@oracle.com, robbin.ehn@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     1
/*
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47216
diff changeset
     2
 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     4
 *
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     8
 *
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    13
 * accompanied this code).
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    14
 *
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    18
 *
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    21
 * questions.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    22
 *
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    23
 */
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    24
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    25
#include "precompiled.hpp"
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    26
#include "asm/macroAssembler.hpp"
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
    27
#include "interpreter/interp_masm.hpp"
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    28
#include "interpreter/interpreter.hpp"
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    29
#include "interpreter/interpreterRuntime.hpp"
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
    30
#include "interpreter/templateInterpreterGenerator.hpp"
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    31
#include "runtime/arguments.hpp"
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
    32
#include "runtime/sharedRuntime.hpp"
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    33
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    34
#define __ _masm->
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    35
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    36
#ifdef _WIN64
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    37
address TemplateInterpreterGenerator::generate_slow_signature_handler() {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    38
  address entry = __ pc();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    39
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    40
  // rbx: method
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    41
  // r14: pointer to locals
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    42
  // c_rarg3: first stack arg - wordSize
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    43
  __ mov(c_rarg3, rsp);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    44
  // adjust rsp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    45
  __ subptr(rsp, 4 * wordSize);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    46
  __ call_VM(noreg,
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    47
             CAST_FROM_FN_PTR(address,
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    48
                              InterpreterRuntime::slow_signature_handler),
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    49
             rbx, r14, c_rarg3);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    50
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    51
  // rax: result handler
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    52
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    53
  // Stack layout:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    54
  // rsp: 3 integer or float args (if static first is unused)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    55
  //      1 float/double identifiers
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    56
  //        return address
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    57
  //        stack args
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    58
  //        garbage
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    59
  //        expression stack bottom
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    60
  //        bcp (NULL)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    61
  //        ...
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    62
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    63
  // Do FP first so we can use c_rarg3 as temp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    64
  __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    65
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    66
  for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    67
    XMMRegister floatreg = as_XMMRegister(i+1);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    68
    Label isfloatordouble, isdouble, next;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    69
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    70
    __ testl(c_rarg3, 1 << (i*2));      // Float or Double?
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    71
    __ jcc(Assembler::notZero, isfloatordouble);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    72
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    73
    // Do Int register here
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    74
    switch ( i ) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    75
      case 0:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    76
        __ movl(rscratch1, Address(rbx, Method::access_flags_offset()));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    77
        __ testl(rscratch1, JVM_ACC_STATIC);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    78
        __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    79
        break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    80
      case 1:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    81
        __ movptr(c_rarg2, Address(rsp, wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    82
        break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    83
      case 2:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    84
        __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    85
        break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    86
      default:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    87
        break;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    88
    }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    89
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    90
    __ jmp (next);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    91
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    92
    __ bind(isfloatordouble);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    93
    __ testl(c_rarg3, 1 << ((i*2)+1));     // Double?
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    94
    __ jcc(Assembler::notZero, isdouble);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    95
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    96
// Do Float Here
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    97
    __ movflt(floatreg, Address(rsp, i * wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    98
    __ jmp(next);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    99
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   100
// Do Double here
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   101
    __ bind(isdouble);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   102
    __ movdbl(floatreg, Address(rsp, i * wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   103
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   104
    __ bind(next);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   105
  }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   106
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   107
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   108
  // restore rsp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   109
  __ addptr(rsp, 4 * wordSize);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   110
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   111
  __ ret(0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   112
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   113
  return entry;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   114
}
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   115
#else
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   116
address TemplateInterpreterGenerator::generate_slow_signature_handler() {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   117
  address entry = __ pc();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   118
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   119
  // rbx: method
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   120
  // r14: pointer to locals
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   121
  // c_rarg3: first stack arg - wordSize
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   122
  __ mov(c_rarg3, rsp);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   123
  // adjust rsp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   124
  __ subptr(rsp, 14 * wordSize);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   125
  __ call_VM(noreg,
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   126
             CAST_FROM_FN_PTR(address,
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   127
                              InterpreterRuntime::slow_signature_handler),
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   128
             rbx, r14, c_rarg3);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   129
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   130
  // rax: result handler
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   131
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   132
  // Stack layout:
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   133
  // rsp: 5 integer args (if static first is unused)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   134
  //      1 float/double identifiers
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   135
  //      8 double args
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   136
  //        return address
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   137
  //        stack args
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   138
  //        garbage
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   139
  //        expression stack bottom
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   140
  //        bcp (NULL)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   141
  //        ...
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   142
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   143
  // Do FP first so we can use c_rarg3 as temp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   144
  __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   145
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   146
  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   147
    const XMMRegister r = as_XMMRegister(i);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   148
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   149
    Label d, done;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   150
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   151
    __ testl(c_rarg3, 1 << i);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   152
    __ jcc(Assembler::notZero, d);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   153
    __ movflt(r, Address(rsp, (6 + i) * wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   154
    __ jmp(done);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   155
    __ bind(d);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   156
    __ movdbl(r, Address(rsp, (6 + i) * wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   157
    __ bind(done);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   158
  }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   159
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   160
  // Now handle integrals.  Only do c_rarg1 if not static.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   161
  __ movl(c_rarg3, Address(rbx, Method::access_flags_offset()));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   162
  __ testl(c_rarg3, JVM_ACC_STATIC);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   163
  __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   164
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   165
  __ movptr(c_rarg2, Address(rsp, wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   166
  __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   167
  __ movptr(c_rarg4, Address(rsp, 3 * wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   168
  __ movptr(c_rarg5, Address(rsp, 4 * wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   169
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   170
  // restore rsp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   171
  __ addptr(rsp, 14 * wordSize);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   172
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   173
  __ ret(0);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   174
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   175
  return entry;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   176
}
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   177
#endif  // __WIN64
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   178
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   179
/**
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   180
 * Method entry for static native methods:
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   181
 *   int java.util.zip.CRC32.update(int crc, int b)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   182
 */
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
   183
address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   184
  if (UseCRC32Intrinsics) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   185
    address entry = __ pc();
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   186
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   187
    // rbx,: Method*
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   188
    // r13: senderSP must preserved for slow path, set SP to it on fast path
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   189
    // c_rarg0: scratch (rdi on non-Win64, rcx on Win64)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   190
    // c_rarg1: scratch (rsi on non-Win64, rdx on Win64)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   191
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   192
    Label slow_path;
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47216
diff changeset
   193
    __ safepoint_poll(slow_path, r15_thread, rscratch1);
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   194
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   195
    // We don't generate local frame and don't align stack because
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   196
    // we call stub code and there is no safepoint on this path.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   197
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   198
    // Load parameters
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   199
    const Register crc = rax;  // crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   200
    const Register val = c_rarg0;  // source java byte value
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   201
    const Register tbl = c_rarg1;  // scratch
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   202
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   203
    // Arguments are reversed on java expression stack
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   204
    __ movl(val, Address(rsp,   wordSize)); // byte value
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   205
    __ movl(crc, Address(rsp, 2*wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   206
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   207
    __ lea(tbl, ExternalAddress(StubRoutines::crc_table_addr()));
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   208
    __ notl(crc); // ~crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   209
    __ update_byte_crc32(crc, val, tbl);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   210
    __ notl(crc); // ~crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   211
    // result in rax
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   212
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   213
    // _areturn
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   214
    __ pop(rdi);                // get return address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   215
    __ mov(rsp, r13);           // set sp to sender sp
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   216
    __ jmp(rdi);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   217
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   218
    // generate a vanilla native entry as the slow path
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   219
    __ bind(slow_path);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   220
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native));
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   221
    return entry;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   222
  }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   223
  return NULL;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   224
}
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   225
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   226
/**
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   227
 * Method entry for static native methods:
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   228
 *   int java.util.zip.CRC32.updateBytes(int crc, byte[] b, int off, int len)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   229
 *   int java.util.zip.CRC32.updateByteBuffer(int crc, long buf, int off, int len)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   230
 */
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
   231
address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   232
  if (UseCRC32Intrinsics) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   233
    address entry = __ pc();
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   234
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   235
    // rbx,: Method*
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   236
    // r13: senderSP must preserved for slow path, set SP to it on fast path
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   237
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   238
    Label slow_path;
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47216
diff changeset
   239
    __ safepoint_poll(slow_path, r15_thread, rscratch1);
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   240
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   241
    // We don't generate local frame and don't align stack because
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   242
    // we call stub code and there is no safepoint on this path.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   243
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   244
    // Load parameters
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   245
    const Register crc = c_rarg0;  // crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   246
    const Register buf = c_rarg1;  // source java byte array address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   247
    const Register len = c_rarg2;  // length
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   248
    const Register off = len;      // offset (never overlaps with 'len')
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   249
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   250
    // Arguments are reversed on java expression stack
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   251
    // Calculate address of start element
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   252
    if (kind == Interpreter::java_util_zip_CRC32_updateByteBuffer) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   253
      __ movptr(buf, Address(rsp, 3*wordSize)); // long buf
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   254
      __ movl2ptr(off, Address(rsp, 2*wordSize)); // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   255
      __ addq(buf, off); // + offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   256
      __ movl(crc,   Address(rsp, 5*wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   257
    } else {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   258
      __ movptr(buf, Address(rsp, 3*wordSize)); // byte[] array
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   259
      __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   260
      __ movl2ptr(off, Address(rsp, 2*wordSize)); // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   261
      __ addq(buf, off); // + offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   262
      __ movl(crc,   Address(rsp, 4*wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   263
    }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   264
    // Can now load 'len' since we're finished with 'off'
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   265
    __ movl(len, Address(rsp, wordSize)); // Length
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   266
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   267
    __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, StubRoutines::updateBytesCRC32()), crc, buf, len);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   268
    // result in rax
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   269
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   270
    // _areturn
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   271
    __ pop(rdi);                // get return address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   272
    __ mov(rsp, r13);           // set sp to sender sp
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   273
    __ jmp(rdi);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   274
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   275
    // generate a vanilla native entry as the slow path
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   276
    __ bind(slow_path);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   277
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native));
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   278
    return entry;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   279
  }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   280
  return NULL;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   281
}
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   282
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   283
/**
38238
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38018
diff changeset
   284
* Method entry for static (non-native) methods:
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   285
*   int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int end)
38238
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38018
diff changeset
   286
*   int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long address, int off, int end)
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   287
*/
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
   288
address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   289
  if (UseCRC32CIntrinsics) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   290
    address entry = __ pc();
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   291
    // Load parameters
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   292
    const Register crc = c_rarg0;  // crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   293
    const Register buf = c_rarg1;  // source java byte array address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   294
    const Register len = c_rarg2;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   295
    const Register off = c_rarg3;  // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   296
    const Register end = len;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   297
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   298
    // Arguments are reversed on java expression stack
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   299
    // Calculate address of start element
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   300
    if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) {
38238
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38018
diff changeset
   301
      __ movptr(buf, Address(rsp, 3 * wordSize)); // long address
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   302
      __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   303
      __ addq(buf, off); // + offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   304
      __ movl(crc, Address(rsp, 5 * wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   305
      // Note on 5 * wordSize vs. 4 * wordSize:
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   306
      // *   int java.util.zip.CRC32C.updateByteBuffer(int crc, long address, int off, int end)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   307
      //                                                   4         2,3          1        0
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   308
      // end starts at SP + 8
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   309
      // The Java(R) Virtual Machine Specification Java SE 7 Edition
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   310
      // 4.10.2.3. Values of Types long and double
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   311
      //    "When calculating operand stack length, values of type long and double have length two."
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   312
    } else {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   313
      __ movptr(buf, Address(rsp, 3 * wordSize)); // byte[] array
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   314
      __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   315
      __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   316
      __ addq(buf, off); // + offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   317
      __ movl(crc, Address(rsp, 4 * wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   318
    }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   319
    __ movl(end, Address(rsp, wordSize)); // end
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   320
    __ subl(end, off); // end - off
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   321
    __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, StubRoutines::updateBytesCRC32C()), crc, buf, len);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   322
    // result in rax
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   323
    // _areturn
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   324
    __ pop(rdi);                // get return address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   325
    __ mov(rsp, r13);           // set sp to sender sp
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   326
    __ jmp(rdi);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   327
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   328
    return entry;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   329
  }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   330
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   331
  return NULL;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   332
}
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   333
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   334
//
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   335
// Various method entries
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   336
//
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   337
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   338
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   339
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   340
  // rbx,: Method*
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   341
  // rcx: scratrch
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   342
  // r13: sender sp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   343
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   344
  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   345
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   346
  address entry_point = __ pc();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   347
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   348
  // These don't need a safepoint check because they aren't virtually
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   349
  // callable. We won't enter these intrinsics from compiled code.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   350
  // If in the future we added an intrinsic which was virtually callable
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   351
  // we'd have to worry about how to safepoint so that this code is used.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   352
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   353
  // mathematical functions inlined by compiler
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   354
  // (interpreter must provide identical implementation
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   355
  // in order to avoid monotonicity bugs when switching
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   356
  // from interpreter to compiler in the middle of some
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   357
  // computation)
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   358
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   359
  // stack: [ ret adr ] <-- rsp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   360
  //        [ lo(arg) ]
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   361
  //        [ hi(arg) ]
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   362
  //
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   363
41323
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   364
  if (kind == Interpreter::java_lang_math_fmaD) {
42580
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents: 41323
diff changeset
   365
    if (!UseFMA) {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents: 41323
diff changeset
   366
      return NULL; // Generate a vanilla entry
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents: 41323
diff changeset
   367
    }
41323
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   368
    __ movdbl(xmm0, Address(rsp, wordSize));
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   369
    __ movdbl(xmm1, Address(rsp, 3 * wordSize));
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   370
    __ movdbl(xmm2, Address(rsp, 5 * wordSize));
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   371
    __ fmad(xmm0, xmm1, xmm2, xmm0);
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   372
  } else if (kind == Interpreter::java_lang_math_fmaF) {
42580
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents: 41323
diff changeset
   373
    if (!UseFMA) {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents: 41323
diff changeset
   374
      return NULL; // Generate a vanilla entry
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents: 41323
diff changeset
   375
    }
41323
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   376
    __ movflt(xmm0, Address(rsp, wordSize));
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   377
    __ movflt(xmm1, Address(rsp, 2 * wordSize));
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   378
    __ movflt(xmm2, Address(rsp, 3 * wordSize));
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   379
    __ fmaf(xmm0, xmm1, xmm2, xmm0);
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38699
diff changeset
   380
  } else if (kind == Interpreter::java_lang_math_sqrt) {
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   381
    __ sqrtsd(xmm0, Address(rsp, wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   382
  } else if (kind == Interpreter::java_lang_math_exp) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   383
    __ movdbl(xmm0, Address(rsp, wordSize));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   384
    if (StubRoutines::dexp() != NULL) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   385
      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   386
    } else {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   387
      __ call_VM_leaf0(CAST_FROM_FN_PTR(address, SharedRuntime::dexp));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   388
    }
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   389
  } else if (kind == Interpreter::java_lang_math_log) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   390
    __ movdbl(xmm0, Address(rsp, wordSize));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   391
    if (StubRoutines::dlog() != NULL) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   392
      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   393
    } else {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   394
      __ call_VM_leaf0(CAST_FROM_FN_PTR(address, SharedRuntime::dlog));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   395
    }
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   396
  } else if (kind == Interpreter::java_lang_math_log10) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   397
    __ movdbl(xmm0, Address(rsp, wordSize));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   398
    if (StubRoutines::dlog10() != NULL) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   399
      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10())));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   400
    } else {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   401
      __ call_VM_leaf0(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   402
    }
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   403
  } else if (kind == Interpreter::java_lang_math_sin) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   404
    __ movdbl(xmm0, Address(rsp, wordSize));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   405
    if (StubRoutines::dsin() != NULL) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   406
      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   407
    } else {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   408
      __ call_VM_leaf0(CAST_FROM_FN_PTR(address, SharedRuntime::dsin));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   409
    }
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   410
  } else if (kind == Interpreter::java_lang_math_cos) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   411
    __ movdbl(xmm0, Address(rsp, wordSize));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   412
    if (StubRoutines::dcos() != NULL) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   413
      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   414
    } else {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   415
      __ call_VM_leaf0(CAST_FROM_FN_PTR(address, SharedRuntime::dcos));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   416
    }
35495
jwilhelm
parents: 35479
diff changeset
   417
  } else if (kind == Interpreter::java_lang_math_pow) {
jwilhelm
parents: 35479
diff changeset
   418
    __ movdbl(xmm1, Address(rsp, wordSize));
jwilhelm
parents: 35479
diff changeset
   419
    __ movdbl(xmm0, Address(rsp, 3 * wordSize));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   420
    if (StubRoutines::dpow() != NULL) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   421
      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   422
    } else {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   423
      __ call_VM_leaf0(CAST_FROM_FN_PTR(address, SharedRuntime::dpow));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   424
    }
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   425
  } else if (kind == Interpreter::java_lang_math_tan) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   426
    __ movdbl(xmm0, Address(rsp, wordSize));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   427
    if (StubRoutines::dtan() != NULL) {
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   428
      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan())));
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   429
    } else {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   430
      __ call_VM_leaf0(CAST_FROM_FN_PTR(address, SharedRuntime::dtan));
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 35495
diff changeset
   431
    }
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   432
  } else {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   433
    __ fld_d(Address(rsp, wordSize));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   434
    switch (kind) {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   435
    case Interpreter::java_lang_math_abs:
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   436
      __ fabs();
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   437
      break;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   438
    default:
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   439
      ShouldNotReachHere();
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   440
    }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   441
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   442
    // return double result in xmm0 for interpreter and compilers.
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   443
    __ subptr(rsp, 2*wordSize);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   444
    // Round to 64bit precision
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   445
    __ fstp_d(Address(rsp, 0));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   446
    __ movdbl(xmm0, Address(rsp, 0));
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   447
    __ addptr(rsp, 2*wordSize);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   448
  }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   449
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   450
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   451
  __ pop(rax);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   452
  __ mov(rsp, r13);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   453
  __ jmp(rax);
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   454
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   455
  return entry_point;
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
   456
}
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38238
diff changeset
   457