History

Address more bugs found during limbo compiler testing

arr committed 9 years ago

Commit 84ac3311 parent 220aaf26 files · +52 −63Browse files

Showing the changes to src/include (2 of 6 files). Show all

Unified · Split

2 files
  1. src/include/runtime.h +1 −1
  2. src/include/vm_memory.h +20 −15
src/include/runtime.h+1−1
@@ -198,7 +198,7 @@ namespace disvm · 197 unmodified lines
198 198
199 public:199 public:
200 vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t length);200 vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t length);
201 vm_array_t(vm_array_t *original, word_t begin_index, word_t length);201 vm_array_t(vm_array_t &original, word_t begin_index, word_t length);
202 vm_array_t(const vm_string_t *s);202 vm_array_t(const vm_string_t *s);
203 ~vm_array_t();203 ~vm_array_t();
204 204
src/include/vm_memory.h+20−15
@@ -60,9 +60,12 @@ namespace disvm · 59 unmodified lines
60 // Destroy supplied memory based on the type descriptor60 // Destroy supplied memory based on the type descriptor
61 void destroy_memory(const type_descriptor_t &type_desc, void *data);61 void destroy_memory(const type_descriptor_t &type_desc, void *data);
62 62
63 // Increment the ref count of all points in the supplied memory allocation63 // Increment the ref count of all pointers in the supplied memory allocation
64 void inc_ref_count_in_memory(const type_descriptor_t &type_desc, void *data);64 void inc_ref_count_in_memory(const type_descriptor_t &type_desc, void *data);
65 65
66 // Decrement the ref count of all pointers in the supplied memory allocation
67 void dec_ref_count_in_memory(const type_descriptor_t &type_desc, void *data);
68
66 // Decrement the ref count and if 0 free the allocation69 // Decrement the ref count and if 0 free the allocation
67 void dec_ref_count_and_free(vm_alloc_t *alloc);70 void dec_ref_count_and_free(vm_alloc_t *alloc);
68 71
@@ -81,20 +84,21 @@ namespace disvm · 12 unmodified lines
81 for (auto i = word_t{ 0 }; i < type_desc.map_in_bytes; ++i, memory += 8, offset_accum += (8 * sizeof(pointer_t)))84 for (auto i = word_t{ 0 }; i < type_desc.map_in_bytes; ++i, memory += 8, offset_accum += (8 * sizeof(pointer_t)))
82 {85 {
83 const auto words8 = type_desc.pointer_map[i];86 const auto words8 = type_desc.pointer_map[i];
84 if (words8 != 0)87 assert(sizeof(words8) == 1);
85 {88 if (words8 == 0)
86 const auto flags = std::bitset<sizeof(words8) * 8>{ words8 };89 continue;
87 90
88 // Enumerating the flags in reverse order so memory access is sequential.91 const auto flags = std::bitset<sizeof(words8) * 8>{ words8 };
89 if (flags[7] && (memory[0] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[0]), offset_accum);92
90 if (flags[6] && (memory[1] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[1]), offset_accum + (1 * sizeof(pointer_t)));93 // Enumerating the flags in reverse order so memory access is sequential.
91 if (flags[5] && (memory[2] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[2]), offset_accum + (2 * sizeof(pointer_t)));94 if (flags[7] && (memory[0] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[0]), offset_accum);
92 if (flags[4] && (memory[3] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[3]), offset_accum + (3 * sizeof(pointer_t)));95 if (flags[6] && (memory[1] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[1]), offset_accum + (1 * sizeof(pointer_t)));
93 if (flags[3] && (memory[4] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[4]), offset_accum + (4 * sizeof(pointer_t)));96 if (flags[5] && (memory[2] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[2]), offset_accum + (2 * sizeof(pointer_t)));
94 if (flags[2] && (memory[5] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[5]), offset_accum + (5 * sizeof(pointer_t)));97 if (flags[4] && (memory[3] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[3]), offset_accum + (3 * sizeof(pointer_t)));
95 if (flags[1] && (memory[6] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[6]), offset_accum + (6 * sizeof(pointer_t)));98 if (flags[3] && (memory[4] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[4]), offset_accum + (4 * sizeof(pointer_t)));
96 if (flags[0] && (memory[7] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[7]), offset_accum + (7 * sizeof(pointer_t)));99 if (flags[2] && (memory[5] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[5]), offset_accum + (5 * sizeof(pointer_t)));
97 }100 if (flags[1] && (memory[6] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[6]), offset_accum + (6 * sizeof(pointer_t)));
101 if (flags[0] && (memory[7] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[7]), offset_accum + (7 * sizeof(pointer_t)));
98 }102 }
99 }103 }
100 104
@@ -112,6 +116,7 @@ namespace disvm · 11 unmodified lines
112 if (byte_offset < type_desc.map_in_bytes)116 if (byte_offset < type_desc.map_in_bytes)
113 {117 {
114 const auto words8 = type_desc.pointer_map[byte_offset];118 const auto words8 = type_desc.pointer_map[byte_offset];
119 assert(sizeof(words8) == 1);
115 if (words8 != 0)120 if (words8 != 0)
116 {121 {
117 const auto flags = std::bitset<sizeof(words8) * 8>{ words8 };122 const auto flags = std::bitset<sizeof(words8) * 8>{ words8 };