diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 51ddc5d866..894871af83 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -740,7 +740,7 @@ targetSize(Thread* t, object typeMaps, object p) if (map->targetArrayElementSizeInBytes) { return map->targetFixedSizeInWords + ceilingDivide(map->targetArrayElementSizeInBytes - * cast + * fieldAtOffset (p, (map->buildFixedSizeInWords - 1) * BytesPerWord), TargetBytesPerWord); } else { @@ -888,7 +888,7 @@ nonObjectsEqual(TypeMap* map, uint8_t* src, uint8_t* dst) if (map->targetArrayElementSizeInBytes) { unsigned fixedSize = map->buildFixedSizeInWords * BytesPerWord; - unsigned count = cast(src, fixedSize - BytesPerWord); + unsigned count = fieldAtOffset(src, fixedSize - BytesPerWord); for (unsigned i = 0; i < count; ++i) { if (not nonObjectsEqual @@ -919,7 +919,7 @@ copy(Thread* t, object typeMaps, object p, uint8_t* dst) if (map->targetArrayElementSizeInBytes) { unsigned fixedSize = map->buildFixedSizeInWords * BytesPerWord; - unsigned count = cast(p, fixedSize - BytesPerWord); + unsigned count = fieldAtOffset(p, fixedSize - BytesPerWord); for (unsigned i = 0; i < count; ++i) { copy(t, src + fixedSize + (i * map->buildArrayElementSizeInBytes), diff --git a/src/builtin.cpp b/src/builtin.cpp index 845c0cebe1..1edec99bef 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -365,7 +365,7 @@ Avian_sun_misc_Unsafe_setMemory ACQUIRE(t, t->m->referenceLock); if (base) { - memset(&cast(base, offset), value, count); + memset(&fieldAtOffset(base, offset), value, count); } else { memset(reinterpret_cast(offset), value, count); } @@ -528,11 +528,11 @@ Avian_sun_misc_Unsafe_copyMemory ACQUIRE(t, t->m->referenceLock); void* src = srcBase - ? &cast(srcBase, srcOffset) + ? &fieldAtOffset(srcBase, srcOffset) : reinterpret_cast(srcOffset); void* dst = dstBase - ? &cast(dstBase, dstOffset) + ? &fieldAtOffset(dstBase, dstOffset) : reinterpret_cast(dstOffset); memcpy(dst, src, count); diff --git a/src/classpath-avian.cpp b/src/classpath-avian.cpp index 703332c518..09fca657ef 100644 --- a/src/classpath-avian.cpp +++ b/src/classpath-avian.cpp @@ -250,21 +250,21 @@ Avian_java_lang_reflect_Field_getPrimitive switch (code) { case ByteField: - return cast(instance, offset); + return fieldAtOffset(instance, offset); case BooleanField: - return cast(instance, offset); + return fieldAtOffset(instance, offset); case CharField: - return cast(instance, offset); + return fieldAtOffset(instance, offset); case ShortField: - return cast(instance, offset); + return fieldAtOffset(instance, offset); case IntField: - return cast(instance, offset); + return fieldAtOffset(instance, offset); case LongField: - return cast(instance, offset); + return fieldAtOffset(instance, offset); case FloatField: - return cast(instance, offset); + return fieldAtOffset(instance, offset); case DoubleField: - return cast(instance, offset); + return fieldAtOffset(instance, offset); default: abort(t); } @@ -277,7 +277,7 @@ Avian_java_lang_reflect_Field_getObject object instance = reinterpret_cast(arguments[0]); int offset = arguments[1]; - return reinterpret_cast(cast(instance, offset)); + return reinterpret_cast(fieldAtOffset(instance, offset)); } extern "C" JNIEXPORT void JNICALL @@ -291,28 +291,28 @@ Avian_java_lang_reflect_Field_setPrimitive switch (code) { case ByteField: - cast(instance, offset) = static_cast(value); + fieldAtOffset(instance, offset) = static_cast(value); break; case BooleanField: - cast(instance, offset) = static_cast(value); + fieldAtOffset(instance, offset) = static_cast(value); break; case CharField: - cast(instance, offset) = static_cast(value); + fieldAtOffset(instance, offset) = static_cast(value); break; case ShortField: - cast(instance, offset) = static_cast(value); + fieldAtOffset(instance, offset) = static_cast(value); break; case IntField: - cast(instance, offset) = static_cast(value); + fieldAtOffset(instance, offset) = static_cast(value); break; case LongField: - cast(instance, offset) = static_cast(value); + fieldAtOffset(instance, offset) = static_cast(value); break; case FloatField: - cast(instance, offset) = static_cast(value); + fieldAtOffset(instance, offset) = static_cast(value); break; case DoubleField: - cast(instance, offset) = static_cast(value); + fieldAtOffset(instance, offset) = static_cast(value); break; default: abort(t); @@ -379,7 +379,7 @@ Avian_java_lang_reflect_Array_getLength unsigned elementSize = classArrayElementSize(t, objectClass(t, array)); if (LIKELY(elementSize)) { - return cast(array, BytesPerWord); + return fieldAtOffset(array, BytesPerWord); } else { throwNew(t, Machine::IllegalArgumentExceptionType); } @@ -666,7 +666,7 @@ Avian_avian_Atomic_compareAndSwapObject uintptr_t update = arguments[4]; bool success = atomicCompareAndSwap - (&cast(target, offset), expect, update); + (&fieldAtOffset(target, offset), expect, update); if (success) { mark(t, target, offset); diff --git a/src/classpath-common.h b/src/classpath-common.h index aff9f8c40c..dad0fd3559 100644 --- a/src/classpath-common.h +++ b/src/classpath-common.h @@ -77,14 +77,14 @@ arrayCopy(Thread* t, object src, int32_t srcOffset, object dst, unsigned elementSize = classArrayElementSize(t, objectClass(t, src)); if (LIKELY(elementSize)) { - intptr_t sl = cast(src, BytesPerWord); - intptr_t dl = cast(dst, BytesPerWord); + intptr_t sl = fieldAtOffset(src, BytesPerWord); + intptr_t dl = fieldAtOffset(dst, BytesPerWord); if (LIKELY(length > 0)) { if (LIKELY(srcOffset >= 0 and srcOffset + length <= sl and dstOffset >= 0 and dstOffset + length <= dl)) { - uint8_t* sbody = &cast(src, ArrayBody); - uint8_t* dbody = &cast(dst, ArrayBody); + uint8_t* sbody = &fieldAtOffset(src, ArrayBody); + uint8_t* dbody = &fieldAtOffset(dst, ArrayBody); if (src == dst) { memmove(dbody + (dstOffset * elementSize), sbody + (srcOffset * elementSize), diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index cab2d85ba0..074f3cf5f3 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -709,7 +709,7 @@ class MyClasspath : public Classpath { set(t, classStaticTable(t, type(t, Machine::ClassLoaderType)), fieldOffset(t, scl), root(t, Machine::AppLoader)); - cast(classStaticTable(t, type(t, Machine::ClassLoaderType)), + fieldAtOffset(classStaticTable(t, type(t, Machine::ClassLoaderType)), fieldOffset(t, sclSet)) = true; } @@ -950,7 +950,7 @@ getFileAttributes MyClasspath* cp = static_cast(t->m->classpath); object file = reinterpret_cast(arguments[1]); - object path = cast(file, cp->filePathField); + object path = fieldAtOffset(file, cp->filePathField); THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1); stringChars(t, path, RUNTIME_ARRAY_BODY(p)); @@ -999,7 +999,7 @@ checkFileAccess object file = reinterpret_cast(arguments[1]); unsigned mask = arguments[2]; - object path = cast(file, cp->filePathField); + object path = fieldAtOffset(file, cp->filePathField); THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1); stringChars(t, path, RUNTIME_ARRAY_BODY(p)); @@ -1045,7 +1045,7 @@ getFileLength MyClasspath* cp = static_cast(t->m->classpath); object file = reinterpret_cast(arguments[1]); - object path = cast(file, cp->filePathField); + object path = fieldAtOffset(file, cp->filePathField); THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1); stringChars(t, path, RUNTIME_ARRAY_BODY(p)); @@ -1131,8 +1131,8 @@ openFile(Thread* t, object method, uintptr_t* arguments) set(t, root(t, Machine::VirtualFiles), ArrayBody + (index * BytesPerWord), region); - cast - (cast + fieldAtOffset + (fieldAtOffset (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField) = index + VirtualFileBase; } else { @@ -1150,8 +1150,8 @@ readByteFromFile(Thread* t, object method, uintptr_t* arguments) MyClasspath* cp = static_cast(t->m->classpath); - int fd = cast - (cast + int fd = fieldAtOffset + (fieldAtOffset (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField); if (fd >= VirtualFileBase) { @@ -1191,8 +1191,8 @@ readBytesFromFile(Thread* t, object method, uintptr_t* arguments) MyClasspath* cp = static_cast(t->m->classpath); - int fd = cast - (cast + int fd = fieldAtOffset + (fieldAtOffset (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField); if (fd >= VirtualFileBase) { @@ -1243,8 +1243,8 @@ skipBytesInFile(Thread* t, object method, uintptr_t* arguments) MyClasspath* cp = static_cast(t->m->classpath); - int fd = cast - (cast + int fd = fieldAtOffset + (fieldAtOffset (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField); if (fd >= VirtualFileBase) { @@ -1284,8 +1284,8 @@ availableBytesInFile(Thread* t, object method, uintptr_t* arguments) MyClasspath* cp = static_cast(t->m->classpath); - int fd = cast - (cast + int fd = fieldAtOffset + (fieldAtOffset (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField); if (fd >= VirtualFileBase) { @@ -1317,8 +1317,8 @@ closeFile(Thread* t, object method, uintptr_t* arguments) MyClasspath* cp = static_cast(t->m->classpath); - int fd = cast - (cast + int fd = fieldAtOffset + (fieldAtOffset (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField); if (fd >= VirtualFileBase) { @@ -1623,15 +1623,15 @@ initializeZipEntryFields(Thread* t, object method, uintptr_t* arguments) set(t, this_, cp->zipEntryNameField, name); - cast(this_, cp->zipEntryTimeField) + fieldAtOffset(this_, cp->zipEntryTimeField) = fileTime(entry->start); - cast(this_, cp->zipEntryCrcField) + fieldAtOffset(this_, cp->zipEntryCrcField) = fileCRC(entry->start); - cast(this_, cp->zipEntrySizeField) + fieldAtOffset(this_, cp->zipEntrySizeField) = uncompressedSize(entry->start); - cast(this_, cp->zipEntryCsizeField) + fieldAtOffset(this_, cp->zipEntryCsizeField) = compressedSize(entry->start); - cast(this_, cp->zipEntryMethodField) + fieldAtOffset(this_, cp->zipEntryMethodField) = compressionMethod(entry->start); } else { t->m->processor->invoke @@ -1771,7 +1771,7 @@ getJarFileMetaInfEntryNames(Thread* t, object method, uintptr_t* arguments) MyClasspath* cp = static_cast(t->m->classpath); - int64_t peer = cast(this_, cp->zipFileJzfileField); + int64_t peer = fieldAtOffset(this_, cp->zipFileJzfileField); ZipFile* file = reinterpret_cast(peer); if (file->region) { return 0; @@ -2839,7 +2839,7 @@ Avian_sun_misc_Unsafe_getObject object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - return cast(o, offset); + return fieldAtOffset(o, offset); } extern "C" JNIEXPORT void JNICALL @@ -2860,7 +2860,7 @@ Avian_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - return cast(o, offset); + return fieldAtOffset(o, offset); } extern "C" JNIEXPORT int64_t JNICALL @@ -2870,7 +2870,7 @@ Avian_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - return cast(o, offset); + return fieldAtOffset(o, offset); } extern "C" JNIEXPORT int64_t JNICALL @@ -2880,7 +2880,7 @@ Avian_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - return cast(o, offset); + return fieldAtOffset(o, offset); } extern "C" JNIEXPORT int64_t JNICALL @@ -2890,7 +2890,7 @@ Avian_sun_misc_Unsafe_getIntVolatile object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - int32_t result = cast(o, offset); + int32_t result = fieldAtOffset(o, offset); loadMemoryBarrier(); return result; } @@ -2902,7 +2902,7 @@ Avian_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - return cast(o, offset); + return fieldAtOffset(o, offset); } extern "C" JNIEXPORT int64_t JNICALL @@ -2928,7 +2928,7 @@ Avian_sun_misc_Unsafe_getLongVolatile acquire(t, field); } - int64_t result = cast(o, offset); + int64_t result = fieldAtOffset(o, offset); if (BytesPerWord < 8) { release(t, field); @@ -2947,7 +2947,7 @@ Avian_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB int64_t offset; memcpy(&offset, arguments + 2, 8); int8_t value = arguments[4]; - cast(o, offset) = value; + fieldAtOffset(o, offset) = value; } extern "C" JNIEXPORT void JNICALL @@ -2958,7 +2958,7 @@ Avian_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS int64_t offset; memcpy(&offset, arguments + 2, 8); int16_t value = arguments[4]; - cast(o, offset) = value; + fieldAtOffset(o, offset) = value; } extern "C" JNIEXPORT void JNICALL @@ -2969,7 +2969,7 @@ Avian_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI int64_t offset; memcpy(&offset, arguments + 2, 8); int32_t value = arguments[4]; - cast(o, offset) = value; + fieldAtOffset(o, offset) = value; } extern "C" JNIEXPORT void JNICALL @@ -2980,7 +2980,7 @@ Avian_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF int64_t offset; memcpy(&offset, arguments + 2, 8); int32_t value = arguments[4]; - cast(o, offset) = value; + fieldAtOffset(o, offset) = value; } extern "C" JNIEXPORT int64_t JNICALL @@ -2990,7 +2990,7 @@ Avian_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - return cast(o, offset); + return fieldAtOffset(o, offset); } extern "C" JNIEXPORT int64_t JNICALL @@ -3009,7 +3009,7 @@ Avian_sun_misc_Unsafe_putBoolean__Ljava_lang_Object_2JZ int64_t offset; memcpy(&offset, arguments + 2, 8); uint8_t value = arguments[4]; - cast(o, offset) = value; + fieldAtOffset(o, offset) = value; } extern "C" JNIEXPORT void JNICALL @@ -3020,7 +3020,7 @@ Avian_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ int64_t offset; memcpy(&offset, arguments + 2, 8); int64_t value; memcpy(&value, arguments + 4, 8); - cast(o, offset) = value; + fieldAtOffset(o, offset) = value; } extern "C" JNIEXPORT int64_t JNICALL @@ -3030,7 +3030,7 @@ Avian_sun_misc_Unsafe_getObjectVolatile object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - uintptr_t value = cast(o, offset); + uintptr_t value = fieldAtOffset(o, offset); loadMemoryBarrier(); return value; } @@ -3065,7 +3065,7 @@ Avian_sun_misc_Unsafe_compareAndSwapInt uint32_t update = arguments[5]; return atomicCompareAndSwap32 - (&cast(target, offset), expect, update); + (&fieldAtOffset(target, offset), expect, update); } extern "C" JNIEXPORT int64_t JNICALL @@ -3078,7 +3078,7 @@ Avian_sun_misc_Unsafe_compareAndSwapObject uintptr_t update = arguments[5]; bool success = atomicCompareAndSwap - (&cast(target, offset), expect, update); + (&fieldAtOffset(target, offset), expect, update); if (success) { mark(t, target, offset); @@ -3098,11 +3098,11 @@ Avian_sun_misc_Unsafe_compareAndSwapLong #ifdef AVIAN_HAS_CAS64 return atomicCompareAndSwap64 - (&cast(target, offset), expect, update); + (&fieldAtOffset(target, offset), expect, update); #else ACQUIRE_FIELD_FOR_WRITE(t, local::fieldForOffset(t, target, offset)); - if (cast(target, offset) == expect) { - cast(target, offset) = update; + if (fieldAtOffset(target, offset) == expect) { + fieldAtOffset(target, offset) = update; return true; } else { return false; @@ -3999,7 +3999,7 @@ EXPORT(JVM_GetArrayLength)(Thread* t, jobject array) { ENTER(t, Thread::ActiveState); - return cast(*array, BytesPerWord); + return fieldAtOffset(*array, BytesPerWord); } uint64_t @@ -4012,40 +4012,40 @@ jvmGetArrayElement(Thread* t, uintptr_t* arguments) case 'Z': return reinterpret_cast (makeLocalReference - (t, makeBoolean(t, cast(*array, ArrayBody + index)))); + (t, makeBoolean(t, fieldAtOffset(*array, ArrayBody + index)))); case 'B': return reinterpret_cast (makeLocalReference - (t, makeByte(t, cast(*array, ArrayBody + index)))); + (t, makeByte(t, fieldAtOffset(*array, ArrayBody + index)))); case 'C': return reinterpret_cast (makeLocalReference - (t, makeChar(t, cast(*array, ArrayBody + (index * 2))))); + (t, makeChar(t, fieldAtOffset(*array, ArrayBody + (index * 2))))); case 'S': return reinterpret_cast (makeLocalReference - (t, makeShort(t, cast(*array, ArrayBody + (index * 2))))); + (t, makeShort(t, fieldAtOffset(*array, ArrayBody + (index * 2))))); case 'I': return reinterpret_cast (makeLocalReference - (t, makeInt(t, cast(*array, ArrayBody + (index * 4))))); + (t, makeInt(t, fieldAtOffset(*array, ArrayBody + (index * 4))))); case 'F': return reinterpret_cast (makeLocalReference - (t, makeFloat(t, cast(*array, ArrayBody + (index * 4))))); + (t, makeFloat(t, fieldAtOffset(*array, ArrayBody + (index * 4))))); case 'J': return reinterpret_cast (makeLocalReference - (t, makeLong(t, cast(*array, ArrayBody + (index * 8))))); + (t, makeLong(t, fieldAtOffset(*array, ArrayBody + (index * 8))))); case 'D': return reinterpret_cast (makeLocalReference - (t, makeDouble(t, cast(*array, ArrayBody + (index * 8))))); + (t, makeDouble(t, fieldAtOffset(*array, ArrayBody + (index * 8))))); case 'L': case '[': return reinterpret_cast (makeLocalReference - (t, cast(*array, ArrayBody + (index * BytesPerWord)))); + (t, fieldAtOffset(*array, ArrayBody + (index * BytesPerWord)))); default: abort(t); } @@ -4071,28 +4071,28 @@ EXPORT(JVM_SetArrayElement)(Thread* t, jobject array, jint index, switch (byteArrayBody(t, className(t, objectClass(t, *array)), 1)) { case 'Z': - cast(*array, ArrayBody + index) = booleanValue(t, *value); + fieldAtOffset(*array, ArrayBody + index) = booleanValue(t, *value); break; case 'B': - cast(*array, ArrayBody + index) = byteValue(t, *value); + fieldAtOffset(*array, ArrayBody + index) = byteValue(t, *value); break; case 'C': - cast(*array, ArrayBody + (index * 2)) = charValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 2)) = charValue(t, *value); break; case 'S': - cast(*array, ArrayBody + (index * 2)) = shortValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 2)) = shortValue(t, *value); break; case 'I': - cast(*array, ArrayBody + (index * 4)) = intValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 4)) = intValue(t, *value); break; case 'F': - cast(*array, ArrayBody + (index * 4)) = floatValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 4)) = floatValue(t, *value); break; case 'J': - cast(*array, ArrayBody + (index * 8)) = longValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 8)) = longValue(t, *value); break; case 'D': - cast(*array, ArrayBody + (index * 8)) = doubleValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 8)) = doubleValue(t, *value); break; case 'L': case '[': @@ -5059,7 +5059,7 @@ jvmConstantPoolGetUTF8At(Thread* t, uintptr_t* arguments) return reinterpret_cast (makeLocalReference (t, t->m->classpath->makeString - (t, array, 0, cast(array, BytesPerWord) - 1))); + (t, array, 0, fieldAtOffset(array, BytesPerWord) - 1))); } extern "C" JNIEXPORT jstring JNICALL diff --git a/src/common.h b/src/common.h index 4aa47d7ab8..3032bafae7 100644 --- a/src/common.h +++ b/src/common.h @@ -476,7 +476,7 @@ getBits(T* map, unsigned bitsPerRecord, unsigned index) template inline T& -cast(void* p, unsigned offset) +fieldAtOffset(void* p, unsigned offset) { return *reinterpret_cast(static_cast(p) + offset); } diff --git a/src/compile.cpp b/src/compile.cpp index 365ea267b4..9e387aff19 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -3047,22 +3047,22 @@ getFieldValue(Thread* t, object target, object field) switch (fieldCode(t, field)) { case ByteField: case BooleanField: - return cast(target, fieldOffset(t, field)); + return fieldAtOffset(target, fieldOffset(t, field)); case CharField: case ShortField: - return cast(target, fieldOffset(t, field)); + return fieldAtOffset(target, fieldOffset(t, field)); case FloatField: case IntField: - return cast(target, fieldOffset(t, field)); + return fieldAtOffset(target, fieldOffset(t, field)); case DoubleField: case LongField: - return cast(target, fieldOffset(t, field)); + return fieldAtOffset(target, fieldOffset(t, field)); case ObjectField: - return cast(target, fieldOffset(t, field)); + return fieldAtOffset(target, fieldOffset(t, field)); default: abort(t); @@ -3105,7 +3105,7 @@ setStaticLongFieldValueFromReference(MyThread* t, object pair, uint64_t value) ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, fieldClass(t, field)), fieldOffset(t, field)) = value; } @@ -3120,7 +3120,7 @@ setLongFieldValueFromReference(MyThread* t, object pair, object instance, ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(instance, fieldOffset(t, field)) = value; + fieldAtOffset(instance, fieldOffset(t, field)) = value; } void @@ -3160,17 +3160,17 @@ setFieldValue(MyThread* t, object target, object field, uint32_t value) switch (fieldCode(t, field)) { case ByteField: case BooleanField: - cast(target, fieldOffset(t, field)) = value; + fieldAtOffset(target, fieldOffset(t, field)) = value; break; case CharField: case ShortField: - cast(target, fieldOffset(t, field)) = value; + fieldAtOffset(target, fieldOffset(t, field)) = value; break; case FloatField: case IntField: - cast(target, fieldOffset(t, field)) = value; + fieldAtOffset(target, fieldOffset(t, field)) = value; break; default: @@ -8498,11 +8498,11 @@ class ArgumentList { case 'J': case 'D': - addLong(cast(objectArrayBody(t, arguments, index++), 8)); + addLong(fieldAtOffset(objectArrayBody(t, arguments, index++), 8)); break; default: - addInt(cast(objectArrayBody(t, arguments, index++), + addInt(fieldAtOffset(objectArrayBody(t, arguments, index++), BytesPerWord)); break; } diff --git a/src/heap.cpp b/src/heap.cpp index 5c87de8b88..f706bca253 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -80,13 +80,13 @@ markBitAtomic(uintptr_t* map, unsigned i) inline void* get(void* o, unsigned offsetInWords) { - return maskAlignedPointer(cast(o, offsetInWords * BytesPerWord)); + return maskAlignedPointer(fieldAtOffset(o, offsetInWords * BytesPerWord)); } inline void** getp(void* o, unsigned offsetInWords) { - return &cast(o, offsetInWords * BytesPerWord); + return &fieldAtOffset(o, offsetInWords * BytesPerWord); } inline void @@ -862,21 +862,21 @@ inline void* follow(Context* c UNUSED, void* o) { assert(c, wasCollected(c, o)); - return cast(o, 0); + return fieldAtOffset(o, 0); } inline void*& parent(Context* c UNUSED, void* o) { assert(c, wasCollected(c, o)); - return cast(o, BytesPerWord); + return fieldAtOffset(o, BytesPerWord); } inline uintptr_t* bitset(Context* c UNUSED, void* o) { assert(c, wasCollected(c, o)); - return &cast(o, BytesPerWord * 2); + return &fieldAtOffset(o, BytesPerWord * 2); } void @@ -1059,7 +1059,7 @@ copy(Context* c, void* o) } // leave a pointer to the copy in the original - cast(o, 0) = r; + fieldAtOffset(o, 0) = r; return r; } diff --git a/src/heapwalk.cpp b/src/heapwalk.cpp index 811382a825..69840abf16 100644 --- a/src/heapwalk.cpp +++ b/src/heapwalk.cpp @@ -228,7 +228,7 @@ inline object get(object o, unsigned offsetInWords) { return static_cast - (mask(cast(o, offsetInWords * BytesPerWord))); + (mask(fieldAtOffset(o, offsetInWords * BytesPerWord))); } unsigned diff --git a/src/interpret.cpp b/src/interpret.cpp index 4a324fd084..cb6adf28d3 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -733,26 +733,26 @@ pushField(Thread* t, object target, object field) switch (fieldCode(t, field)) { case ByteField: case BooleanField: - pushInt(t, cast(target, fieldOffset(t, field))); + pushInt(t, fieldAtOffset(target, fieldOffset(t, field))); break; case CharField: case ShortField: - pushInt(t, cast(target, fieldOffset(t, field))); + pushInt(t, fieldAtOffset(target, fieldOffset(t, field))); break; case FloatField: case IntField: - pushInt(t, cast(target, fieldOffset(t, field))); + pushInt(t, fieldAtOffset(target, fieldOffset(t, field))); break; case DoubleField: case LongField: - pushLong(t, cast(target, fieldOffset(t, field))); + pushLong(t, fieldAtOffset(target, fieldOffset(t, field))); break; case ObjectField: - pushObject(t, cast(target, fieldOffset(t, field))); + pushObject(t, fieldAtOffset(target, fieldOffset(t, field))); break; default: @@ -902,7 +902,7 @@ interpret3(Thread* t, const int base) case arraylength: { object array = popObject(t); if (LIKELY(array)) { - pushInt(t, cast(array, BytesPerWord)); + pushInt(t, fieldAtOffset(array, BytesPerWord)); } else { exception = makeThrowable(t, Machine::NullPointerExceptionType); goto throw_; @@ -2436,17 +2436,17 @@ interpret3(Thread* t, const int base) switch (fieldCode(t, field)) { case ByteField: case BooleanField: - cast(o, fieldOffset(t, field)) = value; + fieldAtOffset(o, fieldOffset(t, field)) = value; break; case CharField: case ShortField: - cast(o, fieldOffset(t, field)) = value; + fieldAtOffset(o, fieldOffset(t, field)) = value; break; case FloatField: case IntField: - cast(o, fieldOffset(t, field)) = value; + fieldAtOffset(o, fieldOffset(t, field)) = value; break; } } else { @@ -2459,7 +2459,7 @@ interpret3(Thread* t, const int base) int64_t value = popLong(t); object o = popObject(t); if (LIKELY(o)) { - cast(o, fieldOffset(t, field)) = value; + fieldAtOffset(o, fieldOffset(t, field)) = value; } else { exception = makeThrowable(t, Machine::NullPointerExceptionType); } @@ -2510,24 +2510,24 @@ interpret3(Thread* t, const int base) switch (fieldCode(t, field)) { case ByteField: case BooleanField: - cast(table, fieldOffset(t, field)) = value; + fieldAtOffset(table, fieldOffset(t, field)) = value; break; case CharField: case ShortField: - cast(table, fieldOffset(t, field)) = value; + fieldAtOffset(table, fieldOffset(t, field)) = value; break; case FloatField: case IntField: - cast(table, fieldOffset(t, field)) = value; + fieldAtOffset(table, fieldOffset(t, field)) = value; break; } } break; case DoubleField: case LongField: { - cast(table, fieldOffset(t, field)) = popLong(t); + fieldAtOffset(table, fieldOffset(t, field)) = popLong(t); } break; case ObjectField: { @@ -2850,11 +2850,11 @@ pushArguments(Thread* t, object this_, const char* spec, object a) case 'J': case 'D': - pushLong(t, cast(objectArrayBody(t, a, index++), 8)); + pushLong(t, fieldAtOffset(objectArrayBody(t, a, index++), 8)); break; default: - pushInt(t, cast(objectArrayBody(t, a, index++), + pushInt(t, fieldAtOffset(objectArrayBody(t, a, index++), BytesPerWord)); break; } diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 2a70b10855..3a61046473 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -232,7 +232,7 @@ GetArrayLength(Thread* t, jarray array) { ENTER(t, Thread::ActiveState); - return cast(*array, BytesPerWord); + return fieldAtOffset(*array, BytesPerWord); } uint64_t @@ -271,7 +271,7 @@ newStringUTF(Thread* t, uintptr_t* arguments) return reinterpret_cast (makeLocalReference (t, t->m->classpath->makeString - (t, array, 0, cast(array, BytesPerWord) - 1))); + (t, array, 0, fieldAtOffset(array, BytesPerWord) - 1))); } jstring JNICALL @@ -1532,7 +1532,7 @@ getObjectField(Thread* t, uintptr_t* arguments) ACQUIRE_FIELD_FOR_READ(t, field); return reinterpret_cast - (makeLocalReference(t, cast(*o, fieldOffset(t, field)))); + (makeLocalReference(t, fieldAtOffset(*o, fieldOffset(t, field)))); } jobject JNICALL @@ -1553,7 +1553,7 @@ getBooleanField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast(*o, fieldOffset(t, field)); + return fieldAtOffset(*o, fieldOffset(t, field)); } jboolean JNICALL @@ -1574,7 +1574,7 @@ getByteField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast(*o, fieldOffset(t, field)); + return fieldAtOffset(*o, fieldOffset(t, field)); } jbyte JNICALL @@ -1595,7 +1595,7 @@ getCharField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast(*o, fieldOffset(t, field)); + return fieldAtOffset(*o, fieldOffset(t, field)); } jchar JNICALL @@ -1616,7 +1616,7 @@ getShortField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast(*o, fieldOffset(t, field)); + return fieldAtOffset(*o, fieldOffset(t, field)); } jshort JNICALL @@ -1637,7 +1637,7 @@ getIntField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast(*o, fieldOffset(t, field)); + return fieldAtOffset(*o, fieldOffset(t, field)); } jint JNICALL @@ -1658,7 +1658,7 @@ getLongField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast(*o, fieldOffset(t, field)); + return fieldAtOffset(*o, fieldOffset(t, field)); } jlong JNICALL @@ -1679,7 +1679,7 @@ getFloatField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return floatToBits(cast(*o, fieldOffset(t, field))); + return floatToBits(fieldAtOffset(*o, fieldOffset(t, field))); } jfloat JNICALL @@ -1700,7 +1700,7 @@ getDoubleField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return doubleToBits(cast(*o, fieldOffset(t, field))); + return doubleToBits(fieldAtOffset(*o, fieldOffset(t, field))); } jdouble JNICALL @@ -1747,7 +1747,7 @@ setBooleanField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(*o, fieldOffset(t, field)) = v; + fieldAtOffset(*o, fieldOffset(t, field)) = v; return 1; } @@ -1772,7 +1772,7 @@ setByteField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(*o, fieldOffset(t, field)) = v; + fieldAtOffset(*o, fieldOffset(t, field)) = v; return 1; } @@ -1797,7 +1797,7 @@ setCharField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(*o, fieldOffset(t, field)) = v; + fieldAtOffset(*o, fieldOffset(t, field)) = v; return 1; } @@ -1822,7 +1822,7 @@ setShortField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(*o, fieldOffset(t, field)) = v; + fieldAtOffset(*o, fieldOffset(t, field)) = v; return 1; } @@ -1847,7 +1847,7 @@ setIntField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(*o, fieldOffset(t, field)) = v; + fieldAtOffset(*o, fieldOffset(t, field)) = v; return 1; } @@ -1872,7 +1872,7 @@ setLongField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(*o, fieldOffset(t, field)) = v; + fieldAtOffset(*o, fieldOffset(t, field)) = v; return 1; } @@ -1898,7 +1898,7 @@ setFloatField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(*o, fieldOffset(t, field)) = v; + fieldAtOffset(*o, fieldOffset(t, field)) = v; return 1; } @@ -1923,7 +1923,7 @@ setDoubleField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast(*o, fieldOffset(t, field)) = v; + fieldAtOffset(*o, fieldOffset(t, field)) = v; return 1; } @@ -1965,7 +1965,7 @@ getStaticObjectField(Thread* t, uintptr_t* arguments) return reinterpret_cast (makeLocalReference - (t, cast + (t, fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)))); } @@ -1990,7 +1990,7 @@ getStaticBooleanField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast + return fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)); } @@ -2015,7 +2015,7 @@ getStaticByteField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast + return fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)); } @@ -2040,7 +2040,7 @@ getStaticCharField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast + return fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)); } @@ -2065,7 +2065,7 @@ getStaticShortField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast + return fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)); } @@ -2090,7 +2090,7 @@ getStaticIntField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast + return fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)); } @@ -2115,7 +2115,7 @@ getStaticLongField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_READ(t, field); - return cast + return fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)); } @@ -2141,7 +2141,7 @@ getStaticFloatField(Thread* t, uintptr_t* arguments) ACQUIRE_FIELD_FOR_READ(t, field); return floatToBits - (cast + (fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field))); } @@ -2167,7 +2167,7 @@ getStaticDoubleField(Thread* t, uintptr_t* arguments) ACQUIRE_FIELD_FOR_READ(t, field); return doubleToBits - (cast + (fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field))); } @@ -2222,7 +2222,7 @@ setStaticBooleanField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v; return 1; @@ -2251,7 +2251,7 @@ setStaticByteField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v; return 1; @@ -2280,7 +2280,7 @@ setStaticCharField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v; return 1; @@ -2309,7 +2309,7 @@ setStaticShortField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v; return 1; @@ -2338,7 +2338,7 @@ setStaticIntField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v; return 1; @@ -2367,7 +2367,7 @@ setStaticLongField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v; return 1; @@ -2397,7 +2397,7 @@ setStaticFloatField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v; return 1; @@ -2426,7 +2426,7 @@ setStaticDoubleField(Thread* t, uintptr_t* arguments) PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); - cast + fieldAtOffset (classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v; return 1; diff --git a/src/machine.cpp b/src/machine.cpp index eda7f87259..fb66d5a87d 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -924,7 +924,7 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, object pool, unsigned i) object value = parseUtf8(t, singletonObject(t, pool, si)); value = t->m->classpath->makeString - (t, value, 0, cast(value, BytesPerWord) - 1); + (t, value, 0, fieldAtOffset(value, BytesPerWord) - 1); value = intern(t, value); set(t, pool, SingletonBody + (i * BytesPerWord), value); @@ -3466,7 +3466,7 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type, object o = reinterpret_cast(t->backupHeap + t->backupHeapIndex); t->backupHeapIndex += ceilingDivide(sizeInBytes, BytesPerWord); - cast(o, 0) = 0; + fieldAtOffset(o, 0) = 0; return o; } else if (UNLIKELY(t->flags & Thread::TracingFlag)) { expect(t, t->heapIndex + ceilingDivide(sizeInBytes, BytesPerWord) @@ -4670,7 +4670,7 @@ walk(Thread* t, Heap::Walker* w, object o, unsigned start) unsigned arrayElementSize = classArrayElementSize(t, class_); unsigned arrayLength = (arrayElementSize ? - cast(o, fixedSize - BytesPerWord) : 0); + fieldAtOffset(o, fixedSize - BytesPerWord) : 0); THREAD_RUNTIME_ARRAY(t, uint32_t, mask, intArrayLength(t, objectMask)); memcpy(RUNTIME_ARRAY_BODY(mask), &intArrayBody(t, objectMask, 0), diff --git a/src/machine.h b/src/machine.h index e972a3be9d..7e75fa0efc 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 maskAlignedPointer(cast(o, 0)); + return maskAlignedPointer(fieldAtOffset(o, 0)); } inline unsigned @@ -1883,18 +1883,18 @@ mark(Thread* t, object o, unsigned offset) inline void set(Thread* t, object target, unsigned offset, object value) { - cast(target, offset) = value; + fieldAtOffset(target, offset) = value; mark(t, target, offset); } inline void setObjectClass(Thread*, object o, object value) { - cast(o, 0) + fieldAtOffset(o, 0) = reinterpret_cast (reinterpret_cast(value) | (reinterpret_cast - (cast(o, 0)) & (~PointerMask))); + (fieldAtOffset(o, 0)) & (~PointerMask))); } inline const char* @@ -2151,7 +2151,7 @@ baseSize(Thread* t, object o, object class_) return ceilingDivide(classFixedSize(t, class_), BytesPerWord) + ceilingDivide(classArrayElementSize(t, class_) - * cast(o, classFixedSize(t, class_) - BytesPerWord), + * fieldAtOffset(o, classFixedSize(t, class_) - BytesPerWord), BytesPerWord); } @@ -2290,7 +2290,7 @@ inline uintptr_t& extendedWord(Thread* t UNUSED, object o, unsigned baseSize) { assert(t, objectExtended(t, o)); - return cast(o, baseSize * BytesPerWord); + return fieldAtOffset(o, baseSize * BytesPerWord); } inline unsigned @@ -2792,7 +2792,7 @@ objectArrayLength(Thread* t UNUSED, object array) { assert(t, classFixedSize(t, objectClass(t, array)) == BytesPerWord * 2); assert(t, classArrayElementSize(t, objectClass(t, array)) == BytesPerWord); - return cast(array, BytesPerWord); + return fieldAtOffset(array, BytesPerWord); } inline object& @@ -2803,7 +2803,7 @@ objectArrayBody(Thread* t UNUSED, object array, unsigned index) assert(t, classObjectMask(t, objectClass(t, array)) == classObjectMask(t, arrayBody (t, t->m->types, Machine::ArrayType))); - return cast(array, ArrayBody + (index * BytesPerWord)); + return fieldAtOffset(array, ArrayBody + (index * BytesPerWord)); } unsigned @@ -2839,7 +2839,7 @@ inline bool atomicCompareAndSwapObject(Thread* t, object target, unsigned offset, object old, object new_) { - if (atomicCompareAndSwap(&cast(target, offset), + if (atomicCompareAndSwap(&fieldAtOffset(target, offset), reinterpret_cast(old), reinterpret_cast(new_))) { @@ -3473,7 +3473,7 @@ inline object resolveClassInObject(Thread* t, object loader, object container, unsigned classOffset, bool throw_ = true) { - object o = cast(container, classOffset); + object o = fieldAtOffset(container, classOffset); loadMemoryBarrier();