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/exec/main.cpp (1 of 10 files). Show all

Unified · Split

src/exec/main.cpp+9−5
@@ -93,13 +93,17 @@ namespace · 92 unmodified lines
9393 if (args != nullptr)
9494 mp_base[2] = args->get_allocation();
9595
96+ // Define the frame offsets for the two arguments
97+ const auto first_arg_offset = vm_frame_constants::limbo_first_arg_register_offset;
98+ const auto second_arg_offset = first_arg_offset + vm_frame_constants::register_size_in_bytes;
99+
96100 e.code_section =
97101 {
98102 { vm_exec_op_t
99103 {
100104 opcode_t::load,
101105 { address_mode_t::offset_indirect_mp, 0, 0 }, // command module path
102− { address_mode_middle_t::small_immediate, 0 },
106+ { address_mode_middle_t::small_immediate, 0 }, // import table index
103107 { address_mode_t::offset_indirect_fp, 20, 0 } // module reference
104108 }
105109 },
@@ -107,7 +111,7 @@ namespace · 1 unmodified line
107111 {
108112 opcode_t::mframe,
109113 { address_mode_t::offset_indirect_fp, 20, 0 }, // module reference
110− { address_mode_middle_t::small_immediate, 0 },
114+ { address_mode_middle_t::small_immediate, 0 }, // function index into module
111115 { address_mode_t::offset_indirect_fp, 24, 0 } // module call frame
112116 }
113117 },
@@ -116,7 +120,7 @@ namespace · 2 unmodified lines
116120 opcode_t::movp,
117121 { address_mode_t::offset_indirect_mp, 4, 0 }, // UI context
118122 { address_mode_middle_t::none },
119− { address_mode_t::offset_double_indirect_fp, 24, 32 } // module call frame -> UI context offset
123+ { address_mode_t::offset_double_indirect_fp, 24, first_arg_offset } // module call frame -> UI context offset
120124 }
121125 },
122126 { vm_exec_op_t
@@ -124,14 +128,14 @@ namespace · 1 unmodified line
124128 opcode_t::movp,
125129 { address_mode_t::offset_indirect_mp, 8, 0 }, // Argument list
126130 { address_mode_middle_t::none },
127− { address_mode_t::offset_double_indirect_fp, 24, 36 } // module call frame -> argument list offset
131+ { address_mode_t::offset_double_indirect_fp, 24, second_arg_offset } // module call frame -> argument list offset
128132 }
129133 },
130134 { vm_exec_op_t
131135 {
132136 opcode_t::mcall,
133137 { address_mode_t::offset_indirect_fp, 24, 0 }, // module call frame
134− { address_mode_middle_t::small_immediate, 0 },
138+ { address_mode_middle_t::small_immediate, 0 }, // function index into module
135139 { address_mode_t::offset_indirect_fp, 20, 0 } // module reference
136140 }
137141 },