| @@ -537,7 +537,7 @@ namespace · 536 unmodified lines |
| 537 | auto type_id = vt_ref<word_t>(r.mid); | 537 | auto type_id = vt_ref<word_t>(r.mid); |
| 538 | const auto &types = r.module_ref->type_section; | 538 | const auto &types = r.module_ref->type_section; |
| 539 | assert(0 <= type_id && type_id < static_cast<word_t>(types.size())); | 539 | assert(0 <= type_id && type_id < static_cast<word_t>(types.size())); |
| 540 | auto type = types[type_id]; | 540 | const auto &type = types[type_id]; |
| 541 | | 541 | |
| 542 | disvm::runtime::inc_ref_count_in_memory(*type, r.src); | 542 | disvm::runtime::inc_ref_count_in_memory(*type, r.src); |
| 543 | destroy_memory(*type, r.dest); | 543 | destroy_memory(*type, r.dest); |
| @@ -971,14 +971,15 @@ namespace · 427 unmodified lines |
| 971 | auto tail_maybe = at_val<vm_list_t>(r.dest); | 971 | auto tail_maybe = at_val<vm_list_t>(r.dest); |
| 972 | | 972 | |
| 973 | // Create a new list | 973 | // Create a new list |
| 974 | auto new_list = new vm_list_t{ type, tail_maybe }; | 974 | const auto type_size_in_bytes = type->size_in_bytes; |
| | 975 | auto new_list = new vm_list_t{ std::move(type), tail_maybe }; |
| 975 | if (tail_maybe != nullptr) | 976 | if (tail_maybe != nullptr) |
| 976 | tail_maybe->release(); | 977 | tail_maybe->release(); |
| 977 | | 978 | |
| 978 | auto destination = new_list->value(); | 979 | auto destination = new_list->value(); |
| 979 | std::memmove(destination, r.src, type->size_in_bytes); | 980 | std::memmove(destination, r.src, type_size_in_bytes); |
| 980 | | 981 | |
| 981 | if (type->map_in_bytes > 0) | 982 | if (type_size_in_bytes > 0) |
| 982 | vm.get_garbage_collector().track_allocation(new_list); | 983 | vm.get_garbage_collector().track_allocation(new_list); |
| 983 | | 984 | |
| 984 | // Return the list | 985 | // Return the list |
| @@ -1329,9 +1330,10 @@ namespace · 344 unmodified lines |
| 1329 | dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest)); | 1330 | dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest)); |
| 1330 | | 1331 | |
| 1331 | auto type_desc = types[type_id]; | 1332 | auto type_desc = types[type_id]; |
| 1332 | auto new_alloc = vm_alloc_t::allocate(type_desc); | 1333 | const auto track_object = type_desc->map_in_bytes > 0; |
| | 1334 | auto new_alloc = vm_alloc_t::allocate(std::move(type_desc)); |
| 1333 | | 1335 | |
| 1334 | if (type_desc->map_in_bytes > 0) | 1336 | if (track_object) |
| 1335 | vm.get_garbage_collector().track_allocation(new_alloc); | 1337 | vm.get_garbage_collector().track_allocation(new_alloc); |
| 1336 | | 1338 | |
| 1337 | pt_ref(r.dest) = new_alloc->get_allocation(); | 1339 | pt_ref(r.dest) = new_alloc->get_allocation(); |
| @@ -1363,9 +1365,10 @@ namespace · 25 unmodified lines |
| 1363 | dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest)); | 1365 | dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest)); |
| 1364 | | 1366 | |
| 1365 | auto type_desc = types[type_id]; | 1367 | auto type_desc = types[type_id]; |
| 1366 | auto new_alloc = vm_alloc_t::allocate(type_desc); | 1368 | const auto track_object = type_desc->map_in_bytes > 0; |
| | 1369 | auto new_alloc = vm_alloc_t::allocate(std::move(type_desc)); |
| 1367 | | 1370 | |
| 1368 | if (type_desc->map_in_bytes > 0) | 1371 | if (track_object) |
| 1369 | vm.get_garbage_collector().track_allocation(new_alloc); | 1372 | vm.get_garbage_collector().track_allocation(new_alloc); |
| 1370 | | 1373 | |
| 1371 | pt_ref(r.dest) = new_alloc->get_allocation(); | 1374 | pt_ref(r.dest) = new_alloc->get_allocation(); |
| @@ -1385,9 +1388,10 @@ namespace · 13 unmodified lines |
| 1385 | dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest)); | 1388 | dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest)); |
| 1386 | | 1389 | |
| 1387 | const auto array_size = vt_ref<word_t>(r.src); | 1390 | const auto array_size = vt_ref<word_t>(r.src); |
| 1388 | auto new_array = new vm_array_t(type_desc, array_size); | 1391 | const auto track_object = type_desc->map_in_bytes > 0; |
| | 1392 | auto new_array = new vm_array_t(std::move(type_desc), array_size); |
| 1389 | | 1393 | |
| 1390 | if (type_desc->map_in_bytes > 0) | 1394 | if (track_object) |
| 1391 | vm.get_garbage_collector().track_allocation(new_array); | 1395 | vm.get_garbage_collector().track_allocation(new_array); |
| 1392 | | 1396 | |
| 1393 | pt_ref(r.dest) = new_array->get_allocation(); | 1397 | pt_ref(r.dest) = new_array->get_allocation(); |
| @@ -1437,7 +1441,7 @@ namespace · 43 unmodified lines |
| 1437 | | 1441 | |
| 1438 | const auto frame_type_id = vt_ref<word_t>(r.src); | 1442 | const auto frame_type_id = vt_ref<word_t>(r.src); |
| 1439 | assert(0 <= frame_type_id && frame_type_id < static_cast<word_t>(types.size())); | 1443 | assert(0 <= frame_type_id && frame_type_id < static_cast<word_t>(types.size())); |
| 1440 | const auto frame_type = types[frame_type_id]; | 1444 | auto frame_type = types[frame_type_id]; |
| 1441 | | 1445 | |
| 1442 | pt_ref(r.dest) = r.stack.alloc_frame(std::move(frame_type))->base(); | 1446 | pt_ref(r.dest) = r.stack.alloc_frame(std::move(frame_type))->base(); |
| 1443 | } | 1447 | } |
| @@ -1456,9 +1460,9 @@ namespace · 12 unmodified lines |
| 1456 | | 1460 | |
| 1457 | const auto frame_type_id = function_ref.frame_type; | 1461 | const auto frame_type_id = function_ref.frame_type; |
| 1458 | assert(0 <= frame_type_id && frame_type_id < static_cast<word_t>(types.size())); | 1462 | assert(0 <= frame_type_id && frame_type_id < static_cast<word_t>(types.size())); |
| 1459 | const auto frame_type = types[frame_type_id]; | 1463 | auto frame_type = types[frame_type_id]; |
| 1460 | | 1464 | |
| 1461 | pt_ref(r.dest) = r.stack.alloc_frame(frame_type)->base(); | 1465 | pt_ref(r.dest) = r.stack.alloc_frame(std::move(frame_type))->base(); |
| 1462 | } | 1466 | } |
| 1463 | | 1467 | |
| 1464 | EXEC_DECL(ret) | 1468 | EXEC_DECL(ret) |