Code analysis violations Bug in scheduler - race during with worker thread shutdown.
Showing the changes to src/vm/execution_table.cpp (1 of 18 files). Show all
Unified · Split
| @@ -17,6 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <utils.h> |
| 18 | 18 | #include <exceptions.h> |
| 19 | 19 | #include <debug.h> |
| 20 | +#include <builtin_module.h> | |
| 20 | 21 | #include "execution_table.h" |
| 21 | 22 | |
| 22 | 23 | using namespace disvm; |
| @@ -31,36 +32,6 @@ namespace · 8 unmodified lines | ||
| 31 | 32 | using uword_t = uint32_t; // unsigned word_t |
| 32 | 33 | using ubig_t = uint64_t; // unsigned big_t |
| 33 | 34 | |
| 34 | − template<typename ValueType> | |
| 35 | − ValueType& vt_ref(pointer_t vt) | |
| 36 | − { | |
| 37 | − assert(vt != nullptr); | |
| 38 | − return *reinterpret_cast<ValueType *>(vt); | |
| 39 | − } | |
| 40 | − | |
| 41 | − template<typename AllocType> | |
| 42 | − typename std::enable_if<std::is_base_of<vm_alloc_t, AllocType>::value, AllocType *>::type | |
| 43 | − at_val(pointer_t at) | |
| 44 | − { | |
| 45 | − assert(at != nullptr); | |
| 46 | − | |
| 47 | − return vm_alloc_t::from_allocation<AllocType>(*reinterpret_cast<pointer_t *>(at)); | |
| 48 | − } | |
| 49 | − | |
| 50 | − template<> | |
| 51 | − vm_alloc_t *at_val<vm_alloc_t>(pointer_t at) | |
| 52 | − { | |
| 53 | − assert(at != nullptr); | |
| 54 | − | |
| 55 | − return vm_alloc_t::from_allocation(*reinterpret_cast<pointer_t *>(at)); | |
| 56 | − } | |
| 57 | − | |
| 58 | − pointer_t &pt_ref(pointer_t pt) | |
| 59 | − { | |
| 60 | − assert(pt != nullptr); | |
| 61 | − return *reinterpret_cast<pointer_t *>(pt); | |
| 62 | − } | |
| 63 | − | |
| 64 | 35 | #define EXEC_DECL(inst_name) void inst_name(vm_registers_t &r, vm_t& vm) |
| 65 | 36 | |
| 66 | 37 | EXEC_DECL(notimpl) { assert(false && "Instruction not implemented"); throw vm_system_exception{ "Instruction not implemented" }; } |
| @@ -805,7 +776,7 @@ namespace · 738 unmodified lines | ||
| 805 | 776 | if (tail_maybe != nullptr) |
| 806 | 777 | tail_maybe->release(); |
| 807 | 778 | |
| 808 | − auto new_list = new vm_list_t(intrinsic_type_desc::type<PrimitiveType>(), tail_maybe); | |
| 779 | + auto new_list = new vm_list_t{ intrinsic_type_desc::type<PrimitiveType>(), tail_maybe }; | |
| 809 | 780 | |
| 810 | 781 | auto value = vt_ref<PrimitiveType>(r.src); |
| 811 | 782 | vt_ref<PrimitiveType>(new_list->value()) = value; |
| @@ -825,7 +796,8 @@ namespace · 13 unmodified lines | ||
| 825 | 796 | tail_maybe->release(); |
| 826 | 797 | |
| 827 | 798 | // Create a new list |
| 828 | − auto new_list = new vm_list_t(intrinsic_type_desc::type<pointer_t>(), tail_maybe); | |
| 799 | + auto new_list = new vm_list_t{ intrinsic_type_desc::type<pointer_t>(), tail_maybe }; | |
| 800 | + | |
| 829 | 801 | auto alloc = at_val<vm_alloc_t>(r.src); |
| 830 | 802 | if (alloc != nullptr) |
| 831 | 803 | { |
| @@ -858,7 +830,8 @@ namespace · 26 unmodified lines | ||
| 858 | 830 | tail_maybe->release(); |
| 859 | 831 | |
| 860 | 832 | // Create a new list |
| 861 | − auto new_list = new vm_list_t(type, tail_maybe); | |
| 833 | + auto new_list = new vm_list_t{ type, tail_maybe }; | |
| 834 | + | |
| 862 | 835 | auto destination = new_list->value(); |
| 863 | 836 | std::memmove(destination, r.src, type->size_in_bytes); |
| 864 | 837 | |