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