]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/layouts.hpp
vm: change "profiler" names to "counting_profiler"
[factor.git] / vm / layouts.hpp
index 048c9c460f072e42d89a60b354772f246d0fc76c..300b819b1fadcc96d612781959fe0d9220ce1072 100644 (file)
@@ -23,6 +23,11 @@ inline static cell align(cell a, cell b)
        return (a + (b-1)) & ~(b-1);
 }
 
+inline static cell alignment_for(cell a, cell b)
+{
+       return align(a,b) - a;
+}
+
 static const cell data_alignment = 16;
 
 #define WORD_SIZE (signed)(sizeof(cell)*8)
@@ -55,7 +60,7 @@ enum code_block_type
 {
        code_block_unoptimized,
        code_block_optimized,
-       code_block_profiling,
+       code_block_counting_profiler,
        code_block_pic
 };
 
@@ -91,8 +96,6 @@ inline static cell tag_fixnum(fixnum untagged)
        return RETAG(untagged << TAG_BITS,FIXNUM_TYPE);
 }
 
-struct object;
-
 #define NO_TYPE_CHECK static const cell type_number = TYPE_COUNT
 
 struct object {
@@ -100,7 +103,10 @@ struct object {
        cell header;
 
        cell size() const;
+       template<typename Fixup> cell size(Fixup fixup) const;
+
        cell binary_payload_start() const;
+       template<typename Fixup> cell binary_payload_start(Fixup fixup) const;
 
        cell *slots() const { return (cell *)this; }
 
@@ -205,53 +211,9 @@ struct string : public object {
        cell hashcode;
 
        u8 *data() const { return (u8 *)(this + 1); }
-
-       cell nth(cell i) const;
 };
 
-/* The compiled code heap is structured into blocks. */
-struct code_block
-{
-       cell header;
-       cell owner; /* tagged pointer to word, quotation or f */
-       cell literals; /* tagged pointer to array or f */
-       cell relocation; /* tagged pointer to byte-array or f */
-
-       bool free_p() const
-       {
-               return (header & 1) == 1;
-       }
-
-       code_block_type type() const
-       {
-               return (code_block_type)((header >> 1) & 0x3);
-       }
-
-       void set_type(code_block_type type)
-       {
-               header = ((header & ~0x7) | (type << 1));
-       }
-
-       bool pic_p() const
-       {
-               return type() == code_block_pic;
-       }
-
-       bool optimized_p() const
-       {
-               return type() == code_block_optimized;
-       }
-
-       cell size() const
-       {
-               return header & ~7;
-       }
-
-       void *xt() const
-       {
-               return (void *)(this + 1);
-       }
-};
+struct code_block;
 
 /* Assembly code makes assumptions about the layout of this struct */
 struct word : public object {
@@ -270,16 +232,16 @@ struct word : public object {
        cell pic_def;
        /* TAGGED alternative entry point for direct tail calls. Used for inline caching */
        cell pic_tail_def;
-       /* TAGGED call count for profiling */
+       /* TAGGED call count for counting_profiler */
        cell counter;
        /* TAGGED machine code for sub-primitive */
        cell subprimitive;
-       /* UNTAGGED execution token: jump here to execute word */
-       void *xt;
+       /* UNTAGGED entry point: jump here to execute word */
+       void *entry_point;
        /* UNTAGGED compiled code block */
        code_block *code;
-       /* UNTAGGED profiler stub */
-       code_block *profiling;
+       /* UNTAGGED counting_profiler stub */
+       code_block *counting_profiler;
 };
 
 /* Assembly code makes assumptions about the layout of this struct */
@@ -308,8 +270,8 @@ struct quotation : public object {
        cell cached_effect;
        /* tagged */
        cell cache_counter;
-       /* UNTAGGED */
-       void *xt;
+       /* UNTAGGED entry point; jump here to call quotation */
+       void *entry_point;
        /* UNTAGGED compiled code block */
        code_block *code;
 };
@@ -340,11 +302,12 @@ struct dll : public object {
        /* tagged byte array holding a C string */
        cell path;
        /* OS-specific handle */
-       void *dll;
+       void *handle;
 };
 
 struct stack_frame {
-       void *xt;
+       /* Updated by procedure prologue with procedure start address */
+       void *entry_point;
        /* Frame size in bytes */
        cell size;
 };