about summary refs log tree commit diff stats
path: root/032array.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 /032array.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 '032array.cc')
-rw-r--r--032array.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/032array.cc b/032array.cc
index 778daa97..3b521263 100644
--- a/032array.cc
+++ b/032array.cc
@@ -66,7 +66,8 @@ case CREATE_ARRAY: {
     put(Memory, base_address+i, 0);
   }
   // no need to update product
-  goto finish_instruction;
+  write_products = false;
+  break;
 }
 
 :(scenario copy_array)
@@ -557,13 +558,14 @@ case PUT_INDEX: {
   trace(9998, "run") << "address to copy to is " << address << end();
   // optimization: directly write the element rather than updating 'product'
   // and writing the entire array
+  write_products = false;
   vector<double> value = read_memory(current_instruction().ingredients.at(2));
   // Write Memory in PUT_INDEX in Run
   for (int i = 0;  i < SIZE(value);  ++i) {
     trace(9999, "mem") << "storing " << no_scientific(value.at(i)) << " in location " << address+i << end();
     put(Memory, address+i, value.at(i));
   }
-  goto finish_instruction;
+  break;
 }
 
 :(scenario put_index_out_of_bounds)