Transitioned all VM messages from outputting to STDOUT to STDERR, to avoid interferin...
authorBrian T. Rice <briantrice@gmail.com>
Tue, 9 Mar 2010 01:47:38 +0000 (17:47 -0800)
committerBrian T. Rice <briantrice@gmail.com>
Tue, 9 Mar 2010 01:47:38 +0000 (17:47 -0800)
src/vm/debug.cpp
src/vm/gc.cpp
src/vm/interpreter.cpp
src/vm/method.cpp
src/vm/object.cpp
src/vm/optimizer.cpp
src/vm/primitives.cpp
src/vm/profiler.cpp
src/vm/vm.cpp

index c6a444d..ad120e7 100644 (file)
@@ -6,11 +6,11 @@
 
 void print_object(struct Object* oop) {
   if (oop == NULL) {
-    printf("<object NULL>\n");
+    fprintf(stderr, "<object NULL>\n");
     return;
   }
   if (oop_is_smallint((word_t)oop)) {
-    printf("<object int_value: %" PRIdPTR ">\n", object_to_smallint(oop));
+    fprintf(stderr, "<object int_value: %" PRIdPTR ">\n", object_to_smallint(oop));
   } else {
     const char* typestr=0;
     switch (object_type(oop)) {
@@ -18,7 +18,7 @@ void print_object(struct Object* oop) {
     case TYPE_OOP_ARRAY: typestr = "oop array"; break;
     case TYPE_BYTE_ARRAY: typestr = "byte array"; break;
     }
-    printf("<object at %p, hash: 0x%" PRIxPTR ", size: %" PRIdPTR ", payload size: %" PRIdPTR ", type: %s>\n", (void*)oop, object_hash(oop), object_size(oop), payload_size(oop), typestr);
+    fprintf(stderr, "<object at %p, hash: 0x%" PRIxPTR ", size: %" PRIdPTR ", payload size: %" PRIdPTR ", type: %s>\n", (void*)oop, object_hash(oop), object_size(oop), payload_size(oop), typestr);
   }
 
 }
@@ -30,25 +30,25 @@ void print_symbol(struct Symbol* name) {
   }
 }
 
-void indent(word_t amount) { word_t i; for (i=0; i<amount; i++) printf("    "); }
+void indent(word_t amount) { word_t i; for (i=0; i<amount; i++) fprintf(stderr, "    "); }
 
 
 void print_byte_array(struct Object* o) {
   word_t i;
   char* elements = (char*)inc_ptr(o, object_array_offset(o));
-  printf("'");
+  fprintf(stderr, "'");
   for (i=0; i < payload_size(o); i++) {
     if (elements[i] >= 32 && elements[i] <= 126) {
-      printf("%c", elements[i]);
+      fprintf(stderr, "%c", elements[i]);
     } else {
-      printf("\\x%02" PRIxPTR "", (word_t)elements[i]);
+      fprintf(stderr, "\\x%02" PRIxPTR "", (word_t)elements[i]);
     }
     if (i > 10 && payload_size(o) - i > 100) {
       i = payload_size(o) - 20;
-      printf("{..snip..}");
+      fprintf(stderr, "{..snip..}");
     }
   }
-  printf("'");
+  fprintf(stderr, "'");
 
 }
 
@@ -60,41 +60,41 @@ void print_object_with_depth(struct object_heap* oh, struct Object* o, word_t de
   word_t i;
 
   if (depth >= max_depth || object_is_smallint(o)) {
-    printf("(depth limit reached) "); print_object(o);
+    fprintf(stderr, "(depth limit reached) "); print_object(o);
     return;
   }
 
   if (o == oh->cached.nil) {
-    printf("<object NilObject>\n");
+    fprintf(stderr, "<object NilObject>\n");
     return;
   }
 
   map = o->map;
   print_object(o);
   if (object_hash(o) >= ID_HASH_RESERVED) {
-    indent(depth); printf("<object is free/reserved>\n");
+    indent(depth); fprintf(stderr, "<object is free/reserved>\n");
     return;
   }
 
-  indent(depth); printf("{\n");
+  indent(depth); fprintf(stderr, "{\n");
 
   if (object_type(o) == TYPE_BYTE_ARRAY) {
-    indent(depth); printf("bytes: ");
-    print_byte_array(o); printf("\n");
+    indent(depth); fprintf(stderr, "bytes: ");
+    print_byte_array(o); fprintf(stderr, "\n");
   }
   if (object_type(o) == TYPE_OOP_ARRAY) {
     struct OopArray* array = (struct OopArray*)o;
-    indent(depth); printf("size(array) = %" PRIdPTR "\n", object_array_size(o));
+    indent(depth); fprintf(stderr, "size(array) = %" PRIdPTR "\n", object_array_size(o));
     for (i=0; i < object_array_size(o); i++) {
-      indent(depth); printf("array[%" PRIdPTR "]: ", i); print_object_with_depth(oh, array->elements[i], depth+1, max_depth);
+      indent(depth); fprintf(stderr, "array[%" PRIdPTR "]: ", i); print_object_with_depth(oh, array->elements[i], depth+1, max_depth);
       if (object_array_size(o) - i > 10) {
-        indent(depth); printf("...\n");
+        indent(depth); fprintf(stderr, "...\n");
         i = object_array_size(o) - 2;
       }
     }
   }
   indent(depth);
-  printf("map flags: %" PRIdPTR " (%s)\n", 
+  fprintf(stderr, "map flags: %" PRIdPTR " (%s)\n", 
          object_to_smallint(map->flags),
          ((((word_t)map->flags & MAP_FLAG_RESTRICT_DELEGATION)==0)? "delegation not restricted":"delegation restricted"));
 
@@ -106,7 +106,7 @@ void print_object_with_depth(struct object_heap* oh, struct Object* o, word_t de
     word_t limit = object_total_size((struct Object*)delegates);
     for (i = 0; offset != limit; offset += sizeof(word_t), i++) {
       struct Object* delegate = object_slot_value_at_offset((struct Object*)delegates, offset);
-      indent(depth); printf("delegate[%" PRIdPTR "] = ", i);
+      indent(depth); fprintf(stderr, "delegate[%" PRIdPTR "] = ", i);
       print_object_with_depth(oh, delegate, 
                               (((word_t)map->flags & MAP_FLAG_RESTRICT_DELEGATION) == 0)?  depth+1 : max(max_depth-1, depth+1), max_depth);
     }
@@ -115,40 +115,40 @@ void print_object_with_depth(struct object_heap* oh, struct Object* o, word_t de
   {/*if?*/
     struct SlotTable* slotTable = map->slotTable;
     word_t limit = slot_table_capacity(map->slotTable);
-    indent(depth); printf("slot count: %" PRIdPTR "\n", object_to_smallint(map->slotCount));
+    indent(depth); fprintf(stderr, "slot count: %" PRIdPTR "\n", object_to_smallint(map->slotCount));
     for (i=0; i < limit; i++) {
       if (slotTable->slots[i].name == (struct Symbol*)oh->cached.nil) continue;
       indent(depth);
-      printf("slot[%" PRIdPTR "]['", i); print_symbol(slotTable->slots[i].name); printf("'] = ");
+      fprintf(stderr, "slot[%" PRIdPTR "]['", i); print_symbol(slotTable->slots[i].name); fprintf(stderr, "'] = ");
       {
         struct Object* obj = object_slot_value_at_offset(o, object_to_smallint(slotTable->slots[i].offset));
         if (object_is_smallint(obj) || object_type(obj) != TYPE_BYTE_ARRAY) {
           print_object(obj);
         } else {
-          print_byte_array(obj); printf("\n");
+          print_byte_array(obj); fprintf(stderr, "\n");
         }
       }
     }
   }
 
 
-  /*indent(depth); printf("map = "); print_object_with_depth(oh, (struct Object*)map, depth+1, max_depth);*/
+  /*indent(depth); fprintf(stderr, "map = "); print_object_with_depth(oh, (struct Object*)map, depth+1, max_depth);*/
     
   /*roles */
   {
     struct RoleTable* roleTable = map->roleTable;
     word_t limit = role_table_capacity(roleTable);
-    indent(depth); printf("role table capacity: %" PRIdPTR "\n", limit);
+    indent(depth); fprintf(stderr, "role table capacity: %" PRIdPTR "\n", limit);
     for (i = 0; i < limit; i++) {
       if (roleTable->roles[i].name == (struct Symbol*)oh->cached.nil) {continue;}
       else {
-        indent(depth); printf("role[%" PRIdPTR "]['", i); print_symbol(roleTable->roles[i].name);
-        printf("'] @ 0x%04" PRIxPTR "\n", object_to_smallint(roleTable->roles[i].rolePositions));
+        indent(depth); fprintf(stderr, "role[%" PRIdPTR "]['", i); print_symbol(roleTable->roles[i].name);
+        fprintf(stderr, "'] @ 0x%04" PRIxPTR "\n", object_to_smallint(roleTable->roles[i].rolePositions));
 #if 0
         print_object_with_depth(oh, (struct Object*)roleTable->roles[i].methodDefinition, max_depth, max_depth);
 #endif
         if (limit - i > 50 && depth >= 2) {
-          indent(depth); printf("...\n");
+          indent(depth); fprintf(stderr, "...\n");
           i = limit - 3;
         }
       }
@@ -158,7 +158,7 @@ void print_object_with_depth(struct object_heap* oh, struct Object* o, word_t de
   }
 
 
-  indent(depth); printf("}\n");
+  indent(depth); fprintf(stderr, "}\n");
 
 }
 
@@ -192,14 +192,14 @@ void print_type(struct object_heap* oh, struct Object* o) {
   struct Object* traitsWindow;
   struct OopArray* x;
   if (object_is_smallint(o)) {
-    printf("<smallint value: %" PRIdPTR " (0x%" PRIuPTR "x)>\n", object_to_smallint(o), object_to_smallint(o));
+    fprintf(stderr, "<smallint value: %" PRIdPTR " (0x%" PRIuPTR "x)>\n", object_to_smallint(o), object_to_smallint(o));
     return;
   }
 
   if (object_type(o) == TYPE_BYTE_ARRAY) {
-    printf("(");
+    fprintf(stderr, "(");
     print_byte_array(o);
-    printf(") ");
+    fprintf(stderr, ") ");
     /*return;*/
   }
   
@@ -210,9 +210,9 @@ void print_type(struct object_heap* oh, struct Object* o) {
 
   {
     if (traitsWindow == oh->cached.compiled_method_window) {
-      printf("(method: ");
+      fprintf(stderr, "(method: ");
       print_byte_array((struct Object*)(((struct CompiledMethod*)o)->method->selector));
-      printf(")");
+      fprintf(stderr, ")");
     }
   }
 
@@ -226,14 +226,14 @@ void print_type(struct object_heap* oh, struct Object* o) {
 
   print_printname(oh, o);
   
-  printf("(");
+  fprintf(stderr, "(");
   print_printname(oh, traits);
-  printf(")\n");
+  fprintf(stderr, ")\n");
 
 
   return;
  fail:
-  printf("<unknown type>\n");
+  fprintf(stderr, "<unknown type>\n");
 }
 
 
@@ -242,7 +242,7 @@ void print_stack(struct object_heap* oh) {
   word_t size = i->stackPointer;
   word_t j;
   for (j=0; j < size; j++) {
-    printf("stack[%" PRIdPTR "] = ", j);
+    fprintf(stderr, "stack[%" PRIdPTR "] = ", j);
     print_detail(oh, i->stack->elements[j]);
   }
 }
@@ -253,7 +253,7 @@ void print_stack_types(struct object_heap* oh, word_t last_count) {
   word_t j;
   for (j=0; j < size; j++) {
     if (size - j > last_count) continue;
-    printf("stack[%" PRIdPTR "] = ", j);
+    fprintf(stderr, "stack[%" PRIdPTR "] = ", j);
     print_type(oh, i->stack->elements[j]);
   }
 }
@@ -269,25 +269,25 @@ void print_backtrace(struct object_heap* oh) {
   word_t codeSize = i->codeSize;
   word_t resultStackPointer = object_to_smallint(i->stack->elements[fp - FRAME_OFFSET_RESULT_STACK_POINTER]);
   struct LexicalContext* lc = (struct LexicalContext*)i->stack->elements[fp - FRAME_OFFSET_LEXICAL_CONTEXT];;
-  printf("printing backtrace from fp=%" PRIdPTR ", sp=%" PRIdPTR "\n", fp, i->stackPointer);
+  fprintf(stderr, "printing backtrace from fp=%" PRIdPTR ", sp=%" PRIdPTR "\n", fp, i->stackPointer);
   do {
     word_t j;
     struct Object** vars;
     word_t input_count = object_to_smallint(closure->method->inputVariables);
     word_t local_count = object_to_smallint(closure->method->localVariables);
     vars = (closure->method->heapAllocate == oh->cached.true_object)? (&lc->variables[0]) : (&i->stack->elements[fp]);
-    printf("------------------------------\n");
-    printf("fp: %" PRIdPTR "\n", fp);
-    printf("sp: %" PRIdPTR "\n", sp);
-    printf("ip: %" PRIdPTR "/%" PRIdPTR "\n", codePointer, codeSize);
-    printf("result: %" PRIdPTR "\n", resultStackPointer);
-    printf("code: %p\n", closure->method->code);
-    printf("selector: "); print_byte_array((struct Object*)(closure->method->selector)); printf("\n");
-    printf("regs: %" PRIdPTR "\n", object_to_smallint(closure->method->registerCount));
-    printf("heap alloc: %s\n", (closure->method->heapAllocate == oh->cached.true_object)? "true" : "false");
+    fprintf(stderr, "------------------------------\n");
+    fprintf(stderr, "fp: %" PRIdPTR "\n", fp);
+    fprintf(stderr, "sp: %" PRIdPTR "\n", sp);
+    fprintf(stderr, "ip: %" PRIdPTR "/%" PRIdPTR "\n", codePointer, codeSize);
+    fprintf(stderr, "result: %" PRIdPTR "\n", resultStackPointer);
+    fprintf(stderr, "code: %p\n", closure->method->code);
+    fprintf(stderr, "selector: "); print_byte_array((struct Object*)(closure->method->selector)); fprintf(stderr, "\n");
+    fprintf(stderr, "regs: %" PRIdPTR "\n", object_to_smallint(closure->method->registerCount));
+    fprintf(stderr, "heap alloc: %s\n", (closure->method->heapAllocate == oh->cached.true_object)? "true" : "false");
 
     for (j = 0; j < input_count; j++) {
-      printf("arg[%" PRIdPTR "] (%p) = ", j, (void*)vars[j]);
+      fprintf(stderr, "arg[%" PRIdPTR "] (%p) = ", j, (void*)vars[j]);
       if (depth > detail_depth) {
         print_type(oh, vars[j]);
       } else {
@@ -296,7 +296,7 @@ void print_backtrace(struct object_heap* oh) {
     }
     if (closure->method->heapAllocate == oh->cached.true_object) {
       for (j = 0; j < local_count; j++) {
-        printf("var[%" PRIdPTR "] (%p)= ", j, (void*)lc->variables[j]);
+        fprintf(stderr, "var[%" PRIdPTR "] (%p)= ", j, (void*)lc->variables[j]);
         if (depth > detail_depth) {
           print_type(oh, lc->variables[j]);
         } else {
@@ -305,7 +305,7 @@ void print_backtrace(struct object_heap* oh) {
       }
     } else {
       for (j = input_count; j < input_count + local_count; j++) {
-        printf("var[%" PRIdPTR "] (%p) = ", j - input_count, (void*)vars[j]);
+        fprintf(stderr, "var[%" PRIdPTR "] (%p) = ", j - input_count, (void*)vars[j]);
         if (depth > detail_depth) {
           print_type(oh, vars[j]);
         } else {
@@ -332,24 +332,24 @@ void print_backtrace(struct object_heap* oh) {
 void heap_print_objects(struct object_heap* oh, byte_t* memory, word_t memorySize) {
   struct Object* obj = (struct Object*) memory;
   word_t pin_count = 0, used_count = 0, free_count = 0;
-  printf("\nmemory:\n");
+  fprintf(stderr, "\nmemory:\n");
   while (object_in_memory(oh, obj, memory, memorySize)) {
     if (object_is_pinned(oh, obj)) {
-      printf("[pinned ");
+      fprintf(stderr, "[pinned ");
       pin_count++;
     } else if (object_is_free(obj)) {
-      printf("[free ");
+      fprintf(stderr, "[free ");
       free_count++;
     } else {
-      printf("[used ");
+      fprintf(stderr, "[used ");
       used_count++;
     }
-    printf("%" PRIdPTR "]\n", object_total_size(obj));
+    fprintf(stderr, "%" PRIdPTR "]\n", object_total_size(obj));
 
     obj = object_after(oh, obj);
   }
-  printf("\n");
-  printf("free: %" PRIdPTR ", used: %" PRIdPTR ", pinned: %" PRIdPTR "\n", free_count, used_count, pin_count);
+  fprintf(stderr, "\n");
+  fprintf(stderr, "free: %" PRIdPTR ", used: %" PRIdPTR ", pinned: %" PRIdPTR "\n", free_count, used_count, pin_count);
 
 }
 
@@ -387,28 +387,28 @@ void heap_print_marks(struct object_heap* oh, byte_t* memory, word_t memorySize)
   struct Object* obj = (struct Object*) memory;
   word_t count = 80;
   word_t pin_count = 0, used_count = 0, free_count = 0;
-  printf("\nmemory:\n");
+  fprintf(stderr, "\nmemory:\n");
   while (object_in_memory(oh, obj, memory, memorySize)) {
     if (object_is_pinned(oh, obj)) {
-      printf("X");
+      fprintf(stderr, "X");
       pin_count++;
     } else if (object_is_free(obj)) {
-      printf(" ");
+      fprintf(stderr, " ");
       free_count++;
     } else {
-      printf("*");
+      fprintf(stderr, "*");
       used_count++;
     }
     count--;
     if (count == 0) {
       count = 80;
-      printf("\n");
+      fprintf(stderr, "\n");
     }
 
     obj = object_after(oh, obj);
   }
-  printf("\n");
-  printf("free: %" PRIdPTR ", used: %" PRIdPTR ", pinned: %" PRIdPTR "\n", free_count, used_count, pin_count);
+  fprintf(stderr, "\n");
+  fprintf(stderr, "free: %" PRIdPTR ", used: %" PRIdPTR ", pinned: %" PRIdPTR "\n", free_count, used_count, pin_count);
 
 }
 
index 7018c2d..8a66841 100644 (file)
@@ -17,7 +17,7 @@ void assert_good_object(struct object_heap* oh, struct Object* obj) {
 
 void heap_integrity_check(struct object_heap* oh, byte_t* memory, word_t memorySize) {
   struct Object* o = (struct Object*)memory;
-  printf("GC integrity check...\n");
+  fprintf(stderr, "GC integrity check...\n");
 
   while (object_in_memory(oh, o, memory, memorySize)) {
 
@@ -73,7 +73,7 @@ struct Object* heap_make_free_space(struct object_heap* oh, struct Object* obj,
   assert(words > 0);
 
 #ifdef PRINT_DEBUG
-  printf("Making %" PRIdPTR " words of free space at: %p\n", words, (void*)start);
+  fprintf(stderr, "Making %" PRIdPTR " words of free space at: %p\n", words, (void*)start);
 #endif
 
 
@@ -256,7 +256,7 @@ struct Object* gc_allocate(struct object_heap* oh, word_t bytes) {
     } else {
       //heap_print_objects(oh, oh->memoryYoung, oh->memoryYoungSize);
       //print_backtrace(oh);
-      printf("Couldn't allocate %" PRIdPTR " bytes... using oldspace\n", bytes + sizeof(struct Object));
+      fprintf(stderr, "Couldn't allocate %" PRIdPTR " bytes... using oldspace\n", bytes + sizeof(struct Object));
       return gc_allocate_old(oh, bytes);
       //assert(0);
     }
@@ -285,7 +285,7 @@ void object_forward_pointers_to(struct object_heap* oh, struct Object* o, struct
     struct Object* val = object_slot_value_at_offset(o, offset);
     if (val == x) {
 #ifdef PRINT_DEBUG
-      printf("Forwarding pointer in "); print_type(oh, o); printf(" to "); print_type(oh, y);
+      fprintf(stderr, "Forwarding pointer in "); print_type(oh, o); fprintf(stderr, " to "); print_type(oh, y);
 #endif
       object_slot_value_at_offset_put(oh, o, offset, y);
     }
@@ -296,7 +296,7 @@ void object_forward_pointers_to(struct object_heap* oh, struct Object* o, struct
 
 void heap_free_object(struct object_heap* oh, struct Object* obj) {
 #ifdef PRINT_DEBUG_GC_MARKINGS
-  printf("freeing "); print_object(obj);
+  fprintf(stderr, "freeing "); print_object(obj);
 #endif
   //fixme
   //  oh->optimizedMethods.erase((struct CompiledMethod*)obj);
@@ -341,7 +341,7 @@ void heap_start_gc(struct object_heap* oh) {
 void heap_remember_old_object(struct object_heap* oh, struct Object* x) {
   if (object_is_old(oh, x) && !object_is_smallint(x)) {
 #if 0
-    printf("remembering "); print_object(x);
+    fprintf(stderr, "remembering "); print_object(x);
 #endif
     oh->rememberedOldObjects.insert(x);
   }
@@ -358,14 +358,14 @@ void heap_mark(struct object_heap* oh, struct Object* obj) {
 
   if (object_markbit(obj) == oh->mark_color) return;
 #ifdef PRINT_DEBUG_GC_MARKINGS
-  printf("marking "); print_object(obj);
+  fprintf(stderr, "marking "); print_object(obj);
 #endif
   object_set_mark(oh, obj);
   
   if (oh->markStackPosition + 1 >=oh->markStackSize) {
     oh->markStackSize *= 2;
 #ifdef PRINT_DEBUG
-    printf("Growing mark stack to %" PRIdPTR "\n", oh->markStackSize);
+    fprintf(stderr, "Growing mark stack to %" PRIdPTR "\n", oh->markStackSize);
 #endif
     oh->markStack = (struct Object**)realloc(oh->markStack, oh->markStackSize * sizeof(struct Object*));
     assert(oh->markStack);
@@ -451,9 +451,9 @@ void heap_free_and_coalesce_unmarked(struct object_heap* oh, byte_t* memory, wor
 
 #ifdef PRINT_DEBUG_GC_1
   if (!oh->quietGC) {
-    printf("GC freed %" PRIdPTR " of %" PRIdPTR " %s objects\n", 
+    fprintf(stderr, "GC freed %" PRIdPTR " of %" PRIdPTR " %s objects\n", 
            free_count, object_count, ((memory == oh->memoryOld)? "old":"new"));
-    printf("GC coalesced %" PRIdPTR " times\n", coalesce_count);
+    fprintf(stderr, "GC coalesced %" PRIdPTR " times\n", coalesce_count);
   }
 #endif
 }
@@ -463,7 +463,7 @@ void heap_unmark_all(struct object_heap* oh, byte_t* memory, word_t memorySize)
 
   while (object_in_memory(oh, obj, memory, memorySize)) {
 #ifdef PRINT_DEBUG_GC_MARKINGS
-    printf("unmarking "); print_object(obj);
+    fprintf(stderr, "unmarking "); print_object(obj);
 #endif
     object_unmark(oh, obj);
     obj = object_after(oh, obj);
@@ -541,8 +541,8 @@ void heap_tenure(struct object_heap* oh) {
         tenure_count++;
         copy_words_into((word_t*)obj, object_word_size(obj), (word_t*) tenure_start);
 #ifdef PRINT_DEBUG_GC_MARKINGS
-        printf("tenuring from "); print_object(obj);
-        printf("tenuring to "); print_object(tenure_start);
+        fprintf(stderr, "tenuring from "); print_object(obj);
+        fprintf(stderr, "tenuring to "); print_object(tenure_start);
 #endif
         oh->tenuredObjects.push_back(tenure_start);
 
@@ -555,7 +555,7 @@ void heap_tenure(struct object_heap* oh) {
   }
 #ifdef PRINT_DEBUG_GC_1
   if (!oh->quietGC) {
-    printf("Full GC freed %" PRIdPTR " young objects and tenured %" PRIdPTR " of %" PRIdPTR " objects (%" PRIdPTR " pinned)\n", 
+    fprintf(stderr, "Full GC freed %" PRIdPTR " young objects and tenured %" PRIdPTR " of %" PRIdPTR " objects (%" PRIdPTR " pinned)\n", 
            free_count, tenure_count, object_count, pin_count);
   }
 #endif
@@ -643,7 +643,7 @@ void heap_mark_remembered(struct object_heap* oh) {
 
 #ifdef PRINT_DEBUG_GC_3
   if (!oh->quietGC) {
-    printf("Removing %" PRIdPTR " entries from the remembered table\n", badRemembered.size());
+    fprintf(stderr, "Removing %" PRIdPTR " entries from the remembered table\n", badRemembered.size());
   }
 #endif
 
@@ -654,7 +654,7 @@ void heap_mark_remembered(struct object_heap* oh) {
 
 #ifdef PRINT_DEBUG_GC_2
   if (!oh->quietGC) {
-    printf("Young GC found %" PRIdPTR " old objects pointing to %" PRIdPTR " young objects\n", 
+    fprintf(stderr, "Young GC found %" PRIdPTR " old objects pointing to %" PRIdPTR " young objects\n", 
            object_count, remember_count);
   }
 #endif
index ddd2342..a3e1651 100644 (file)
@@ -25,7 +25,7 @@ void interpreter_stack_allocate(struct object_heap* oh, struct Interpreter* i, w
   i->stackPointer += n;
 
 #ifdef PRINT_DEBUG_STACK_PUSH
-  printf("stack allocate, new stack pointer: %" PRIdPTR "\n", i->stackPointer);
+  fprintf(stderr, "stack allocate, new stack pointer: %" PRIdPTR "\n", i->stackPointer);
 #endif
 
 }
@@ -33,7 +33,7 @@ void interpreter_stack_allocate(struct object_heap* oh, struct Interpreter* i, w
 void interpreter_stack_push(struct object_heap* oh, struct Interpreter* i, struct Object* value) {
 
 #ifdef PRINT_DEBUG_STACK_PUSH
-  printf("Stack push at %" PRIdPTR " (fp=%" PRIdPTR "): ", i->stackPointer, i->framePointer); print_type(oh, value);
+  fprintf(stderr, "Stack push at %" PRIdPTR " (fp=%" PRIdPTR "): ", i->stackPointer, i->framePointer); print_type(oh, value);
 #endif
   if (!object_is_smallint(value)) {
     assert(object_hash(value) < ID_HASH_RESERVED); /*catch gc bugs earlier*/
@@ -58,7 +58,7 @@ struct Object* interpreter_stack_pop(struct object_heap* oh, struct Interpreter*
   {
     struct Object* o = i->stack->elements[i->stackPointer];
 #ifdef PRINT_DEBUG_STACK_POINTER
-    printf("popping from stack, new stack pointer: %" PRIdPTR "\n", i->stackPointer);
+    fprintf(stderr, "popping from stack, new stack pointer: %" PRIdPTR "\n", i->stackPointer);
     /*print_detail(oh, o);*/
 #endif
     return o;
@@ -80,12 +80,12 @@ void interpreter_stack_pop_amount(struct object_heap* oh, struct Interpreter* i,
 
 void unhandled_signal(struct object_heap* oh, struct Symbol* selector, word_t n, struct Object* args[]) {
   word_t i;
-  printf("Unhandled signal: "); print_symbol(selector); printf(" with %" PRIdPTR " arguments: \n", n);
+  fprintf(stderr, "Unhandled signal: "); print_symbol(selector); fprintf(stderr, " with %" PRIdPTR " arguments: \n", n);
   for (i = 0; i<n; i++) {
-    printf("arg[%" PRIdPTR "] = ", i);
+    fprintf(stderr, "arg[%" PRIdPTR "] = ", i);
     print_detail(oh, args[i]);
   }
-  printf("partial stack: \n");
+  fprintf(stderr, "partial stack: \n");
   /*print_stack_types(oh, 200);*/
   print_backtrace(oh);
   assert(0);
@@ -177,7 +177,7 @@ void interpreter_apply_to_arity_with_optionals(struct object_heap* oh, struct In
   
 
 #ifdef PRINT_DEBUG
-  printf("apply to arity %" PRIdPTR "\n", n);
+  fprintf(stderr, "apply to arity %" PRIdPTR "\n", n);
 #endif
 
   struct Object* traitsWindow = closure->base.map->delegates->elements[0];
@@ -318,13 +318,13 @@ void send_to_through_arity_with_optionals(struct object_heap* oh,
       if ((struct Object*)def==NULL) {
         addToPic = TRUE;
 #ifdef PRINT_DEBUG_PIC_HITS
-        printf("PIC miss\n");
+        fprintf(stderr, "PIC miss\n");
 #endif
 
       }
       else {
 #ifdef PRINT_DEBUG_PIC_HITS
-        printf("PIC hit\n");
+        fprintf(stderr, "PIC hit\n");
 #endif
       }
     }
@@ -336,7 +336,7 @@ void send_to_through_arity_with_optionals(struct object_heap* oh,
     def = method_dispatch_on(oh, selector, dispatchers, arity, NULL);
   } else {
 #ifdef PRINT_DEBUG_PIC_HITS
-    printf("Using PIC over dispatch\n");
+    fprintf(stderr, "Using PIC over dispatch\n");
 #endif
   }
   if ((struct Object*)def == NULL) {
@@ -371,7 +371,7 @@ void send_to_through_arity_with_optionals(struct object_heap* oh,
   traitsWindow = method->base.map->delegates->elements[0]; /*fix should this location be hardcoded as the first element?*/
   if (traitsWindow == oh->cached.primitive_method_window) {
 #ifdef PRINT_DEBUG
-    printf("calling primitive: %" PRIdPTR "\n", object_to_smallint(((struct PrimitiveMethod*)method)->index));
+    fprintf(stderr, "calling primitive: %" PRIdPTR "\n", object_to_smallint(((struct PrimitiveMethod*)method)->index));
 #endif
     //sometimes primitives call sent_to or apply_to which can screw up the call stack. i won't measure them for now
     
@@ -414,9 +414,9 @@ bool_t interpreter_return_result(struct object_heap* oh, struct Interpreter* i,
   word_t resultStackPointer;
 
 #ifdef PRINT_DEBUG_FUNCALL
-      printf("interpreter_return_result BEFORE\n");
-      printf("stack pointer: %" PRIdPTR "\n", i->stackPointer);
-      printf("frame pointer: %" PRIdPTR "\n", i->framePointer);
+      fprintf(stderr, "interpreter_return_result BEFORE\n");
+      fprintf(stderr, "stack pointer: %" PRIdPTR "\n", i->stackPointer);
+      fprintf(stderr, "frame pointer: %" PRIdPTR "\n", i->framePointer);
       print_stack_types(oh, MAX_ARITY);
 #endif
 
@@ -440,7 +440,7 @@ bool_t interpreter_return_result(struct object_heap* oh, struct Interpreter* i,
    if this is right*/
   if (result != NULL) {
 #ifdef PRINT_DEBUG_STACK
-    printf("setting stack[%" PRIdPTR "] = ", resultStackPointer); print_object(result);
+    fprintf(stderr, "setting stack[%" PRIdPTR "] = ", resultStackPointer); print_object(result);
 #endif
 
     i->stack->elements[resultStackPointer] = result;
@@ -452,12 +452,12 @@ bool_t interpreter_return_result(struct object_heap* oh, struct Interpreter* i,
     Pinned<struct Object> ensureHandler(oh);
     ensureHandler = i->stack->elements[ensureHandlers+1];
 #ifdef PRINT_DEBUG_ENSURE
-  printf("current ensure handlers at %" PRIdPTR "\n", object_to_smallint(i->ensureHandlers));
+  fprintf(stderr, "current ensure handlers at %" PRIdPTR "\n", object_to_smallint(i->ensureHandlers));
 #endif
     assert(object_to_smallint(i->stack->elements[ensureHandlers]) < 0x1000000); /*sanity check*/
     i->ensureHandlers = i->stack->elements[ensureHandlers];
 #ifdef PRINT_DEBUG_ENSURE
-  printf("reset ensure handlers at %" PRIdPTR "\n", object_to_smallint(i->ensureHandlers));
+  fprintf(stderr, "reset ensure handlers at %" PRIdPTR "\n", object_to_smallint(i->ensureHandlers));
 #endif
 
     interpreter_stack_push(oh, i, smallint_to_object(i->stackPointer));
@@ -508,9 +508,9 @@ bool_t interpreter_return_result(struct object_heap* oh, struct Interpreter* i,
   i->codeSize = array_size(i->method->code);
 
 #ifdef PRINT_DEBUG_FUNCALL
-      printf("interpreter_return_result AFTER\n");
-      printf("stack pointer: %" PRIdPTR "\n", i->stackPointer);
-      printf("frame pointer: %" PRIdPTR "\n", i->framePointer);
+      fprintf(stderr, "interpreter_return_result AFTER\n");
+      fprintf(stderr, "stack pointer: %" PRIdPTR "\n", i->stackPointer);
+      fprintf(stderr, "frame pointer: %" PRIdPTR "\n", i->framePointer);
       print_stack_types(oh, MAX_ARITY);
 #endif
 
@@ -571,7 +571,7 @@ void interpreter_resend_message(struct object_heap* oh, struct Interpreter* i, w
   traitsWindow = method->base.map->delegates->elements[0];
   if (traitsWindow == oh->cached.primitive_method_window) {
 #ifdef PRINT_DEBUG
-    printf("calling primitive: %" PRIdPTR "\n", object_to_smallint(((struct PrimitiveMethod*)method)->index));
+    fprintf(stderr, "calling primitive: %" PRIdPTR "\n", object_to_smallint(((struct PrimitiveMethod*)method)->index));
 #endif
     primitives[object_to_smallint(((struct PrimitiveMethod*)method)->index)](oh, args, n, NULL, 0, resultStackPointer);
     return;
@@ -674,9 +674,9 @@ void interpret(struct object_heap* oh) {
 #endif
 
 #ifdef PRINT_DEBUG
-  printf("Interpret: img:%p size:%" PRIdPTR " spec:%p next:%" PRIdPTR "\n",
+  fprintf(stderr, "Interpret: img:%p size:%" PRIdPTR " spec:%p next:%" PRIdPTR "\n",
          (void*)oh->memoryOld, oh->memoryOldSize, (void*)oh->special_objects_oop, oh->lastHash);
-  printf("Special oop: "); print_object((struct Object*)oh->special_objects_oop);
+  fprintf(stderr, "Special oop: "); print_object((struct Object*)oh->special_objects_oop);
 #endif
 
   cache_specials(oh);
@@ -689,10 +689,10 @@ void interpret(struct object_heap* oh) {
   pinnedObjects[5] = (struct Object*) oh->cached.closure_method_window;
 
 #ifdef PRINT_DEBUG
-  printf("Interpreter stack: "); print_object((struct Object*)oh->cached.interpreter);
-  printf("Interpreter stack size: %" PRIdPTR "\n", oh->cached.interpreter->stackSize);
-  printf("Interpreter stack pointer: %" PRIdPTR "\n", oh->cached.interpreter->stackPointer);
-  printf("Interpreter frame pointer: %" PRIdPTR "\n", oh->cached.interpreter->framePointer);
+  fprintf(stderr, "Interpreter stack: "); print_object((struct Object*)oh->cached.interpreter);
+  fprintf(stderr, "Interpreter stack size: %" PRIdPTR "\n", oh->cached.interpreter->stackSize);
+  fprintf(stderr, "Interpreter stack pointer: %" PRIdPTR "\n", oh->cached.interpreter->stackPointer);
+  fprintf(stderr, "Interpreter frame pointer: %" PRIdPTR "\n", oh->cached.interpreter->framePointer);
 #endif 
   /*fixme this should only be called in the initial bootstrap because
     the stack doesn't have enough room for the registers */
@@ -719,7 +719,7 @@ void interpret(struct object_heap* oh) {
       }
       
       if (globalInterrupt) {
-        printf("\nInterrupting...\n");
+        fprintf(stderr, "\nInterrupting...\n");
         interpreter_signal_with(oh, oh->cached.interpreter, get_special(oh, SPECIAL_OOP_TYPE_ERROR_ON), oh->cached.nil, NULL, 0, object_to_smallint(i->stack->elements[i->framePointer - FRAME_OFFSET_RESULT_STACK_POINTER]));
         globalInterrupt = 0;
       }
@@ -734,7 +734,7 @@ void interpret(struct object_heap* oh) {
       prevPointer = i->codePointer;
       op = (word_t)i->method->code->elements[i->codePointer];
 #ifdef PRINT_DEBUG_CODE_POINTER
-      printf("(%" PRIdPTR "/%" PRIdPTR ") %" PRIdPTR " ", i->codePointer, i->codeSize, op>>1);
+      fprintf(stderr, "(%" PRIdPTR "/%" PRIdPTR ") %" PRIdPTR " ", i->codePointer, i->codeSize, op>>1);
 #endif
       i->codePointer++;
 
@@ -752,7 +752,7 @@ void interpret(struct object_heap* oh) {
 
 
 #ifdef PRINT_DEBUG_OPCODES
-          printf("send message fp: %" PRIdPTR ", result: %" PRIdPTR ", arity: %" PRIdPTR ", message: ", i->framePointer, result, arity);
+          fprintf(stderr, "send message fp: %" PRIdPTR ", result: %" PRIdPTR ", arity: %" PRIdPTR ", message: ", i->framePointer, result, arity);
           print_type(oh, selector);
 #endif
           assert(arity <= MAX_ARITY);
@@ -779,7 +779,7 @@ void interpret(struct object_heap* oh) {
           optsArray = (struct OopArray*)SSA_REGISTER(optsArrayReg);
           optCount = array_size(optsArray);
 #ifdef PRINT_DEBUG_OPCODES
-          printf("send message with opts fp: %" PRIdPTR ", result: %" PRIdPTR " arity: %" PRIdPTR ", opts: %" PRIdPTR ", message: ", i->framePointer, result, arity, optsArrayReg);
+          fprintf(stderr, "send message with opts fp: %" PRIdPTR ", result: %" PRIdPTR " arity: %" PRIdPTR ", opts: %" PRIdPTR ", message: ", i->framePointer, result, arity, optsArrayReg);
           print_type(oh, selector);
 #endif
           assert(arity <= MAX_ARITY && optCount <= MAX_OPTS);
@@ -833,7 +833,7 @@ void interpret(struct object_heap* oh) {
           size = SSA_NEXT_PARAM_SMALLINT;
 
 #ifdef PRINT_DEBUG_OPCODES
-          printf("new array, result: %" PRIdPTR ", size: %" PRIdPTR "\n", result, size);
+          fprintf(stderr, "new array, result: %" PRIdPTR ", size: %" PRIdPTR "\n", result, size);
 #endif
           array = heap_clone_oop_array_sized(oh, get_special(oh, SPECIAL_OOP_ARRAY_PROTO), size);
           for (k = 0; k < size; k++) {
@@ -841,7 +841,7 @@ void interpret(struct object_heap* oh) {
           }
           heap_store_into(oh, (struct Object*)i->stack, (struct Object*)array);
 #ifdef PRINT_DEBUG_STACK
-    printf("%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(result)); print_object((struct Object*)array);
+    fprintf(stderr, "%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(result)); print_object((struct Object*)array);
 #endif
           ASSERT_VALID_REGISTER(result);
           SSA_REGISTER(result) = (struct Object*) array;
@@ -855,7 +855,7 @@ void interpret(struct object_heap* oh) {
           result = SSA_NEXT_PARAM_SMALLINT;
           block = (struct CompiledMethod*)SSA_NEXT_PARAM_OBJECT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("new closure, result: %" PRIdPTR ", block", result);
+          fprintf(stderr, "new closure, result: %" PRIdPTR ", block", result);
           print_type(oh, (struct Object*)block);
 #endif
           if ((struct CompiledMethod *) i->closure == i->method) {
@@ -872,13 +872,13 @@ void interpret(struct object_heap* oh) {
           heap_store_into(oh, (struct Object*)newClosure, (struct Object*)i->lexicalContext);
 #if 1
           if (object_is_free((struct Object*)block)) {
-            /*printf("%d\n", instruction_counter);*/
+            /*fprintf(stderr, "%d\n", instruction_counter);*/
           }
 #endif
           heap_store_into(oh, (struct Object*)newClosure, (struct Object*)block);
           heap_store_into(oh, (struct Object*)i->stack, (struct Object*)newClosure);
 #ifdef PRINT_DEBUG_STACK
-    printf("%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(result)); print_object((struct Object*)newClosure);
+    fprintf(stderr, "%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(result)); print_object((struct Object*)newClosure);
 #endif
           ASSERT_VALID_REGISTER(result);
           SSA_REGISTER(result) = (struct Object*) newClosure;
@@ -891,12 +891,12 @@ void interpret(struct object_heap* oh) {
           destReg = SSA_NEXT_PARAM_SMALLINT;
           literal = SSA_NEXT_PARAM_OBJECT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("load literal into reg %" PRIdPTR ", value: ", destReg);
+          fprintf(stderr, "load literal into reg %" PRIdPTR ", value: ", destReg);
           print_type(oh, literal);
 #endif
           heap_store_into(oh, (struct Object*)i->stack, literal);
 #ifdef PRINT_DEBUG_STACK
-    printf("%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(destReg)); print_object((struct Object*)literal);
+    fprintf(stderr, "%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(destReg)); print_object((struct Object*)literal);
 #endif
           ASSERT_VALID_REGISTER(destReg);
           SSA_REGISTER(destReg) = literal;
@@ -908,7 +908,7 @@ void interpret(struct object_heap* oh) {
           resultRegister = SSA_NEXT_PARAM_SMALLINT;
           lexicalOffset = SSA_NEXT_PARAM_SMALLINT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("resend message reg %" PRIdPTR ", offset: %" PRIdPTR "\n", resultRegister, lexicalOffset);
+          fprintf(stderr, "resend message reg %" PRIdPTR ", offset: %" PRIdPTR "\n", resultRegister, lexicalOffset);
 #endif
           interpreter_resend_message(oh, i, lexicalOffset, i->framePointer + resultRegister);
           break;
@@ -918,18 +918,18 @@ void interpret(struct object_heap* oh) {
           word_t var;
           var = SSA_NEXT_PARAM_SMALLINT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("load var %" PRIdPTR "\n", var);
+          fprintf(stderr, "load var %" PRIdPTR "\n", var);
 #endif
           if (i->method->heapAllocate == oh->cached.true_object) {
             heap_store_into(oh, (struct Object*)i->stack, (struct Object*)i->lexicalContext);
 #ifdef PRINT_DEBUG_STACK
-            printf("%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(var)); print_object(i->lexicalContext->variables[var]);
+            fprintf(stderr, "%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(var)); print_object(i->lexicalContext->variables[var]);
 #endif
             ASSERT_VALID_REGISTER(var);
             SSA_REGISTER(var) = i->lexicalContext->variables[var];
           }
 #ifdef PRINT_DEBUG_OPCODES
-          printf("var val =");
+          fprintf(stderr, "var val =");
           print_type(oh, SSA_REGISTER(var));
 #endif
           /*if it's not heap allocated the register is already loaded*/
@@ -940,7 +940,7 @@ void interpret(struct object_heap* oh) {
           word_t var;
           var = SSA_NEXT_PARAM_SMALLINT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("store var %" PRIdPTR "\n", var);
+          fprintf(stderr, "store var %" PRIdPTR "\n", var);
 #endif
           if (i->method->heapAllocate == oh->cached.true_object) {
             heap_store_into(oh, (struct Object*)i->lexicalContext, (struct Object*)i->stack);
@@ -948,7 +948,7 @@ void interpret(struct object_heap* oh) {
           }
           /*if it's not heap allocated the register is already loaded*/
 #ifdef PRINT_DEBUG_OPCODES
-          printf("var val =");
+          fprintf(stderr, "var val =");
           print_type(oh, SSA_REGISTER(var));
 #endif
           break;
@@ -960,17 +960,17 @@ void interpret(struct object_heap* oh) {
           lexOffset = SSA_NEXT_PARAM_SMALLINT;
           varIndex = SSA_NEXT_PARAM_SMALLINT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("load free var to: %" PRIdPTR ", lexoffset: %" PRIdPTR ", index: %" PRIdPTR "\n", destReg, lexOffset, varIndex);
+          fprintf(stderr, "load free var to: %" PRIdPTR ", lexoffset: %" PRIdPTR ", index: %" PRIdPTR "\n", destReg, lexOffset, varIndex);
 #endif
           heap_store_into(oh, (struct Object*)i->stack, (struct Object*)i->closure->lexicalWindow[lexOffset-1]);
 #ifdef PRINT_DEBUG_STACK
-          printf("%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(destReg)); print_object(i->closure->lexicalWindow[lexOffset-1]->variables[varIndex]);
+          fprintf(stderr, "%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(destReg)); print_object(i->closure->lexicalWindow[lexOffset-1]->variables[varIndex]);
 #endif
           ASSERT_VALID_REGISTER(destReg);
           SSA_REGISTER(destReg) = i->closure->lexicalWindow[lexOffset-1]->variables[varIndex];
 
 #ifdef PRINT_DEBUG_OPCODES
-          printf("var val =");
+          fprintf(stderr, "var val =");
           print_type(oh, SSA_REGISTER(destReg));
 #endif
           break;
@@ -982,13 +982,13 @@ void interpret(struct object_heap* oh) {
           varIndex = SSA_NEXT_PARAM_SMALLINT;
           srcReg = SSA_NEXT_PARAM_SMALLINT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("store free var from: %" PRIdPTR ", lexoffset: %" PRIdPTR ", index: %" PRIdPTR "\n", srcReg, lexOffset, varIndex);
+          fprintf(stderr, "store free var from: %" PRIdPTR ", lexoffset: %" PRIdPTR ", index: %" PRIdPTR "\n", srcReg, lexOffset, varIndex);
 #endif
           heap_store_into(oh, (struct Object*)i->closure->lexicalWindow[lexOffset-1], (struct Object*)i->stack);
           i->closure->lexicalWindow[lexOffset-1]->variables[varIndex] = SSA_REGISTER(srcReg);
 
 #ifdef PRINT_DEBUG_OPCODES
-          printf("var val =");
+          fprintf(stderr, "var val =");
           print_type(oh, SSA_REGISTER(srcReg));
 #endif
           break;
@@ -1000,11 +1000,11 @@ void interpret(struct object_heap* oh) {
           srcReg = SSA_NEXT_PARAM_SMALLINT;
 
 #ifdef PRINT_DEBUG_OPCODES
-          printf("move reg %" PRIdPTR ", %" PRIdPTR "\n", destReg, srcReg);
+          fprintf(stderr, "move reg %" PRIdPTR ", %" PRIdPTR "\n", destReg, srcReg);
 #endif
           heap_store_into(oh, (struct Object*)i->stack, SSA_REGISTER(srcReg));
 #ifdef PRINT_DEBUG_STACK
-          printf("%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(destReg)); print_object(SSA_REGISTER(srcReg));
+          fprintf(stderr, "%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(destReg)); print_object(SSA_REGISTER(srcReg));
 #endif
           ASSERT_VALID_REGISTER(destReg);
           SSA_REGISTER(destReg) = SSA_REGISTER(srcReg);
@@ -1027,13 +1027,13 @@ void interpret(struct object_heap* oh) {
           srcReg = SSA_NEXT_PARAM_SMALLINT;
 
 #ifdef PRINT_DEBUG_OPCODES
-          printf("is identical %" PRIdPTR ", %" PRIdPTR "\n", destReg, srcReg);
+          fprintf(stderr, "is identical %" PRIdPTR ", %" PRIdPTR "\n", destReg, srcReg);
 #endif
           ASSERT_VALID_REGISTER(resultReg);
           
           SSA_REGISTER(resultReg) = (SSA_REGISTER(destReg) == SSA_REGISTER(srcReg)) ? oh->cached.true_object : oh->cached.false_object;
 #ifdef PRINT_DEBUG_STACK
-          printf("%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(resultReg)); print_object(SSA_REGISTER(resultReg));
+          fprintf(stderr, "%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(resultReg)); print_object(SSA_REGISTER(resultReg));
 #endif
           break;
         }
@@ -1047,7 +1047,7 @@ void interpret(struct object_heap* oh) {
 
           /*assert(0);*/
 #ifdef PRINT_DEBUG_OPCODES
-          printf("branch keyed: %" PRIdPTR "/%" PRIdPTR "\n", tableReg, keyReg);
+          fprintf(stderr, "branch keyed: %" PRIdPTR "/%" PRIdPTR "\n", tableReg, keyReg);
 #endif
           table = (struct OopArray*)SSA_REGISTER(tableReg);
           key = (struct OopArray*)SSA_REGISTER(keyReg);
@@ -1065,7 +1065,7 @@ void interpret(struct object_heap* oh) {
           val = SSA_REGISTER(condReg);
 
 #ifdef PRINT_DEBUG_OPCODES
-          printf("branch if true: %" PRIdPTR ", offset: %" PRIdPTR ", val: ", condReg, offset);
+          fprintf(stderr, "branch if true: %" PRIdPTR ", offset: %" PRIdPTR ", val: ", condReg, offset);
           print_type(oh, val);
 #endif
           if (val == oh->cached.true_object) {
@@ -1088,7 +1088,7 @@ void interpret(struct object_heap* oh) {
           val = SSA_REGISTER(condReg);
 
 #ifdef PRINT_DEBUG_OPCODES
-          printf("branch if false: %" PRIdPTR ", offset: %" PRIdPTR ", val: ", condReg, offset);
+          fprintf(stderr, "branch if false: %" PRIdPTR ", offset: %" PRIdPTR ", val: ", condReg, offset);
           print_type(oh, val);
 #endif
           if (val == oh->cached.false_object) {
@@ -1107,7 +1107,7 @@ void interpret(struct object_heap* oh) {
           offset = SSA_NEXT_PARAM_SMALLINT - 1;
           assert(offset < 20000 && offset > -20000);
 #ifdef PRINT_DEBUG_OPCODES
-          printf("jump to offset: %" PRIdPTR "\n", offset);
+          fprintf(stderr, "jump to offset: %" PRIdPTR "\n", offset);
 #endif
           i->codePointer = i->codePointer + offset;
           
@@ -1118,14 +1118,14 @@ void interpret(struct object_heap* oh) {
           word_t next_param;
           next_param = SSA_NEXT_PARAM_SMALLINT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("load environment into reg %" PRIdPTR ", value: ", next_param);
+          fprintf(stderr, "load environment into reg %" PRIdPTR ", value: ", next_param);
           print_type(oh, i->method->environment);
 #endif
           heap_store_into(oh, (struct Object*)i->stack, (struct Object*)i->method->environment);
           ASSERT_VALID_REGISTER(next_param);
           SSA_REGISTER(next_param) = i->method->environment;
 #ifdef PRINT_DEBUG_STACK
-          printf("%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(next_param)); print_object(SSA_REGISTER(next_param));
+          fprintf(stderr, "%" PRIuPTR "u: setting stack[%" PRIdPTR "] = ", instruction_counter, REG_STACK_POINTER(next_param)); print_object(SSA_REGISTER(next_param));
 #endif
           break;
         }
@@ -1134,18 +1134,18 @@ void interpret(struct object_heap* oh) {
           word_t reg;
           reg = SSA_NEXT_PARAM_SMALLINT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("return reg %" PRIdPTR ", value: ", reg);
+          fprintf(stderr, "return reg %" PRIdPTR ", value: ", reg);
           print_type(oh, SSA_REGISTER(reg));
 #endif
 #ifdef PRINT_DEBUG_STACK
-          printf("%" PRIuPTR "u: ", instruction_counter);
+          fprintf(stderr, "%" PRIuPTR "u: ", instruction_counter);
 #endif
           ASSERT_VALID_REGISTER(reg);
           Pinned<struct Object> result(oh);
           result = SSA_REGISTER(reg);
           interpreter_return_result(oh, i, 0, result, prevPointer);
 #ifdef PRINT_DEBUG_OPCODES
-          printf("in function: \n");
+          fprintf(stderr, "in function: \n");
           print_type(oh, (struct Object*)i->method);
 #endif
           break;
@@ -1158,7 +1158,7 @@ void interpret(struct object_heap* oh) {
           /*interpreter_return_result(oh, i, 0, NULL);*/
           interpreter_return_result(oh, i, 0, NULL, prevPointer);
 #ifdef PRINT_DEBUG_OPCODES
-          printf("in function: \n");
+          fprintf(stderr, "in function: \n");
           print_type(oh, (struct Object*)i->method);
 #endif
           break;
@@ -1170,18 +1170,18 @@ void interpret(struct object_heap* oh) {
           reg = SSA_NEXT_PARAM_SMALLINT;
           offset = SSA_NEXT_PARAM_SMALLINT;
 #ifdef PRINT_DEBUG_OPCODES
-          printf("return result reg: %" PRIdPTR ", offset: %" PRIdPTR ", value: ", reg, offset);
+          fprintf(stderr, "return result reg: %" PRIdPTR ", offset: %" PRIdPTR ", value: ", reg, offset);
           print_type(oh, SSA_REGISTER(reg));
 #endif
 #ifdef PRINT_DEBUG_STACK
-          printf("%" PRIuPTR "u: ", instruction_counter);
+          fprintf(stderr, "%" PRIuPTR "u: ", instruction_counter);
 #endif
           ASSERT_VALID_REGISTER(reg);
           Pinned<struct Object> result(oh);
           result = SSA_REGISTER(reg);
           interpreter_return_result(oh, i, offset, result, prevPointer);
 #ifdef PRINT_DEBUG_OPCODES
-          printf("in function: \n");
+          fprintf(stderr, "in function: \n");
           print_type(oh, (struct Object*)i->method);
 #endif
           break;
@@ -1192,11 +1192,11 @@ void interpret(struct object_heap* oh) {
           PRINTOP("op: return obj\n");
           obj = SSA_NEXT_PARAM_OBJECT;
 #ifdef PRINT_DEBUG_STACK
-          printf("%" PRIuPTR "u: ", instruction_counter);
+          fprintf(stderr, "%" PRIuPTR "u: ", instruction_counter);
 #endif
           interpreter_return_result(oh, i, 0, obj, prevPointer);
 #ifdef PRINT_DEBUG_OPCODES
-          printf("in function: \n");
+          fprintf(stderr, "in function: \n");
           print_type(oh, (struct Object*)i->method);
 #endif
           break;
@@ -1315,7 +1315,7 @@ void interpret(struct object_heap* oh) {
         }
 
       default:
-        printf("error bad opcode... %" PRIdPTR "\n", op>>1);
+        fprintf(stderr, "error bad opcode... %" PRIdPTR "\n", op>>1);
         assert(0);
         break;
       }
index 8620f05..7729dcd 100644 (file)
@@ -70,13 +70,13 @@ struct MethodDefinition* method_dispatch_on(struct object_heap* oh, struct Symbo
 
 
 #ifdef PRINT_DEBUG_DISPATCH
-  printf("dispatch to: '");
+  fprintf(stderr, "dispatch to: '");
   print_symbol(name);
-  printf("' (arity: %" PRIdPTR ")\n", arity);
+  fprintf(stderr, "' (arity: %" PRIdPTR ")\n", arity);
   for (i = 0; i < arity; i++) {
-    printf("arguments[%" PRIdPTR "] (%p) = ", i, (void*)arguments[i]); print_type(oh, arguments[i]);
+    fprintf(stderr, "arguments[%" PRIdPTR "] (%p) = ", i, (void*)arguments[i]); print_type(oh, arguments[i]);
   }
-  /*  printf("resend: "); print_object(resendMethod);*/
+  /*  fprintf(stderr, "resend: "); print_object(resendMethod);*/
 #endif
 
   dispatch = NULL;
@@ -151,7 +151,7 @@ struct MethodDefinition* method_dispatch_on(struct object_heap* oh, struct Symbo
               def->foundPositions |= (1 << i);
 
 #ifdef PRINT_DEBUG_FOUND_ROLE
-              printf("found role index %" PRIdPTR " <%p> for '%s' foundPos: %" PRIuPTR "x dispatchPos: %" PRIuPTR "x\n",
+              fprintf(stderr, "found role index %" PRIdPTR " <%p> for '%s' foundPos: %" PRIuPTR "x dispatchPos: %" PRIuPTR "x\n",
                      i,
                      (void*) role,
                      ((struct Symbol*)(role->name))->elements, def->foundPositions, def->dispatchPositions);
@@ -209,7 +209,7 @@ struct MethodDefinition* method_dispatch_on(struct object_heap* oh, struct Symbo
             arguments[0] = slotLocation;
             /*do we need to try to do a heap_store_into?*/
 #ifdef PRINT_DEBUG_DISPATCH_SLOT_CHANGES
-            printf("arguments[0] changed to slot location: \n");
+            fprintf(stderr, "arguments[0] changed to slot location: \n");
             print_detail(oh, arguments[0]);
 #endif
           }
@@ -254,7 +254,7 @@ struct MethodDefinition* method_dispatch_on(struct object_heap* oh, struct Symbo
     /*check heap store into?*/
     arguments[0] = slotLocation;
 #ifdef PRINT_DEBUG_DISPATCH_SLOT_CHANGES
-            printf("arguments[0] changed to slot location: \n");
+            fprintf(stderr, "arguments[0] changed to slot location: \n");
             print_detail(oh, arguments[0]);
 #endif
 
@@ -289,10 +289,10 @@ bool method_on_call_stack(struct object_heap* oh, struct CompiledMethod* method)
 
 void method_unoptimize(struct object_heap* oh, struct CompiledMethod* method) {
 #ifdef PRINT_DEBUG_UNOPTIMIZER
-  printf("Unoptimizing '"); print_symbol(method->selector); printf("'\n");
+  fprintf(stderr, "Unoptimizing '"); print_symbol(method->selector); fprintf(stderr, "'\n");
 #endif
   if (method_on_call_stack(oh, method)) {
-    printf("Fixme cannot unoptimizing because on call stack: '"); print_symbol(method->selector); printf("'\n");
+    fprintf(stderr, "Fixme cannot unoptimizing because on call stack: '"); print_symbol(method->selector); fprintf(stderr, "'\n");
     return;
   }
 
@@ -349,13 +349,13 @@ void method_optimize(struct object_heap* oh, struct CompiledMethod* method) {
   }
 
 #ifdef PRINT_DEBUG_OPTIMIZER
-  printf("Optimizing '"); print_symbol(method->selector); printf("'\n");
+  fprintf(stderr, "Optimizing '"); print_symbol(method->selector); fprintf(stderr, "'\n");
 #endif
 
 
 #ifdef PRINT_DEBUG_OPTIMIZER2
   method_print_debug_info(oh, method);
-  printf("This method is called by:\n");
+  fprintf(stderr, "This method is called by:\n");
   method_print_debug_info(oh, oh->cached.interpreter->method);
 #endif
 
@@ -371,13 +371,13 @@ void method_optimize(struct object_heap* oh, struct CompiledMethod* method) {
   method->isInlined = oh->cached.true_object;
   oh->optimizedMethods.insert(method);
 #ifdef SLATE_SHOW_INLINER_CODE
-  printf("before:\n");
+  fprintf(stderr, "before:\n");
   print_type(oh, (struct Object*)method->selector);
   print_code_disassembled(oh, method->code);
 #endif
   optimizer_inline_callees(oh, method);
 #ifdef SLATE_SHOW_INLINER_CODE
-  printf("after:\n");
+  fprintf(stderr, "after:\n");
   print_code_disassembled(oh, method->code);
 #endif
   
index adc711f..feadcff 100644 (file)
@@ -694,7 +694,7 @@ void adjust_oop_pointers_from(struct object_heap* oh, word_t shift_amount, byte_
 
   struct Object* o = (struct Object*)memory;
 #ifdef PRINT_DEBUG
-  printf("First object: "); print_object(o);
+  fprintf(stderr, "First object: "); print_object(o);
 #endif
   while (object_in_memory(oh, o, memory, memorySize)) {
     /*print_object(o);*/
index b5df092..65d44c1 100644 (file)
@@ -44,15 +44,15 @@ void print_opcode_args(struct object_heap* oh, std::vector<struct Object*>& code
 void print_code(struct object_heap* oh, std::vector<struct Object*> code) {
 
   for (size_t i = 0; i < code.size(); i += opcode_length(code, i)) {
-    printf("[%" PRIuMAX "] ", i);
+    fprintf(stderr, "[%" PRIuMAX "] ", i);
     word_t rawop = (word_t)code[i];
     if (rawop >= OP_INTERNAL_SEND) {
-      printf("<internal>");
+      fprintf(stderr, "<internal>");
     } else {
-      printf("%s", opcode_names[rawop>>1]);
+      fprintf(stderr, "%s", opcode_names[rawop>>1]);
     }
     print_opcode_args(oh, code, i+1, opcode_length(code, i)-1);
-    printf("\n");
+    fprintf(stderr, "\n");
   }
 
   
index af29d98..e71849c 100644 (file)
@@ -12,7 +12,7 @@
 
 void prim_fixme(struct object_heap* oh, struct Object* args[], word_t arity, struct Object* opts[], word_t optCount, word_t resultStackPointer) {
   struct Object* x = args[0];
-  printf("UNIMPLEMENTED PRIMITIVE\n");
+  fprintf(stderr, "UNIMPLEMENTED PRIMITIVE\n");
   interpreter_signal_with(oh, oh->cached.interpreter, get_special(oh, SPECIAL_OOP_TYPE_ERROR_ON), x, NULL, 0, resultStackPointer);
 }
 
@@ -51,7 +51,7 @@ void prim_forward_to(struct object_heap* oh, struct Object* args[], word_t arity
        if (x == get_special(oh, SPECIAL_OOP_NIL) 
                || x == get_special(oh, SPECIAL_OOP_TRUE)
                || x == get_special(oh, SPECIAL_OOP_FALSE)) {
-               printf("Error... you cannot call forwardTo on this special object (did you add a slot to Nil/True/False?)\n");
+               fprintf(stderr, "Error... you cannot call forwardTo on this special object (did you add a slot to Nil/True/False?)\n");
                interpreter_signal_with(oh, oh->cached.interpreter, get_special(oh, SPECIAL_OOP_TYPE_ERROR_ON), x, NULL, 0, resultStackPointer); \
                return;
        }
@@ -293,7 +293,7 @@ void prim_ensure(struct object_heap* oh, struct Object* args[], word_t arity, st
   interpreter_stack_push(oh, oh->cached.interpreter, ensureHandler);
   oh->cached.interpreter->ensureHandlers = smallint_to_object(oh->cached.interpreter->stackPointer - 2);
 #ifdef PRINT_DEBUG_ENSURE
-       printf("ensure handlers at %" PRIdPTR "\n", oh->cached.interpreter->stackPointer - 2);
+       fprintf(stderr, "ensure handlers at %" PRIdPTR "\n", oh->cached.interpreter->stackPointer - 2);
 #endif
        
 }
@@ -381,17 +381,17 @@ void prim_as_method_on(struct object_heap* oh, struct Object* args[], word_t ari
        method_flush_cache(oh, selector);
 #ifdef PRINT_DEBUG_DEFUN
        if (!oh->quiet) {
-               printf("Defining function '"); print_symbol(selector);
-               printf("' on: ");
-               if (!print_printname(oh, ((struct OopArray*)roles)->elements[0])) printf("NoRole");
+               fprintf(stderr, "Defining function '"); print_symbol(selector);
+               fprintf(stderr, "' on: ");
+               if (!print_printname(oh, ((struct OopArray*)roles)->elements[0])) fprintf(stderr, "NoRole");
                {
                        word_t i;
                        for (i = 1; i < object_array_size(roles); i++) {
-                               printf(", ");
-                               if (!print_printname(oh, ((struct OopArray*)roles)->elements[i])) printf("NoRole");
+                               fprintf(stderr, ", ");
+                               if (!print_printname(oh, ((struct OopArray*)roles)->elements[i])) fprintf(stderr, "NoRole");
                        }
                }
-               printf("\n");
+               fprintf(stderr, "\n");
        }
 #endif
        
@@ -471,17 +471,17 @@ void prim_as_accessor(struct object_heap* oh, struct Object* args[], word_t arit
        
 #ifdef PRINT_DEBUG_DEFUN
        if (!oh->quiet) {
-               printf("Defining accessor '"); print_symbol(selector);
-               printf("' on: ");
-               if (!print_printname(oh, ((struct OopArray*)roles)->elements[0])) printf("NoRole");
+               fprintf(stderr, "Defining accessor '"); print_symbol(selector);
+               fprintf(stderr, "' on: ");
+               if (!print_printname(oh, ((struct OopArray*)roles)->elements[0])) fprintf(stderr, "NoRole");
                {
                        word_t i;
                        for (i = 1; i < array_size(roles); i++) {
-                               printf(", ");
-                               if (!print_printname(oh, ((struct OopArray*)roles)->elements[i])) printf("NoRole");
+                               fprintf(stderr, ", ");
+                               if (!print_printname(oh, ((struct OopArray*)roles)->elements[i])) fprintf(stderr, "NoRole");
                        }
                }
-               printf("\n");
+               fprintf(stderr, "\n");
        }
 #endif
 }
@@ -1726,7 +1726,7 @@ void prim_daemonizeSystem(struct object_heap* oh, struct Object* args[], word_t
        if (lock_filename && lock_filename[0]) {
                lfp = open(lock_filename,O_RDWR|O_CREAT,0640);
                if (lfp < 0) {
-                       printf("Unable to create lock file %s, code=%d (%s)",
+                       fprintf(stderr, "Unable to create lock file %s, code=%d (%s)",
                                   lock_filename, errno, strerror(errno));
                        exit(EXIT_FAILURE);
                }
@@ -1737,7 +1737,7 @@ void prim_daemonizeSystem(struct object_heap* oh, struct Object* args[], word_t
                struct passwd *pw = getpwnam(RUN_AS_USER);
                if (pw) {
                        if (!oh->quiet)
-                               printf("Setting user to " RUN_AS_USER);
+                               fprintf(stderr, "Setting user to " RUN_AS_USER);
                        setuid(pw->pw_uid);
                }
        }
@@ -1750,7 +1750,7 @@ void prim_daemonizeSystem(struct object_heap* oh, struct Object* args[], word_t
        /* Fork off the parent process */
        pid = fork();
        if (pid < 0) {
-               printf("Unable to fork daemon, code=%d (%s)",
+               fprintf(stderr, "Unable to fork daemon, code=%d (%s)",
                           errno, strerror(errno));
                exit(EXIT_FAILURE);
        }
@@ -1782,7 +1782,7 @@ void prim_daemonizeSystem(struct object_heap* oh, struct Object* args[], word_t
        /* Create a new SID for the child process */
        sid = setsid();
        if (sid < 0) {
-               printf("Unable to create a new session, code %d (%s)",
+               fprintf(stderr, "Unable to create a new session, code %d (%s)",
                           errno, strerror(errno));
                exit(EXIT_FAILURE);
        }
@@ -1790,7 +1790,7 @@ void prim_daemonizeSystem(struct object_heap* oh, struct Object* args[], word_t
        /* Change the current working directory.  This prevents the current
      directory from being locked; hence not being able to remove it. */
        if ((chdir("/")) < 0) {
-               printf("Unable to change directory to %s, code %d (%s)",
+               fprintf(stderr, "Unable to change directory to %s, code %d (%s)",
                           "/", errno, strerror(errno));
                exit(EXIT_FAILURE);
        }
@@ -1982,7 +1982,7 @@ void prim_profilerStatistics(struct object_heap* oh, struct Object* args[], word
 
 void prim_heap_gc(struct object_heap* oh, struct Object* args[], word_t arity, struct Object* opts[], word_t optCount, word_t resultStackPointer) {
   if (!oh->quiet) {
-    printf("Collecting garbage...\n");
+    fprintf(stderr, "Collecting garbage...\n");
   };
   heap_full_gc(oh);
 }
@@ -2025,7 +2025,7 @@ void prim_save_image(struct object_heap* oh, struct Object* args[], word_t arity
                
     return;
   }
-  printf("Saving image to %s\n", nameString);
+  fprintf(stderr, "Saving image to %s\n", nameString);
   heap_full_gc(oh);
   totalSize = oh->memoryOldSize + oh->memoryYoungSize;
   forwardPointerEntryCount = ((totalSize / 4) + sizeof(struct ForwardPointerEntry) - 1) / sizeof(struct ForwardPointerEntry);
@@ -2064,7 +2064,7 @@ void prim_exit(struct object_heap* oh, struct Object* args[], word_t arity, stru
   /*  print_backtrace(oh);*/
   ASSURE_SMALLINT_ARG(1);
   if (!oh->quiet) {
-    printf("Slate process %d exiting...\n", getpid());
+    fprintf(stderr, "Slate process %d exiting...\n", getpid());
   }
   exit(object_to_smallint(args[1]));
 }
index 9dcb1f5..6591383 100644 (file)
@@ -29,7 +29,7 @@ void profiler_enter_method(struct object_heap* oh, struct Object* fromMethod, st
   if (!oh->currentlyProfiling) return;
 
 
-  //printf("%p -> %p (%d) (%d)\n", fromMethod, toMethod, (int)push, (int) oh->profilerCallStack.size());
+  //fprintf(stderr, "%p -> %p (%d) (%d)\n", fromMethod, toMethod, (int)push, (int) oh->profilerCallStack.size());
 
   oh->profilerTime = getRealTimeClock();
   word_t timeDiff = oh->profilerTime - oh->profilerLastTime;
@@ -84,7 +84,7 @@ void profiler_enter_method(struct object_heap* oh, struct Object* fromMethod, st
 
 void profiler_notice_forwarded_object(struct object_heap* oh, struct Object* from, struct Object* to) {
   if (!oh->currentlyProfiling) return;
-  //printf("pf %p -> %p\n", from, to);
+  //fprintf(stderr, "pf %p -> %p\n", from, to);
   if (oh->profiledMethods.find(from) == oh->profiledMethods.end()) return;
   oh->profiledMethods.erase(from); oh->profiledMethods.insert(to);
 
@@ -122,7 +122,7 @@ void profiler_notice_forwarded_object(struct object_heap* oh, struct Object* fro
 /*this will be called when the GC deletes the object*/
 void profiler_delete_method(struct object_heap* oh, struct Object* method) {
   if (!oh->currentlyProfiling) return;
-  //printf("pf del %p\n", method);
+  //fprintf(stderr, "pf del %p\n", method);
   oh->profiledMethods.erase(method);
   oh->profilerSelfTime.erase(method);
   oh->profilerCallCounts.erase(method);
index 7c5e6b2..b10010e 100644 (file)
@@ -195,9 +195,9 @@ int main(int argc, char** argv, char **envp) {
   heap->quietGC = quietGC;
   heap->envp = envp;
   if (!heap->quiet) {
-    printf("Old Memory size: %" PRIdPTR " bytes\n", memory_limit);
-    printf("New Memory size: %" PRIdPTR " bytes\n", young_limit);
-    printf("Image size: %" PRIdPTR " bytes\n", sih.size);
+    fprintf(stderr, "Old Memory size: %" PRIdPTR " bytes\n", memory_limit);
+    fprintf(stderr, "New Memory size: %" PRIdPTR " bytes\n", young_limit);
+    fprintf(stderr, "Image size: %" PRIdPTR " bytes\n", sih.size);
   }
 
   // Read in the heap contents from the image file: