29183
|
1 |
/*
|
|
2 |
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
|
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
5 |
*
|
|
6 |
* This code is free software; you can redistribute it and/or modify it
|
|
7 |
* under the terms of the GNU General Public License version 2 only, as
|
|
8 |
* published by the Free Software Foundation.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
#include "precompiled.hpp"
|
|
27 |
#include "asm/macroAssembler.hpp"
|
|
28 |
#include "memory/resourceArea.hpp"
|
|
29 |
#include "prims/jniFastGetField.hpp"
|
|
30 |
#include "prims/jvm_misc.hpp"
|
|
31 |
#include "runtime/safepoint.hpp"
|
|
32 |
|
|
33 |
#define __ masm->
|
|
34 |
|
|
35 |
#define BUFFER_SIZE 30*wordSize
|
|
36 |
|
|
37 |
// Instead of issuing a LoadLoad barrier we create an address
|
|
38 |
// dependency between loads; this might be more efficient.
|
|
39 |
|
|
40 |
// Common register usage:
|
|
41 |
// r0/v0: result
|
|
42 |
// c_rarg0: jni env
|
|
43 |
// c_rarg1: obj
|
|
44 |
// c_rarg2: jfield id
|
|
45 |
|
|
46 |
static const Register robj = r3;
|
|
47 |
static const Register rcounter = r4;
|
|
48 |
static const Register roffset = r5;
|
|
49 |
static const Register rcounter_addr = r6;
|
|
50 |
static const Register result = r7;
|
|
51 |
|
|
52 |
address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
|
|
53 |
const char *name;
|
|
54 |
switch (type) {
|
|
55 |
case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
|
|
56 |
case T_BYTE: name = "jni_fast_GetByteField"; break;
|
|
57 |
case T_CHAR: name = "jni_fast_GetCharField"; break;
|
|
58 |
case T_SHORT: name = "jni_fast_GetShortField"; break;
|
|
59 |
case T_INT: name = "jni_fast_GetIntField"; break;
|
|
60 |
case T_LONG: name = "jni_fast_GetLongField"; break;
|
|
61 |
case T_FLOAT: name = "jni_fast_GetFloatField"; break;
|
|
62 |
case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;
|
|
63 |
default: ShouldNotReachHere();
|
35127
|
64 |
name = NULL; // unreachable
|
29183
|
65 |
}
|
|
66 |
ResourceMark rm;
|
|
67 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE);
|
|
68 |
CodeBuffer cbuf(blob);
|
|
69 |
MacroAssembler* masm = new MacroAssembler(&cbuf);
|
|
70 |
address fast_entry = __ pc();
|
|
71 |
|
|
72 |
Label slow;
|
|
73 |
|
|
74 |
unsigned long offset;
|
|
75 |
__ adrp(rcounter_addr,
|
|
76 |
SafepointSynchronize::safepoint_counter_addr(), offset);
|
|
77 |
Address safepoint_counter_addr(rcounter_addr, offset);
|
|
78 |
__ ldrw(rcounter, safepoint_counter_addr);
|
|
79 |
__ andw(rscratch1, rcounter, 1);
|
|
80 |
__ cbnzw(rscratch1, slow);
|
|
81 |
__ eor(robj, c_rarg1, rcounter);
|
|
82 |
__ eor(robj, robj, rcounter); // obj, since
|
|
83 |
// robj ^ rcounter ^ rcounter == robj
|
|
84 |
// robj is address dependent on rcounter.
|
|
85 |
__ ldr(robj, Address(robj, 0)); // *obj
|
|
86 |
__ lsr(roffset, c_rarg2, 2); // offset
|
|
87 |
|
|
88 |
assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
|
|
89 |
speculative_load_pclist[count] = __ pc(); // Used by the segfault handler
|
|
90 |
switch (type) {
|
|
91 |
case T_BOOLEAN: __ ldrb (result, Address(robj, roffset)); break;
|
|
92 |
case T_BYTE: __ ldrsb (result, Address(robj, roffset)); break;
|
|
93 |
case T_CHAR: __ ldrh (result, Address(robj, roffset)); break;
|
|
94 |
case T_SHORT: __ ldrsh (result, Address(robj, roffset)); break;
|
|
95 |
case T_FLOAT: __ ldrw (result, Address(robj, roffset)); break;
|
|
96 |
case T_INT: __ ldrsw (result, Address(robj, roffset)); break;
|
|
97 |
case T_DOUBLE:
|
|
98 |
case T_LONG: __ ldr (result, Address(robj, roffset)); break;
|
|
99 |
default: ShouldNotReachHere();
|
|
100 |
}
|
|
101 |
|
|
102 |
// counter_addr is address dependent on result.
|
|
103 |
__ eor(rcounter_addr, rcounter_addr, result);
|
|
104 |
__ eor(rcounter_addr, rcounter_addr, result);
|
|
105 |
__ ldrw(rscratch1, safepoint_counter_addr);
|
|
106 |
__ cmpw(rcounter, rscratch1);
|
|
107 |
__ br (Assembler::NE, slow);
|
|
108 |
|
|
109 |
switch (type) {
|
|
110 |
case T_FLOAT: __ fmovs(v0, result); break;
|
|
111 |
case T_DOUBLE: __ fmovd(v0, result); break;
|
|
112 |
default: __ mov(r0, result); break;
|
|
113 |
}
|
|
114 |
__ ret(lr);
|
|
115 |
|
|
116 |
slowcase_entry_pclist[count++] = __ pc();
|
|
117 |
__ bind(slow);
|
|
118 |
address slow_case_addr;
|
|
119 |
switch (type) {
|
|
120 |
case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
|
|
121 |
case T_BYTE: slow_case_addr = jni_GetByteField_addr(); break;
|
|
122 |
case T_CHAR: slow_case_addr = jni_GetCharField_addr(); break;
|
|
123 |
case T_SHORT: slow_case_addr = jni_GetShortField_addr(); break;
|
|
124 |
case T_INT: slow_case_addr = jni_GetIntField_addr(); break;
|
|
125 |
case T_LONG: slow_case_addr = jni_GetLongField_addr(); break;
|
|
126 |
case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break;
|
|
127 |
case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;
|
|
128 |
default: ShouldNotReachHere();
|
35127
|
129 |
slow_case_addr = NULL; // unreachable
|
29183
|
130 |
}
|
|
131 |
|
|
132 |
{
|
|
133 |
__ enter();
|
|
134 |
__ lea(rscratch1, ExternalAddress(slow_case_addr));
|
|
135 |
__ blr(rscratch1);
|
|
136 |
__ maybe_isb();
|
|
137 |
__ leave();
|
|
138 |
__ ret(lr);
|
|
139 |
}
|
|
140 |
__ flush ();
|
|
141 |
|
|
142 |
return fast_entry;
|
|
143 |
}
|
|
144 |
|
|
145 |
address JNI_FastGetField::generate_fast_get_boolean_field() {
|
|
146 |
return generate_fast_get_int_field0(T_BOOLEAN);
|
|
147 |
}
|
|
148 |
|
|
149 |
address JNI_FastGetField::generate_fast_get_byte_field() {
|
|
150 |
return generate_fast_get_int_field0(T_BYTE);
|
|
151 |
}
|
|
152 |
|
|
153 |
address JNI_FastGetField::generate_fast_get_char_field() {
|
|
154 |
return generate_fast_get_int_field0(T_CHAR);
|
|
155 |
}
|
|
156 |
|
|
157 |
address JNI_FastGetField::generate_fast_get_short_field() {
|
|
158 |
return generate_fast_get_int_field0(T_SHORT);
|
|
159 |
}
|
|
160 |
|
|
161 |
address JNI_FastGetField::generate_fast_get_int_field() {
|
|
162 |
return generate_fast_get_int_field0(T_INT);
|
|
163 |
}
|
|
164 |
|
|
165 |
address JNI_FastGetField::generate_fast_get_long_field() {
|
|
166 |
return generate_fast_get_int_field0(T_LONG);
|
|
167 |
}
|
|
168 |
|
|
169 |
address JNI_FastGetField::generate_fast_get_float_field() {
|
|
170 |
return generate_fast_get_int_field0(T_FLOAT);
|
|
171 |
}
|
|
172 |
|
|
173 |
address JNI_FastGetField::generate_fast_get_double_field() {
|
|
174 |
return generate_fast_get_int_field0(T_DOUBLE);
|
|
175 |
}
|
|
176 |
|