Showing the changes to src/vm/vm.cpp (1 of 16 files). Show all
Unified · Split
| @@ -19,7 +19,7 @@ · 18 unmodified lines | ||
| 19 | 19 | using namespace disvm; |
| 20 | 20 | using namespace disvm::runtime; |
| 21 | 21 | |
| 22 | −vm_t::loaded_module_t::loaded_module_t(std::unique_ptr<runtime::vm_string_t> origin, std::shared_ptr<const runtime::vm_module_t> module) | |
| 22 | +vm_t::loaded_module_t::loaded_module_t(std::unique_ptr<runtime::vm_string_t> origin, std::shared_ptr<runtime::vm_module_t> module) | |
| 23 | 23 | : origin{ std::move(origin) } |
| 24 | 24 | , module{ module } |
| 25 | 25 | { |
| @@ -126,7 +126,7 @@ const runtime::vm_thread_t& vm_t::fork( · 100 unmodified lines | ||
| 126 | 126 | if (initial_pc < 0 || static_cast<vm_pc_t>(module_ref.code_section.size()) <= initial_pc) |
| 127 | 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 | 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 | 179 | return new_module; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | +std::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 | + | |
| 182 | 197 | runtime::vm_scheduler_control_t &vm_t::get_scheduler_control() const |
| 183 | 198 | { |
| 184 | 199 | return _scheduler->get_controller(); |