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
91 {91 {
92#ifndef NDEBUG92#ifndef NDEBUG
93 assert(t != nullptr);93 assert(t != nullptr);
94 *t = reinterpret_cast<T *>(0xbada110c);94 assign_debug_memory(t, sizeof(t));
95#endif95#endif
96 }96 }
97 }97 }
src/include/runtime.h+0−8
@@ -89,21 +89,14 @@ namespace disvm · 88 unmodified lines
89 static std::shared_ptr<const type_descriptor_t> type();89 static std::shared_ptr<const type_descriptor_t> type();
90 };90 };
91 91
92 // Type used to indicate allocated memory should be zeroed out.
93 struct zero_memory_t
94 { };
95
96 // VM memory allocation92 // VM memory allocation
97 class vm_alloc_t93 class vm_alloc_t
98 {94 {
99 public: // static95 public: // static
100 static const zero_memory_t zero_memory;
101
102 static void *operator new(std::size_t sz);96 static void *operator new(std::size_t sz);
103 static void operator delete(void *ptr);97 static void operator delete(void *ptr);
104 98
105 static vm_alloc_t *allocate(std::shared_ptr<const type_descriptor_t> td);99 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 &);
107 static vm_alloc_t *copy(const vm_alloc_t &other);100 static vm_alloc_t *copy(const vm_alloc_t &other);
108 static vm_alloc_t *from_allocation(pointer_t allocation);101 static vm_alloc_t *from_allocation(pointer_t allocation);
109 102
@@ -205,7 +198,6 @@ namespace disvm · 95 unmodified lines
205 198
206 public:199 public:
207 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);
208 vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t length, const zero_memory_t&);
209 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);
210 vm_array_t(const vm_string_t *s);202 vm_array_t(const vm_string_t *s);
211 ~vm_array_t();203 ~vm_array_t();
src/include/vm_memory.h+3−10
@@ -40,7 +40,9 @@ namespace disvm · 39 unmodified lines
40 // While this lock is taken all further allocations will block.40 // While this lock is taken all further allocations will block.
41 global_alloc_lock_t get_global_alloc_lock();41 global_alloc_lock_t get_global_alloc_lock();
42 42
43 // Allocate memory from the VM heap43 // 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.
44 void *alloc_memory(std::size_t amount_in_bytes);46 void *alloc_memory(std::size_t amount_in_bytes);
45 47
46 template<typename T>48 template<typename T>
@@ -49,15 +51,6 @@ namespace disvm · 2 unmodified lines
49 return reinterpret_cast<T *>(alloc_memory(amount_in_bytes));51 return reinterpret_cast<T *>(alloc_memory(amount_in_bytes));
50 }52 }
51 53
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
61 // Free memory on the VM heap54 // Free memory on the VM heap
62 void free_memory(void *memory);55 void free_memory(void *memory);
63 56

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