History

Various perf and style fixes

arr committed 9 years ago

Commit 08c36e01 parent b1b22c24 files · +29 −23Browse files

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

Unified · Split

src/vm/execution_table.cpp+17−13
@@ -537,7 +537,7 @@ namespace · 536 unmodified lines
537537 auto type_id = vt_ref<word_t>(r.mid);
538538 const auto &types = r.module_ref->type_section;
539539 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];
541541
542542 disvm::runtime::inc_ref_count_in_memory(*type, r.src);
543543 destroy_memory(*type, r.dest);
@@ -971,14 +971,15 @@ namespace · 427 unmodified lines
971971 auto tail_maybe = at_val<vm_list_t>(r.dest);
972972
973973 // 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 };
975976 if (tail_maybe != nullptr)
976977 tail_maybe->release();
977978
978979 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);
980981
981− if (type->map_in_bytes > 0)
982+ if (type_size_in_bytes > 0)
982983 vm.get_garbage_collector().track_allocation(new_list);
983984
984985 // Return the list
@@ -1329,9 +1330,10 @@ namespace · 344 unmodified lines
13291330 dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest));
13301331
13311332 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));
13331335
1334− if (type_desc->map_in_bytes > 0)
1336+ if (track_object)
13351337 vm.get_garbage_collector().track_allocation(new_alloc);
13361338
13371339 pt_ref(r.dest) = new_alloc->get_allocation();
@@ -1363,9 +1365,10 @@ namespace · 25 unmodified lines
13631365 dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest));
13641366
13651367 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));
13671370
1368− if (type_desc->map_in_bytes > 0)
1371+ if (track_object)
13691372 vm.get_garbage_collector().track_allocation(new_alloc);
13701373
13711374 pt_ref(r.dest) = new_alloc->get_allocation();
@@ -1385,9 +1388,10 @@ namespace · 13 unmodified lines
13851388 dec_ref_count_and_free(at_val<vm_alloc_t>(r.dest));
13861389
13871390 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);
13891393
1390− if (type_desc->map_in_bytes > 0)
1394+ if (track_object)
13911395 vm.get_garbage_collector().track_allocation(new_array);
13921396
13931397 pt_ref(r.dest) = new_array->get_allocation();
@@ -1437,7 +1441,7 @@ namespace · 43 unmodified lines
14371441
14381442 const auto frame_type_id = vt_ref<word_t>(r.src);
14391443 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];
14411445
14421446 pt_ref(r.dest) = r.stack.alloc_frame(std::move(frame_type))->base();
14431447 }
@@ -1456,9 +1460,9 @@ namespace · 12 unmodified lines
14561460
14571461 const auto frame_type_id = function_ref.frame_type;
14581462 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];
14601464
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();
14621466 }
14631467
14641468 EXEC_DECL(ret)