about summary refs log tree commit diff stats
path: root/034address.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-02-25 00:17:46 -0800
committerKartik Agaram <vc@akkartik.com>2019-02-25 01:50:53 -0800
commitc442a5ad806b6cccbb3ec4c5744b14b0c1f31a01 (patch)
tree318fb1d56e7ee3c750635d3326ad0739dfdacefe /034address.cc
parente5998f74ac29bb4bf2aedfdd6fbea801ffdb08f6 (diff)
downloadmu-c442a5ad806b6cccbb3ec4c5744b14b0c1f31a01.tar.gz
4987 - support `browse_trace` tool in SubX
I've extracted it into a separate binary, independent of my Mu prototype.

I also cleaned up my tracing layer to be a little nicer. Major improvements:

- Realized that incremental tracing really ought to be the default.
  And to minimize printing traces to screen.

- Finally figured out how to combine layers and call stack frames in a
  single dimension of depth. The answer: optimize for the experience of
  `browse_trace`. Instructions occupy a range of depths based on their call
  stack frame, and minor details of an instruction lie one level deeper
  in each case.

Other than that, I spent some time adjusting levels everywhere to make
`browse_trace` useful.
Diffstat (limited to '034address.cc')
-rw-r--r--034address.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/034address.cc b/034address.cc
index a71f5194..af98fc14 100644
--- a/034address.cc
+++ b/034address.cc
@@ -215,7 +215,7 @@ Transform.push_back(transform_new_to_allocate);  // idempotent
 
 :(code)
 void transform_new_to_allocate(const recipe_ordinal r) {
-  trace(9991, "transform") << "--- convert 'new' to 'allocate' for recipe " << get(Recipe, r).name << end();
+  trace(101, "transform") << "--- convert 'new' to 'allocate' for recipe " << get(Recipe, r).name << end();
   for (int i = 0;  i < SIZE(get(Recipe, r).steps);  ++i) {
     instruction& inst = get(Recipe, r).steps.at(i);
     // Convert 'new' To 'allocate'
@@ -224,7 +224,7 @@ void transform_new_to_allocate(const recipe_ordinal r) {
       inst.operation = ALLOCATE;
       type_tree* type = new_type_tree(inst.ingredients.at(0).name);
       inst.ingredients.at(0).set_value(size_of(type));
-      trace(9992, "new") << "size of '" << inst.ingredients.at(0).name << "' is " << inst.ingredients.at(0).value << end();
+      trace(102, "new") << "size of '" << inst.ingredients.at(0).name << "' is " << inst.ingredients.at(0).value << end();
       delete type;
     }
   }
@@ -245,7 +245,7 @@ int alloc, alloc_max;
 alloc = Memory_allocated_until;
 Memory_allocated_until += Initial_memory_per_routine;
 alloc_max = Memory_allocated_until;
-trace("new") << "routine allocated memory from " << alloc << " to " << alloc_max << end();
+trace(Callstack_depth+1, "new") << "routine allocated memory from " << alloc << " to " << alloc_max << end();
 
 :(before "End Primitive Recipe Declarations")
 ALLOCATE,
@@ -259,16 +259,16 @@ case ALLOCATE: {
   Next_alloc_id++;
   if (SIZE(ingredients) > 1) {
     // array allocation
-    trace("mem") << "array length is " << ingredients.at(1).at(0) << end();
+    trace(Callstack_depth+1, "mem") << "array length is " << ingredients.at(1).at(0) << end();
     size = /*space for length*/1 + size*ingredients.at(1).at(0);
   }
   int result = allocate(size);
   // initialize alloc-id in payload
-  trace("mem") << "storing alloc-id " << alloc_id << " in location " << result << end();
+  trace(Callstack_depth+1, "mem") << "storing alloc-id " << alloc_id << " in location " << result << end();
   put(Memory, result, alloc_id);
   if (SIZE(current_instruction().ingredients) > 1) {
     // initialize array length
-    trace("mem") << "storing array length " << ingredients.at(1).at(0) << " in location " << result+/*skip alloc id*/1 << end();
+    trace(Callstack_depth+1, "mem") << "storing array length " << ingredients.at(1).at(0) << " in location " << result+/*skip alloc id*/1 << end();
     put(Memory, result+/*skip alloc id*/1, ingredients.at(1).at(0));
   }
   products.resize(1);
@@ -280,7 +280,7 @@ case ALLOCATE: {
 int allocate(int size) {
   // include space for alloc id
   ++size;
-  trace("mem") << "allocating size " << size << end();
+  trace(Callstack_depth+1, "mem") << "allocating size " << size << end();
 //?   Total_alloc += size;
 //?   ++Num_alloc;
   // Allocate Special-cases
@@ -288,10 +288,10 @@ int allocate(int size) {
   // really crappy at the moment
   ensure_space(size);
   const int result = Current_routine->alloc;
-  trace("mem") << "new alloc: " << result << end();
+  trace(Callstack_depth+1, "mem") << "new alloc: " << result << end();
   // initialize allocated space
   for (int address = result;  address < result+size;  ++address) {
-    trace("mem") << "storing 0 in location " << address << end();
+    trace(Callstack_depth+1, "mem") << "storing 0 in location " << address << end();
     put(Memory, address, 0);
   }
   Current_routine->alloc += size;
@@ -325,7 +325,7 @@ void ensure_space(int size) {
     Current_routine->alloc = Memory_allocated_until;
     Memory_allocated_until += Initial_memory_per_routine;
     Current_routine->alloc_max = Memory_allocated_until;
-    trace("new") << "routine allocated memory from " << Current_routine->alloc << " to " << Current_routine->alloc_max << end();
+    trace(Callstack_depth+1, "new") << "routine allocated memory from " << Current_routine->alloc << " to " << Current_routine->alloc_max << end();
   }
 }