History

Merged in poly_type_support (pull request #6)

Poly type support

Aaron R Robinson committed 9 years ago

Commit 0621a9d2 parents e5f1252 75d434e18 files · +231 −119Browse files

Unified · Split

18 files
  1. limbo/basic_limbo_tests.b +39 −0
  2. src/asm/sbl_reader.cpp +1 −4
  3. src/exec/main.cpp +74 −10
  4. src/include/runtime.h +4 −1
  5. src/vm/array.cpp +10 −10
  6. src/vm/channel.cpp +9 −9
  7. src/vm/execution_table.cpp +8 −8
  8. src/vm/garbage_collector.cpp +7 −7
  9. src/vm/list.cpp +2 −2
  10. src/vm/module_ref.cpp +4 −4
  11. src/vm/scheduler.cpp +12 −12
  12. src/vm/stack.cpp +8 −8
  13. src/vm/string.cpp +3 −3
  14. src/vm/sys/Sysmod.cpp +6 −6
  15. src/vm/thread.cpp +5 −5
  16. src/vm/vm.cpp +2 −2
  17. src/vm/vm_exception_handler.cpp +3 −3
  18. src/vm/vm_memory.cpp +34 −25
limbo/basic_limbo_tests.b+39−0
@@ -22,6 +22,7 @@ init(args: list of string) · 21 unmodified lines
22 args = tl args;22 args = tl args;
23 }23 }
24 24
25 test_poly();
25 test_function_refs();26 test_function_refs();
26 test_alt();27 test_alt();
27 test_channel();28 test_channel();
@@ -39,6 +40,44 @@ init(args: list of string) · 11 unmodified lines
39 test_for_loop_function_call();40 test_for_loop_function_call();
40}41}
41 42
43reverse[T](l: list of T): list of T
44{
45 rl: list of T;
46 for(; l != nil; l = tl l)
47 rl = hd l :: rl;
48 return rl;
49}
50
51equal[T](l, r: list of T): int
52{
53 l_v, r_v : T;
54 l_v = hd l;
55 r_v = hd r;
56 l = tl l;
57 r = tl r;
58
59 while (l_v == r_v)
60 {
61 l_v = hd l;
62 r_v = hd r;
63 l = tl l;
64 r = tl r;
65
66 if (l == nil || r == nil)
67 break;
68 }
69
70 return l == r;
71}
72
73test_poly()
74{
75 sys->print("test_poly()\n");
76 l1 := list of {"a", "b", "c"};
77 l2 := reverse(l1);
78 if (!equal(l1, reverse(l2)) != 0) raise TEST_FAILED();
79}
80
42str_cmp(s1: string, s2: string): int81str_cmp(s1: string, s2: string): int
43{82{
44 if (s1 < s2)83 if (s1 < s2)
src/asm/sbl_reader.cpp+1−4
@@ -599,10 +599,7 @@ namespace · 598 unmodified lines
599 case type_class_t::integer: return "int";599 case type_class_t::integer: return "int";
600 case type_class_t::real: return "real";600 case type_class_t::real: return "real";
601 case type_class_t::string: return "string";601 case type_class_t::string: return "string";
602 602 case type_class_t::poly: return "*";
603 case type_class_t::poly:
604 assert(false && "Not fully implemented");
605 return "poly<T>";
606 603
607 case type_class_t::array:604 case type_class_t::array:
608 return "array of " + to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt);605 return "array of " + to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt);
src/exec/main.cpp+74−10
@@ -32,10 +32,10 @@ namespace · 31 unmodified lines
32 {32 {
33 word_t noret;33 word_t noret;
34 pointer_t command_module_ref;34 pointer_t command_module_ref;
35 pointer_t command_stack_frame;35 pointer_t command_stack_frame; // Should not be marked as memory managed pointer field
36 };36 };
37 37
38 const auto entry_frame_pointer_map = std::vector<byte_t>{ 0x06 };38 const auto entry_frame_pointer_map = std::vector<byte_t>{ 0x04 };
39 39
40 std::shared_ptr<const vm_module_t> command_module;40 std::shared_ptr<const vm_module_t> command_module;
41 41
@@ -231,14 +231,55 @@ void print_banner(const exec_options &options) · 189 unmodified lines
231void print_help()231void print_help()
232{232{
233 std::cout233 std::cout
234 << "Usage: disvm-exec [-d[e|m|x]*] [-t <num>] [-q] [-?] <entry module> <args>*\n"234 << "Usage: disvm-exec [-d[e|m|x]*] [-l[s|S|t|T|e|g|m]*] [-t <num>] [-q] [-?] <entry module> <args>*\n"
235 << " d - Enable debugger\n"235 " d - Enable debugger\n"
236 << " e - Break on entry\n"236 " e - Break on entry\n"
237 << " m - Break on module load\n"237 " m - Break on module load\n"
238 << " x - Break on exception (first chance)\n"238 " x - Break on exception (first chance)\n"
239 << " q - Suppress banner and configuration\n"239 " l - Enable logging in a component\n"
240 << " t - Specify the number of system threads to use (0 < x <= 4)\n"240 " s - Scheduler\n"
241 << " ? - Print help\n";241 " S - Stack\n"
242 " t - Threads\n"
243 " T - Tool extensions\n"
244 " e - Exceptions\n"
245 " g - Garbage collector (noisy)\n"
246 " m - Memory allocations (noisy)\n"
247 " q - Suppress banner and configuration\n"
248 " t - Specify the number of system threads to use (0 < x <= 4)\n"
249 " ? - Print help\n";
250}
251
252void log_callback(const debug::component_trace_t origin, const debug::log_level_t level, const char *msg_fmt, std::va_list args)
253{
254 std::stringstream ss;
255
256 switch (level)
257 {
258 case debug::log_level_t::warning:
259 ss << "w: ";
260 break;
261 case debug::log_level_t::debug:
262 ss << "d: ";
263 break;
264 }
265
266 std::array<char, 1024> buffer;
267 const auto r = std::vsnprintf(buffer.data(), buffer.size(), msg_fmt, args);
268 buffer[r] = '\0';
269
270 ss << buffer.data() << "\n";
271 if (r == buffer.size() - 1)
272 ss << " <Possible truncation>\n";
273
274 std::cout << ss.str();
275}
276
277void enable_logging(debug::component_trace_t c)
278{
279 debug::set_component_tracing(c, true);
280
281 // Constantly setting the callback
282 debug::set_logging_callback(log_callback);
242}283}
243 284
244void process_arg(char* arg, std::function<char *()> next, exec_options &options)285void process_arg(char* arg, std::function<char *()> next, exec_options &options)
@@ -289,6 +330,29 @@ void process_arg(char* arg, std::function<char *()> next, exec_options &options) · 44 unmodified lines
289 }330 }
290 break;331 break;
291 332
333 case 'l':
334 for (auto i = std::size_t{ 2 }; i < arg_len; ++i)
335 {
336 switch (arg[i])
337 {
338 case 's': enable_logging(debug::component_trace_t::scheduler);
339 break;
340 case 'S': enable_logging(debug::component_trace_t::stack);
341 break;
342 case 't': enable_logging(debug::component_trace_t::thread);
343 break;
344 case 'T': enable_logging(debug::component_trace_t::tool);
345 break;
346 case 'e': enable_logging(debug::component_trace_t::exception);
347 break;
348 case 'g': enable_logging(debug::component_trace_t::garbage_collector);
349 break;
350 case 'm': enable_logging(debug::component_trace_t::memory);
351 break;
352 }
353 }
354 break;
355
292 case 'q':356 case 'q':
293 options.quiet_start = true;357 options.quiet_start = true;
294 break;358 break;
src/include/runtime.h+4−1
@@ -65,7 +65,7 @@ namespace disvm · 64 unmodified lines
65 vm_alloc_instance_finalizer_t finalizer = type_descriptor_t::no_finalizer);65 vm_alloc_instance_finalizer_t finalizer = type_descriptor_t::no_finalizer);
66 66
67 public:67 public:
68 type_descriptor_t(word_t size_in_bytes, word_t map_in_bytes, const byte_t * pointer_map, vm_alloc_instance_finalizer_t finalizer);68 type_descriptor_t(word_t size_in_bytes, word_t map_in_bytes, const byte_t * pointer_map, vm_alloc_instance_finalizer_t finalizer, const char *debug_name);
69 type_descriptor_t(const type_descriptor_t&) = delete;69 type_descriptor_t(const type_descriptor_t&) = delete;
70 type_descriptor_t& operator=(const type_descriptor_t&) = delete;70 type_descriptor_t& operator=(const type_descriptor_t&) = delete;
71 71
@@ -73,6 +73,9 @@ namespace disvm · 1 unmodified line
73 const word_t map_in_bytes;73 const word_t map_in_bytes;
74 const byte_t * const pointer_map;74 const byte_t * const pointer_map;
75 const vm_alloc_instance_finalizer_t finalizer;75 const vm_alloc_instance_finalizer_t finalizer;
76#ifndef NDEBUG
77 const char *debug_type_name;
78#endif
76 };79 };
77 80
78 // Access to type descriptors for VM intrinsic types81 // Access to type descriptors for VM intrinsic types
src/vm/array.cpp+10−10
@@ -27,20 +27,20 @@ vm_array_t::vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t lengt · 26 unmodified lines
27 assert(_element_type != nullptr);27 assert(_element_type != nullptr);
28 assert(_length >= 0);28 assert(_length >= 0);
29 _arr = alloc_memory<byte_t>(_length * _element_type->size_in_bytes);29 _arr = alloc_memory<byte_t>(_length * _element_type->size_in_bytes);
30 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm array: %d\n", _length);30 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm array: %d", _length);
31 31
32 // Initialize the array32 // Initialize the array
33 auto arr_local = _arr;33 auto arr_local = _arr;
34 const auto array_len = _length;34 const auto array_len = _length;
35 const auto &element_type = *_element_type;35 const auto &element_type = *_element_type;
36 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "begin: init: elements: %d\n", array_len);36 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "begin: init: elements: %d", array_len);
37 for (word_t i = 0; i < array_len; ++i)37 for (word_t i = 0; i < array_len; ++i)
38 {38 {
39 init_memory(element_type, arr_local);39 init_memory(element_type, arr_local);
40 arr_local += element_type.size_in_bytes;40 arr_local += element_type.size_in_bytes;
41 }41 }
42 42
43 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "end: init: elements: %d\n", array_len);43 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "end: init: elements: %d", array_len);
44}44}
45 45
46vm_array_t::vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t length, const zero_memory_t&)46vm_array_t::vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t length, const zero_memory_t&)
@@ -53,7 +53,7 @@ vm_array_t::vm_array_t(std::shared_ptr<const type_descriptor_t> td, word_t lengt · 6 unmodified lines
53 assert(_element_type != nullptr);53 assert(_element_type != nullptr);
54 assert(_length >= 0);54 assert(_length >= 0);
55 _arr = calloc_memory<byte_t>(_length * _element_type->size_in_bytes);55 _arr = calloc_memory<byte_t>(_length * _element_type->size_in_bytes);
56 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "initz: vm array: %d\n", _length);56 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "initz: vm array: %d", _length);
57}57}
58 58
59vm_array_t::vm_array_t(vm_array_t *original, word_t begin_index, word_t length)59vm_array_t::vm_array_t(vm_array_t *original, word_t begin_index, word_t length)
@@ -68,7 +68,7 @@ vm_array_t::vm_array_t(vm_array_t *original, word_t begin_index, word_t length) · 8 unmodified lines
68 assert(_length >= 0 && (_length + begin_index) <= _original->get_length());68 assert(_length >= 0 && (_length + begin_index) <= _original->get_length());
69 69
70 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())70 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
71 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm array: slice: %d %d\n", begin_index, _length);71 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm array: slice: %d %d", begin_index, _length);
72 72
73 // Set the data to reference the original array73 // Set the data to reference the original array
74 _arr = _original->_arr + (begin_index * _element_type->size_in_bytes);74 _arr = _original->_arr + (begin_index * _element_type->size_in_bytes);
@@ -104,7 +104,7 @@ vm_array_t::vm_array_t(const vm_string_t *s) · 29 unmodified lines
104 }104 }
105 105
106 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())106 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
107 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm array: vm string: %d\n", _length);107 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm array: vm string: %d", _length);
108}108}
109 109
110vm_array_t::~vm_array_t()110vm_array_t::~vm_array_t()
@@ -118,7 +118,7 @@ vm_array_t::~vm_array_t() · 7 unmodified lines
118 dec_ref_count_and_free(_original);118 dec_ref_count_and_free(_original);
119 debug::assign_debug_pointer(&_original);119 debug::assign_debug_pointer(&_original);
120 120
121 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm array: slice\n");121 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm array: slice");
122 }122 }
123 else123 else
124 {124 {
@@ -126,19 +126,19 @@ vm_array_t::~vm_array_t() · 1 unmodified line
126 auto arr_local = _arr;126 auto arr_local = _arr;
127 const auto array_len = _length;127 const auto array_len = _length;
128 const auto &element_type = *_element_type;128 const auto &element_type = *_element_type;
129 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "begin: destroy: elements: %d\n", array_len);129 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "begin: destroy: elements: %d", array_len);
130 for (word_t i = 0; i < array_len; ++i)130 for (word_t i = 0; i < array_len; ++i)
131 {131 {
132 destroy_memory(element_type, arr_local);132 destroy_memory(element_type, arr_local);
133 arr_local += element_type.size_in_bytes;133 arr_local += element_type.size_in_bytes;
134 }134 }
135 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "end: destroy: elements: %d\n", array_len);135 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "end: destroy: elements: %d", array_len);
136 136
137 // Free array memory137 // Free array memory
138 free_memory(_arr);138 free_memory(_arr);
139 139
140 debug::assign_debug_pointer(&_arr);140 debug::assign_debug_pointer(&_arr);
141 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm array\n");141 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm array");
142 }142 }
143 143
144}144}
src/vm/channel.cpp+9−9
@@ -44,13 +44,13 @@ vm_channel_t::vm_channel_t( · 43 unmodified lines
44 if (buffer_len > 0)44 if (buffer_len > 0)
45 _data_buffer = new vm_array_t{ td, buffer_len };45 _data_buffer = new vm_array_t{ td, buffer_len };
46 46
47 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm channel\n");47 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm channel");
48}48}
49 49
50vm_channel_t::~vm_channel_t()50vm_channel_t::~vm_channel_t()
51{51{
52 dec_ref_count_and_free(_data_buffer);52 dec_ref_count_and_free(_data_buffer);
53 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm channel\n");53 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm channel");
54}54}
55 55
56std::shared_ptr<const type_descriptor_t> vm_channel_t::get_data_type() const56std::shared_ptr<const type_descriptor_t> vm_channel_t::get_data_type() const
@@ -88,7 +88,7 @@ bool vm_channel_t::send_data(vm_channel_request_t &send_request) · 31 unmodified lines
88 }88 }
89 89
90 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())90 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())
91 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: send: queue: %d\n", send_request.thread_id);91 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: send: queue: %d", send_request.thread_id);
92 92
93 _data_senders.emplace_back(std::move(send_request));93 _data_senders.emplace_back(std::move(send_request));
94 return false;94 return false;
@@ -122,7 +122,7 @@ bool vm_channel_t::send_data(vm_channel_request_t &send_request) · 27 unmodified lines
122 data_lock.unlock();122 data_lock.unlock();
123 123
124 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())124 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())
125 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: send: %d %d\n", send_request.thread_id, receiver.thread_id);125 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: send: %d %d", send_request.thread_id, receiver.thread_id);
126 126
127 receiver.request_handled_callback(*this);127 receiver.request_handled_callback(*this);
128 128
@@ -159,7 +159,7 @@ bool vm_channel_t::receive_data(vm_channel_request_t &receive_request) · 30 unmodified lines
159 }159 }
160 160
161 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())161 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())
162 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: receive: queue: %d\n", receive_request.thread_id);162 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: receive: queue: %d", receive_request.thread_id);
163 163
164 _data_receivers.emplace_back(std::move(receive_request));164 _data_receivers.emplace_back(std::move(receive_request));
165 return false;165 return false;
@@ -201,7 +201,7 @@ bool vm_channel_t::receive_data(vm_channel_request_t &receive_request) · 35 unmodified lines
201 _data_transfer(receive_request.data, sender.data, _data_type.get());201 _data_transfer(receive_request.data, sender.data, _data_type.get());
202 202
203 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())203 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())
204 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: receive: %d %d\n", receive_request.thread_id, sender.thread_id);204 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: receive: %d %d", receive_request.thread_id, sender.thread_id);
205 }205 }
206 206
207 // Release channel and pending request lock after data transfer207 // Release channel and pending request lock after data transfer
@@ -235,7 +235,7 @@ void vm_channel_t::cancel_request(uint32_t thread_id) · 27 unmodified lines
235 }235 }
236 236
237 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())237 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())
238 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: cancel: request: %d\n", thread_id);238 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: cancel: request: %d", thread_id);
239}239}
240 240
241word_t vm_channel_t::get_buffer_size() const241word_t vm_channel_t::get_buffer_size() const
@@ -267,7 +267,7 @@ bool vm_channel_t::try_send_to_buffer(vm_channel_request_t &send_request) · 25 unmodified lines
267 send_request.request_mutex.get().pending_request = false;267 send_request.request_mutex.get().pending_request = false;
268 268
269 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())269 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())
270 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: send: buffer: %d\n", send_request.thread_id);270 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: send: buffer: %d", send_request.thread_id);
271 271
272 return true;272 return true;
273}273}
@@ -294,7 +294,7 @@ bool vm_channel_t::try_receive_from_buffer(vm_channel_request_t &receive_request · 20 unmodified lines
294 receive_request.request_mutex.get().pending_request = false;294 receive_request.request_mutex.get().pending_request = false;
295 295
296 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())296 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())
297 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: receive: buffer: %d\n", receive_request.thread_id);297 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "channel: receive: buffer: %d", receive_request.thread_id);
298 298
299 return true;299 return true;
300}300}
src/vm/execution_table.cpp+8−8
@@ -1094,7 +1094,7 @@ namespace · 1093 unmodified lines
1094 EXEC_DECL(newcl) { _newc_(r, vm, intrinsic_type_desc::type<big_t>(), _mov_<big_t>); }1094 EXEC_DECL(newcl) { _newc_(r, vm, intrinsic_type_desc::type<big_t>(), _mov_<big_t>); }
1095 EXEC_DECL(newcp) { _newc_(r, vm, intrinsic_type_desc::type<pointer_t>(), _mov_<vm_alloc_t>); }1095 EXEC_DECL(newcp) { _newc_(r, vm, intrinsic_type_desc::type<pointer_t>(), _mov_<vm_alloc_t>); }
1096 1096
1097 EXEC_DECL(newcm) 1097 EXEC_DECL(newcm)
1098 {1098 {
1099 auto memory_size = vt_ref<word_t>(r.src); 1099 auto memory_size = vt_ref<word_t>(r.src);
1100 auto channel_data_type = type_descriptor_t::create(memory_size); 1100 auto channel_data_type = type_descriptor_t::create(memory_size);
@@ -1279,7 +1279,7 @@ namespace · 178 unmodified lines
1279 r.request_mutex.pending_request = false;1279 r.request_mutex.pending_request = false;
1280 1280
1281 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())1281 if (debug::is_component_tracing_enabled<debug::component_trace_t::channel>())
1282 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "alt: request: non-blocking\n");1282 debug::log_msg(debug::component_trace_t::channel, debug::log_level_t::debug, "alt: request: non-blocking");
1283 1283
1284 // Cancel request in all channels.1284 // Cancel request in all channels.
1285 for (auto i = word_t{ 0 }; i < channel_count; ++i)1285 for (auto i = word_t{ 0 }; i < channel_count; ++i)
@@ -1471,7 +1471,7 @@ namespace · 185 unmodified lines
1471 r.current_thread_state = vm_thread_state_t::empty_stack;1471 r.current_thread_state = vm_thread_state_t::empty_stack;
1472 1472
1473 if (debug::is_component_tracing_enabled<debug::component_trace_t::stack>())1473 if (debug::is_component_tracing_enabled<debug::component_trace_t::stack>())
1474 debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "exit: function\n");1474 debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "exit: function");
1475 }1475 }
1476 1476
1477 EXEC_DECL(call)1477 EXEC_DECL(call)
@@ -1488,7 +1488,7 @@ namespace · 10 unmodified lines
1488 1488
1489 r.pc = vt_ref<vm_pc_t>(r.dest);1489 r.pc = vt_ref<vm_pc_t>(r.dest);
1490 1490
1491 debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "enter: function\n");1491 debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "enter: function");
1492 }1492 }
1493 1493
1494 EXEC_DECL(mcall)1494 EXEC_DECL(mcall)
@@ -1522,7 +1522,7 @@ namespace · 27 unmodified lines
1522 debug::log_msg(1522 debug::log_msg(
1523 debug::component_trace_t::stack,1523 debug::component_trace_t::stack,
1524 debug::log_level_t::debug,1524 debug::log_level_t::debug,
1525 "enter: function: inter-module: %d >>%s<< %d %s\n",1525 "enter: function: inter-module: %d >>%s<< %d %s",
1526 export_id,1526 export_id,
1527 target_module->module->module_name->str(),1527 target_module->module->module_name->str(),
1528 function_pc,1528 function_pc,
@@ -1649,7 +1649,7 @@ namespace · 120 unmodified lines
1649 exception_id = static_cast<vm_string_t *>(e);1649 exception_id = static_cast<vm_string_t *>(e);
1650 1650
1651 if (debug::is_component_tracing_enabled<debug::component_trace_t::exception>())1651 if (debug::is_component_tracing_enabled<debug::component_trace_t::exception>())
1652 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "raise: string: >>%s<<\n", exception_id->str());1652 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "raise: string: >>%s<<", exception_id->str());
1653 }1653 }
1654 else1654 else
1655 {1655 {
@@ -1661,7 +1661,7 @@ namespace · 5 unmodified lines
1661 exception_id = at_val<vm_string_t>(content);1661 exception_id = at_val<vm_string_t>(content);
1662 1662
1663 if (debug::is_component_tracing_enabled<debug::component_trace_t::exception>())1663 if (debug::is_component_tracing_enabled<debug::component_trace_t::exception>())
1664 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "raise: exception: >>%s<<\n", exception_id->str());1664 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "raise: exception: >>%s<<", exception_id->str());
1665 }1665 }
1666 1666
1667 // Check if the tool dispatcher has been supplied1667 // Check if the tool dispatcher has been supplied
@@ -1772,7 +1772,7 @@ namespace · 104 unmodified lines
1772 }1772 }
1773 catch (const vm_module_exception &e)1773 catch (const vm_module_exception &e)
1774 {1774 {
1775 debug::log_msg(debug::component_trace_t::module, debug::log_level_t::debug, "exception: load: >>%s<<\n", e.what());1775 debug::log_msg(debug::component_trace_t::module, debug::log_level_t::debug, "exception: load: >>%s<<", e.what());
1776 assert(false && "Failure reading module");1776 assert(false && "Failure reading module");
1777 return;1777 return;
1778 }1778 }
src/vm/garbage_collector.cpp+7−7
@@ -93,7 +93,7 @@ void default_garbage_collector_t::track_allocation(vm_alloc_t *alloc) · 92 unmodified lines
93 assert(alloc != nullptr);93 assert(alloc != nullptr);
94 94
95 if (debug::is_component_tracing_enabled<debug::component_trace_t::garbage_collector>())95 if (debug::is_component_tracing_enabled<debug::component_trace_t::garbage_collector>())
96 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: track: %#" PRIxPTR "\n", alloc);96 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: track: %#" PRIxPTR, alloc);
97 97
98 alloc->add_ref();98 alloc->add_ref();
99 set_gc_colour(alloc, get_current_colour(_collection_epoch));99 set_gc_colour(alloc, get_current_colour(_collection_epoch));
@@ -152,13 +152,13 @@ namespace · 52 unmodified lines
152 const auto log_enabled = debug::is_component_tracing_enabled<debug::component_trace_t::garbage_collector>();152 const auto log_enabled = debug::is_component_tracing_enabled<debug::component_trace_t::garbage_collector>();
153 if (log_enabled)153 if (log_enabled)
154 {154 {
155 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: roots found: %" PRIuPTR "\n", allocs.size());155 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: roots found: %" PRIuPTR, allocs.size());
156 156
157 // If logging is enabled update the callback with logging157 // If logging is enabled update the callback with logging
158 add_pointer_to_queue = std::function<void(pointer_t p, std::size_t)>{ [&allocs](pointer_t p, std::size_t) -> void158 add_pointer_to_queue = std::function<void(pointer_t p, std::size_t)>{ [&allocs](pointer_t p, std::size_t) -> void
159 {159 {
160 auto a = vm_alloc_t::from_allocation(p);160 auto a = vm_alloc_t::from_allocation(p);
161 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, " ref: %#" PRIxPTR "\n", a);161 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, " ref: %#" PRIxPTR, a);
162 allocs.push(a);162 allocs.push(a);
163 } };163 } };
164 }164 }
@@ -170,7 +170,7 @@ namespace · 5 unmodified lines
170 allocs.pop();170 allocs.pop();
171 171
172 if (log_enabled)172 if (log_enabled)
173 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: mark: alloc: %#" PRIxPTR "\n", curr);173 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: mark: alloc: %#" PRIxPTR, curr);
174 174
175 if (curr->alloc_type->map_in_bytes > 0)175 if (curr->alloc_type->map_in_bytes > 0)
176 enum_pointer_fields(*curr->alloc_type, curr->get_allocation(), add_pointer_to_queue);176 enum_pointer_fields(*curr->alloc_type, curr->get_allocation(), add_pointer_to_queue);
@@ -198,7 +198,7 @@ namespace · 21 unmodified lines
198 }198 }
199 199
200 if (debug::is_component_tracing_enabled<debug::component_trace_t::garbage_collector>())200 if (debug::is_component_tracing_enabled<debug::component_trace_t::garbage_collector>())
201 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: sweep: %u\n", freed);201 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: sweep: %u", freed);
202 }202 }
203}203}
204 204
@@ -213,7 +213,7 @@ bool default_garbage_collector_t::collect(std::vector<std::shared_ptr<const vm_t · 8 unmodified lines
213 213
214 const auto log_enabled = debug::is_component_tracing_enabled<debug::component_trace_t::garbage_collector>();214 const auto log_enabled = debug::is_component_tracing_enabled<debug::component_trace_t::garbage_collector>();
215 if (log_enabled)215 if (log_enabled)
216 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: begin: collect\n");216 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: begin: collect");
217 217
218 const auto curr_colour = get_current_colour(_collection_epoch);218 const auto curr_colour = get_current_colour(_collection_epoch);
219 mark(threads, curr_colour);219 mark(threads, curr_colour);
@@ -222,7 +222,7 @@ bool default_garbage_collector_t::collect(std::vector<std::shared_ptr<const vm_t · 2 unmodified lines
222 sweep(_tracking_allocs, sweeper_colour);222 sweep(_tracking_allocs, sweeper_colour);
223 223
224 if (log_enabled)224 if (log_enabled)
225 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: end: collect\n");225 debug::log_msg(debug::component_trace_t::garbage_collector, debug::log_level_t::debug, "gc: end: collect");
226 226
227 ++_collection_epoch;227 ++_collection_epoch;
228 return true;228 return true;
src/vm/list.cpp+2−2
@@ -39,7 +39,7 @@ vm_list_t::vm_list_t(std::shared_ptr<const type_descriptor_t> td, vm_list_t *tai · 38 unmodified lines
39 }39 }
40 40
41 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())41 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
42 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm list\n");42 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm list");
43}43}
44 44
45vm_list_t::~vm_list_t()45vm_list_t::~vm_list_t()
@@ -60,7 +60,7 @@ vm_list_t::~vm_list_t() · 14 unmodified lines
60 }60 }
61 61
62 debug::assign_debug_pointer(&_mem.alloc);62 debug::assign_debug_pointer(&_mem.alloc);
63 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm list\n");63 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm list");
64}64}
65 65
66std::shared_ptr<const type_descriptor_t> vm_list_t::get_element_type() const66std::shared_ptr<const type_descriptor_t> vm_list_t::get_element_type() const
src/vm/module_ref.cpp+4−4
@@ -52,7 +52,7 @@ namespace · 51 unmodified lines
52 debug::log_msg(52 debug::log_msg(
53 debug::component_trace_t::module,53 debug::component_trace_t::module,
54 debug::log_level_t::debug,54 debug::log_level_t::debug,
55 "export: %d %#08x >>%s<<\n",55 "export: %d %#08x >>%s<<",
56 index,56 index,
57 export_entry.sig,57 export_entry.sig,
58 export_entry.name->str());58 export_entry.name->str());
@@ -80,7 +80,7 @@ vm_module_ref_t::vm_module_ref_t(std::shared_ptr<const vm_module_t> module) · 21 unmodified lines
80 mp_base = vm_alloc_t::copy(*module->original_mp);80 mp_base = vm_alloc_t::copy(*module->original_mp);
81 81
82 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())82 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
83 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm module ref\n");83 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm module ref");
84}84}
85 85
86vm_module_ref_t::vm_module_ref_t(std::shared_ptr<const vm_module_t> module, const import_vm_module_t &imports)86vm_module_ref_t::vm_module_ref_t(std::shared_ptr<const vm_module_t> module, const import_vm_module_t &imports)
@@ -98,7 +98,7 @@ vm_module_ref_t::vm_module_ref_t(std::shared_ptr<const vm_module_t> module, cons · 11 unmodified lines
98 mp_base = vm_alloc_t::copy(*module->original_mp);98 mp_base = vm_alloc_t::copy(*module->original_mp);
99 99
100 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())100 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
101 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm module ref: exported %d\n", _function_refs->get_length());101 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm module ref: exported %d", _function_refs->get_length());
102}102}
103 103
104vm_module_ref_t::~vm_module_ref_t()104vm_module_ref_t::~vm_module_ref_t()
@@ -109,7 +109,7 @@ vm_module_ref_t::~vm_module_ref_t() · 4 unmodified lines
109 _function_refs->release();109 _function_refs->release();
110 110
111 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())111 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
112 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm module ref\n");112 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm module ref");
113}113}
114 114
115bool vm_module_ref_t::is_builtin_module() const115bool vm_module_ref_t::is_builtin_module() const
src/vm/scheduler.cpp+12−12
@@ -25,7 +25,7 @@ vm_scheduler_control_t::~vm_scheduler_control_t() · 24 unmodified lines
25 25
26void default_scheduler_t::worker_main(default_scheduler_t &instance)26void default_scheduler_t::worker_main(default_scheduler_t &instance)
27{27{
28 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: worker: start\n");28 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: worker: start");
29 29
30 auto current_thread = std::shared_ptr<thread_instance_t>{};30 auto current_thread = std::shared_ptr<thread_instance_t>{};
31 31
@@ -36,12 +36,12 @@ void default_scheduler_t::worker_main(default_scheduler_t &instance) · 4 unmodified lines
36 current_thread = instance.next_thread(std::move(current_thread));36 current_thread = instance.next_thread(std::move(current_thread));
37 if (current_thread == nullptr)37 if (current_thread == nullptr)
38 {38 {
39 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: worker: stop\n");39 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: worker: stop");
40 break;40 break;
41 }41 }
42 42
43 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())43 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())
44 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: worker: execute: %d\n", current_thread->vm_thread->get_thread_id());44 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: worker: execute: %d", current_thread->vm_thread->get_thread_id());
45 45
46 current_thread->vm_thread->execute(instance._vm, instance._vm_thread_quanta);46 current_thread->vm_thread->execute(instance._vm, instance._vm_thread_quanta);
47 }47 }
@@ -113,7 +113,7 @@ default_scheduler_t::~default_scheduler_t() · 65 unmodified lines
113 for (auto &w : _worker_pool)113 for (auto &w : _worker_pool)
114 w.join();114 w.join();
115 115
116 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: shutdown\n");116 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: shutdown");
117}117}
118 118
119bool default_scheduler_t::is_idle() const119bool default_scheduler_t::is_idle() const
@@ -134,7 +134,7 @@ const vm_thread_t& default_scheduler_t::schedule_thread(std::unique_ptr<runtime: · 14 unmodified lines
134 throw vm_system_exception{ "Scheduled thread in invalid state" };134 throw vm_system_exception{ "Scheduled thread in invalid state" };
135 135
136 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())136 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())
137 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: scheduled: %d\n", thread->get_thread_id());137 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: scheduled: %d", thread->get_thread_id());
138 138
139 std::unique_lock<std::mutex> lock{ _vm_threads_lock };139 std::unique_lock<std::mutex> lock{ _vm_threads_lock };
140 140
@@ -249,7 +249,7 @@ void default_scheduler_t::enqueue_blocked_thread(uint32_t thread_id) · 108 unmodified lines
249 _blocked_vm_thread_ids.erase(blocked_iter);249 _blocked_vm_thread_ids.erase(blocked_iter);
250 250
251 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())251 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())
252 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: enqueue blocked: %d\n", thread_id);252 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: enqueue blocked: %d", thread_id);
253 253
254 const bool runnable_thread = enqueue_thread_unsafe(std::move(thread_container), vm_thread_state_t::ready);254 const bool runnable_thread = enqueue_thread_unsafe(std::move(thread_container), vm_thread_state_t::ready);
255 if (runnable_thread)255 if (runnable_thread)
@@ -344,7 +344,7 @@ std::shared_ptr<default_scheduler_t::thread_instance_t> default_scheduler_t::nex · 88 unmodified lines
344 344
345 if (!_all_vm_threads.empty() && _blocked_vm_thread_ids.size() == _all_vm_threads.size())345 if (!_all_vm_threads.empty() && _blocked_vm_thread_ids.size() == _all_vm_threads.size())
346 {346 {
347 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::warning, "scheduler: deadlock detected\n");347 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::warning, "scheduler: deadlock detected");
348 assert(false && "VM thread deadlock detected");348 assert(false && "VM thread deadlock detected");
349 }349 }
350 350
@@ -352,7 +352,7 @@ std::shared_ptr<default_scheduler_t::thread_instance_t> default_scheduler_t::nex · 1 unmodified line
352 return{};352 return{};
353 353
354 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())354 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())
355 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: worker: waiting\n");355 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: worker: waiting");
356 356
357 _worker_event.wait(lock);357 _worker_event.wait(lock);
358 358
@@ -402,7 +402,7 @@ bool default_scheduler_t::enqueue_thread_unsafe(std::shared_ptr<thread_instance_ · 43 unmodified lines
402 _runnable_vm_thread_ids.push_back(thread_id);402 _runnable_vm_thread_ids.push_back(thread_id);
403 403
404 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())404 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())
405 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: enqueue: %d\n", thread_id);405 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: enqueue: %d", thread_id);
406 406
407 return true;407 return true;
408 }408 }
@@ -414,7 +414,7 @@ bool default_scheduler_t::enqueue_thread_unsafe(std::shared_ptr<thread_instance_ · 5 unmodified lines
414 _blocked_vm_thread_ids.insert(thread_id);414 _blocked_vm_thread_ids.insert(thread_id);
415 415
416 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())416 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())
417 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: blocked: %d\n", thread_id);417 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: blocked: %d", thread_id);
418 418
419 break;419 break;
420 }420 }
@@ -423,7 +423,7 @@ bool default_scheduler_t::enqueue_thread_unsafe(std::shared_ptr<thread_instance_ · 2 unmodified lines
423 case vm_thread_state_t::exiting:423 case vm_thread_state_t::exiting:
424 {424 {
425 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())425 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())
426 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: exiting: %d\n", thread_id);426 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: exiting: %d", thread_id);
427 427
428 // Remove the thread428 // Remove the thread
429 auto thread_to_remove = _all_vm_threads.find(thread_id);429 auto thread_to_remove = _all_vm_threads.find(thread_id);
@@ -436,7 +436,7 @@ bool default_scheduler_t::enqueue_thread_unsafe(std::shared_ptr<thread_instance_ · 6 unmodified lines
436 case vm_thread_state_t::broken:436 case vm_thread_state_t::broken:
437 {437 {
438 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())438 if (debug::is_component_tracing_enabled<debug::component_trace_t::scheduler>())
439 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: broken: %d\n", thread_id);439 debug::log_msg(debug::component_trace_t::scheduler, debug::log_level_t::debug, "scheduler: broken: %d", thread_id);
440 440
441 auto err_msg = thread_instance->vm_thread->get_error_message();441 auto err_msg = thread_instance->vm_thread->get_error_message();
442 assert(err_msg != nullptr);442 assert(err_msg != nullptr);
src/vm/stack.cpp+8−8
@@ -76,7 +76,7 @@ namespace · 75 unmodified lines
76 top_page->page_limit_addr = reinterpret_cast<std::uintptr_t>(top_page)+stack_page_size;76 top_page->page_limit_addr = reinterpret_cast<std::uintptr_t>(top_page)+stack_page_size;
77 77
78 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())78 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
79 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "alloc: vm stack alloc: %#" PRIxPTR " %#" PRIxPTR "\n", top_page, top_page->page_limit_addr);79 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "alloc: vm stack alloc: %#" PRIxPTR " %#" PRIxPTR, top_page, top_page->page_limit_addr);
80 80
81 return top_page->stack_data();81 return top_page->stack_data();
82 }82 }
@@ -90,7 +90,7 @@ namespace · 7 unmodified lines
90 free_memory(top_page);90 free_memory(top_page);
91 91
92 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())92 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
93 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "free: vm stack alloc\n");93 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "free: vm stack alloc");
94 94
95 // Set the top page95 // Set the top page
96 top_page = current_stack_page;96 top_page = current_stack_page;
@@ -111,7 +111,7 @@ vm_frame_t::vm_frame_t(std::shared_ptr<const type_descriptor_t> &td) · 14 unmodified lines
111 prev_module_ref() = nullptr;111 prev_module_ref() = nullptr;
112 112
113 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())113 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
114 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm frame: %#" PRIxPTR " %d\n", this, frame_type->size_in_bytes);114 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm frame: %#" PRIxPTR " %d", this, frame_type->size_in_bytes);
115}115}
116 116
117vm_frame_t::~vm_frame_t()117vm_frame_t::~vm_frame_t()
@@ -121,7 +121,7 @@ vm_frame_t::~vm_frame_t() · 3 unmodified lines
121 destroy_memory(*frame_type, base());121 destroy_memory(*frame_type, base());
122 122
123 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())123 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
124 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm frame: %#" PRIxPTR "\n", this);124 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm frame: %#" PRIxPTR, this);
125}125}
126 126
127void vm_frame_t::copy_frame_contents(const vm_frame_t &other)127void vm_frame_t::copy_frame_contents(const vm_frame_t &other)
@@ -181,7 +181,7 @@ vm_stack_t::vm_stack_t(std::size_t stack_extent) · 53 unmodified lines
181 : _mem{ std::make_unique<vm_stack_layout>(stack_extent) }181 : _mem{ std::make_unique<vm_stack_layout>(stack_extent) }
182{182{
183 assert(0 < stack_extent && stack_extent < static_cast<std::size_t>(std::numeric_limits<word_t>::max()));183 assert(0 < stack_extent && stack_extent < static_cast<std::size_t>(std::numeric_limits<word_t>::max()));
184 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm stack\n");184 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm stack");
185}185}
186 186
187vm_stack_t::~vm_stack_t()187vm_stack_t::~vm_stack_t()
@@ -195,7 +195,7 @@ vm_stack_t::~vm_stack_t() · 7 unmodified lines
195 _mem->release();195 _mem->release();
196 _mem.reset();196 _mem.reset();
197 197
198 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm stack\n");198 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm stack");
199}199}
200 200
201vm_frame_t *vm_stack_t::alloc_frame(std::shared_ptr<const type_descriptor_t> frame_type)201vm_frame_t *vm_stack_t::alloc_frame(std::shared_ptr<const type_descriptor_t> frame_type)
@@ -245,7 +245,7 @@ vm_frame_t *vm_stack_t::push_frame() · 43 unmodified lines
245 layout->top_frame = new_top_frame;245 layout->top_frame = new_top_frame;
246 246
247 if (debug::is_component_tracing_enabled<debug::component_trace_t::stack>())247 if (debug::is_component_tracing_enabled<debug::component_trace_t::stack>())
248 debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "update: push vm frame: %#" PRIxPTR "\n", new_top_frame);248 debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "update: push vm frame: %#" PRIxPTR, new_top_frame);
249 249
250 return new_top_frame;250 return new_top_frame;
251}251}
@@ -285,7 +285,7 @@ vm_frame_t *vm_stack_t::pop_frame() · 33 unmodified lines
285 }285 }
286 286
287 if (debug::is_component_tracing_enabled<debug::component_trace_t::stack>())287 if (debug::is_component_tracing_enabled<debug::component_trace_t::stack>())
288 debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "update: pop vm frame: %#" PRIxPTR "\n", current_frame);288 debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "update: pop vm frame: %#" PRIxPTR, current_frame);
289 289
290 return current_frame;290 return current_frame;
291}291}
src/vm/string.cpp+3−3
@@ -222,7 +222,7 @@ vm_string_t::vm_string_t(std::size_t encoded_str_len, const uint8_t *encoded_str · 221 unmodified lines
222 }222 }
223 223
224 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())224 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
225 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm string: %d %d >>%s<<\n", _length, (_length_max * _character_size), dest);225 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm string: %d %d >>%s<<", _length, (_length_max * _character_size), dest);
226}226}
227 227
228vm_string_t::vm_string_t(const vm_string_t &s1, const vm_string_t &s2)228vm_string_t::vm_string_t(const vm_string_t &s1, const vm_string_t &s2)
@@ -282,7 +282,7 @@ vm_string_t::vm_string_t(const vm_string_t &other, word_t begin_index, word_t en · 53 unmodified lines
282 282
283 // Copy over string content starting at the correct index (char vs. rune_t)283 // Copy over string content starting at the correct index (char vs. rune_t)
284 std::memcpy(dest, (src + (begin_index * _character_size)), length_in_bytes);284 std::memcpy(dest, (src + (begin_index * _character_size)), length_in_bytes);
285 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "copy: vm string: %#" PRIxPTR " %d %d %#" PRIxPTR "\n", &other, begin_index, end_index, this);285 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "copy: vm string: %#" PRIxPTR " %d %d %#" PRIxPTR, &other, begin_index, end_index, this);
286}286}
287 287
288vm_string_t::~vm_string_t()288vm_string_t::~vm_string_t()
@@ -301,7 +301,7 @@ vm_string_t::~vm_string_t() · 12 unmodified lines
301 free_memory(_encoded_str);301 free_memory(_encoded_str);
302 }302 }
303 303
304 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm string\n");304 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm string");
305 305
306 debug::assign_debug_pointer(&_mem.alloc);306 debug::assign_debug_pointer(&_mem.alloc);
307 debug::assign_debug_pointer(&_encoded_str);307 debug::assign_debug_pointer(&_encoded_str);
src/vm/sys/Sysmod.cpp+6−6
@@ -90,7 +90,7 @@ namespace · 89 unmodified lines
90 debug::log_msg(90 debug::log_msg(
91 debug::component_trace_t::builtin,91 debug::component_trace_t::builtin,
92 debug::log_level_t::debug,92 debug::log_level_t::debug,
93 "sys: fd: finalize: %d\n",93 "sys: fd: finalize: %d",
94 fd->fd);94 fd->fd);
95 }95 }
96 96
@@ -236,21 +236,21 @@ Sysmodinit(void) · 139 unmodified lines
236 auto vm_stdin = vm_alloc_t::allocate(T_FD);236 auto vm_stdin = vm_alloc_t::allocate(T_FD);
237 const auto fd = sys::create_fd_record(vm_stdin);237 const auto fd = sys::create_fd_record(vm_stdin);
238 fd_stdin = ::new(vm_stdin->get_allocation())vm_fd_t{ fd, std::cin };238 fd_stdin = ::new(vm_stdin->get_allocation())vm_fd_t{ fd, std::cin };
239 debug::log_msg(debug::component_trace_t::builtin, debug::log_level_t::debug, "sys: stdin: %d\n", fd);239 debug::log_msg(debug::component_trace_t::builtin, debug::log_level_t::debug, "sys: stdin: %d", fd);
240 }240 }
241 241
242 {242 {
243 auto vm_stdout = vm_alloc_t::allocate(T_FD);243 auto vm_stdout = vm_alloc_t::allocate(T_FD);
244 const auto fd = sys::create_fd_record(vm_stdout);244 const auto fd = sys::create_fd_record(vm_stdout);
245 fd_stdout = ::new(vm_stdout->get_allocation())vm_fd_t{ fd, std::cout };245 fd_stdout = ::new(vm_stdout->get_allocation())vm_fd_t{ fd, std::cout };
246 debug::log_msg(debug::component_trace_t::builtin, debug::log_level_t::debug, "sys: stdout: %d\n", fd);246 debug::log_msg(debug::component_trace_t::builtin, debug::log_level_t::debug, "sys: stdout: %d", fd);
247 }247 }
248 248
249 {249 {
250 auto vm_stderr = vm_alloc_t::allocate(T_FD);250 auto vm_stderr = vm_alloc_t::allocate(T_FD);
251 const auto fd = sys::create_fd_record(vm_stderr);251 const auto fd = sys::create_fd_record(vm_stderr);
252 fd_stderr = ::new(vm_stderr->get_allocation())vm_fd_t{ fd, std::cerr };252 fd_stderr = ::new(vm_stderr->get_allocation())vm_fd_t{ fd, std::cerr };
253 debug::log_msg(debug::component_trace_t::builtin, debug::log_level_t::debug, "sys: stderr: %d\n", fd);253 debug::log_msg(debug::component_trace_t::builtin, debug::log_level_t::debug, "sys: stderr: %d", fd);
254 }254 }
255}255}
256 256
@@ -390,7 +390,7 @@ Sys_create(vm_registers_t &r, vm_t &vm) · 133 unmodified lines
390 debug::log_msg(390 debug::log_msg(
391 debug::component_trace_t::builtin,391 debug::component_trace_t::builtin,
392 debug::log_level_t::debug,392 debug::log_level_t::debug,
393 "sys: create: %d >>%s<< %#x %#x\n",393 "sys: create: %d >>%s<< %#x %#x",
394 fd,394 fd,
395 path->str(),395 path->str(),
396 fp.mode,396 fp.mode,
@@ -542,7 +542,7 @@ Sys_open(vm_registers_t &r, vm_t &vm) · 145 unmodified lines
542 debug::log_msg(542 debug::log_msg(
543 debug::component_trace_t::builtin,543 debug::component_trace_t::builtin,
544 debug::log_level_t::debug,544 debug::log_level_t::debug,
545 "sys: open: %d >>%s<< %#x\n",545 "sys: open: %d >>%s<< %#x",
546 fd,546 fd,
547 path->str(),547 path->str(),
548 fp.mode);548 fp.mode);
src/vm/thread.cpp+5−5
@@ -34,7 +34,7 @@ namespace · 33 unmodified lines
34 debug::log_msg(34 debug::log_msg(
35 debug::component_trace_t::addressing,35 debug::component_trace_t::addressing,
36 debug::log_level_t::debug,36 debug::log_level_t::debug,
37 "decode: registers: %d (%#" PRIxPTR " %#" PRIxPTR " %#" PRIxPTR ")\n",37 "decode: registers: %d (%#" PRIxPTR " %#" PRIxPTR " %#" PRIxPTR ")",
38 inst.opcode,38 inst.opcode,
39 reg.src,39 reg.src,
40 reg.mid,40 reg.mid,
@@ -127,7 +127,7 @@ vm_thread_t::vm_thread_t( · 86 unmodified lines
127 // Pushing the initial frame sets the FP register127 // Pushing the initial frame sets the FP register
128 _registers.stack.push_frame();128 _registers.stack.push_frame();
129 129
130 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "init: vm thread: %d %d\n", _thread_id, _parent_thread_id);130 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "init: vm thread: %d %d", _thread_id, _parent_thread_id);
131}131}
132 132
133vm_thread_t::vm_thread_t(133vm_thread_t::vm_thread_t(
@@ -157,13 +157,13 @@ vm_thread_t::vm_thread_t( · 23 unmodified lines
157 current_frame->copy_frame_contents(initial_frame);157 current_frame->copy_frame_contents(initial_frame);
158 158
159 if (debug::is_component_tracing_enabled<debug::component_trace_t::thread>())159 if (debug::is_component_tracing_enabled<debug::component_trace_t::thread>())
160 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "init: vm thread: %d %d\n", _thread_id, _parent_thread_id);160 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "init: vm thread: %d %d", _thread_id, _parent_thread_id);
161}161}
162 162
163vm_thread_t::~vm_thread_t()163vm_thread_t::~vm_thread_t()
164{164{
165 if (debug::is_component_tracing_enabled<debug::component_trace_t::thread>())165 if (debug::is_component_tracing_enabled<debug::component_trace_t::thread>())
166 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "destroy: vm thread: %d %d\n", _thread_id, _parent_thread_id);166 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "destroy: vm thread: %d %d", _thread_id, _parent_thread_id);
167 167
168 free_memory(_error_message);168 free_memory(_error_message);
169 debug::assign_debug_pointer(&_error_message);169 debug::assign_debug_pointer(&_error_message);
@@ -267,7 +267,7 @@ vm_thread_state_t vm_thread_t::execute(vm_t &vm, const uint32_t quanta) · 97 unmodified lines
267 debug::log_msg(267 debug::log_msg(
268 debug::component_trace_t::thread,268 debug::component_trace_t::thread,
269 debug::log_level_t::debug,269 debug::log_level_t::debug,
270 "status: vm thread: execute: %d %d %d %d\n",270 "status: vm thread: execute: %d %d %d %d",
271 _thread_id,271 _thread_id,
272 (quanta - _registers.current_thread_quanta),272 (quanta - _registers.current_thread_quanta),
273 quanta,273 quanta,
src/vm/vm.cpp+2−2
@@ -144,7 +144,7 @@ std::shared_ptr<runtime::vm_module_t> vm_t::load_module(const char *path) · 143 unmodified lines
144 144
145 iter->module = module;145 iter->module = module;
146 146
147 debug::log_msg(debug::component_trace_t::module, debug::log_level_t::debug, "reload: vm module: >>%s<<\n", path);147 debug::log_msg(debug::component_trace_t::module, debug::log_level_t::debug, "reload: vm module: >>%s<<", path);
148 }148 }
149 149
150 return module;150 return module;
@@ -182,7 +182,7 @@ std::shared_ptr<runtime::vm_module_t> vm_t::load_module(const char *path) · 31 unmodified lines
182 }182 }
183 183
184 if (debug::is_component_tracing_enabled<debug::component_trace_t::module>())184 if (debug::is_component_tracing_enabled<debug::component_trace_t::module>())
185 debug::log_msg(debug::component_trace_t::module, debug::log_level_t::debug, "load: vm module: >>%s<<\n", path);185 debug::log_msg(debug::component_trace_t::module, debug::log_level_t::debug, "load: vm module: >>%s<<", path);
186 186
187 return new_module;187 return new_module;
188}188}
src/vm/vm_exception_handler.cpp+3−3
@@ -26,7 +26,7 @@ std::tuple<const handler_t *, vm_frame_t *, vm_pc_t> disvm::runtime::find_except · 25 unmodified lines
26 26
27 while (current_frame != nullptr)27 while (current_frame != nullptr)
28 {28 {
29 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "begin: handler: %d\n", unwind_depth);29 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "begin: handler: %d", unwind_depth);
30 30
31 auto &handler_section = current_module->module->handler_section;31 auto &handler_section = current_module->module->handler_section;
32 32
@@ -42,12 +42,12 @@ std::tuple<const handler_t *, vm_frame_t *, vm_pc_t> disvm::runtime::find_except · 9 unmodified lines
42 auto exception_name = exception.name.get();42 auto exception_name = exception.name.get();
43 if (exception_id.compare_to(exception_name) == 0)43 if (exception_id.compare_to(exception_name) == 0)
44 {44 {
45 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "end: handler: match: %d\n", unwind_depth);45 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "end: handler: match: %d", unwind_depth);
46 return std::make_tuple(&handler, current_frame, exception.pc);46 return std::make_tuple(&handler, current_frame, exception.pc);
47 }47 }
48 else if (exception_name == nullptr && exception.pc != runtime_constants::invalid_program_counter)48 else if (exception_name == nullptr && exception.pc != runtime_constants::invalid_program_counter)
49 {49 {
50 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "end: handler: fallback: %d\n", unwind_depth);50 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "end: handler: fallback: %d", unwind_depth);
51 return std::make_tuple(&handler, current_frame, exception.pc);51 return std::make_tuple(&handler, current_frame, exception.pc);
52 }52 }
53 }53 }
src/vm/vm_memory.cpp+34−25
@@ -110,7 +110,7 @@ void *disvm::runtime::alloc_memory(std::size_t amount_in_bytes) · 109 unmodified lines
110 throw vm_system_exception{ "Out of memory" };110 throw vm_system_exception{ "Out of memory" };
111 111
112 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())112 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
113 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "alloc: %#" PRIxPTR " %d\n", memory, amount_in_bytes);113 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "alloc: %#" PRIxPTR " %d", memory, amount_in_bytes);
114 114
115 return memory;115 return memory;
116}116}
@@ -124,7 +124,7 @@ void *disvm::runtime::calloc_memory(std::size_t amount_in_bytes) · 7 unmodified lines
124 throw vm_system_exception{ "Out of memory" };124 throw vm_system_exception{ "Out of memory" };
125 125
126 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())126 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
127 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "alloc: zeroed: %#" PRIxPTR " %d\n", memory, amount_in_bytes);127 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "alloc: zeroed: %#" PRIxPTR " %d", memory, amount_in_bytes);
128 128
129 return memory;129 return memory;
130}130}
@@ -135,7 +135,7 @@ void disvm::runtime::free_memory(void *memory) · 4 unmodified lines
135 return;135 return;
136 136
137 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())137 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
138 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "free: %#" PRIxPTR "\n", memory);138 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "free: %#" PRIxPTR, memory);
139 139
140 std::free(memory);140 std::free(memory);
141}141}
@@ -233,7 +233,7 @@ vm_alloc_t *vm_alloc_t::allocate(std::shared_ptr<const type_descriptor_t> td) · 91 unmodified lines
233 // Initialize pointer types233 // Initialize pointer types
234 init_memory(*td, alloc->get_allocation());234 init_memory(*td, alloc->get_allocation());
235 235
236 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm alloc: %d\n", td->size_in_bytes);236 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm alloc: %d", td->size_in_bytes);
237 return alloc;237 return alloc;
238}238}
239 239
@@ -247,7 +247,7 @@ vm_alloc_t *vm_alloc_t::allocate(std::shared_ptr<const type_descriptor_t> td, co · 7 unmodified lines
247 auto mem = calloc_memory(sizeof(vm_alloc_t) + td->size_in_bytes);247 auto mem = calloc_memory(sizeof(vm_alloc_t) + td->size_in_bytes);
248 auto alloc = ::new(mem)vm_alloc_t{ td };248 auto alloc = ::new(mem)vm_alloc_t{ td };
249 249
250 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "initz: vm alloc: %d\n", td->size_in_bytes);250 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "initz: vm alloc: %d", td->size_in_bytes);
251 return alloc;251 return alloc;
252}252}
253 253
@@ -261,7 +261,7 @@ vm_alloc_t *vm_alloc_t::copy(const vm_alloc_t &other) · 7 unmodified lines
261 // Ref count all dynamic allocations261 // Ref count all dynamic allocations
262 inc_ref_count_in_memory(*alloc_copy->alloc_type, alloc_copy->get_allocation());262 inc_ref_count_in_memory(*alloc_copy->alloc_type, alloc_copy->get_allocation());
263 263
264 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "copy: vm alloc: %#" PRIxPTR " %#" PRIxPTR "\n", &other, alloc_copy);264 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "copy: vm alloc: %#" PRIxPTR " %#" PRIxPTR, &other, alloc_copy);
265 return alloc_copy;265 return alloc_copy;
266}266}
267 267
@@ -291,7 +291,7 @@ vm_alloc_t::~vm_alloc_t() · 23 unmodified lines
291 291
292 // Free pointer types292 // Free pointer types
293 destroy_memory(*alloc_type, get_allocation());293 destroy_memory(*alloc_type, get_allocation());
294 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm alloc\n");294 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: vm alloc");
295}295}
296 296
297std::size_t vm_alloc_t::add_ref()297std::size_t vm_alloc_t::add_ref()
@@ -326,24 +326,28 @@ namespace · 28 unmodified lines
326{326{
327 namespace hidden_type_desc327 namespace hidden_type_desc
328 {328 {
329 const type_descriptor_t byte{ sizeof(byte_t), 0, nullptr, type_descriptor_t::no_finalizer };329#define TYPE_DESC(N,S,MS,M,F) const type_descriptor_t N{ S, MS, M, F, #N }
330 const type_descriptor_t short_word{ sizeof(short_word_t), 0, nullptr, type_descriptor_t::no_finalizer };330
331 const type_descriptor_t word{ sizeof(word_t), 0, nullptr, type_descriptor_t::no_finalizer };331 TYPE_DESC(byte, sizeof(byte_t), 0, nullptr, type_descriptor_t::no_finalizer);
332 const type_descriptor_t short_real{ sizeof(short_real_t), 0, nullptr, type_descriptor_t::no_finalizer };332 TYPE_DESC(short_word, sizeof(short_word_t), 0, nullptr, type_descriptor_t::no_finalizer);
333 const type_descriptor_t real{ sizeof(real_t), 0, nullptr, type_descriptor_t::no_finalizer };333 TYPE_DESC(word, sizeof(word_t), 0, nullptr, type_descriptor_t::no_finalizer);
334 const type_descriptor_t big{ sizeof(big_t), 0, nullptr, type_descriptor_t::no_finalizer };334 TYPE_DESC(short_real, sizeof(short_real_t), 0, nullptr, type_descriptor_t::no_finalizer);
335 TYPE_DESC(real, sizeof(real_t), 0, nullptr, type_descriptor_t::no_finalizer);
336 TYPE_DESC(big, sizeof(big_t), 0, nullptr, type_descriptor_t::no_finalizer);
335 337
336 const byte_t pointer_map[] = { 0x80 };338 const byte_t pointer_map[] = { 0x80 };
337 const type_descriptor_t pointer{ sizeof(pointer_t), (sizeof(pointer_map) / sizeof(pointer_map[0])), pointer_map, type_descriptor_t::no_finalizer };339 TYPE_DESC(pointer, sizeof(pointer_t), (sizeof(pointer_map) / sizeof(pointer_map[0])), pointer_map, type_descriptor_t::no_finalizer);
340
341 TYPE_DESC(vm_array, 0, 0, nullptr, type_descriptor_t::no_finalizer);
342 TYPE_DESC(vm_list, 0, 0, nullptr, type_descriptor_t::no_finalizer);
343 TYPE_DESC(vm_channel, 0, 0, nullptr, type_descriptor_t::no_finalizer);
344 TYPE_DESC(vm_string, 0, 0, nullptr, type_descriptor_t::no_finalizer);
338 345
339 const type_descriptor_t vm_array{ 0, 0, nullptr, type_descriptor_t::no_finalizer };346 TYPE_DESC(vm_module_ref, 0, 0, nullptr, type_descriptor_t::no_finalizer);
340 const type_descriptor_t vm_list{ 0, 0, nullptr, type_descriptor_t::no_finalizer };347 TYPE_DESC(vm_stack, 0, 0, nullptr, type_descriptor_t::no_finalizer);
341 const type_descriptor_t vm_channel{ 0, 0, nullptr, type_descriptor_t::no_finalizer };348 TYPE_DESC(vm_thread, 0, 0, nullptr, type_descriptor_t::no_finalizer);
342 const type_descriptor_t vm_string{ 0, 0, nullptr, type_descriptor_t::no_finalizer };
343 349
344 const type_descriptor_t vm_module_ref{ 0, 0, nullptr, type_descriptor_t::no_finalizer };350#undef TYPE_DESC
345 const type_descriptor_t vm_stack{ 0, 0, nullptr, type_descriptor_t::no_finalizer };
346 const type_descriptor_t vm_thread{ 0, 0, nullptr, type_descriptor_t::no_finalizer };
347 351
348 struct352 struct
349 {353 {
@@ -480,7 +484,7 @@ std::shared_ptr<const type_descriptor_t> type_descriptor_t::create( · 130 unmodified lines
480 debug::assign_debug_pointer(const_cast<byte_t **>(&td->pointer_map));484 debug::assign_debug_pointer(const_cast<byte_t **>(&td->pointer_map));
481 485
482 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())486 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
483 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: type descriptor\n");487 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "destroy: type descriptor");
484 488
485 free_memory(td);489 free_memory(td);
486 }490 }
@@ -496,7 +500,7 @@ std::shared_ptr<const type_descriptor_t> type_descriptor_t::create( · 9 unmodified lines
496 pointer_map_local[i] = pointer_map[i];500 pointer_map_local[i] = pointer_map[i];
497 }501 }
498 502
499 auto new_type = ::new(new_type_memory) type_descriptor_t{ size_in_bytes, pointer_map_length, pointer_map_local, finalizer };503 auto new_type = ::new(new_type_memory) type_descriptor_t{ size_in_bytes, pointer_map_length, pointer_map_local, finalizer, "#" };
500 return std::shared_ptr<type_descriptor_t>{ new_type, deleter };504 return std::shared_ptr<type_descriptor_t>{ new_type, deleter };
501}505}
502 506
@@ -504,12 +508,17 @@ type_descriptor_t::type_descriptor_t( · 1 unmodified line
504 word_t size_in_bytes,508 word_t size_in_bytes,
505 word_t map_in_bytes,509 word_t map_in_bytes,
506 const byte_t * pointer_map,510 const byte_t * pointer_map,
507 vm_alloc_instance_finalizer_t finalizer)511 vm_alloc_instance_finalizer_t finalizer,
512 const char *debug_name)
508 : size_in_bytes{ size_in_bytes }513 : size_in_bytes{ size_in_bytes }
509 , map_in_bytes{ map_in_bytes }514 , map_in_bytes{ map_in_bytes }
510 , pointer_map{ pointer_map }515 , pointer_map{ pointer_map }
511 , finalizer{ finalizer }516 , finalizer{ finalizer }
517#ifndef NDEBUG
518 , debug_type_name{ debug_name }
519#endif
512{520{
521 (void)debug_name;
513 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())522 if (debug::is_component_tracing_enabled<debug::component_trace_t::memory>())
514 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: type descriptor\n");523 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: type descriptor");
515}524}