hotspot/src/cpu/x86/vm/jniFastGetField_x86_32.cpp
author xlu
Wed, 24 Dec 2008 13:06:09 -0800
changeset 1888 bbf498fb4354
parent 1217 5eb97f366a6a
child 5547 f4b087cbb361
permissions -rw-r--r--
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t Summary: Avoid casting between int32_t and intptr_t specifically for MasmAssembler::movptr in 32 bit platforms. Reviewed-by: jrose, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
1217
5eb97f366a6a 6754988: Update copyright year
xdono
parents: 1066
diff changeset
     2
 * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_jniFastGetField_x86_32.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
#define __ masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
#define BUFFER_SIZE 30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
#ifdef _WINDOWS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
GetBooleanField_t JNI_FastGetField::jni_fast_GetBooleanField_fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
GetByteField_t    JNI_FastGetField::jni_fast_GetByteField_fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
GetCharField_t    JNI_FastGetField::jni_fast_GetCharField_fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
GetShortField_t   JNI_FastGetField::jni_fast_GetShortField_fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
GetIntField_t     JNI_FastGetField::jni_fast_GetIntField_fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
GetLongField_t    JNI_FastGetField::jni_fast_GetLongField_fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
GetFloatField_t   JNI_FastGetField::jni_fast_GetFloatField_fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
GetDoubleField_t  JNI_FastGetField::jni_fast_GetDoubleField_fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// Instead of issuing lfence for LoadLoad barrier, we create data dependency
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// between loads, which is much more efficient than lfence.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  const char *name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    case T_BYTE:    name = "jni_fast_GetByteField";    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    case T_CHAR:    name = "jni_fast_GetCharField";    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    case T_SHORT:   name = "jni_fast_GetShortField";   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    case T_INT:     name = "jni_fast_GetIntField";     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    default:        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  address fast_entry = b->instructions_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  CodeBuffer cbuf(fast_entry, b->instructions_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  MacroAssembler* masm = new MacroAssembler(&cbuf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  Label slow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // stack layout:    offset from rsp (in words):
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  //  return pc        0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  //  jni env          1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  //  obj              2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  //  jfieldID         3
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  __ mov32 (rcx, counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  __ testb (rcx, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  __ jcc (Assembler::notZero, slow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  if (os::is_MP()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    75
    __ mov(rax, rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    76
    __ andptr(rax, 1);                         // rax, must end up 0
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    77
    __ movptr(rdx, Address(rsp, rax, Address::times_1, 2*wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
                                              // obj, notice rax, is 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
                                              // rdx is data dependent on rcx.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    81
    __ movptr (rdx, Address(rsp, 2*wordSize));  // obj
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    83
  __ movptr(rax, Address(rsp, 3*wordSize));  // jfieldID
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    84
  __ movptr(rdx, Address(rdx, 0));           // *obj
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    85
  __ shrptr (rax, 2);                         // offset
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  speculative_load_pclist[count] = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  switch (type) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    90
    case T_BOOLEAN: __ movzbl (rax, Address(rdx, rax, Address::times_1)); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    91
    case T_BYTE:    __ movsbl (rax, Address(rdx, rax, Address::times_1)); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    92
    case T_CHAR:    __ movzwl (rax, Address(rdx, rax, Address::times_1)); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    93
    case T_SHORT:   __ movswl (rax, Address(rdx, rax, Address::times_1)); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    case T_INT:     __ movl   (rax, Address(rdx, rax, Address::times_1)); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    default:        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  Address ca1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    __ lea(rdx, counter);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   101
    __ xorptr(rdx, rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   102
    __ xorptr(rdx, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    __ cmp32(rcx, Address(rdx, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    // ca1 is the same as ca because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    // rax, ^ counter_addr ^ rax, = address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    // ca1 is data dependent on rax,.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    __ cmp32(rcx, counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  __ jcc (Assembler::notEqual, slow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
#ifndef _WINDOWS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  __ ret (0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // __stdcall calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  __ ret (3*wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  slowcase_entry_pclist[count++] = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  __ bind (slow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  address slow_case_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    case T_BYTE:    slow_case_addr = jni_GetByteField_addr();    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    case T_CHAR:    slow_case_addr = jni_GetCharField_addr();    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    case T_SHORT:   slow_case_addr = jni_GetShortField_addr();   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    case T_INT:     slow_case_addr = jni_GetIntField_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // tail call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  __ jump (ExternalAddress(slow_case_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  __ flush ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
#ifndef _WINDOWS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  return fast_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    case T_BOOLEAN: jni_fast_GetBooleanField_fp = (GetBooleanField_t)fast_entry; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    case T_BYTE:    jni_fast_GetByteField_fp = (GetByteField_t)fast_entry; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    case T_CHAR:    jni_fast_GetCharField_fp = (GetCharField_t)fast_entry; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    case T_SHORT:   jni_fast_GetShortField_fp = (GetShortField_t)fast_entry; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    case T_INT:     jni_fast_GetIntField_fp = (GetIntField_t)fast_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  return os::win32::fast_jni_accessor_wrapper(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
address JNI_FastGetField::generate_fast_get_boolean_field() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  return generate_fast_get_int_field0(T_BOOLEAN);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
address JNI_FastGetField::generate_fast_get_byte_field() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  return generate_fast_get_int_field0(T_BYTE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
address JNI_FastGetField::generate_fast_get_char_field() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  return generate_fast_get_int_field0(T_CHAR);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
address JNI_FastGetField::generate_fast_get_short_field() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  return generate_fast_get_int_field0(T_SHORT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
address JNI_FastGetField::generate_fast_get_int_field() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  return generate_fast_get_int_field0(T_INT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
address JNI_FastGetField::generate_fast_get_long_field() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  const char *name = "jni_fast_GetLongField";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  address fast_entry = b->instructions_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  CodeBuffer cbuf(fast_entry, b->instructions_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  MacroAssembler* masm = new MacroAssembler(&cbuf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  Label slow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  // stack layout:    offset from rsp (in words):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  //  old rsi          0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  //  return pc        1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  //  jni env          2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  //  obj              3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  //  jfieldID         4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   187
  __ push  (rsi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  __ mov32 (rcx, counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  __ testb (rcx, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  __ jcc (Assembler::notZero, slow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  if (os::is_MP()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   192
    __ mov(rax, rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   193
    __ andptr(rax, 1);                         // rax, must end up 0
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   194
    __ movptr(rdx, Address(rsp, rax, Address::times_1, 3*wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
                                              // obj, notice rax, is 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
                                              // rdx is data dependent on rcx.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   198
    __ movptr(rdx, Address(rsp, 3*wordSize));  // obj
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   200
  __ movptr(rsi, Address(rsp, 4*wordSize));  // jfieldID
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   201
  __ movptr(rdx, Address(rdx, 0));           // *obj
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   202
  __ shrptr(rsi, 2);                         // offset
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  assert(count < LIST_CAPACITY-1, "LIST_CAPACITY too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  speculative_load_pclist[count++] = __ pc();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   206
  __ movptr(rax, Address(rdx, rsi, Address::times_1));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   207
#ifndef _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  speculative_load_pclist[count] = __ pc();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   209
  __ movl(rdx, Address(rdx, rsi, Address::times_1, 4));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   210
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  if (os::is_MP()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   213
    __ lea(rsi, counter);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   214
    __ xorptr(rsi, rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   215
    __ xorptr(rsi, rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   216
    __ xorptr(rsi, rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   217
    __ xorptr(rsi, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    __ cmp32(rcx, Address(rsi, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    // ca1 is the same as ca because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    // rax, ^ rdx ^ counter_addr ^ rax, ^ rdx = address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    // ca1 is data dependent on both rax, and rdx.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    __ cmp32(rcx, counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  __ jcc (Assembler::notEqual, slow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   227
  __ pop (rsi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
#ifndef _WINDOWS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  __ ret (0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  // __stdcall calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  __ ret (3*wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  slowcase_entry_pclist[count-1] = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  slowcase_entry_pclist[count++] = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  __ bind (slow);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   239
  __ pop  (rsi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  address slow_case_addr = jni_GetLongField_addr();;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // tail call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  __ jump (ExternalAddress(slow_case_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  __ flush ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
#ifndef _WINDOWS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  return fast_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  jni_fast_GetLongField_fp = (GetLongField_t)fast_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  return os::win32::fast_jni_accessor_wrapper(T_LONG);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  const char *name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    case T_FLOAT:  name = "jni_fast_GetFloatField";  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    default:       ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  address fast_entry = b->instructions_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  CodeBuffer cbuf(fast_entry, b->instructions_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  MacroAssembler* masm = new MacroAssembler(&cbuf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  Label slow_with_pop, slow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  // stack layout:    offset from rsp (in words):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  //  return pc        0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  //  jni env          1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  //  obj              2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  //  jfieldID         3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  __ mov32 (rcx, counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  __ testb (rcx, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  __ jcc (Assembler::notZero, slow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  if (os::is_MP()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   281
    __ mov(rax, rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   282
    __ andptr(rax, 1);                         // rax, must end up 0
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   283
    __ movptr(rdx, Address(rsp, rax, Address::times_1, 2*wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
                                              // obj, notice rax, is 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
                                              // rdx is data dependent on rcx.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   287
    __ movptr(rdx, Address(rsp, 2*wordSize)); // obj
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   289
  __ movptr(rax, Address(rsp, 3*wordSize));  // jfieldID
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   290
  __ movptr(rdx, Address(rdx, 0));           // *obj
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   291
  __ shrptr(rax, 2);                         // offset
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  speculative_load_pclist[count] = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  switch (type) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   296
#ifndef _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    case T_FLOAT:  __ fld_s (Address(rdx, rax, Address::times_1)); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    case T_DOUBLE: __ fld_d (Address(rdx, rax, Address::times_1)); break;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   299
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   300
    case T_FLOAT:  __ movflt (xmm0, Address(robj, roffset, Address::times_1)); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   301
    case T_DOUBLE: __ movdbl (xmm0, Address(robj, roffset, Address::times_1)); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   302
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    default:       ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  Address ca1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    __ fst_s (Address(rsp, -4));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    __ lea(rdx, counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    __ movl (rax, Address(rsp, -4));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   311
    // garbage hi-order bits on 64bit are harmless.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   312
    __ xorptr(rdx, rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   313
    __ xorptr(rdx, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    __ cmp32(rcx, Address(rdx, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
                                          // rax, ^ counter_addr ^ rax, = address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
                                          // ca1 is data dependent on the field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
                                          // access.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    __ cmp32(rcx, counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  __ jcc (Assembler::notEqual, slow_with_pop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
#ifndef _WINDOWS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  __ ret (0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  // __stdcall calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  __ ret (3*wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  __ bind (slow_with_pop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  // invalid load. pop FPU stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  __ fstp_d (0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  slowcase_entry_pclist[count++] = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  __ bind (slow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  address slow_case_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    case T_FLOAT:  slow_case_addr = jni_GetFloatField_addr();  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    default:       ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  // tail call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  __ jump (ExternalAddress(slow_case_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  __ flush ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
#ifndef _WINDOWS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  return fast_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    case T_FLOAT:  jni_fast_GetFloatField_fp = (GetFloatField_t)fast_entry; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    case T_DOUBLE: jni_fast_GetDoubleField_fp = (GetDoubleField_t)fast_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  return os::win32::fast_jni_accessor_wrapper(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
address JNI_FastGetField::generate_fast_get_float_field() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  return generate_fast_get_float_field0(T_FLOAT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
address JNI_FastGetField::generate_fast_get_double_field() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  return generate_fast_get_float_field0(T_DOUBLE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
}