@@ -186,6 +186,75 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
186
186
class Handle ;
187
187
}
188
188
189
+ struct MemoryFlags {
190
+ #ifdef RBX_LITTLE_ENDIAN
191
+ // Header status flags
192
+ unsigned int forwarded : 1 ;
193
+ unsigned int inflated : 1 ;
194
+
195
+ // Memory flags
196
+ unsigned int thread_id : 12 ;
197
+ unsigned int region : 2 ;
198
+
199
+ // Garbage collector flags
200
+ unsigned int marked : 2 ;
201
+ unsigned int scanned : 1 ;
202
+
203
+ // Data type flags
204
+ object_type type_id : 15 ;
205
+ unsigned int data : 1 ;
206
+
207
+ // Memory object flags
208
+ unsigned int frozen : 1 ;
209
+ unsigned int tainted : 1 ;
210
+ unsigned int locked : 1 ;
211
+ unsigned int inflated_lock : 1 ;
212
+ unsigned int object_id : 20 ;
213
+ unsigned int reserved : 3 ;
214
+
215
+ // Graph flags
216
+ unsigned int visited : 2 ;
217
+ #else
218
+ // Graph flags
219
+ unsigned int visited : 2 ;
220
+
221
+ unsigned int reserved : 3 ;
222
+ unsigned int object_id : 20 ;
223
+ unsigned int inflated_lock : 1 ;
224
+ unsigned int locked : 1 ;
225
+ unsigned int tainted : 1 ;
226
+ unsigned int frozen : 1 ;
227
+
228
+ // Data type flags
229
+ unsigned int data : 1 ;
230
+ object_type type_id : 15 ;
231
+
232
+ // Garbage collector flags
233
+ unsigned int scanned : 1 ;
234
+ unsigned int marked : 2 ;
235
+
236
+ // Memory flags
237
+ unsigned int region : 2 ;
238
+ unsigned int thread_id : 12 ;
239
+
240
+ // Header status flags
241
+ unsigned int inflated : 1 ;
242
+ unsigned int forwarded : 1 ;
243
+ #endif
244
+ };
245
+
246
+ class MemoryHeader {
247
+ union {
248
+ struct MemoryFlags f;
249
+ uint64_t flags;
250
+ } header;
251
+
252
+ public:
253
+
254
+ object_type type_id () const {
255
+ return header.f .type_id ;
256
+ }
257
+ };
189
258
190
259
/* *
191
260
* An InflatedHeader is used on the infrequent occasions when an Object needs
@@ -280,20 +349,10 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
280
349
private:
281
350
};
282
351
283
- class DataHeader {
284
- HeaderWord header;
352
+ class DataHeader : public MemoryHeader {
285
353
void * __body__[0 ];
286
354
287
355
public:
288
-
289
- ObjectFlags flags () const {
290
- return header.f ;
291
- }
292
-
293
- object_type type_id () const {
294
- return flags ().obj_type ;
295
- }
296
-
297
356
/* It's the slow case, should be called only if there's no cached
298
357
* instance size. */
299
358
size_t slow_size_in_bytes (VM* vm) const ;
0 commit comments