diff --git a/src/common.h b/src/common.h index 33e960cd44..4aa47d7ab8 100644 --- a/src/common.h +++ b/src/common.h @@ -483,7 +483,7 @@ cast(void* p, unsigned offset) template inline T* -mask(T* p) +maskAlignedPointer(T* p) { return reinterpret_cast(reinterpret_cast(p) & PointerMask); } diff --git a/src/heap.cpp b/src/heap.cpp index 39e1b3c572..5c87de8b88 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -80,7 +80,7 @@ markBitAtomic(uintptr_t* map, unsigned i) inline void* get(void* o, unsigned offsetInWords) { - return mask(cast(o, offsetInWords * BytesPerWord)); + return maskAlignedPointer(cast(o, offsetInWords * BytesPerWord)); } inline void** @@ -1179,12 +1179,12 @@ updateHeapMap(Context* c, void* p, void* target, unsigned offset, void* result) void* update(Context* c, void** p, void* target, unsigned offset, bool* needsVisit) { - if (mask(*p) == 0) { + if (maskAlignedPointer(*p) == 0) { *needsVisit = false; return 0; } - void* result = update2(c, mask(*p), needsVisit); + void* result = update2(c, maskAlignedPointer(*p), needsVisit); if (result) { updateHeapMap(c, p, target, offset, result); @@ -1297,20 +1297,20 @@ bitsetNext(Context* c, uintptr_t* p) void collect(Context* c, void** p, void* target, unsigned offset) { - void* original = mask(*p); + void* original = maskAlignedPointer(*p); void* parent_ = 0; if (Debug) { fprintf(stderr, "update %p (%s) at %p (%s)\n", - mask(*p), segment(c, *p), p, segment(c, p)); + maskAlignedPointer(*p), segment(c, *p), p, segment(c, p)); } bool needsVisit; - local::set(p, update(c, mask(p), target, offset, &needsVisit)); + local::set(p, update(c, maskAlignedPointer(p), target, offset, &needsVisit)); if (Debug) { fprintf(stderr, " result: %p (%s) (visit? %d)\n", - mask(*p), segment(c, *p), needsVisit); + maskAlignedPointer(*p), segment(c, *p), needsVisit); } if (not needsVisit) return; @@ -1966,10 +1966,10 @@ class MyHeap: public Heap { bool dirty = false; for (unsigned i = 0; i < count; ++i) { void** target = static_cast(p) + offset + i; - if (targetNeedsMark(mask(*target))) { + if (targetNeedsMark(maskAlignedPointer(*target))) { if (DebugFixies) { fprintf(stderr, "dirty fixie %p at %d (%p): %p\n", - f, offset, f->body() + offset, mask(*target)); + f, offset, f->body() + offset, maskAlignedPointer(*target)); } dirty = true; @@ -1994,7 +1994,7 @@ class MyHeap: public Heap { for (unsigned i = 0; i < count; ++i) { void** target = static_cast(p) + offset + i; - if (targetNeedsMark(mask(*target))) { + if (targetNeedsMark(maskAlignedPointer(*target))) { #ifdef USE_ATOMIC_OPERATIONS map->markAtomic(target); #else @@ -2041,7 +2041,7 @@ class MyHeap: public Heap { } virtual Status status(void* p) { - p = mask(p); + p = maskAlignedPointer(p); if (p == 0) { return Null; diff --git a/src/machine.cpp b/src/machine.cpp index 6660ae891e..eda7f87259 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2763,7 +2763,7 @@ class HeapClient: public Heap::Client { virtual unsigned sizeInWords(void* p) { Thread* t = m->rootThread; - object o = static_cast(m->heap->follow(mask(p))); + object o = static_cast(m->heap->follow(maskAlignedPointer(p))); unsigned n = baseSize(t, o, static_cast (m->heap->follow(objectClass(t, o)))); @@ -2778,7 +2778,7 @@ class HeapClient: public Heap::Client { virtual unsigned copiedSizeInWords(void* p) { Thread* t = m->rootThread; - object o = static_cast(m->heap->follow(mask(p))); + object o = static_cast(m->heap->follow(maskAlignedPointer(p))); assert(t, not objectFixed(t, o)); unsigned n = baseSize(t, o, static_cast @@ -2794,7 +2794,7 @@ class HeapClient: public Heap::Client { virtual void copy(void* srcp, void* dstp) { Thread* t = m->rootThread; - object src = static_cast(m->heap->follow(mask(srcp))); + object src = static_cast(m->heap->follow(maskAlignedPointer(srcp))); assert(t, not objectFixed(t, src)); object class_ = static_cast @@ -2815,7 +2815,7 @@ class HeapClient: public Heap::Client { } virtual void walk(void* p, Heap::Walker* w) { - object o = static_cast(m->heap->follow(mask(p))); + object o = static_cast(m->heap->follow(maskAlignedPointer(p))); ::walk(m->rootThread, w, o, 0); } diff --git a/src/machine.h b/src/machine.h index c315661ddb..e972a3be9d 100644 --- a/src/machine.h +++ b/src/machine.h @@ -1611,7 +1611,7 @@ typedef uint64_t (JNICALL *FastNativeFunction)(Thread*, object, uintptr_t*); inline object objectClass(Thread*, object o) { - return mask(cast(o, 0)); + return maskAlignedPointer(cast(o, 0)); } inline unsigned