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