Floating point division is now relying on underlying FPU and IEEE for behavior with respect to divide by 0
Showing the changes to src/include (3 of 11 files). Show all
Unified · Split
| @@ -91,7 +91,7 @@ namespace disvm · 90 unmodified lines | ||
| 91 | 91 | { |
| 92 | 92 | #ifndef NDEBUG |
| 93 | 93 | assert(t != nullptr); |
| 94 | − *t = reinterpret_cast<T *>(0xbada110c); | |
| 94 | + assign_debug_memory(t, sizeof(t)); | |
| 95 | 95 | #endif |
| 96 | 96 | } |
| 97 | 97 | } |
| @@ -89,21 +89,14 @@ namespace disvm · 88 unmodified lines | ||
| 89 | 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 | 92 | // VM memory allocation |
| 97 | 93 | class vm_alloc_t |
| 98 | 94 | { |
| 99 | 95 | public: // static |
| 100 | − static const zero_memory_t zero_memory; | |
| 101 | − | |
| 102 | 96 | static void *operator new(std::size_t sz); |
| 103 | 97 | static void operator delete(void *ptr); |
| 104 | 98 | |
| 105 | 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 | 100 | static vm_alloc_t *copy(const vm_alloc_t &other); |
| 108 | 101 | static vm_alloc_t *from_allocation(pointer_t allocation); |
| 109 | 102 | |
| @@ -205,7 +198,6 @@ namespace disvm · 95 unmodified lines | ||
| 205 | 198 | |
| 206 | 199 | public: |
| 207 | 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 | 201 | vm_array_t(vm_array_t *original, word_t begin_index, word_t length); |
| 210 | 202 | vm_array_t(const vm_string_t *s); |
| 211 | 203 | ~vm_array_t(); |
| @@ -40,7 +40,9 @@ namespace disvm · 39 unmodified lines | ||
| 40 | 40 | // While this lock is taken all further allocations will block. |
| 41 | 41 | global_alloc_lock_t get_global_alloc_lock(); |
| 42 | 42 | |
| 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. | |
| 44 | 46 | void *alloc_memory(std::size_t amount_in_bytes); |
| 45 | 47 | |
| 46 | 48 | template<typename T> |
| @@ -49,15 +51,6 @@ namespace disvm · 2 unmodified lines | ||
| 49 | 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 | 54 | // Free memory on the VM heap |
| 62 | 55 | void free_memory(void *memory); |
| 63 | 56 | |