Showing the changes to src/include (2 of 6 files). Show all
Unified · Split
| @@ -198,7 +198,7 @@ namespace disvm · 197 unmodified lines | ||
| 198 | 198 | |
| 199 | 199 | public: |
| 200 | 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 | 202 | vm_array_t(const vm_string_t *s); |
| 203 | 203 | ~vm_array_t(); |
| 204 | 204 | |
| @@ -60,9 +60,12 @@ namespace disvm · 59 unmodified lines | ||
| 60 | 60 | // Destroy supplied memory based on the type descriptor |
| 61 | 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 allocation | |
| 63 | + // Increment the ref count of all pointers in the supplied memory allocation | |
| 64 | 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 | 69 | // Decrement the ref count and if 0 free the allocation |
| 67 | 70 | void dec_ref_count_and_free(vm_alloc_t *alloc); |
| 68 | 71 | |
| @@ -81,20 +84,21 @@ namespace disvm · 12 unmodified lines | ||
| 81 | 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 | 86 | const auto words8 = type_desc.pointer_map[i]; |
| 84 | − if (words8 != 0) | |
| 85 | − { | |
| 86 | − const auto flags = std::bitset<sizeof(words8) * 8>{ words8 }; | |
| 87 | − | |
| 88 | − // Enumerating the flags in reverse order so memory access is sequential. | |
| 89 | − if (flags[7] && (memory[0] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[0]), offset_accum); | |
| 90 | − if (flags[6] && (memory[1] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[1]), offset_accum + (1 * sizeof(pointer_t))); | |
| 91 | − if (flags[5] && (memory[2] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[2]), offset_accum + (2 * sizeof(pointer_t))); | |
| 92 | − if (flags[4] && (memory[3] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[3]), offset_accum + (3 * 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))); | |
| 94 | − if (flags[2] && (memory[5] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[5]), offset_accum + (5 * 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))); | |
| 96 | − if (flags[0] && (memory[7] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[7]), offset_accum + (7 * sizeof(pointer_t))); | |
| 97 | − } | |
| 87 | + assert(sizeof(words8) == 1); | |
| 88 | + if (words8 == 0) | |
| 89 | + continue; | |
| 90 | + | |
| 91 | + const auto flags = std::bitset<sizeof(words8) * 8>{ words8 }; | |
| 92 | + | |
| 93 | + // Enumerating the flags in reverse order so memory access is sequential. | |
| 94 | + if (flags[7] && (memory[0] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[0]), offset_accum); | |
| 95 | + if (flags[6] && (memory[1] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[1]), offset_accum + (1 * 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))); | |
| 97 | + if (flags[4] && (memory[3] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[3]), offset_accum + (3 * 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))); | |
| 99 | + if (flags[2] && (memory[5] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[5]), offset_accum + (5 * sizeof(pointer_t))); | |
| 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 | 116 | if (byte_offset < type_desc.map_in_bytes) |
| 113 | 117 | { |
| 114 | 118 | const auto words8 = type_desc.pointer_map[byte_offset]; |
| 119 | + assert(sizeof(words8) == 1); | |
| 115 | 120 | if (words8 != 0) |
| 116 | 121 | { |
| 117 | 122 | const auto flags = std::bitset<sizeof(words8) * 8>{ words8 }; |