]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/layouts.hpp
Fix conflict
[factor.git] / vm / layouts.hpp
index 541ee227ee752f40eaaa4705c6388e311aa0da91..b03a0d22444b7518090b04c63a295f94d954d2e2 100644 (file)
@@ -51,8 +51,6 @@ static const cell data_alignment = 16;
 
 #define TYPE_COUNT 14
 
-#define FORWARDING_POINTER 5 /* can be anything other than FIXNUM_TYPE */
-
 enum code_block_type
 {
        code_block_unoptimized,
@@ -95,59 +93,59 @@ inline static cell tag_fixnum(fixnum untagged)
 
 struct object;
 
-struct header {
-       cell value;
+#define NO_TYPE_CHECK static const cell type_number = TYPE_COUNT
+
+struct object {
+       NO_TYPE_CHECK;
+       cell header;
+
+       cell size() const;
+       cell binary_payload_start() const;
 
-        /* Default ctor to make gcc 3.x happy */
-        explicit header() { abort(); }
+       cell *slots() const { return (cell *)this; }
 
-       explicit header(cell value_) : value(value_ << TAG_BITS) {}
+       template<typename Iterator> void each_slot(Iterator &iter);
 
-       void check_header() const
+       /* Only valid for objects in tenured space; must cast to free_heap_block
+       to do anything with it if its free */
+       bool free_p() const
        {
-#ifdef FACTOR_DEBUG
-               assert(TAG(value) == FIXNUM_TYPE && untag_fixnum(value) < TYPE_COUNT);
-#endif
+               return (header & 1) == 1;
        }
 
-       cell hi_tag() const
+       cell type() const
        {
-               check_header();
-               return value >> TAG_BITS;
+               return (header >> 2) & TAG_MASK;
        }
 
-       bool forwarding_pointer_p() const
+       void initialize(cell type)
        {
-               return TAG(value) == FORWARDING_POINTER;
+               header = type << 2;
        }
 
-       object *forwarding_pointer() const
+       cell hashcode() const
        {
-               return (object *)UNTAG(value);
+               return (header >> 6);
        }
 
-       void forward_to(object *pointer)
+       void set_hashcode(cell hashcode)
        {
-               value = RETAG(pointer,FORWARDING_POINTER);
+               header = (header & 0x3f) | (hashcode << 6);
        }
-};
 
-#define NO_TYPE_CHECK static const cell type_number = TYPE_COUNT
-
-struct object {
-       NO_TYPE_CHECK;
-       header h;
-
-       cell size() const;
-       cell binary_payload_start() const;
+       bool forwarding_pointer_p() const
+       {
+               return (header & 2) == 2;
+       }
 
-       cell *slots()  const { return (cell *)this; }
+       object *forwarding_pointer() const
+       {
+               return (object *)UNTAG(header);
+       }
 
-       /* Only valid for objects in tenured space; must fast to free_heap_block
-       to do anything with it if its free */
-       bool free_p() const
+       void forward_to(object *pointer)
        {
-               return h.value & 1 == 1;
+               header = ((cell)pointer | 2);
        }
 };