Skip to content

Commit 6dfb473

Browse files
authored
Update (2023.03.09)
29860: LA port of 8300255: Introduce interface for GC oop verification in the assembler
1 parent ce2e630 commit 6dfb473

File tree

5 files changed

+36
-24
lines changed

5 files changed

+36
-24
lines changed

src/hotspot/cpu/loongarch/gc/shared/barrierSetAssembler_loongarch.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,16 @@ void BarrierSetAssembler::c2i_entry_barrier(MacroAssembler* masm) {
344344
__ bind(method_live);
345345
}
346346

347+
void BarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
348+
// Check if the oop is in the right area of memory
349+
__ li(tmp2, (intptr_t) Universe::verify_oop_mask());
350+
__ andr(tmp1, obj, tmp2);
351+
__ li(tmp2, (intptr_t) Universe::verify_oop_bits());
352+
353+
// Compare tmp1 and tmp2.
354+
__ bne(tmp1, tmp2, error);
355+
356+
// make sure klass is 'reasonable', which is not zero.
357+
__ load_klass(obj, obj); // get klass
358+
__ beqz(obj, error); // if klass is NULL it is broken
359+
}

src/hotspot/cpu/loongarch/gc/shared/barrierSetAssembler_loongarch.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2018, 2022, Loongson Technology. All rights reserved.
3+
* Copyright (c) 2018, 2023, Loongson Technology. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,8 @@ class BarrierSetAssembler: public CHeapObj<mtGC> {
8888
virtual void nmethod_entry_barrier(MacroAssembler* masm, Label* slow_path, Label* continuation, Label* guard);
8989
virtual void c2i_entry_barrier(MacroAssembler* masm);
9090

91+
virtual void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
92+
9193
virtual bool supports_instruction_patching() {
9294
NMethodPatchingType patching_type = nmethod_patching_type();
9395
return patching_type == NMethodPatchingType::conc_instruction_and_data_patch ||

src/hotspot/cpu/loongarch/gc/z/zBarrierSetAssembler_loongarch.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2021, 2022, Loongson Technology. All rights reserved.
3+
* Copyright (c) 2021, 2023, Loongson Technology. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -456,3 +456,17 @@ void ZBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, Z
456456
#undef __
457457

458458
#endif // COMPILER2
459+
460+
#define __ masm->
461+
462+
void ZBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
463+
// Check if mask is good.
464+
// verifies that ZAddressBadMask & obj == 0
465+
__ ld_d(tmp2, Address(TREG, ZThreadLocalData::address_bad_mask_offset()));
466+
__ andr(tmp1, obj, tmp2);
467+
__ bnez(tmp1, error);
468+
469+
BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error);
470+
}
471+
472+
#undef __

src/hotspot/cpu/loongarch/gc/z/zBarrierSetAssembler_loongarch.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2021, 2022, Loongson Technology. All rights reserved.
3+
* Copyright (c) 2021, 2023, Loongson Technology. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -97,6 +97,8 @@ class ZBarrierSetAssembler : public ZBarrierSetAssemblerBase {
9797
void generate_c2_load_barrier_stub(MacroAssembler* masm,
9898
ZLoadBarrierStubC2* stub) const;
9999
#endif // COMPILER2
100+
101+
void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
100102
};
101103

102104
#endif // CPU_LOONGARCH_GC_Z_ZBARRIERSETASSEMBLER_LOONGARCH_HPP

src/hotspot/cpu/loongarch/stubGenerator_loongarch_64.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -464,27 +464,8 @@ class StubGenerator: public StubCodeGenerator {
464464
// make sure object is 'reasonable'
465465
__ beqz(oop, exit); // if obj is NULL it is OK
466466

467-
#if INCLUDE_ZGC
468-
if (UseZGC) {
469-
// Check if mask is good.
470-
// verifies that ZAddressBadMask & object == 0
471-
__ ld_d(c_rarg3, Address(TREG, ZThreadLocalData::address_bad_mask_offset()));
472-
__ andr(c_rarg2, oop, c_rarg3);
473-
__ bnez(c_rarg2, error);
474-
}
475-
#endif
476-
477-
// Check if the oop is in the right area of memory
478-
__ li(c_rarg3, (intptr_t) Universe::verify_oop_mask());
479-
__ andr(c_rarg2, oop, c_rarg3);
480-
__ li(c_rarg3, (intptr_t) Universe::verify_oop_bits());
481-
482-
// Compare c_rarg2 and c_rarg3.
483-
__ bne(c_rarg2, c_rarg3, error);
484-
485-
// make sure klass is 'reasonable', which is not zero.
486-
__ load_klass(c_rarg2, oop); // get klass
487-
__ beqz(c_rarg2, error); // if klass is NULL it is broken
467+
BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler();
468+
bs_asm->check_oop(_masm, oop, c_rarg2, c_rarg3, error);
488469

489470
// return if everything seems ok
490471
__ bind(exit);

0 commit comments

Comments
 (0)