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/vm/vm_memory.cpp (1 of 6 files). Show all

Unified · Split

src/vm/vm_memory.cpp+9−6
@@ -158,19 +158,22 @@ namespace · 157 unmodified lines
158 158
159void disvm::runtime::destroy_memory(const type_descriptor_t &type_desc, void *data)159void disvm::runtime::destroy_memory(const type_descriptor_t &type_desc, void *data)
160{160{
161 enum_pointer_fields(type_desc, data, dec_ref_and_free_pointer_field);161 dec_ref_count_in_memory(type_desc, data);
162
163 debug::assign_debug_memory(data, type_desc.size_in_bytes);162 debug::assign_debug_memory(data, type_desc.size_in_bytes);
164}163}
165 164
166void disvm::runtime::inc_ref_count_in_memory(const type_descriptor_t &type_desc, void *data)165void disvm::runtime::inc_ref_count_in_memory(const type_descriptor_t &type_desc, void *data)
167{166{
168 if (data == nullptr)167 assert(data != nullptr);
169 return;
170
171 enum_pointer_fields(type_desc, data, add_ref_pointer_field);168 enum_pointer_fields(type_desc, data, add_ref_pointer_field);
172}169}
173 170
171void disvm::runtime::dec_ref_count_in_memory(const type_descriptor_t &type_desc, void *data)
172{
173 assert(data != nullptr);
174 enum_pointer_fields(type_desc, data, dec_ref_and_free_pointer_field);
175}
176
174void disvm::runtime::dec_ref_count_and_free(vm_alloc_t *alloc)177void disvm::runtime::dec_ref_count_and_free(vm_alloc_t *alloc)
175{178{
176 if (alloc == nullptr)179 if (alloc == nullptr)
@@ -460,7 +463,7 @@ std::shared_ptr<const type_descriptor_t> type_descriptor_t::create( · 283 unmodified lines
460 pointer_map_local[i] = pointer_map[i];463 pointer_map_local[i] = pointer_map[i];
461 }464 }
462 465
463 auto new_type = ::new(new_type_memory) type_descriptor_t{ size_in_bytes, pointer_map_length, pointer_map_local, finalizer, "#" };466 auto new_type = ::new(new_type_memory) type_descriptor_t{ size_in_bytes, pointer_map_length, pointer_map_local, finalizer, "?" };
464 return std::shared_ptr<type_descriptor_t>{ new_type, deleter };467 return std::shared_ptr<type_descriptor_t>{ new_type, deleter };
465}468}
466 469