History

Propagate the nil pointer when computing a double indirect address.

arr committed 9 years ago

Commit 2a79c031 parent 1f4bace1 file · +16 −4Browse files

Showing the changes to src (1 of 1 file). Show all

Unified · Split

src/vm/address_decoding.inc+16−4
@@ -32,7 +32,10 @@ void dec_src<address_mode_t::offset_double_indirect_fp>(const vm_exec_op_t &inst · 31 unmodified lines
3232 {
3333 assert(inst.source.mode == address_mode_t::offset_double_indirect_fp);
3434 const auto frame_offset = *reinterpret_cast<std::size_t *>(reinterpret_cast<uint8_t *>(reg.stack.peek_frame()->base()) + inst.source.register1);
35− reg.src = reinterpret_cast<pointer_t>(frame_offset + inst.source.register2);
35+ if (frame_offset != disvm::runtime::runtime_constants::nil)
36+ reg.src = reinterpret_cast<pointer_t>(frame_offset + inst.source.register2);
37+ else
38+ reg.src = reinterpret_cast<pointer_t>(disvm::runtime::runtime_constants::nil);
3639 }
3740
3841 template<>
@@ -40,7 +43,10 @@ void dec_src<address_mode_t::offset_double_indirect_mp>(const vm_exec_op_t &inst · 1 unmodified line
4043 {
4144 assert(inst.source.mode == address_mode_t::offset_double_indirect_mp);
4245 const auto mp_offset = *reinterpret_cast<std::size_t *>(reinterpret_cast<uint8_t *>(reg.mp_base->get_allocation()) + inst.source.register1);
43− reg.src = reinterpret_cast<pointer_t>(mp_offset + inst.source.register2);
46+ if (mp_offset != disvm::runtime::runtime_constants::nil)
47+ reg.src = reinterpret_cast<pointer_t>(mp_offset + inst.source.register2);
48+ else
49+ reg.src = reinterpret_cast<pointer_t>(disvm::runtime::runtime_constants::nil);
4450 }
4551
4652 template<>
@@ -85,7 +91,10 @@ void dec_dest<address_mode_t::offset_double_indirect_fp>(const vm_exec_op_t &ins · 38 unmodified lines
8591 {
8692 assert(inst.destination.mode == address_mode_t::offset_double_indirect_fp);
8793 const auto frame_offset = *reinterpret_cast<std::size_t *>(reinterpret_cast<uint8_t *>(reg.stack.peek_frame()->base()) + inst.destination.register1);
88− reg.dest = reinterpret_cast<pointer_t>(frame_offset + inst.destination.register2);
94+ if (frame_offset != disvm::runtime::runtime_constants::nil)
95+ reg.dest = reinterpret_cast<pointer_t>(frame_offset + inst.destination.register2);
96+ else
97+ reg.dest = reinterpret_cast<pointer_t>(disvm::runtime::runtime_constants::nil);
8998 }
9099
91100 template<>
@@ -93,7 +102,10 @@ void dec_dest<address_mode_t::offset_double_indirect_mp>(const vm_exec_op_t &ins · 1 unmodified line
93102 {
94103 assert(inst.destination.mode == address_mode_t::offset_double_indirect_mp);
95104 const auto mp_offset = *reinterpret_cast<std::size_t *>(reinterpret_cast<uint8_t *>(reg.mp_base->get_allocation()) + inst.destination.register1);
96− reg.dest = reinterpret_cast<pointer_t>(mp_offset + inst.destination.register2);
105+ if (mp_offset != disvm::runtime::runtime_constants::nil)
106+ reg.dest = reinterpret_cast<pointer_t>(mp_offset + inst.destination.register2);
107+ else
108+ reg.dest = reinterpret_cast<pointer_t>(disvm::runtime::runtime_constants::nil);
97109 }
98110
99111 template<>