History

Create specific exception when index is out of range. Update thread class to print out exception details. Throw exception when an invalid op-code is detected. Enforce mspawn instruction cannot start from a built-in module.

arr committed 10 years ago

Commit 266fad61 parent 9af409310 files · +63 −40Browse files

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

Unified · Split

src/vm/execution_table.cpp+6−2
@@ -846,7 +846,7 @@ namespace · 845 unmodified lines
846 846
847 auto index = vt_ref<word_t>(r.dest);847 auto index = vt_ref<word_t>(r.dest);
848 if (index < 0 || arr->get_length() <= index)848 if (index < 0 || arr->get_length() <= index)
849 throw out_of_range_memory{ 0, arr->get_length(), index };849 throw index_out_of_range_memory{ 0, arr->get_length(), index };
850 850
851 // Return the address, not the value851 // Return the address, not the value
852 pt_ref(r.mid) = arr->at(index);852 pt_ref(r.mid) = arr->at(index);
@@ -1577,6 +1577,10 @@ namespace · 724 unmodified lines
1577 1577
1578 const auto &function_ref = target_module_ref->get_function_ref(import_function_id);1578 const auto &function_ref = target_module_ref->get_function_ref(import_function_id);
1579 1579
1580 // Spawning a built-in module is not permitted
1581 if (target_module_ref->is_builtin_module())
1582 throw vm_user_exception{ "Spawning a built-in module is not permitted" };
1583
1580 vm.fork(r.thread, *target_module_ref, *spawned_frame, function_ref.entry_pc);1584 vm.fork(r.thread, *target_module_ref, *spawned_frame, function_ref.entry_pc);
1581 1585
1582 // After the new thread is forked pop off the argument passing frame.1586 // After the new thread is forked pop off the argument passing frame.
@@ -1685,7 +1689,7 @@ namespace · 102 unmodified lines
1685 auto imported_module = std::shared_ptr<const vm_module_t>{};1689 auto imported_module = std::shared_ptr<const vm_module_t>{};
1686 1690
1687 // Handle self loading module optimization.1691 // Handle self loading module optimization.
1688 if (::strcmp(str->str(), "$self") == 0)1692 if (std::strcmp(str->str(), "$self") == 0)
1689 {1693 {
1690 imported_module = r.module_ref->module;1694 imported_module = r.module_ref->module;
1691 }1695 }