History

Various work for tool support in the VM. Update some type names (i.e. _t) and alter API signatures to be more consistent.

arr committed 10 years ago

Commit e5d3f861 parent bcb413516 files · +514 −45Browse files

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

Unified · Split

src/vm/vm.cpp+17−2
@@ -19,7 +19,7 @@ · 18 unmodified lines
19using namespace disvm;19using namespace disvm;
20using namespace disvm::runtime;20using namespace disvm::runtime;
21 21
22vm_t::loaded_module_t::loaded_module_t(std::unique_ptr<runtime::vm_string_t> origin, std::shared_ptr<const runtime::vm_module_t> module)22vm_t::loaded_module_t::loaded_module_t(std::unique_ptr<runtime::vm_string_t> origin, std::shared_ptr<runtime::vm_module_t> module)
23 : origin{ std::move(origin) }23 : origin{ std::move(origin) }
24 , module{ module }24 , module{ module }
25{25{
@@ -126,7 +126,7 @@ const runtime::vm_thread_t& vm_t::fork( · 100 unmodified lines
126 if (initial_pc < 0 || static_cast<vm_pc_t>(module_ref.code_section.size()) <= initial_pc)126 if (initial_pc < 0 || static_cast<vm_pc_t>(module_ref.code_section.size()) <= initial_pc)
127 throw vm_system_exception{ "Invalid entry program counter" };127 throw vm_system_exception{ "Invalid entry program counter" };
128 128
129 auto thread = std::make_unique<vm_thread_t>(module_ref, initial_frame, initial_pc, parent.get_thread_id());129 auto thread = std::make_unique<vm_thread_t>(module_ref, parent.get_thread_id(), initial_frame, initial_pc);
130 return _scheduler->schedule_thread(std::move(thread));130 return _scheduler->schedule_thread(std::move(thread));
131}131}
132 132
@@ -179,6 +179,21 @@ std::shared_ptr<const runtime::vm_module_t> vm_t::load_module(const char *path) · 46 unmodified lines
179 return new_module;179 return new_module;
180}180}
181 181
182std::vector<std::shared_ptr<const runtime::vm_module_t>> vm_t::get_loaded_modules() const
183{
184 auto result = std::vector<std::shared_ptr<const runtime::vm_module_t>>{};
185
186 std::lock_guard<std::mutex> lock{ _modules_lock };
187 for (auto &m : _modules)
188 {
189 auto loaded_module_maybe = m.module.lock();
190 if (loaded_module_maybe != nullptr)
191 result.push_back(loaded_module_maybe);
192 }
193
194 return result;
195}
196
182runtime::vm_scheduler_control_t &vm_t::get_scheduler_control() const197runtime::vm_scheduler_control_t &vm_t::get_scheduler_control() const
183{198{
184 return _scheduler->get_controller();199 return _scheduler->get_controller();