History

DisVM will now only use 0 initialized memory. - The alloc_memory function will only return 0 initialize memory - calloc_memory was removed

Floating point division is now relying on underlying FPU and IEEE for behavior with respect to divide by 0

arr committed 9 years ago

Commit b92328e1 parent bd1f49311 files · +48 −112Browse files

Showing the changes to src/include (3 of 11 files). Show all

Unified · Split

3 files
  1. src/include/debug.h +1 −1
  2. src/include/runtime.h +0 −8
  3. src/include/vm_memory.h +3 −10
src/include/debug.h+1−1
@@ -91,7 +91,7 @@ namespace disvm · 90 unmodified lines
9191 {
9292 #ifndef NDEBUG
9393 assert(t != nullptr);
94− *t = reinterpret_cast<T *>(0xbada110c);
94+ assign_debug_memory(t, sizeof(t));
9595 #endif
9696 }
9797 }
src/include/runtime.h+0−8
@@ -89,21 +89,14 @@ namespace disvm · 88 unmodified lines
8989 static std::shared_ptr<const type_descriptor_t> type();
9090 };
9191
92− // Type used to indicate allocated memory should be zeroed out.
93− struct zero_memory_t
94− { };
95−
9692 // VM memory allocation
9793 class vm_alloc_t
9894 {
9995 public: // static
100− static const zero_memory_t zero_memory;
101−
10296 static void *operator new(std::size_t sz);
10397 static void operator delete(void *ptr);
10498
10599 static vm_alloc_t *allocate(std::shared_ptr<const type_descriptor_t> td);
106− static vm_alloc_t *allocate(std::shared_ptr<const type_descriptor_t> td, const zero_memory_t &);
107100 static vm_alloc_t *copy(const vm_alloc_t &other);
108101 static vm_alloc_t *from_allocation(pointer_t allocation);
109102
@@ -205,7 +198,6 @@ namespace disvm · 95 unmodified lines
205198
206199 public:
207200 vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t length);
208− vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t length, const zero_memory_t&);
209201 vm_array_t(vm_array_t *original, word_t begin_index, word_t length);
210202 vm_array_t(const vm_string_t *s);
211203 ~vm_array_t();
src/include/vm_memory.h+3−10
@@ -40,7 +40,9 @@ namespace disvm · 39 unmodified lines
4040 // While this lock is taken all further allocations will block.
4141 global_alloc_lock_t get_global_alloc_lock();
4242
43− // Allocate memory from the VM heap
43+ // Allocate memory from the VM heap that is initialize to 0.
44+ // [SPEC] All memory in this implementation of the Dis VM spec
45+ // will be 0 initialized.
4446 void *alloc_memory(std::size_t amount_in_bytes);
4547
4648 template<typename T>
@@ -49,15 +51,6 @@ namespace disvm · 2 unmodified lines
4951 return reinterpret_cast<T *>(alloc_memory(amount_in_bytes));
5052 }
5153
52− // Allocate memory from the VM heap and initialize to 0.
53− void *calloc_memory(std::size_t amount_in_bytes);
54−
55− template<typename T>
56− T *calloc_memory(std::size_t amount_in_bytes = sizeof(T))
57− {
58− return reinterpret_cast<T *>(calloc_memory(amount_in_bytes));
59− }
60−
6154 // Free memory on the VM heap
6255 void free_memory(void *memory);
6356

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t