From 46423dfebf3c1c6ccb50e70b83c8b0df1efb1715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Fri, 3 Jul 2015 19:12:57 +0200 Subject: [PATCH] VM: merge strings.hpp and tuples.hpp into layouts.hpp, because those header files were so tiny --- GNUmakefile | 2 -- vm/layouts.hpp | 19 +++++++++++++++++++ vm/master.hpp | 2 -- vm/strings.hpp | 9 --------- vm/tuples.hpp | 8 -------- 5 files changed, 19 insertions(+), 21 deletions(-) delete mode 100644 vm/strings.hpp delete mode 100644 vm/tuples.hpp diff --git a/GNUmakefile b/GNUmakefile index 951aa6849c..8478e646c2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -91,7 +91,6 @@ ifdef CONFIG vm/mark_bits.hpp \ vm/free_list.hpp \ vm/fixup.hpp \ - vm/tuples.hpp \ vm/free_list_allocator.hpp \ vm/write_barrier.hpp \ vm/object_start_map.hpp \ @@ -100,7 +99,6 @@ ifdef CONFIG vm/data_heap.hpp \ vm/code_heap.hpp \ vm/gc.hpp \ - vm/strings.hpp \ vm/float_bits.hpp \ vm/io.hpp \ vm/image.hpp \ diff --git a/vm/layouts.hpp b/vm/layouts.hpp index d02f44461d..263a469dc0 100644 --- a/vm/layouts.hpp +++ b/vm/layouts.hpp @@ -107,6 +107,14 @@ inline static cell tag_fixnum(fixnum untagged) { struct object { NO_TYPE_CHECK; + // header format (bits indexed with least significant as zero): + // bit 0 : free? + // if not forwarding: + // bit 1 : forwarding pointer? + // bit 2-5 : tag + // bit 7-end : hashcode + // if forwarding: + // bit 2-end : forwarding pointer cell header; template cell base_size(Fixup fixup) const; @@ -324,4 +332,15 @@ struct tuple : public object { cell* data() const { return (cell*)(this + 1); } }; +inline static cell tuple_size(const tuple_layout* layout) { + cell size = untag_fixnum(layout->size); + return sizeof(tuple) + size * sizeof(cell); +} + +inline static cell string_capacity(const string* str) { + return untag_fixnum(str->length); +} + +inline static cell string_size(cell size) { return sizeof(string) + size; } + } diff --git a/vm/master.hpp b/vm/master.hpp index e7a43d27cd..dcfc4ff579 100644 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -109,7 +109,6 @@ namespace factor { struct factor_vm; } #include "mark_bits.hpp" #include "free_list.hpp" #include "fixup.hpp" -#include "tuples.hpp" #include "free_list_allocator.hpp" #include "write_barrier.hpp" #include "object_start_map.hpp" @@ -118,7 +117,6 @@ namespace factor { struct factor_vm; } #include "data_heap.hpp" #include "code_heap.hpp" #include "gc.hpp" -#include "strings.hpp" #include "float_bits.hpp" #include "io.hpp" #include "image.hpp" diff --git a/vm/strings.hpp b/vm/strings.hpp deleted file mode 100644 index af9813329d..0000000000 --- a/vm/strings.hpp +++ /dev/null @@ -1,9 +0,0 @@ -namespace factor { - -inline static cell string_capacity(const string* str) { - return untag_fixnum(str->length); -} - -inline static cell string_size(cell size) { return sizeof(string) + size; } - -} diff --git a/vm/tuples.hpp b/vm/tuples.hpp deleted file mode 100644 index 75f91fced7..0000000000 --- a/vm/tuples.hpp +++ /dev/null @@ -1,8 +0,0 @@ -namespace factor { - -inline static cell tuple_size(const tuple_layout* layout) { - cell size = untag_fixnum(layout->size); - return sizeof(tuple) + size * sizeof(cell); -} - -}