fix aliasing warnings

This commit is contained in:
Joel Dice 2007-10-28 18:51:38 -06:00
parent 09cedfd7cb
commit a80677d673
2 changed files with 13 additions and 9 deletions

View File

@ -112,7 +112,7 @@ ifeq ($(mode),stress-major)
cflags += -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR cflags += -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
endif endif
ifeq ($(mode),fast) ifeq ($(mode),fast)
cflags += -O3 -DNDEBUG cflags += -O3 -g3 -DNDEBUG
strip = strip strip = strip
show-size = ls -l show-size = ls -l
endif endif

View File

@ -419,8 +419,12 @@ class Fixie {
add(handle); add(handle);
} }
void** body() {
return static_cast<void**>(static_cast<void*>(body_));
}
uintptr_t* mask(unsigned size) { uintptr_t* mask(unsigned size) {
return body + size; return body_ + size;
} }
static unsigned maskSize(unsigned size, bool hasMask) { static unsigned maskSize(unsigned size, bool hasMask) {
@ -441,7 +445,7 @@ class Fixie {
bool dirty; bool dirty;
Fixie* next; Fixie* next;
Fixie** handle; Fixie** handle;
uintptr_t body[0]; uintptr_t body_[0];
}; };
Fixie* Fixie*
@ -686,7 +690,7 @@ sweepFixies(Context* c)
Fixie* f = *p; Fixie* f = *p;
*p = f->next; *p = f->next;
unsigned size = c->client->sizeInWords(f->body); unsigned size = c->client->sizeInWords(f->body());
++ f->age; ++ f->age;
if (f->age > FixieTenureThreshold) { if (f->age > FixieTenureThreshold) {
@ -1156,14 +1160,14 @@ visitDirtyFixies(Context* c)
Fixie* f = *p; Fixie* f = *p;
*p = f->next; *p = f->next;
unsigned size = c->client->sizeInWords(f->body); unsigned size = c->client->sizeInWords(f->body());
uintptr_t* mask = f->mask(size); uintptr_t* mask = f->mask(size);
for (unsigned word = 0; word < wordOf(size); ++ word) { for (unsigned word = 0; word < wordOf(size); ++ word) {
if (mask[word]) { if (mask[word]) {
for (unsigned bit = 0; bit < bitOf(size); ++ bit) { for (unsigned bit = 0; bit < bitOf(size); ++ bit) {
unsigned index = indexOf(word, bit); unsigned index = indexOf(word, bit);
if (getBit(mask, index)) { if (getBit(mask, index)) {
collect(c, reinterpret_cast<void**>(f->body) + index); collect(c, f->body() + index);
} }
} }
} }
@ -1199,9 +1203,9 @@ visitMarkedFixies(Context* c)
Context* c; Context* c;
void** p; void** p;
} w(c, reinterpret_cast<void**>(f->body)); } w(c, f->body());
c->client->walk(reinterpret_cast<void**>(f->body), &w); c->client->walk(f->body(), &w);
f->move(&(c->visitedFixies)); f->move(&(c->visitedFixies));
} }
@ -1352,7 +1356,7 @@ class MyHeap: public Heap {
{ {
*totalInBytes = Fixie::totalSize(sizeInWords, objectMask); *totalInBytes = Fixie::totalSize(sizeInWords, objectMask);
return (new (c.system->allocate(*totalInBytes)) return (new (c.system->allocate(*totalInBytes))
Fixie(sizeInWords, objectMask, &(c.fixies)))->body; Fixie(sizeInWords, objectMask, &(c.fixies)))->body();
} }
virtual bool needsMark(void* p) { virtual bool needsMark(void* p) {