hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp
author coleenp
Sat, 05 Dec 2015 10:40:22 -0500
changeset 34651 07b1cc0f6040
child 35214 d86005e0b4c2
permissions -rw-r--r--
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions Summary: merged templateInterpreter_x86_32/64 into templateInterpreterGenerator_x86.cpp (some 32/64 functions remain for the hand coded crc functions). Reviewed-by: goetz, jrose, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     1
/*
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
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"
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    27
#include "interpreter/interpreter.hpp"
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    28
#include "interpreter/interpreterGenerator.hpp"
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    29
#include "runtime/arguments.hpp"
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    30
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    31
#define __ _masm->
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    32
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    33
#ifndef CC_INTERP
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    34
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    35
/**
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    36
 * Method entry for static native methods:
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    37
 *   int java.util.zip.CRC32.update(int crc, int b)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    38
 */
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    39
address InterpreterGenerator::generate_CRC32_update_entry() {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    40
  if (UseCRC32Intrinsics) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    41
    address entry = __ pc();
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    42
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    43
    // rbx,: Method*
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    44
    // 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
    45
    // c_rarg0: scratch (rdi on non-Win64, rcx on Win64)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    46
    // c_rarg1: scratch (rsi on non-Win64, rdx on Win64)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    47
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    48
    Label slow_path;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    49
    // If we need a safepoint check, generate full interpreter entry.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    50
    ExternalAddress state(SafepointSynchronize::address_of_state());
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    51
    __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    52
             SafepointSynchronize::_not_synchronized);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    53
    __ jcc(Assembler::notEqual, slow_path);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    54
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    55
    // We don't generate local frame and don't align stack because
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    56
    // we call stub code and there is no safepoint on this path.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    57
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    58
    // Load parameters
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    59
    const Register crc = rax;  // crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    60
    const Register val = c_rarg0;  // source java byte value
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    61
    const Register tbl = c_rarg1;  // scratch
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    62
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    63
    // Arguments are reversed on java expression stack
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    64
    __ movl(val, Address(rsp,   wordSize)); // byte value
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    65
    __ movl(crc, Address(rsp, 2*wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    66
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    67
    __ lea(tbl, ExternalAddress(StubRoutines::crc_table_addr()));
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    68
    __ notl(crc); // ~crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    69
    __ update_byte_crc32(crc, val, tbl);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    70
    __ notl(crc); // ~crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    71
    // result in rax
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    72
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    73
    // _areturn
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    74
    __ pop(rdi);                // get return address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    75
    __ mov(rsp, r13);           // set sp to sender sp
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    76
    __ jmp(rdi);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    77
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    78
    // generate a vanilla native entry as the slow path
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    79
    __ bind(slow_path);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    80
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native));
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    81
    return entry;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    82
  }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    83
  return NULL;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    84
}
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    85
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    86
/**
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    87
 * Method entry for static native methods:
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    88
 *   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
    89
 *   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
    90
 */
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    91
address InterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    92
  if (UseCRC32Intrinsics) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    93
    address entry = __ pc();
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    94
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    95
    // rbx,: Method*
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    96
    // 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
    97
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    98
    Label slow_path;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
    99
    // If we need a safepoint check, generate full interpreter entry.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   100
    ExternalAddress state(SafepointSynchronize::address_of_state());
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   101
    __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   102
             SafepointSynchronize::_not_synchronized);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   103
    __ jcc(Assembler::notEqual, slow_path);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   104
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   105
    // We don't generate local frame and don't align stack because
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   106
    // we call stub code and there is no safepoint on this path.
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   107
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   108
    // Load parameters
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   109
    const Register crc = c_rarg0;  // crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   110
    const Register buf = c_rarg1;  // source java byte array address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   111
    const Register len = c_rarg2;  // length
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   112
    const Register off = len;      // offset (never overlaps with 'len')
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   113
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   114
    // Arguments are reversed on java expression stack
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   115
    // Calculate address of start element
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   116
    if (kind == Interpreter::java_util_zip_CRC32_updateByteBuffer) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   117
      __ movptr(buf, Address(rsp, 3*wordSize)); // long buf
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   118
      __ movl2ptr(off, Address(rsp, 2*wordSize)); // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   119
      __ addq(buf, off); // + offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   120
      __ movl(crc,   Address(rsp, 5*wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   121
    } else {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   122
      __ movptr(buf, Address(rsp, 3*wordSize)); // byte[] array
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   123
      __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   124
      __ movl2ptr(off, Address(rsp, 2*wordSize)); // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   125
      __ addq(buf, off); // + offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   126
      __ movl(crc,   Address(rsp, 4*wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   127
    }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   128
    // Can now load 'len' since we're finished with 'off'
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   129
    __ movl(len, Address(rsp, wordSize)); // Length
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   130
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   131
    __ 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
   132
    // result in rax
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   133
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   134
    // _areturn
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   135
    __ pop(rdi);                // get return address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   136
    __ mov(rsp, r13);           // set sp to sender sp
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   137
    __ jmp(rdi);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   138
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   139
    // generate a vanilla native entry as the slow path
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   140
    __ bind(slow_path);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   141
    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native));
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   142
    return entry;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   143
  }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   144
  return NULL;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   145
}
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   146
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   147
/**
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   148
* Method entry for static native methods:
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   149
*   int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int end)
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   150
*   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
   151
*/
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   152
address InterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   153
  if (UseCRC32CIntrinsics) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   154
    address entry = __ pc();
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   155
    // Load parameters
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   156
    const Register crc = c_rarg0;  // crc
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   157
    const Register buf = c_rarg1;  // source java byte array address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   158
    const Register len = c_rarg2;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   159
    const Register off = c_rarg3;  // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   160
    const Register end = len;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   161
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   162
    // Arguments are reversed on java expression stack
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   163
    // Calculate address of start element
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   164
    if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   165
      __ movptr(buf, Address(rsp, 3 * wordSize)); // long buf
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   166
      __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   167
      __ addq(buf, off); // + offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   168
      __ movl(crc, Address(rsp, 5 * wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   169
      // Note on 5 * wordSize vs. 4 * wordSize:
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   170
      // *   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
   171
      //                                                   4         2,3          1        0
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   172
      // end starts at SP + 8
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   173
      // The Java(R) Virtual Machine Specification Java SE 7 Edition
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   174
      // 4.10.2.3. Values of Types long and double
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   175
      //    "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
   176
    } else {
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   177
      __ movptr(buf, Address(rsp, 3 * wordSize)); // byte[] array
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   178
      __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   179
      __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   180
      __ addq(buf, off); // + offset
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   181
      __ movl(crc, Address(rsp, 4 * wordSize)); // Initial CRC
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   182
    }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   183
    __ movl(end, Address(rsp, wordSize)); // end
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   184
    __ subl(end, off); // end - off
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   185
    __ 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
   186
    // result in rax
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   187
    // _areturn
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   188
    __ pop(rdi);                // get return address
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   189
    __ mov(rsp, r13);           // set sp to sender sp
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   190
    __ jmp(rdi);
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   191
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   192
    return entry;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   193
  }
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   194
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   195
  return NULL;
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   196
}
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
diff changeset
   197
#endif // ! CC_INTERP