History

Remove vm_thread reference from exec/fork vm functions.

arr committed 9 years ago

Commit a64d7751 parent 98ad0165 files · +30 −23Browse files

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

Unified · Split

src/vm/vm.cpp+17−8
@@ -226,26 +226,32 @@ namespace · 225 unmodified lines
226 }226 }
227}227}
228 228
229const vm_thread_t& vm_t::exec(const char *path)229uint32_t vm_t::exec(const char *path)
230{230{
231 assert(path != nullptr);231 assert(path != nullptr);
232 auto entry_module = load_module(path);232 auto entry_module = load_module(path);
233 233
234 auto entry_module_ref = std::make_unique<vm_module_ref_t>(entry_module);234 auto entry_module_ref = std::make_unique<vm_module_ref_t>(entry_module);
235 auto thread = _create_thread_safe(std::move(entry_module_ref));235 auto thread = _create_thread_safe(std::move(entry_module_ref));
236 return schedule_thread(std::move(thread));236
237 const auto thread_id = thread->get_thread_id();
238 schedule_thread(std::move(thread));
239 return thread_id;
237}240}
238 241
239const vm_thread_t& vm_t::exec(std::unique_ptr<vm_module_t> entry_module)242uint32_t vm_t::exec(std::unique_ptr<vm_module_t> entry_module)
240{243{
241 assert(entry_module != nullptr);244 assert(entry_module != nullptr);
242 245
243 auto entry_module_ref = std::make_unique<vm_module_ref_t>(std::move(entry_module));246 auto entry_module_ref = std::make_unique<vm_module_ref_t>(std::move(entry_module));
244 auto thread = _create_thread_safe(std::move(entry_module_ref));247 auto thread = _create_thread_safe(std::move(entry_module_ref));
245 return schedule_thread(std::move(thread));248
249 const auto thread_id = thread->get_thread_id();
250 schedule_thread(std::move(thread));
251 return thread_id;
246}252}
247 253
248const vm_thread_t& vm_t::fork(254uint32_t vm_t::fork(
249 const uint32_t parent_tid,255 const uint32_t parent_tid,
250 vm_module_ref_t &module_ref,256 vm_module_ref_t &module_ref,
251 const vm_frame_t &initial_frame,257 const vm_frame_t &initial_frame,
@@ -255,7 +261,10 @@ const vm_thread_t& vm_t::fork( · 3 unmodified lines
255 throw vm_user_exception{ "Invalid entry program counter" };261 throw vm_user_exception{ "Invalid entry program counter" };
256 262
257 auto thread = std::make_unique<vm_thread_t>(module_ref, parent_tid, initial_frame, initial_pc);263 auto thread = std::make_unique<vm_thread_t>(module_ref, parent_tid, initial_frame, initial_pc);
258 return schedule_thread(std::move(thread));264
265 const auto thread_id = thread->get_thread_id();
266 schedule_thread(std::move(thread));
267 return thread_id;
259}268}
260 269
261namespace270namespace
@@ -445,7 +454,7 @@ void vm_t::unload_tool(std::size_t tool_id) · 183 unmodified lines
445 }454 }
446}455}
447 456
448const vm_thread_t &vm_t::schedule_thread(std::unique_ptr<vm_thread_t> thread)457void vm_t::schedule_thread(std::unique_ptr<vm_thread_t> thread)
449{458{
450 assert(thread != nullptr);459 assert(thread != nullptr);
451 460
@@ -459,5 +468,5 @@ const vm_thread_t &vm_t::schedule_thread(std::unique_ptr<vm_thread_t> thread) · 7 unmodified lines
459 }468 }
460 }469 }
461 470
462 return _scheduler->schedule_thread(std::move(thread));471 _scheduler->schedule_thread(std::move(thread));
463}472}