bool arlCore::PlaneSystem::isConnected( unsigned int plane1, unsigned int plane2, long int date, long int time, bool SetInv, bool ToTag ) { assert(!outOfRange(plane1) && !outOfRange(plane2)); if(outOfRange(plane1, plane2)) return false; if(plane1==plane2 || isTagged(plane1,plane2) || isTagged(plane2,plane1)) return false; unsigned int index = getIndex(plane1, plane2); if(getStatus(index)!=STATE_UNDEFINED && getStatus(index)!=STATE_COMPUTED/* && m_trfTable[index].isEquivalent(date,time)*/) { if(ToTag) tag(plane1, plane2); return true; } const unsigned int InvIndex = getIndex(plane2, plane1); if(getStatus(InvIndex)!=STATE_UNDEFINED && getStatus(InvIndex)!=STATE_COMPUTED/* && m_trfTable[inv].isEquivalent(date,time)*/) { if(SetInv) { // Object::update(); if(m_trfTable[index].invert(m_trfTable[InvIndex])) { m_trfState[index] = getStatus(InvIndex); m_trfWeight[index] = getWeight(InvIndex); } } if(ToTag) tag(plane1,plane2); return true; } return false; }
/* Callback for HeapReferences in FollowReferences (Shows alive objects in the whole JVM) */ static jint JNICALL callback_all_alive_objects (jvmtiHeapReferenceKind reference_kind, const jvmtiHeapReferenceInfo* reference_info, jlong class_tag, jlong referrer_class_tag, jlong size, jlong* tag_ptr, jlong* referrer_tag_ptr, jint length, void* user_data) { ResourcePrincipal* princ = (ResourcePrincipal*)user_data; // the class has a tag if ( (class_tag != (jlong)0)) { ClassDetails *d = (ClassDetails*)getDataFromTag(class_tag); char* className = getClassSignature(d); if (isClassClass(d)) { // it's a class object. I have to discover if I already visited it if ((*tag_ptr) == 0) return 0; d = (ClassDetails*)getDataFromTag(*tag_ptr); if (!isTagged(*tag_ptr)) { attachToPrincipal(*tag_ptr, princ); d = (ClassDetails*)getDataFromTag(class_tag); d->count++; d->space += (int)size; return JVMTI_VISIT_OBJECTS; } return 0; } else if (isTagged((*tag_ptr))) { // it is a tagged thread, or // it is an object already visited by this resource principal, or // it is an object already visited for another resource principal in this iteration return 0; // ignore it } else if (!isTagged( (*tag_ptr))) { // It it neither a class object nor an object I already visited, so follow references and account of it d = (ClassDetails*)getDataFromTag(class_tag); d->count++; d->space += (int)size; *tag_ptr = tagForObject(princ); return JVMTI_VISIT_OBJECTS; } } return 0; // I don't know the class of this object, so don't explore it }
void arlCore::PlaneSystem::untag( unsigned int plane1, unsigned int plane2 ) { assert(!outOfRange(plane1) && !outOfRange(plane2)); const unsigned int Index = getIndex(plane1, plane2); if(isTagged(Index)) { //Object::update(); m_trfState[Index] = (ARL_PLANE_STATE)(m_trfState[Index] - NBSTATES); } const unsigned int InvIndex = getIndex(plane1, plane2); if(isTagged(InvIndex)) { //Object::update(); m_trfState[InvIndex] = (ARL_PLANE_STATE)(m_trfState[InvIndex] - NBSTATES); } }
CommandTokens AddCommandTokeniser::tokeniseUserInput(std::string userInput) { assert(canTokeniseUserInput(userInput)); CommandTokens tokenisedCommand(CommandTokens::PrimaryCommandType::Add); if (isTagged(userInput)) { tokeniseTags(userInput, &tokenisedCommand); userInput = trimTags(userInput); } if (isAddFromTo(userInput)) { tokeniseAddFromTo(userInput, &tokenisedCommand); } else if (isAddBy(userInput)) { tokeniseAddBy(userInput, &tokenisedCommand); } else if (isAddFloating(userInput)) { tokeniseAddFloating(userInput, &tokenisedCommand); } return tokenisedCommand; }
/* Callback for HeapReferences in FollowReferences (Memory consumed by Thread) */ static jint JNICALL callback_all_references (jvmtiHeapReferenceKind reference_kind, const jvmtiHeapReferenceInfo* reference_info, jlong class_tag, jlong referrer_class_tag, jlong size, jlong* tag_ptr, jlong* referrer_tag_ptr, jint length, void* user_data) { ClassDetails *d; ResourcePrincipal* princ = (ResourcePrincipal*)user_data; if (class_tag == (jlong)0) return 0; d = (ClassDetails*)getDataFromTag(class_tag); switch(reference_kind) { case JVMTI_HEAP_REFERENCE_THREAD: if (isTagged(*tag_ptr)) // if tagged from another principal return 0; d->count++; d->space += (int)size; *(tag_ptr) = tagForObject(princ); return JVMTI_VISIT_OBJECTS; case JVMTI_HEAP_REFERENCE_STACK_LOCAL: if (isTagged(reference_info->stack_local.thread_tag) && !isTaggedByPrincipal(reference_info->stack_local.thread_tag, princ)) // if tagged for a different principal return 0; default: if (isClassClass(d)) { // it's a class object. I have to discover if I already visited it if ((*tag_ptr) == 0) return 0; d = (ClassDetails*)getDataFromTag(*tag_ptr); if (!isTagged(*tag_ptr) && isSystemClass(d)) { attachToPrincipal(*tag_ptr, princ); d = (ClassDetails*)getDataFromTag(class_tag); d->count++; d->space += (int)size; return JVMTI_VISIT_OBJECTS; } return 0; } else if (isTagged(*tag_ptr)) { // it is an object already visited by this resource principal, or // it is an object already visited for another resource principal in this iteration return 0; // ignore it } else if (!isTagged(*tag_ptr)) { // It is neither a class object nor an object I already visited, so follow references and account of it d->count++; d->space += (int)size; *tag_ptr = tagForObject(princ); return JVMTI_VISIT_OBJECTS; } } return JVMTI_VISIT_OBJECTS; }
bool arlCore::PlaneSystem::isTagged( unsigned int plane1, unsigned int plane2 ) const { assert(!outOfRange(plane1) && !outOfRange(plane2)); return isTagged( getIndex(plane1, plane2) ); }
arlCore::PlaneSystem::ARL_PLANE_STATE arlCore::PlaneSystem::getStatus( unsigned int index ) const { assert( index<m_trfState.size() ); if(!isTagged(index)) return m_trfState[index]; return(ARL_PLANE_STATE)(m_trfState[index] - NBSTATES); }