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
846846
847847 auto index = vt_ref<word_t>(r.dest);
848848 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 };
850850
851851 // Return the address, not the value
852852 pt_ref(r.mid) = arr->at(index);
@@ -1577,6 +1577,10 @@ namespace · 724 unmodified lines
15771577
15781578 const auto &function_ref = target_module_ref->get_function_ref(import_function_id);
15791579
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+
15801584 vm.fork(r.thread, *target_module_ref, *spawned_frame, function_ref.entry_pc);
15811585
15821586 // After the new thread is forked pop off the argument passing frame.
@@ -1685,7 +1689,7 @@ namespace · 102 unmodified lines
16851689 auto imported_module = std::shared_ptr<const vm_module_t>{};
16861690
16871691 // Handle self loading module optimization.
1688− if (::strcmp(str->str(), "$self") == 0)
1692+ if (std::strcmp(str->str(), "$self") == 0)
16891693 {
16901694 imported_module = r.module_ref->module;
16911695 }