1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 #ifndef CPU_X86_VM_MACROASSEMBLER_X86_HPP
26 #define CPU_X86_VM_MACROASSEMBLER_X86_HPP
27
28 #include "asm/assembler.hpp"
29 #include "utilities/macros.hpp"
30 #include "runtime/rtmLocking.hpp"
31
32
33 // MacroAssembler extends Assembler by frequently used macros.
34 //
35 // Instructions for which a 'better' code sequence exists depending
36 // on arguments should also go in here.
37
38 class MacroAssembler: public Assembler {
39 friend class LIR_Assembler;
40 friend class Runtime1; // as_Address()
41
42 protected:
43
44 Address as_Address(AddressLiteral adr);
45 Address as_Address(ArrayAddress adr);
46
47 // Support for VM calls
48 //
49 // This is the base routine called by the different versions of call_VM_leaf. The interpreter
50 // may customize this version by overriding it for its purposes (e.g., to save/restore
51 // additional registers when doing a VM call).
52 #ifdef CC_INTERP
1188
1189 // Can push value or effective address
1190 void pushptr(AddressLiteral src);
1191
1192 void pushptr(Address src) { LP64_ONLY(pushq(src)) NOT_LP64(pushl(src)); }
1193 void popptr(Address src) { LP64_ONLY(popq(src)) NOT_LP64(popl(src)); }
1194
1195 void pushoop(jobject obj);
1196 void pushklass(Metadata* obj);
1197
1198 // sign extend as need a l to ptr sized element
1199 void movl2ptr(Register dst, Address src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(movl(dst, src)); }
1200 void movl2ptr(Register dst, Register src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(if (dst != src) movl(dst, src)); }
1201
1202 // C2 compiled method's prolog code.
1203 void verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b);
1204
1205 // clear memory of size 'cnt' qwords, starting at 'base'.
1206 void clear_mem(Register base, Register cnt, Register rtmp);
1207
1208 // IndexOf strings.
1209 // Small strings are loaded through stack if they cross page boundary.
1210 void string_indexof(Register str1, Register str2,
1211 Register cnt1, Register cnt2,
1212 int int_cnt2, Register result,
1213 XMMRegister vec, Register tmp);
1214
1215 // IndexOf for constant substrings with size >= 8 elements
1216 // which don't need to be loaded through stack.
1217 void string_indexofC8(Register str1, Register str2,
1218 Register cnt1, Register cnt2,
1219 int int_cnt2, Register result,
1220 XMMRegister vec, Register tmp);
1221
1222 // Smallest code: we don't need to load through stack,
1223 // check string tail.
1224
1225 // Compare strings.
1226 void string_compare(Register str1, Register str2,
1227 Register cnt1, Register cnt2, Register result,
1228 XMMRegister vec1);
1229
1230 // Compare char[] arrays.
1231 void char_arrays_equals(bool is_array_equ, Register ary1, Register ary2,
1232 Register limit, Register result, Register chr,
1233 XMMRegister vec1, XMMRegister vec2);
1234
1235 // Fill primitive arrays
1236 void generate_fill(BasicType t, bool aligned,
1237 Register to, Register value, Register count,
1238 Register rtmp, XMMRegister xtmp);
1239
1240 void encode_iso_array(Register src, Register dst, Register len,
1241 XMMRegister tmp1, XMMRegister tmp2, XMMRegister tmp3,
1242 XMMRegister tmp4, Register tmp5, Register result);
1243
1244 #ifdef _LP64
1245 void add2_with_carry(Register dest_hi, Register dest_lo, Register src1, Register src2);
1246 void multiply_64_x_64_loop(Register x, Register xstart, Register x_xstart,
1247 Register y, Register y_idx, Register z,
1248 Register carry, Register product,
1249 Register idx, Register kdx);
1250 void multiply_add_128_x_128(Register x_xstart, Register y, Register z,
1251 Register yz_idx, Register idx,
1252 Register carry, Register product, int offset);
1253 void multiply_128_x_128_bmi2_loop(Register y, Register z,
1254 Register carry, Register carry2,
1307 XMMRegister w_xtmp1, XMMRegister w_xtmp2, XMMRegister w_xtmp3,
1308 Register tmp1, Register tmp2,
1309 Register n_tmp3);
1310 void crc32c_proc_chunk(uint32_t size, uint32_t const_or_pre_comp_const_index_u1, uint32_t const_or_pre_comp_const_index_u2, bool is_pclmulqdq_supported,
1311 Register in_out1, Register in_out2, Register in_out3,
1312 Register tmp1, Register tmp2, Register tmp3,
1313 XMMRegister w_xtmp1, XMMRegister w_xtmp2, XMMRegister w_xtmp3,
1314 Register tmp4, Register tmp5,
1315 Register n_tmp6);
1316 void crc32c_ipl_alg2_alt2(Register in_out, Register in1, Register in2,
1317 Register tmp1, Register tmp2, Register tmp3,
1318 Register tmp4, Register tmp5, Register tmp6,
1319 XMMRegister w_xtmp1, XMMRegister w_xtmp2, XMMRegister w_xtmp3,
1320 bool is_pclmulqdq_supported);
1321 // Fold 128-bit data chunk
1322 void fold_128bit_crc32(XMMRegister xcrc, XMMRegister xK, XMMRegister xtmp, Register buf, int offset);
1323 void fold_128bit_crc32(XMMRegister xcrc, XMMRegister xK, XMMRegister xtmp, XMMRegister xbuf);
1324 // Fold 8-bit data
1325 void fold_8bit_crc32(Register crc, Register table, Register tmp);
1326 void fold_8bit_crc32(XMMRegister crc, Register table, XMMRegister xtmp, Register tmp);
1327
1328 #undef VIRTUAL
1329
1330 };
1331
1332 /**
1333 * class SkipIfEqual:
1334 *
1335 * Instantiating this class will result in assembly code being output that will
1336 * jump around any code emitted between the creation of the instance and it's
1337 * automatic destruction at the end of a scope block, depending on the value of
1338 * the flag passed to the constructor, which will be checked at run-time.
1339 */
1340 class SkipIfEqual {
1341 private:
1342 MacroAssembler* _masm;
1343 Label _label;
1344
1345 public:
1346 SkipIfEqual(MacroAssembler*, const bool* flag_addr, bool value);
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 #ifndef CPU_X86_VM_MACROASSEMBLER_X86_HPP
26 #define CPU_X86_VM_MACROASSEMBLER_X86_HPP
27
28 #include "asm/assembler.hpp"
29 #include "utilities/macros.hpp"
30 #include "runtime/rtmLocking.hpp"
31
32 // MacroAssembler extends Assembler by frequently used macros.
33 //
34 // Instructions for which a 'better' code sequence exists depending
35 // on arguments should also go in here.
36
37 class MacroAssembler: public Assembler {
38 friend class LIR_Assembler;
39 friend class Runtime1; // as_Address()
40
41 protected:
42
43 Address as_Address(AddressLiteral adr);
44 Address as_Address(ArrayAddress adr);
45
46 // Support for VM calls
47 //
48 // This is the base routine called by the different versions of call_VM_leaf. The interpreter
49 // may customize this version by overriding it for its purposes (e.g., to save/restore
50 // additional registers when doing a VM call).
51 #ifdef CC_INTERP
1187
1188 // Can push value or effective address
1189 void pushptr(AddressLiteral src);
1190
1191 void pushptr(Address src) { LP64_ONLY(pushq(src)) NOT_LP64(pushl(src)); }
1192 void popptr(Address src) { LP64_ONLY(popq(src)) NOT_LP64(popl(src)); }
1193
1194 void pushoop(jobject obj);
1195 void pushklass(Metadata* obj);
1196
1197 // sign extend as need a l to ptr sized element
1198 void movl2ptr(Register dst, Address src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(movl(dst, src)); }
1199 void movl2ptr(Register dst, Register src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(if (dst != src) movl(dst, src)); }
1200
1201 // C2 compiled method's prolog code.
1202 void verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b);
1203
1204 // clear memory of size 'cnt' qwords, starting at 'base'.
1205 void clear_mem(Register base, Register cnt, Register rtmp);
1206
1207 #ifdef COMPILER2
1208 void string_indexof_char(Register str1, Register cnt1, Register ch, Register result,
1209 XMMRegister vec1, XMMRegister vec2, XMMRegister vec3, Register tmp);
1210
1211 // IndexOf strings.
1212 // Small strings are loaded through stack if they cross page boundary.
1213 void string_indexof(Register str1, Register str2,
1214 Register cnt1, Register cnt2,
1215 int int_cnt2, Register result,
1216 XMMRegister vec, Register tmp,
1217 int ae);
1218
1219 // IndexOf for constant substrings with size >= 8 elements
1220 // which don't need to be loaded through stack.
1221 void string_indexofC8(Register str1, Register str2,
1222 Register cnt1, Register cnt2,
1223 int int_cnt2, Register result,
1224 XMMRegister vec, Register tmp,
1225 int ae);
1226
1227 // Smallest code: we don't need to load through stack,
1228 // check string tail.
1229
1230 // helper function for string_compare
1231 void load_next_elements(Register elem1, Register elem2, Register str1, Register str2,
1232 Address::ScaleFactor scale, Address::ScaleFactor scale1,
1233 Address::ScaleFactor scale2, Register index, int ae);
1234 // Compare strings.
1235 void string_compare(Register str1, Register str2,
1236 Register cnt1, Register cnt2, Register result,
1237 XMMRegister vec1, int ae);
1238
1239 // Search for Non-ASCII character (Negative byte value) in a byte array,
1240 // return true if it has any and false otherwise.
1241 void has_negatives(Register ary1, Register len,
1242 Register result, Register tmp1,
1243 XMMRegister vec1, XMMRegister vec2);
1244
1245 // Compare char[] or byte[] arrays.
1246 void arrays_equals(bool is_array_equ, Register ary1, Register ary2,
1247 Register limit, Register result, Register chr,
1248 XMMRegister vec1, XMMRegister vec2, bool is_char);
1249
1250 #endif
1251
1252 // Fill primitive arrays
1253 void generate_fill(BasicType t, bool aligned,
1254 Register to, Register value, Register count,
1255 Register rtmp, XMMRegister xtmp);
1256
1257 void encode_iso_array(Register src, Register dst, Register len,
1258 XMMRegister tmp1, XMMRegister tmp2, XMMRegister tmp3,
1259 XMMRegister tmp4, Register tmp5, Register result);
1260
1261 #ifdef _LP64
1262 void add2_with_carry(Register dest_hi, Register dest_lo, Register src1, Register src2);
1263 void multiply_64_x_64_loop(Register x, Register xstart, Register x_xstart,
1264 Register y, Register y_idx, Register z,
1265 Register carry, Register product,
1266 Register idx, Register kdx);
1267 void multiply_add_128_x_128(Register x_xstart, Register y, Register z,
1268 Register yz_idx, Register idx,
1269 Register carry, Register product, int offset);
1270 void multiply_128_x_128_bmi2_loop(Register y, Register z,
1271 Register carry, Register carry2,
1324 XMMRegister w_xtmp1, XMMRegister w_xtmp2, XMMRegister w_xtmp3,
1325 Register tmp1, Register tmp2,
1326 Register n_tmp3);
1327 void crc32c_proc_chunk(uint32_t size, uint32_t const_or_pre_comp_const_index_u1, uint32_t const_or_pre_comp_const_index_u2, bool is_pclmulqdq_supported,
1328 Register in_out1, Register in_out2, Register in_out3,
1329 Register tmp1, Register tmp2, Register tmp3,
1330 XMMRegister w_xtmp1, XMMRegister w_xtmp2, XMMRegister w_xtmp3,
1331 Register tmp4, Register tmp5,
1332 Register n_tmp6);
1333 void crc32c_ipl_alg2_alt2(Register in_out, Register in1, Register in2,
1334 Register tmp1, Register tmp2, Register tmp3,
1335 Register tmp4, Register tmp5, Register tmp6,
1336 XMMRegister w_xtmp1, XMMRegister w_xtmp2, XMMRegister w_xtmp3,
1337 bool is_pclmulqdq_supported);
1338 // Fold 128-bit data chunk
1339 void fold_128bit_crc32(XMMRegister xcrc, XMMRegister xK, XMMRegister xtmp, Register buf, int offset);
1340 void fold_128bit_crc32(XMMRegister xcrc, XMMRegister xK, XMMRegister xtmp, XMMRegister xbuf);
1341 // Fold 8-bit data
1342 void fold_8bit_crc32(Register crc, Register table, Register tmp);
1343 void fold_8bit_crc32(XMMRegister crc, Register table, XMMRegister xtmp, Register tmp);
1344
1345 // Compress char[] array to byte[].
1346 void char_array_compress(Register src, Register dst, Register len,
1347 XMMRegister tmp1, XMMRegister tmp2, XMMRegister tmp3,
1348 XMMRegister tmp4, Register tmp5, Register result);
1349
1350 // Inflate byte[] array to char[].
1351 void byte_array_inflate(Register src, Register dst, Register len,
1352 XMMRegister tmp1, Register tmp2);
1353
1354 #undef VIRTUAL
1355
1356 };
1357
1358 /**
1359 * class SkipIfEqual:
1360 *
1361 * Instantiating this class will result in assembly code being output that will
1362 * jump around any code emitted between the creation of the instance and it's
1363 * automatic destruction at the end of a scope block, depending on the value of
1364 * the flag passed to the constructor, which will be checked at run-time.
1365 */
1366 class SkipIfEqual {
1367 private:
1368 MacroAssembler* _masm;
1369 Label _label;
1370
1371 public:
1372 SkipIfEqual(MacroAssembler*, const bool* flag_addr, bool value);
|