Skip to content

Commit 4a1e59b

Browse files
committed
Refactor mmtkObjectBarrier
1 parent d6cc6b2 commit 4a1e59b

7 files changed

+108
-82
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "precompiled.hpp"
2+
#include "mmtkObjectBarrier.hpp"
3+
#include "runtime/interfaceSupport.inline.hpp"
4+
5+
#define __ masm->
6+
7+
void MMTkObjectBarrierSetAssembler::object_reference_write_post(MacroAssembler* masm, DecoratorSet decorators, Address dst, Register val, Register tmp1, Register tmp2) const {
8+
assert(false, "Not implemented");
9+
}
10+
11+
void MMTkObjectBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register src, Register dst, Register count) {
12+
assert(false, "Not implemented");
13+
}
14+
15+
#undef __
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_RISCV_HPP
2+
#define MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_RISCV_HPP
3+
4+
class MMTkObjectBarrierSetAssembler: public MMTkBarrierSetAssembler {
5+
protected:
6+
virtual void object_reference_write_post(MacroAssembler* masm, DecoratorSet decorators, Address dst, Register val, Register tmp1, Register tmp2) const override;
7+
public:
8+
virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register src, Register dst, Register count) override;
9+
};
10+
#endif // MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_RISCV_HPP
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#include "precompiled.hpp"
2+
#include "mmtkObjectBarrier.hpp"
3+
#include "runtime/interfaceSupport.inline.hpp"
4+
5+
#define __ masm->
6+
7+
void MMTkObjectBarrierSetAssembler::object_reference_write_post(MacroAssembler* masm, DecoratorSet decorators, Address dst, Register val, Register tmp1, Register tmp2) const {
8+
if (can_remove_barrier(decorators, val, /* skip_const_null */ true)) return;
9+
#if MMTK_ENABLE_BARRIER_FASTPATH
10+
Label done;
11+
12+
Register tmp3 = rscratch1;
13+
Register tmp4 = rscratch2;
14+
Register obj = dst.base();
15+
assert_different_registers(obj, tmp2, tmp3);
16+
assert_different_registers(tmp4, rcx);
17+
18+
// tmp2 = load-byte (SIDE_METADATA_BASE_ADDRESS + (obj >> 6));
19+
__ movptr(tmp3, obj);
20+
__ shrptr(tmp3, 6);
21+
__ movptr(tmp2, SIDE_METADATA_BASE_ADDRESS);
22+
__ movb(tmp2, Address(tmp2, tmp3));
23+
// tmp3 = (obj >> 3) & 7
24+
__ movptr(tmp3, obj);
25+
__ shrptr(tmp3, 3);
26+
__ andptr(tmp3, 7);
27+
// tmp2 = tmp2 >> tmp3
28+
__ movptr(tmp4, rcx);
29+
__ movl(rcx, tmp3);
30+
__ shrptr(tmp2);
31+
__ movptr(rcx, tmp4);
32+
// if ((tmp2 & 1) == 1) goto slowpath;
33+
__ andptr(tmp2, 1);
34+
__ cmpptr(tmp2, 1);
35+
__ jcc(Assembler::notEqual, done);
36+
37+
__ movptr(c_rarg0, obj);
38+
__ lea(c_rarg1, dst);
39+
if (val == noreg) {
40+
__ movptr(c_rarg2, NULL_WORD);
41+
} else {
42+
__ movptr(c_rarg2, val);
43+
}
44+
__ call_VM_leaf_base(FN_ADDR(MMTkBarrierSetRuntime::object_reference_write_slow_call), 3);
45+
46+
__ bind(done);
47+
#else
48+
__ movptr(c_rarg0, obj);
49+
__ lea(c_rarg1, dst);
50+
__ movptr(c_rarg2, val == noreg ? (int32_t) NULL_WORD : val);
51+
__ call_VM_leaf_base(FN_ADDR(MMTkBarrierSetRuntime::object_reference_write_post_call), 3);
52+
#endif
53+
}
54+
55+
void MMTkObjectBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register src, Register dst, Register count) {
56+
const bool dest_uninitialized = (decorators & IS_DEST_UNINITIALIZED) != 0;
57+
if ((type == T_OBJECT || type == T_ARRAY) && !dest_uninitialized) {
58+
__ pusha();
59+
__ movptr(c_rarg0, src);
60+
__ movptr(c_rarg1, dst);
61+
__ movptr(c_rarg2, count);
62+
__ call_VM_leaf_base(FN_ADDR(MMTkBarrierSetRuntime::object_reference_array_copy_post_call), 3);
63+
__ popa();
64+
}
65+
}
66+
67+
#undef __
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_X86_HPP
2+
#define MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_X86_HPP
3+
4+
class MMTkObjectBarrierSetAssembler: public MMTkBarrierSetAssembler {
5+
protected:
6+
virtual void object_reference_write_post(MacroAssembler* masm, DecoratorSet decorators, Address dst, Register val, Register tmp1, Register tmp2) const override;
7+
public:
8+
virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register src, Register dst, Register count) override;
9+
};
10+
#endif // MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_X86_HPP
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifndef MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_ZERO_HPP
2+
#define MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_ZERO_HPP
3+
4+
class MMTkObjectBarrierSetAssembler;
5+
#endif // MMTK_OPENJDK_MMTK_OBJECT_BARRIER_SET_ASSEMBLER_ZERO_HPP

openjdk/share/barriers/mmtkObjectBarrier.cpp

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -17,77 +17,6 @@ void MMTkObjectBarrierSetRuntime::object_reference_write_post(oop src, oop* slot
1717
#endif
1818
}
1919

20-
#ifndef ZERO
21-
#define __ masm->
22-
23-
void MMTkObjectBarrierSetAssembler::object_reference_write_post(MacroAssembler* masm, DecoratorSet decorators, Address dst, Register val, Register tmp1, Register tmp2) const {
24-
//if (can_remove_barrier(decorators, val, /* skip_const_null */ true)) return;
25-
/*
26-
#if MMTK_ENABLE_BARRIER_FASTPATH
27-
Label done;
28-
29-
Register tmp3 = rscratch1;
30-
Register tmp4 = rscratch2;
31-
Register obj = dst.base();
32-
assert_different_registers(obj, tmp2, tmp3);
33-
assert_different_registers(tmp4, rcx);
34-
35-
// tmp2 = load-byte (SIDE_METADATA_BASE_ADDRESS + (obj >> 6));
36-
__ movptr(tmp3, obj);
37-
__ shrptr(tmp3, 6);
38-
__ movptr(tmp2, SIDE_METADATA_BASE_ADDRESS);
39-
__ movb(tmp2, Address(tmp2, tmp3));
40-
// tmp3 = (obj >> 3) & 7
41-
__ movptr(tmp3, obj);
42-
__ shrptr(tmp3, 3);
43-
__ andptr(tmp3, 7);
44-
// tmp2 = tmp2 >> tmp3
45-
__ movptr(tmp4, rcx);
46-
__ movl(rcx, tmp3);
47-
__ shrptr(tmp2);
48-
__ movptr(rcx, tmp4);
49-
// if ((tmp2 & 1) == 1) goto slowpath;
50-
__ andptr(tmp2, 1);
51-
__ cmpptr(tmp2, 1);
52-
__ jcc(Assembler::notEqual, done);
53-
54-
__ movptr(c_rarg0, obj);
55-
__ lea(c_rarg1, dst);
56-
if (val == noreg) {
57-
__ movptr(c_rarg2, NULL_WORD);
58-
} else {
59-
__ movptr(c_rarg2, val);
60-
}
61-
__ call_VM_leaf_base(FN_ADDR(MMTkBarrierSetRuntime::object_reference_write_slow_call), 3);
62-
63-
__ bind(done);
64-
#else
65-
__ movptr(c_rarg0, obj);
66-
__ lea(c_rarg1, dst);
67-
__ movptr(c_rarg2, val == noreg ? (int32_t) NULL_WORD : val);
68-
__ call_VM_leaf_base(FN_ADDR(MMTkBarrierSetRuntime::object_reference_write_post_call), 3);
69-
#endif
70-
*/
71-
assert(false, "Not implemented");
72-
}
73-
74-
void MMTkObjectBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register src, Register dst, Register count) {
75-
// const bool dest_uninitialized = (decorators & IS_DEST_UNINITIALIZED) != 0;
76-
// if ((type == T_OBJECT || type == T_ARRAY) && !dest_uninitialized) {
77-
// __ pusha();
78-
// __ movptr(c_rarg0, src);
79-
// __ movptr(c_rarg1, dst);
80-
// __ movptr(c_rarg2, count);
81-
// __ call_VM_leaf_base(FN_ADDR(MMTkBarrierSetRuntime::object_reference_array_copy_post_call), 3);
82-
// __ popa();
83-
// }
84-
assert(false, "Not implemented");
85-
}
86-
87-
#undef __
88-
89-
#endif
90-
9120
#ifdef COMPILER1
9221
#ifdef ASSERT
9322
#define __ gen->lir(__FILE__, __LINE__)->

openjdk/share/barriers/mmtkObjectBarrier.hpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef ZERO
77
#include "utilities/macros.hpp"
88
#include CPU_HEADER(mmtkBarrierSetAssembler)
9+
#include CPU_HEADER(mmtkObjectBarrierSetAssembler)
910
#endif
1011
#ifdef COMPILER1
1112
#include "../mmtkBarrierSetC1.hpp"
@@ -34,17 +35,6 @@ class MMTkObjectBarrierSetRuntime: public MMTkBarrierSetRuntime {
3435
}
3536
};
3637

37-
#ifdef ZERO
38-
class MMTkObjectBarrierSetAssembler;
39-
#else
40-
class MMTkObjectBarrierSetAssembler: public MMTkBarrierSetAssembler {
41-
protected:
42-
virtual void object_reference_write_post(MacroAssembler* masm, DecoratorSet decorators, Address dst, Register val, Register tmp1, Register tmp2) const override;
43-
public:
44-
virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register src, Register dst, Register count);
45-
};
46-
#endif
47-
4838
#ifdef COMPILER1
4939
class MMTkObjectBarrierSetC1: public MMTkBarrierSetC1 {
5040
protected:

0 commit comments

Comments
 (0)