Skip to content

Commit f0373ac

Browse files
committedJul 21, 2016
Added start of new managed memory header.
1 parent 7cd67e4 commit f0373ac

File tree

1 file changed

+70
-11
lines changed

1 file changed

+70
-11
lines changed
 

‎machine/oop.hpp

+70-11
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,75 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
186186
class Handle;
187187
}
188188

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+
};
189258

190259
/**
191260
* An InflatedHeader is used on the infrequent occasions when an Object needs
@@ -280,20 +349,10 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
280349
private:
281350
};
282351

283-
class DataHeader {
284-
HeaderWord header;
352+
class DataHeader : public MemoryHeader {
285353
void* __body__[0];
286354

287355
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-
297356
/* It's the slow case, should be called only if there's no cached
298357
* instance size. */
299358
size_t slow_size_in_bytes(VM* vm) const;

0 commit comments

Comments
 (0)