diff --git a/src/avian/machine.h b/src/avian/machine.h index f509758960..358289a1ed 100644 --- a/src/avian/machine.h +++ b/src/avian/machine.h @@ -1703,9 +1703,6 @@ bool instanceOf(Thread* t, GcClass* class_, object o); template T* GcObject::as(Thread* t UNUSED) { - if (this == 0) { - return 0; - } assertT(t, t->m->unsafe || instanceOf(t, reinterpret_cast(arrayBodyUnsafe( diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index 10f572fb0f..24ac8c9239 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -1909,9 +1909,7 @@ void setStubRead(Context* c, StubReadPair* p, Value* v) if (DebugReads) { fprintf(stderr, "add stub read %p to %p\n", r, v); } - // TODO: this is rather icky looking... but despite how it looks, it will - // not cause an NPE - ((Event*)0)->addRead(c, v, r); + finishAddRead(c, v, r); p->value = v; p->read = r; @@ -2113,9 +2111,7 @@ void addForkElement(Context* c, Value* v, ForkState* state, unsigned index) if (DebugReads) { fprintf(stderr, "add multi read %p to %p\n", r, v); } - // TODO: this is rather icky looking... but despite how it looks, it will not - // cause an NPE - ((Event*)0)->addRead(c, v, r); + finishAddRead(c, v, r); ForkElement* p = state->elements + index; p->value = v; diff --git a/src/codegen/compiler/event.cpp b/src/codegen/compiler/event.cpp index 47e82c7ab5..49c406c08e 100644 --- a/src/codegen/compiler/event.cpp +++ b/src/codegen/compiler/event.cpp @@ -136,16 +136,20 @@ void Event::addRead(Context* c, Value* v, Read* r) v, v->lastRead, this, - (this ? this->name() : 0)); + this->name()); } + r->event = this; + r->eventNext = this->reads; + this->reads = r; + ++this->readCount; + + finishAddRead(c, v, r); +} + +void finishAddRead(Context* c, Value* v, Read* r) +{ r->value = v; - if (this) { - r->event = this; - r->eventNext = this->reads; - this->reads = r; - ++this->readCount; - } if (v->lastRead) { if (DebugReads) { diff --git a/src/codegen/compiler/event.h b/src/codegen/compiler/event.h index 25e2ce75b8..8aa68bec11 100644 --- a/src/codegen/compiler/event.h +++ b/src/codegen/compiler/event.h @@ -90,6 +90,8 @@ class Event { unsigned readCount; }; +void finishAddRead(Context* c, Value* v, Read* r); + class StubReadPair { public: Value* value; diff --git a/src/compile.cpp b/src/compile.cpp index 56830b2eb0..18fc34b797 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -8266,11 +8266,11 @@ class CompilationHandlerList { void dispose(Allocator* allocator) { - if (this) { + if (next) { next->dispose(allocator); - handler->dispose(); - allocator->free(this, sizeof(*this)); } + handler->dispose(); + allocator->free(this, sizeof(*this)); } CompilationHandlerList* next; @@ -8804,7 +8804,9 @@ class MyProcessor : public Processor { #endif } - compilationHandlers->dispose(allocator); + if(compilationHandlers) { + compilationHandlers->dispose(allocator); + } signals.unregisterHandler(SignalRegistrar::SegFault); signals.unregisterHandler(SignalRegistrar::DivideByZero); diff --git a/src/tools/binary-to-object/main.cpp b/src/tools/binary-to-object/main.cpp index aa713f98e5..a6b25ae137 100644 --- a/src/tools/binary-to-object/main.cpp +++ b/src/tools/binary-to-object/main.cpp @@ -35,7 +35,7 @@ void* operator new(size_t size) return malloc(size); } -void operator delete(void*) +void operator delete(void*) throw() { abort(); }