7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "asm/macroAssembler.hpp"
27 #include "interpreter/interpreter.hpp"
28 #include "interpreter/interpreterGenerator.hpp"
29 #include "runtime/arguments.hpp"
30
31 #define __ _masm->
32
33 #ifndef CC_INTERP
34
35 /**
36 * Method entry for static native methods:
37 * int java.util.zip.CRC32.update(int crc, int b)
38 */
39 address InterpreterGenerator::generate_CRC32_update_entry() {
40 if (UseCRC32Intrinsics) {
41 address entry = __ pc();
42
43 // rbx,: Method*
44 // r13: senderSP must preserved for slow path, set SP to it on fast path
45 // c_rarg0: scratch (rdi on non-Win64, rcx on Win64)
46 // c_rarg1: scratch (rsi on non-Win64, rdx on Win64)
47
48 Label slow_path;
49 // If we need a safepoint check, generate full interpreter entry.
50 ExternalAddress state(SafepointSynchronize::address_of_state());
51 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
52 SafepointSynchronize::_not_synchronized);
53 __ jcc(Assembler::notEqual, slow_path);
54
55 // We don't generate local frame and don't align stack because
56 // we call stub code and there is no safepoint on this path.
57
58 // Load parameters
59 const Register crc = rax; // crc
71 // result in rax
72
73 // _areturn
74 __ pop(rdi); // get return address
75 __ mov(rsp, r13); // set sp to sender sp
76 __ jmp(rdi);
77
78 // generate a vanilla native entry as the slow path
79 __ bind(slow_path);
80 __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native));
81 return entry;
82 }
83 return NULL;
84 }
85
86 /**
87 * Method entry for static native methods:
88 * int java.util.zip.CRC32.updateBytes(int crc, byte[] b, int off, int len)
89 * int java.util.zip.CRC32.updateByteBuffer(int crc, long buf, int off, int len)
90 */
91 address InterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
92 if (UseCRC32Intrinsics) {
93 address entry = __ pc();
94
95 // rbx,: Method*
96 // r13: senderSP must preserved for slow path, set SP to it on fast path
97
98 Label slow_path;
99 // If we need a safepoint check, generate full interpreter entry.
100 ExternalAddress state(SafepointSynchronize::address_of_state());
101 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
102 SafepointSynchronize::_not_synchronized);
103 __ jcc(Assembler::notEqual, slow_path);
104
105 // We don't generate local frame and don't align stack because
106 // we call stub code and there is no safepoint on this path.
107
108 // Load parameters
109 const Register crc = c_rarg0; // crc
110 const Register buf = c_rarg1; // source java byte array address
111 const Register len = c_rarg2; // length
132 // result in rax
133
134 // _areturn
135 __ pop(rdi); // get return address
136 __ mov(rsp, r13); // set sp to sender sp
137 __ jmp(rdi);
138
139 // generate a vanilla native entry as the slow path
140 __ bind(slow_path);
141 __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native));
142 return entry;
143 }
144 return NULL;
145 }
146
147 /**
148 * Method entry for static native methods:
149 * int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int end)
150 * int java.util.zip.CRC32C.updateByteBuffer(int crc, long address, int off, int end)
151 */
152 address InterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
153 if (UseCRC32CIntrinsics) {
154 address entry = __ pc();
155 // Load parameters
156 const Register crc = c_rarg0; // crc
157 const Register buf = c_rarg1; // source java byte array address
158 const Register len = c_rarg2;
159 const Register off = c_rarg3; // offset
160 const Register end = len;
161
162 // Arguments are reversed on java expression stack
163 // Calculate address of start element
164 if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) {
165 __ movptr(buf, Address(rsp, 3 * wordSize)); // long buf
166 __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
167 __ addq(buf, off); // + offset
168 __ movl(crc, Address(rsp, 5 * wordSize)); // Initial CRC
169 // Note on 5 * wordSize vs. 4 * wordSize:
170 // * int java.util.zip.CRC32C.updateByteBuffer(int crc, long address, int off, int end)
171 // 4 2,3 1 0
172 // end starts at SP + 8
177 __ movptr(buf, Address(rsp, 3 * wordSize)); // byte[] array
178 __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
179 __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
180 __ addq(buf, off); // + offset
181 __ movl(crc, Address(rsp, 4 * wordSize)); // Initial CRC
182 }
183 __ movl(end, Address(rsp, wordSize)); // end
184 __ subl(end, off); // end - off
185 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, StubRoutines::updateBytesCRC32C()), crc, buf, len);
186 // result in rax
187 // _areturn
188 __ pop(rdi); // get return address
189 __ mov(rsp, r13); // set sp to sender sp
190 __ jmp(rdi);
191
192 return entry;
193 }
194
195 return NULL;
196 }
197 #endif // ! CC_INTERP
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "asm/macroAssembler.hpp"
27 #include "interpreter/interp_masm.hpp"
28 #include "interpreter/interpreter.hpp"
29 #include "interpreter/templateInterpreterGenerator.hpp"
30 #include "runtime/arguments.hpp"
31
32 #define __ _masm->
33
34 /**
35 * Method entry for static native methods:
36 * int java.util.zip.CRC32.update(int crc, int b)
37 */
38 address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
39 if (UseCRC32Intrinsics) {
40 address entry = __ pc();
41
42 // rbx,: Method*
43 // r13: senderSP must preserved for slow path, set SP to it on fast path
44 // c_rarg0: scratch (rdi on non-Win64, rcx on Win64)
45 // c_rarg1: scratch (rsi on non-Win64, rdx on Win64)
46
47 Label slow_path;
48 // If we need a safepoint check, generate full interpreter entry.
49 ExternalAddress state(SafepointSynchronize::address_of_state());
50 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
51 SafepointSynchronize::_not_synchronized);
52 __ jcc(Assembler::notEqual, slow_path);
53
54 // We don't generate local frame and don't align stack because
55 // we call stub code and there is no safepoint on this path.
56
57 // Load parameters
58 const Register crc = rax; // crc
70 // result in rax
71
72 // _areturn
73 __ pop(rdi); // get return address
74 __ mov(rsp, r13); // set sp to sender sp
75 __ jmp(rdi);
76
77 // generate a vanilla native entry as the slow path
78 __ bind(slow_path);
79 __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native));
80 return entry;
81 }
82 return NULL;
83 }
84
85 /**
86 * Method entry for static native methods:
87 * int java.util.zip.CRC32.updateBytes(int crc, byte[] b, int off, int len)
88 * int java.util.zip.CRC32.updateByteBuffer(int crc, long buf, int off, int len)
89 */
90 address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
91 if (UseCRC32Intrinsics) {
92 address entry = __ pc();
93
94 // rbx,: Method*
95 // r13: senderSP must preserved for slow path, set SP to it on fast path
96
97 Label slow_path;
98 // If we need a safepoint check, generate full interpreter entry.
99 ExternalAddress state(SafepointSynchronize::address_of_state());
100 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
101 SafepointSynchronize::_not_synchronized);
102 __ jcc(Assembler::notEqual, slow_path);
103
104 // We don't generate local frame and don't align stack because
105 // we call stub code and there is no safepoint on this path.
106
107 // Load parameters
108 const Register crc = c_rarg0; // crc
109 const Register buf = c_rarg1; // source java byte array address
110 const Register len = c_rarg2; // length
131 // result in rax
132
133 // _areturn
134 __ pop(rdi); // get return address
135 __ mov(rsp, r13); // set sp to sender sp
136 __ jmp(rdi);
137
138 // generate a vanilla native entry as the slow path
139 __ bind(slow_path);
140 __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native));
141 return entry;
142 }
143 return NULL;
144 }
145
146 /**
147 * Method entry for static native methods:
148 * int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int end)
149 * int java.util.zip.CRC32C.updateByteBuffer(int crc, long address, int off, int end)
150 */
151 address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
152 if (UseCRC32CIntrinsics) {
153 address entry = __ pc();
154 // Load parameters
155 const Register crc = c_rarg0; // crc
156 const Register buf = c_rarg1; // source java byte array address
157 const Register len = c_rarg2;
158 const Register off = c_rarg3; // offset
159 const Register end = len;
160
161 // Arguments are reversed on java expression stack
162 // Calculate address of start element
163 if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) {
164 __ movptr(buf, Address(rsp, 3 * wordSize)); // long buf
165 __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
166 __ addq(buf, off); // + offset
167 __ movl(crc, Address(rsp, 5 * wordSize)); // Initial CRC
168 // Note on 5 * wordSize vs. 4 * wordSize:
169 // * int java.util.zip.CRC32C.updateByteBuffer(int crc, long address, int off, int end)
170 // 4 2,3 1 0
171 // end starts at SP + 8
176 __ movptr(buf, Address(rsp, 3 * wordSize)); // byte[] array
177 __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
178 __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
179 __ addq(buf, off); // + offset
180 __ movl(crc, Address(rsp, 4 * wordSize)); // Initial CRC
181 }
182 __ movl(end, Address(rsp, wordSize)); // end
183 __ subl(end, off); // end - off
184 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, StubRoutines::updateBytesCRC32C()), crc, buf, len);
185 // result in rax
186 // _areturn
187 __ pop(rdi); // get return address
188 __ mov(rsp, r13); // set sp to sender sp
189 __ jmp(rdi);
190
191 return entry;
192 }
193
194 return NULL;
195 }
|