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)) {
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);
}
}
}
}
-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, "'");
}
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"));
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);
}
{/*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;
}
}
}
- indent(depth); printf("}\n");
+ indent(depth); fprintf(stderr, "}\n");
}
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;*/
}
{
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, ")");
}
}
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");
}
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]);
}
}
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]);
}
}
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 {
}
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 {
}
} 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 {
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);
}
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);
}
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)) {
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
} 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);
}
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);
}
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);
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);
}
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);
#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
}
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);
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);
}
#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
#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
#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
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
}
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*/
{
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;
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);
#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];
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
}
}
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) {
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
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
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;
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));
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
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;
#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);
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 */
}
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;
}
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++;
#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);
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);
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++) {
}
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;
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) {
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;
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;
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;
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*/
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);
}
/*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;
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;
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;
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);
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;
}
/*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);
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) {
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) {
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;
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;
}
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;
/*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;
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;
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;
}
default:
- printf("error bad opcode... %" PRIdPTR "\n", op>>1);
+ fprintf(stderr, "error bad opcode... %" PRIdPTR "\n", op>>1);
assert(0);
break;
}
#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;
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);
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
}
/*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
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;
}
}
#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
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
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);*/
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");
}
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);
}
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;
}
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
}
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
#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
}
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);
}
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);
}
}
/* 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);
}
/* 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);
}
/* 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);
}
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);
}
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);
/* 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]));
}
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;
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);
/*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);
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: