History

Basic implementation of Sys module functions - Sys.create, Sys.open, Sys.read, Sys.write - Sys.tokenize

Code analysis violations Bug in scheduler - race during with worker thread shutdown.

arr committed 10 years ago

Commit 992a33f1 parent 6d77c2d18 files · +695 −243Browse files

Showing the changes to src/vm/execution_table.cpp (1 of 18 files). Show all

Unified · Split

src/vm/execution_table.cpp+6−33
@@ -17,6 +17,7 @@ · 16 unmodified lines
17#include <utils.h>17#include <utils.h>
18#include <exceptions.h>18#include <exceptions.h>
19#include <debug.h>19#include <debug.h>
20#include <builtin_module.h>
20#include "execution_table.h"21#include "execution_table.h"
21 22
22using namespace disvm;23using namespace disvm;
@@ -31,36 +32,6 @@ namespace · 8 unmodified lines
31 using uword_t = uint32_t; // unsigned word_t32 using uword_t = uint32_t; // unsigned word_t
32 using ubig_t = uint64_t; // unsigned big_t33 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#define EXEC_DECL(inst_name) void inst_name(vm_registers_t &r, vm_t& vm)35#define EXEC_DECL(inst_name) void inst_name(vm_registers_t &r, vm_t& vm)
65 36
66 EXEC_DECL(notimpl) { assert(false && "Instruction not implemented"); throw vm_system_exception{ "Instruction not implemented" }; }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 if (tail_maybe != nullptr)776 if (tail_maybe != nullptr)
806 tail_maybe->release();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 auto value = vt_ref<PrimitiveType>(r.src);781 auto value = vt_ref<PrimitiveType>(r.src);
811 vt_ref<PrimitiveType>(new_list->value()) = value;782 vt_ref<PrimitiveType>(new_list->value()) = value;
@@ -825,7 +796,8 @@ namespace · 13 unmodified lines
825 tail_maybe->release();796 tail_maybe->release();
826 797
827 // Create a new list798 // 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 auto alloc = at_val<vm_alloc_t>(r.src);801 auto alloc = at_val<vm_alloc_t>(r.src);
830 if (alloc != nullptr)802 if (alloc != nullptr)
831 {803 {
@@ -858,7 +830,8 @@ namespace · 26 unmodified lines
858 tail_maybe->release();830 tail_maybe->release();
859 831
860 // Create a new list832 // 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 auto destination = new_list->value();835 auto destination = new_list->value();
863 std::memmove(destination, r.src, type->size_in_bytes);836 std::memmove(destination, r.src, type->size_in_bytes);
864 837