@@ -27,21 +27,51 @@ class GCPointerBase : public CompressedPointer {
27
27
template <typename NeedsBarriers>
28
28
inline GCPointerBase (PointerBase &base, GCCell *ptr, GC &gc, NeedsBarriers);
29
29
30
+ inline GCPointerBase (
31
+ PointerBase &base,
32
+ GCCell *ptr,
33
+ GC &gc,
34
+ const GCCell *owningObj);
35
+
30
36
public:
31
37
// These classes are used as arguments to GCPointer constructors, to
32
38
// indicate whether write barriers are necessary in initializing the
33
39
// GCPointer.
34
40
class NoBarriers : public std ::false_type {};
35
41
class YesBarriers : public std ::true_type {};
36
42
37
- // / This must be used to assign a new value to this GCPointer.
43
+ // / This must be used to assign a new value to this GCPointer. This must not
44
+ // / be used if it lives in an object that supports large allocation.
38
45
// / \param ptr The memory being pointed to.
39
46
// / \param base The base of ptr.
40
47
// / \param gc Used for write barriers.
41
48
inline void set (PointerBase &base, GCCell *ptr, GC &gc);
42
49
inline void set (PointerBase &base, CompressedPointer ptr, GC &gc);
43
50
inline void setNonNull (PointerBase &base, GCCell *ptr, GC &gc);
44
51
52
+ // / This must be used to assign a new value to this GCPointer, which lives in
53
+ // / an object of kind that supports large allocation.
54
+ // / \param ptr The memory being pointed to.
55
+ // / \param base The base of ptr.
56
+ // / \param gc Used for write barriers.
57
+ // / \param owningObj The object that contains this GCPointer, used by the
58
+ // / writer barriers.
59
+ inline void setInLargeObj (
60
+ PointerBase &base,
61
+ GCCell *ptr,
62
+ GC &gc,
63
+ const GCCell *owningObj);
64
+ inline void setInLargeObj (
65
+ PointerBase &base,
66
+ CompressedPointer ptr,
67
+ GC &gc,
68
+ const GCCell *owningObj);
69
+ inline void setNonNullInLargeObj (
70
+ PointerBase &base,
71
+ GCCell *ptr,
72
+ GC &gc,
73
+ const GCCell *owningObj);
74
+
45
75
// / Set this pointer to null. This needs a write barrier in some types of
46
76
// / garbage collectors.
47
77
inline void setNull (GC &gc);
@@ -64,12 +94,26 @@ class GCPointer : public GCPointerBase {
64
94
template <typename NeedsBarriers>
65
95
GCPointer (PointerBase &base, T *ptr, GC &gc, NeedsBarriers needsBarriers)
66
96
: GCPointerBase(base, ptr, gc, needsBarriers) {}
97
+ // / Pass the owning object pointer to perform barriers when the object
98
+ // / supports large allocation.
99
+ template <typename NeedsBarriers>
100
+ GCPointer (
101
+ PointerBase &base,
102
+ T *ptr,
103
+ GC &gc,
104
+ const GCCell *owningObj,
105
+ NeedsBarriers needsBarriers)
106
+ : GCPointerBase(base, ptr, gc, owningObj, needsBarriers) {}
67
107
68
108
// / Same as the constructor above, with the default for
69
109
// / NeedsBarriers as "YesBarriers". (We can't use default template
70
110
// / arguments with the idiom used above.)
71
- inline GCPointer (PointerBase &base, T *ptr, GC &gc)
111
+ GCPointer (PointerBase &base, T *ptr, GC &gc)
72
112
: GCPointer<T>(base, ptr, gc, YesBarriers()) {}
113
+ // / Pass the owning object pointer to perform barriers when the object
114
+ // / supports large allocation.
115
+ GCPointer (PointerBase &base, T *ptr, GC &gc, const GCCell *owningObj)
116
+ : GCPointer<T>(base, ptr, gc, owningObj, YesBarriers()) {}
73
117
74
118
// / We are not allowed to copy-construct or assign GCPointers.
75
119
GCPointer (const GCPointerBase &) = delete ;
@@ -86,7 +130,8 @@ class GCPointer : public GCPointerBase {
86
130
return vmcast<T>(GCPointerBase::getNonNull (base));
87
131
}
88
132
89
- // / Assign a new value to this GCPointer.
133
+ // / Assign a new value to this GCPointer. This must not be used if it lives in
134
+ // / an object that supports large allocation.
90
135
// / \param base The base of ptr.
91
136
// / \param ptr The memory being pointed to.
92
137
// / \param gc Used for write barriers.
@@ -97,10 +142,40 @@ class GCPointer : public GCPointerBase {
97
142
GCPointerBase::setNonNull (base, ptr, gc);
98
143
}
99
144
100
- // / Convenience overload of GCPointer::set for other GCPointers.
145
+ // / Assign a new value to this GCPointer, which lives in an object of kind
146
+ // / that supports large allocation.
147
+ // / \param base The base of ptr.
148
+ // / \param ptr The memory being pointed to.
149
+ // / \param gc Used for write barriers.
150
+ // / \param owningObj The object that contains this GCPointer, used by the
151
+ // / writer barriers.
152
+ void
153
+ setInLargeObj (PointerBase &base, T *ptr, GC &gc, const GCCell *owningObj) {
154
+ GCPointerBase::set (base, ptr, gc, owningObj);
155
+ }
156
+ void setNonNullInLargeObj (
157
+ PointerBase &base,
158
+ T *ptr,
159
+ GC &gc,
160
+ const GCCell *owningObj) {
161
+ GCPointerBase::setNonNull (base, ptr, gc, owningObj);
162
+ }
163
+
164
+ // / Convenience overload of GCPointer::set for other GCPointers. This must not
165
+ // / be used if it lives in an object that supports large allocation.
101
166
void set (PointerBase &base, const GCPointer<T> &ptr, GC &gc) {
102
167
GCPointerBase::set (base, ptr, gc);
103
168
}
169
+
170
+ // / Convenience overload of GCPointer::set for other GCPointers. \p owningObj
171
+ // / is used by the writer barriers.
172
+ void setInLargeObj (
173
+ PointerBase &base,
174
+ const GCPointer<T> &ptr,
175
+ GC &gc,
176
+ const GCCell *owningObj) {
177
+ GCPointerBase::set (base, ptr, gc, owningObj);
178
+ }
104
179
};
105
180
106
181
} // namespace vm
0 commit comments