5077 }
5078
5079 void MacroAssembler::load_method_holder_cld(Register rresult, Register rmethod) {
5080 load_method_holder(rresult, rmethod);
5081 ldr(rresult, Address(rresult, InstanceKlass::class_loader_data_offset()));
5082 }
5083
5084 void MacroAssembler::load_method_holder(Register holder, Register method) {
5085 ldr(holder, Address(method, Method::const_offset())); // ConstMethod*
5086 ldr(holder, Address(holder, ConstMethod::constants_offset())); // ConstantPool*
5087 ldr(holder, Address(holder, ConstantPool::pool_holder_offset())); // InstanceKlass*
5088 }
5089
5090 // Loads the obj's Klass* into dst.
5091 // Preserves all registers (incl src, rscratch1 and rscratch2).
5092 // Input:
5093 // src - the oop we want to load the klass from.
5094 // dst - output narrow klass.
5095 void MacroAssembler::load_narrow_klass_compact(Register dst, Register src) {
5096 assert(UseCompactObjectHeaders, "expects UseCompactObjectHeaders");
5097 ldr(dst, Address(src, oopDesc::mark_offset_in_bytes()));
5098 lsr(dst, dst, markWord::klass_shift);
5099 }
5100
5101 void MacroAssembler::load_klass(Register dst, Register src) {
5102 if (UseCompactObjectHeaders) {
5103 load_narrow_klass_compact(dst, src);
5104 } else {
5105 ldrw(dst, Address(src, oopDesc::klass_offset_in_bytes()));
5106 }
5107 decode_klass_not_null(dst);
5108 }
5109
5110 void MacroAssembler::restore_cpu_control_state_after_jni(Register tmp1, Register tmp2) {
5111 if (RestoreMXCSROnJNICalls) {
5112 Label OK;
5113 get_fpcr(tmp1);
5114 mov(tmp2, tmp1);
5115 // Set FPCR to the state we need. We do want Round to Nearest. We
5116 // don't want non-IEEE rounding modes or floating-point traps.
5117 bfi(tmp1, zr, 22, 4); // Clear DN, FZ, and Rmode
5118 bfi(tmp1, zr, 8, 5); // Clear exception-control bits (8-12)
5897 b(DONE);
5898
5899 BIND(SET_RESULT);
5900
5901 add(len, len, wordSize);
5902 sub(result, result, len);
5903
5904 BIND(DONE);
5905 postcond(pc() != badAddress);
5906 return pc();
5907 }
5908
5909 // Clobbers: rscratch1, rscratch2, rflags
5910 // May also clobber v0-v7 when (!UseSimpleArrayEquals && UseSIMDForArrayEquals)
5911 address MacroAssembler::arrays_equals(Register a1, Register a2, Register tmp3,
5912 Register tmp4, Register tmp5, Register result,
5913 Register cnt1, int elem_size) {
5914 Label DONE, SAME;
5915 Register tmp1 = rscratch1;
5916 Register tmp2 = rscratch2;
5917 int elem_per_word = wordSize/elem_size;
5918 int log_elem_size = exact_log2(elem_size);
5919 int klass_offset = arrayOopDesc::klass_offset_in_bytes();
5920 int length_offset = arrayOopDesc::length_offset_in_bytes();
5921 int base_offset
5922 = arrayOopDesc::base_offset_in_bytes(elem_size == 2 ? T_CHAR : T_BYTE);
5923 // When the length offset is not aligned to 8 bytes,
5924 // then we align it down. This is valid because the new
5925 // offset will always be the klass which is the same
5926 // for type arrays.
5927 int start_offset = align_down(length_offset, BytesPerWord);
5928 int extra_length = base_offset - start_offset;
5929 assert(start_offset == length_offset || start_offset == klass_offset,
5930 "start offset must be 8-byte-aligned or be the klass offset");
5931 assert(base_offset != start_offset, "must include the length field");
5932 extra_length = extra_length / elem_size; // We count in elements, not bytes.
5933 int stubBytesThreshold = 3 * 64 + (UseSIMDForArrayEquals ? 0 : 16);
5934
5935 assert(elem_size == 1 || elem_size == 2, "must be char or byte");
5936 assert_different_registers(a1, a2, result, cnt1, rscratch1, rscratch2);
5937
5938 #ifndef PRODUCT
5939 {
5940 const char kind = (elem_size == 2) ? 'U' : 'L';
5941 char comment[64];
5942 os::snprintf_checked(comment, sizeof comment, "array_equals%c{", kind);
5943 BLOCK_COMMENT(comment);
5944 }
5945 #endif
5946
5947 // if (a1 == a2)
5948 // return true;
5949 cmpoop(a1, a2); // May have read barriers for a1 and a2.
5950 br(EQ, SAME);
5951
|
5077 }
5078
5079 void MacroAssembler::load_method_holder_cld(Register rresult, Register rmethod) {
5080 load_method_holder(rresult, rmethod);
5081 ldr(rresult, Address(rresult, InstanceKlass::class_loader_data_offset()));
5082 }
5083
5084 void MacroAssembler::load_method_holder(Register holder, Register method) {
5085 ldr(holder, Address(method, Method::const_offset())); // ConstMethod*
5086 ldr(holder, Address(holder, ConstMethod::constants_offset())); // ConstantPool*
5087 ldr(holder, Address(holder, ConstantPool::pool_holder_offset())); // InstanceKlass*
5088 }
5089
5090 // Loads the obj's Klass* into dst.
5091 // Preserves all registers (incl src, rscratch1 and rscratch2).
5092 // Input:
5093 // src - the oop we want to load the klass from.
5094 // dst - output narrow klass.
5095 void MacroAssembler::load_narrow_klass_compact(Register dst, Register src) {
5096 assert(UseCompactObjectHeaders, "expects UseCompactObjectHeaders");
5097 ldrw(dst, Address(src, oopDesc::mark_offset_in_bytes()));
5098 lsrw(dst, dst, markWord::klass_shift);
5099 }
5100
5101 void MacroAssembler::load_klass(Register dst, Register src) {
5102 if (UseCompactObjectHeaders) {
5103 load_narrow_klass_compact(dst, src);
5104 } else {
5105 ldrw(dst, Address(src, oopDesc::klass_offset_in_bytes()));
5106 }
5107 decode_klass_not_null(dst);
5108 }
5109
5110 void MacroAssembler::restore_cpu_control_state_after_jni(Register tmp1, Register tmp2) {
5111 if (RestoreMXCSROnJNICalls) {
5112 Label OK;
5113 get_fpcr(tmp1);
5114 mov(tmp2, tmp1);
5115 // Set FPCR to the state we need. We do want Round to Nearest. We
5116 // don't want non-IEEE rounding modes or floating-point traps.
5117 bfi(tmp1, zr, 22, 4); // Clear DN, FZ, and Rmode
5118 bfi(tmp1, zr, 8, 5); // Clear exception-control bits (8-12)
5897 b(DONE);
5898
5899 BIND(SET_RESULT);
5900
5901 add(len, len, wordSize);
5902 sub(result, result, len);
5903
5904 BIND(DONE);
5905 postcond(pc() != badAddress);
5906 return pc();
5907 }
5908
5909 // Clobbers: rscratch1, rscratch2, rflags
5910 // May also clobber v0-v7 when (!UseSimpleArrayEquals && UseSIMDForArrayEquals)
5911 address MacroAssembler::arrays_equals(Register a1, Register a2, Register tmp3,
5912 Register tmp4, Register tmp5, Register result,
5913 Register cnt1, int elem_size) {
5914 Label DONE, SAME;
5915 Register tmp1 = rscratch1;
5916 Register tmp2 = rscratch2;
5917 Register cnt2 = tmp2; // cnt2 only used in array length compare
5918 int elem_per_word = wordSize/elem_size;
5919 int log_elem_size = exact_log2(elem_size);
5920 int klass_offset = arrayOopDesc::klass_offset_in_bytes();
5921 int length_offset = arrayOopDesc::length_offset_in_bytes();
5922 int base_offset
5923 = arrayOopDesc::base_offset_in_bytes(elem_size == 2 ? T_CHAR : T_BYTE);
5924 // When the length offset is not aligned to 8 bytes,
5925 // then we align it down. This is valid because the new
5926 // offset will always be the klass which is the same
5927 // for type arrays.
5928 // With 4-byte headers, we need to start at the base-offset, and check
5929 // the length field explicitly.
5930 int start_offset = UseCompactObjectHeaders ? base_offset : align_down(length_offset, BytesPerWord);
5931 int extra_length = base_offset - start_offset;
5932 if (UseCompactObjectHeaders) {
5933 assert(base_offset == start_offset, "must start at base-offset");
5934 } else {
5935 assert(start_offset == length_offset || start_offset == klass_offset,
5936 "start offset must be 8-byte-aligned or be the klass offset");
5937 assert(base_offset != start_offset, "must include the length field");
5938 }
5939 extra_length = extra_length / elem_size; // We count in elements, not bytes.
5940 int stubBytesThreshold = 3 * 64 + (UseSIMDForArrayEquals ? 0 : 16);
5941
5942 assert(elem_size == 1 || elem_size == 2, "must be char or byte");
5943 assert_different_registers(a1, a2, result, cnt1, rscratch1, rscratch2);
5944
5945 #ifndef PRODUCT
5946 {
5947 const char kind = (elem_size == 2) ? 'U' : 'L';
5948 char comment[64];
5949 os::snprintf_checked(comment, sizeof comment, "array_equals%c{", kind);
5950 BLOCK_COMMENT(comment);
5951 }
5952 #endif
5953
5954 // if (a1 == a2)
5955 // return true;
5956 cmpoop(a1, a2); // May have read barriers for a1 and a2.
5957 br(EQ, SAME);
5958
|