about summary refs log tree commit diff stats
path: root/024jump.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-05-28 14:28:07 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-05-28 23:00:47 -0700
commit5987486862b8c989452bc62d359168a5686b462e (patch)
tree4b8aa541eb7bbf614619d49723ddea6198163689 /024jump.cc
parentec7c8c8b7434f498098c6b3417bb9c47d5b12881 (diff)
downloadmu-5987486862b8c989452bc62d359168a5686b462e.tar.gz
3887 - clean up early exits in interpreter loop
It's always confusing when `break` refers to a `switch` but `continue`
refers to the loop around the `switch`. But we've done ugly things like
this and `goto` for expedience. However, we're starting to run into cases
where we now need to insert code at every `continue` or `continue`-mimicking
`goto` inside the core interpreter loop. Better to make the loop single-entry-single-exit.
Common things to run after every instruction will now happen inside the
`finish_instruction` function rather than at the `finish_instruction` label.
Diffstat (limited to '024jump.cc')
-rw-r--r--024jump.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/024jump.cc b/024jump.cc
index 5e345eca..748b2405 100644
--- a/024jump.cc
+++ b/024jump.cc
@@ -30,7 +30,10 @@ case JUMP: {
   assert(current_instruction().ingredients.at(0).initialized);
   current_step_index() += ingredients.at(0).at(0)+1;
   trace(9998, "run") << "jumping to instruction " << current_step_index() << end();
-  continue;  // skip rest of this instruction
+  // skip rest of this instruction
+  write_products = false;
+  fall_through_to_next_instruction = false;
+  break;
 }
 
 //: special type to designate jump targets
@@ -78,7 +81,10 @@ case JUMP_IF: {
   }
   current_step_index() += ingredients.at(1).at(0)+1;
   trace(9998, "run") << "jumping to instruction " << current_step_index() << end();
-  continue;  // skip rest of this instruction
+  // skip rest of this instruction
+  write_products = false;
+  fall_through_to_next_instruction = false;
+  break;
 }
 
 :(scenario jump_if)
@@ -131,7 +137,10 @@ case JUMP_UNLESS: {
   }
   current_step_index() += ingredients.at(1).at(0)+1;
   trace(9998, "run") << "jumping to instruction " << current_step_index() << end();
-  continue;  // skip rest of this instruction
+  // skip rest of this instruction
+  write_products = false;
+  fall_through_to_next_instruction = false;
+  break;
 }
 
 :(scenario jump_unless)