put all commented code in if(false) blocks instead; fix ensuing broken code

This commit is contained in:
Joshua Warner 2014-07-12 10:16:03 -06:00
parent 4e9da8deb2
commit 80f19abf3a
9 changed files with 153 additions and 84 deletions

View File

@ -594,9 +594,13 @@ object invoke(Thread* t, GcMethod* method, object instance, object args)
object arg = objectArrayBody(t, args, i++); object arg = objectArrayBody(t, args, i++);
if ((arg == 0 and (not objectType)) if ((arg == 0 and (not objectType))
or (arg and (not instanceOf(t, type, arg)))) { or (arg and (not instanceOf(t, type, arg)))) {
// fprintf(stderr, "%s is not a %s\n", arg ? &byteArrayBody(t, if (false) {
// className(t, objectClass(t, arg)), 0) : reinterpret_cast<const fprintf(stderr,
// int8_t*>("<null>"), &byteArrayBody(t, className(t, type), 0)); "%s is not a %s\n",
arg ? objectClass(t, arg)->name()->body().begin()
: reinterpret_cast<const int8_t*>("<null>"),
type->name()->body().begin());
}
throwNew(t, GcIllegalArgumentException::Type); throwNew(t, GcIllegalArgumentException::Type);
} }
@ -661,12 +665,17 @@ void intercept(Thread* t,
} else { } else {
// If we can't find the method, just ignore it, since ProGuard may // If we can't find the method, just ignore it, since ProGuard may
// have stripped it out as unused. Otherwise, the code below can // have stripped it out as unused. Otherwise, the code below can
// be uncommented for debugging purposes. // be enabled for debugging purposes.
// fprintf(stderr, "unable to find %s%s in %s\n", if (false) {
// name, spec, &byteArrayBody(t, c->name(), 0)); fprintf(stderr,
"unable to find %s%s in %s\n",
name,
spec,
c->name()->body().begin());
// abort(t); abort(t);
}
} }
} }

View File

@ -1354,11 +1354,14 @@ unsigned frameFootprint(Context* c, Stack* s)
void visit(Context* c, Link* link) void visit(Context* c, Link* link)
{ {
// fprintf(stderr, "visit link from %d to %d fork %p junction %p\n", if (false) {
// link->predecessor->logicalInstruction->index, fprintf(stderr,
// link->successor->logicalInstruction->index, "visit link from %d to %d fork %p junction %p\n",
// link->forkState, link->predecessor->logicalInstruction->index,
// link->junctionState); link->successor->logicalInstruction->index,
link->forkState,
link->junctionState);
}
ForkState* forkState = link->forkState; ForkState* forkState = link->forkState;
if (forkState) { if (forkState) {
@ -1366,8 +1369,9 @@ void visit(Context* c, Link* link)
ForkElement* p = forkState->elements + i; ForkElement* p = forkState->elements + i;
Value* v = p->value; Value* v = p->value;
v->reads = p->read->nextTarget(); v->reads = p->read->nextTarget();
// fprintf(stderr, "next read %p for %p from %p\n", v->reads, v, if (false) {
// p->read); fprintf(stderr, "next read %p for %p from %p\n", v->reads, v, p->read);
}
if (not live(c, v)) { if (not live(c, v)) {
v->clearSites(c); v->clearSites(c);
} }
@ -1865,9 +1869,16 @@ void restore(Context* c, Event* e, Snapshot* snapshots)
} }
} }
// char buffer[256]; sitesToString(c, s->sites, buffer, 256); if (false) {
// fprintf(stderr, "restore %p buddy %p sites %s live %p\n", char buffer[256];
// s->value, s->value->buddy, buffer, live(c, s->value)); sitesToString(c, s->sites, buffer, 256);
fprintf(stderr,
"restore %p buddy %p sites %s live %p\n",
s->value,
s->value->buddy,
buffer,
live(c, s->value));
}
} }
} }

View File

@ -148,9 +148,9 @@ void Event::addRead(Context* c, Value* v, Read* r)
} }
if (v->lastRead) { if (v->lastRead) {
// if (DebugReads) { if (DebugReads) {
// fprintf(stderr, "append %p to %p for %p\n", r, v->lastRead, v); fprintf(stderr, "append %p to %p for %p\n", r, v->lastRead, v);
// } }
v->lastRead->append(c, r); v->lastRead->append(c, r);
} else { } else {
@ -298,9 +298,9 @@ Value* slicePushWord(Context* c,
assertT(c, slice.count < slice.capacity); assertT(c, slice.count < slice.capacity);
slice.push(v); slice.push(v);
// if (DebugFrame) { if (false) {
// fprintf(stderr, "push %p\n", v); fprintf(stderr, "push %p\n", v);
// } }
if (v) { if (v) {
v->home = frameIndex(c, index + stackBase + c->localFootprint); v->home = frameIndex(c, index + stackBase + c->localFootprint);
@ -1102,13 +1102,19 @@ class CombineEvent : public Event {
c, c,
firstValue->source->type(c) == firstValue->nextWord->source->type(c)); firstValue->source->type(c) == firstValue->nextWord->source->type(c));
// if (secondValue->source->type(c) != if (false) {
// secondValue->nextWord->source->type(c)) { if (secondValue->source->type(c)
// fprintf(stderr, "%p %p %d : %p %p %d\n", != secondValue->nextWord->source->type(c)) {
// secondValue, secondValue->source, secondValue->source->type(c), fprintf(stderr,
// secondValue->nextWord, secondValue->nextWord->source, "%p %p %d : %p %p %d\n",
// secondValue->nextWord->source->type(c)); secondValue,
// } secondValue->source,
secondValue->source->type(c),
secondValue->nextWord,
secondValue->nextWord->source,
secondValue->nextWord->source->type(c));
}
}
assertT( assertT(
c, c,
@ -1149,10 +1155,16 @@ class CombineEvent : public Event {
resultHighMask) resultHighMask)
: low); : low);
// fprintf(stderr, "combine %p:%p and %p:%p into %p:%p\n", if (false) {
// firstValue, firstValue->nextWord, fprintf(stderr,
// secondValue, secondValue->nextWord, "combine %p:%p and %p:%p into %p:%p\n",
// resultValue, resultValue->nextWord); firstValue,
firstValue->nextWord,
secondValue,
secondValue->nextWord,
resultValue,
resultValue->nextWord);
}
apply(c, apply(c,
op, op,

View File

@ -123,7 +123,9 @@ void MultiRead::append(Context* c, Read* r)
} }
lastRead = cell; lastRead = cell;
// fprintf(stderr, "append %p to %p for %p\n", r, lastTarget, this); if (false) {
fprintf(stderr, "append %p to %p for %p\n", r, lastTarget, this);
}
lastTarget->item = r; lastTarget->item = r;
} }
@ -137,7 +139,9 @@ void MultiRead::allocateTarget(Context* c)
{ {
List<Read*>* cell = cons<Read*>(c, 0, 0); List<Read*>* cell = cons<Read*>(c, 0, 0);
// fprintf(stderr, "allocate target for %p: %p\n", this, cell); if (false) {
fprintf(stderr, "allocate target for %p: %p\n", this, cell);
}
if (lastTarget) { if (lastTarget) {
lastTarget->next = cell; lastTarget->next = cell;
@ -149,7 +153,9 @@ void MultiRead::allocateTarget(Context* c)
Read* MultiRead::nextTarget() Read* MultiRead::nextTarget()
{ {
// fprintf(stderr, "next target for %p: %p\n", this, firstTarget); if (false) {
fprintf(stderr, "next target for %p: %p\n", this, firstTarget);
}
Read* r = firstTarget->item; Read* r = firstTarget->item;
firstTarget = firstTarget->next; firstTarget = firstTarget->next;

View File

@ -989,8 +989,12 @@ class MyAssembler : public Assembler {
static_cast<target_uintptr_t*>(e->address), static_cast<target_uintptr_t*>(e->address),
e->callOffset ? dst + e->callOffset->value() + 8 : 0); e->callOffset ? dst + e->callOffset->value() + 8 : 0);
} }
// fprintf(stderr, "constant %p at %p\n", if (false) {
// reinterpret_cast<void*>(e->constant->value()), e->address); fprintf(stderr,
"constant %p at %p\n",
reinterpret_cast<void*>(e->constant->value()),
e->address);
}
} }
} }

View File

@ -450,20 +450,18 @@ void nextFrame(MyThread* t,
methodIsMostRecent = false; methodIsMostRecent = false;
} }
// fprintf(stderr, "nextFrame %s.%s%s target %s.%s%s ip %p sp %p\n", if (false) {
// method->class_()->name()->body().begin(), fprintf(stderr,
// method->name()->body().begin(), "nextFrame %s.%s%s target %s.%s%s ip %p sp %p\n",
// method->spec()->body().begin(), method->class_()->name()->body().begin(),
// target method->name()->body().begin(),
// ? &byteArrayBody(t, target->class_()->name(), 0) method->spec()->body().begin(),
// : 0, target ? target->class_()->name()->body().begin() : 0,
// target target ? target->name()->body().begin() : 0,
// ? &byteArrayBody(t, target->name(), 0) target ? target->spec()->body().begin() : 0,
// : 0, *ip,
// target *sp);
// ? &byteArrayBody(t, target->spec(), 0) }
// : 0,
// *ip, *sp);
t->arch->nextFrame(reinterpret_cast<void*>(start), t->arch->nextFrame(reinterpret_cast<void*>(start),
code->compiledSize(), code->compiledSize(),
@ -474,7 +472,9 @@ void nextFrame(MyThread* t,
ip, ip,
sp); sp);
// fprintf(stderr, "next frame ip %p sp %p\n", *ip, *sp); if (false) {
fprintf(stderr, "next frame ip %p sp %p\n", *ip, *sp);
}
} }
void* getIp(MyThread* t, void* ip, void* stack) void* getIp(MyThread* t, void* ip, void* stack)
@ -556,7 +556,9 @@ class MyStackWalker : public Processor::StackWalker {
bool valid() bool valid()
{ {
while (true) { while (true) {
// fprintf(stderr, "state: %d\n", state); if (false) {
fprintf(stderr, "state: %d\n", state);
}
switch (state) { switch (state) {
case Start: case Start:
if (trace and trace->nativeMethod) { if (trace and trace->nativeMethod) {
@ -638,9 +640,12 @@ class MyStackWalker : public Processor::StackWalker {
virtual GcMethod* method() virtual GcMethod* method()
{ {
// fprintf(stderr, "method %s.%s\n", &byteArrayBody if (false) {
// (t, className(t, methodClass(t, method_)), 0), fprintf(stderr,
// &byteArrayBody(t, methodName(t, method_), 0)); "method %s.%s\n",
method_->class_()->name()->body().begin(),
method_->name()->body().begin());
}
return method_; return method_;
} }
@ -3924,8 +3929,6 @@ loop:
c->threadRegister()); c->threadRegister());
} }
// fprintf(stderr, "ip: %d map: %ld\n", ip, *(frame->map));
if (DebugInstructions) { if (DebugInstructions) {
unsigned startingIp = ip; unsigned startingIp = ip;
fprintf(stderr, " stack: ["); fprintf(stderr, " stack: [");
@ -6991,10 +6994,13 @@ void compile(MyThread* t, Context* context)
{ {
avian::codegen::Compiler* c = context->compiler; avian::codegen::Compiler* c = context->compiler;
// fprintf(stderr, "compiling %s.%s%s\n", if (false) {
// context->method->class_()->name()->body().begin(), fprintf(stderr,
// context->method->name()->body().begin(), "compiling %s.%s%s\n",
// context->method->spec()->body().begin()); context->method->class_()->name()->body().begin(),
context->method->name()->body().begin(),
context->method->spec()->body().begin());
}
unsigned footprint = context->method->parameterFootprint(); unsigned footprint = context->method->parameterFootprint();
unsigned locals = localSize(t, context->method); unsigned locals = localSize(t, context->method);
@ -9527,8 +9533,13 @@ void fixupHeap(MyThread* t UNUSED,
if (number) { if (number) {
*p = reinterpret_cast<uintptr_t>(heap + (number - 1)) | mark; *p = reinterpret_cast<uintptr_t>(heap + (number - 1)) | mark;
// fprintf(stderr, "fixup %d: %d 0x%x\n", index, if (false) {
// static_cast<unsigned>(number), static_cast<unsigned>(*p)); fprintf(stderr,
"fixup %d: %d 0x%x\n",
index,
static_cast<unsigned>(number),
static_cast<unsigned>(*p));
}
} else { } else {
*p = mark; *p = mark;
} }
@ -9675,14 +9686,19 @@ void boot(MyThread* t, BootImage* image, uint8_t* code)
t->heapImage = p->heapImage = heap; t->heapImage = p->heapImage = heap;
// fprintf(stderr, "heap from %p to %p\n", if (false) {
// heap, heap + ceilingDivide(image->heapSize, BytesPerWord)); fprintf(stderr,
"heap from %p to %p\n",
heap,
heap + ceilingDivide(image->heapSize, BytesPerWord));
}
t->codeImage = p->codeImage = code; t->codeImage = p->codeImage = code;
p->codeImageSize = image->codeSize; p->codeImageSize = image->codeSize;
// fprintf(stderr, "code from %p to %p\n", if (false) {
// code, code + image->codeSize); fprintf(stderr, "code from %p to %p\n", code, code + image->codeSize);
}
if (not image->initialized) { if (not image->initialized) {
fixupHeap(t, heapMap, heapMapSizeInWords, heap); fixupHeap(t, heapMap, heapMapSizeInWords, heap);

View File

@ -3088,9 +3088,14 @@ uint64_t registerNatives(Thread* t, uintptr_t* arguments)
// case, but that would prevent using a code shrinker like // case, but that would prevent using a code shrinker like
// ProGuard effectively. Instead, we just ignore it. // ProGuard effectively. Instead, we just ignore it.
// fprintf(stderr, "not found: %s.%s%s\n", &byteArrayBody(t, if (false) {
// className(t, (*c)->vmClass()), 0), methods[i].name, sig); fprintf(stderr,
// abort(t); "not found: %s.%s%s\n",
(*c)->vmClass()->name()->body().begin(),
methods[i].name,
sig);
abort(t);
}
} else { } else {
registerNative(t, method, methods[i].function); registerNative(t, method, methods[i].function);
} }

View File

@ -3536,16 +3536,18 @@ object findInTable(Thread* t,
} }
} }
// fprintf(stderr, "%s %s not in\n", if (false) {
// name->body().begin(), fprintf(
// spec->body().begin(); stderr, "%s %s not in\n", name->body().begin(), spec->body().begin());
// for (unsigned i = 0; i < arrayLength(t, table); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
// object o = arrayBody(t, table, i); object o = table->body()[i];
// fprintf(stderr, "\t%s %s\n", fprintf(stderr,
// &byteArrayBody(t, getName(t, o), 0), "\t%s %s\n",
// &byteArrayBody(t, getSpec(t, o), 0)); getName(t, o)->body().begin(),
// } getSpec(t, o)->body().begin());
}
}
} }
return 0; return 0;

View File

@ -354,7 +354,9 @@ GcTriple* makeCodeImage(Thread* t,
if (endsWith(".class", name, nameSize) if (endsWith(".class", name, nameSize)
and (className == 0 or strncmp(name, className, nameSize - 6) == 0)) { and (className == 0 or strncmp(name, className, nameSize - 6) == 0)) {
// fprintf(stderr, "pass 1 %.*s\n", nameSize - 6, name); if (false) {
fprintf(stderr, "pass 1 %.*s\n", nameSize - 6, name);
}
GcClass* c GcClass* c
= resolveSystemClass(t, = resolveSystemClass(t,
roots(t)->bootLoader(), roots(t)->bootLoader(),
@ -690,7 +692,9 @@ GcTriple* makeCodeImage(Thread* t,
if (endsWith(".class", name, nameSize) if (endsWith(".class", name, nameSize)
and (className == 0 or strncmp(name, className, nameSize - 6) == 0)) { and (className == 0 or strncmp(name, className, nameSize - 6) == 0)) {
// fprintf(stderr, "pass 2 %.*s\n", nameSize - 6, name); if (false) {
fprintf(stderr, "pass 2 %.*s\n", nameSize - 6, name);
}
GcClass* c = 0; GcClass* c = 0;
PROTECT(t, c); PROTECT(t, c);