/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This file is part of SableVM. * * See the file "LICENSE" for Copyright information and the * * terms and conditions for copying, distribution and * * modification of SableVM. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifdef COMMENT #include "includes.h" /* ---------------------------------------------------------------------- _svmf_get_hashcode ---------------------------------------------------------------------- */ jint _svmf_get_hashcode (_svmt_JNIEnv *env, _svmt_object_instance *obj) { switch (_svmm_lockw_get_hashcode (obj->lockword)) { case 0: { obj->lockword = (void *) _svmm_lockw_set_hashcode (obj->lockword, 1); env->vm->heap.hashed_notmoved++; return env->vm->heap.hashcode_base + (jint) obj; } break; case 1: { return env->vm->heap.hashcode_base + (jint) obj; } break; case 2: { if (_svmm_lockw_is_array (obj->lockword)) { size_t next_offset = ARRAY_HEADER_SIZE; jint size = ((_svmt_array_instance *) obj)->size; switch (_svmm_lockw_type (obj->lockword)) { case SVM_TYPE_BOOLEAN: { next_offset += (((size_t) size) + 7) / 8; } break; case SVM_TYPE_BYTE: { next_offset += ((size_t) size); } break; case SVM_TYPE_SHORT: { next_offset += ((size_t) size) * 2; } break; case SVM_TYPE_CHAR: { next_offset += ((size_t) size) * 2; } break; case SVM_TYPE_INT: { next_offset += ((size_t) size) * 4; } break; case SVM_TYPE_LONG: { next_offset += ((size_t) size) * 8; } break; case SVM_TYPE_FLOAT: { next_offset += ((size_t) size) * 4; } break; case SVM_TYPE_DOUBLE: { next_offset += ((size_t) size) * 8; } break; case SVM_TYPE_REFERENCE: { } break; default: { abort (); } break; } next_offset = ALIGNED_SIZE (next_offset); return *((jint *) (((char *) obj) + next_offset)); } else { size_t end = _svmm_lockw_end (obj->lockword); size_t next_offset = end * SVM_ALIGNMENT; if (end == SVM_LOCKW_OVRFLW) { next_offset = ((_svmt_object_instance *) obj)->vtable->next_offset; } return *((jint *) (((char *) obj) + next_offset)); } } break; default: { abort (); } break; } return -1; } /* ---------------------------------------------------------------------- Garbage Collectors ---------------------------------------------------------------------- */ #if defined (_SABLEVM_COPY_GC) && !defined(_SABLEVM_GEN_COPY_GC) #include "copying_collector.c" #elif defined (_SABLEVM_GEN_COPY_GC) #include "generational_collector.c" #else #error You must define one of _SABLEVM_COPY_GC and _SABLEVM_GEN_COPY_GC #endif #endif /* COMMENT */