001: //
002: // Copyright (C) 2005 United States Government as represented by the
003: // Administrator of the National Aeronautics and Space Administration
004: // (NASA). All Rights Reserved.
005: //
006: // This software is distributed under the NASA Open Source Agreement
007: // (NOSA), version 1.3. The NOSA has been approved by the Open Source
008: // Initiative. See the file NOSA-1.3-JPF at the top of the distribution
009: // directory tree for the complete NOSA document.
010: //
011: // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
012: // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
013: // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
014: // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
015: // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
016: // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
017: // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
018: //
019: package gov.nasa.jpf.jvm;
020:
021: import gov.nasa.jpf.util.HashData;
022:
023: /**
024: * helper object to store per thread information about atomic line
025: * execution
026: * <2do> check if we can't do this less expensive. atomic-lines is not
027: * the default anymore
028: */
029: public class AtomicData {
030: /**
031: * The method in which the line step started.
032: */
033: public MethodInfo currentMethod;
034:
035: /**
036: * The line at which the line step started.
037: */
038: public int line;
039:
040: /**
041: * Set to true if we still are in the same method in which we were
042: * when the line step started.
043: */
044: public boolean inSameMethod;
045:
046: public Object clone() {
047: AtomicData a = new AtomicData();
048:
049: a.currentMethod = currentMethod;
050: a.line = line;
051: a.inSameMethod = inSameMethod;
052:
053: return a;
054: }
055:
056: public boolean equals(Object o) {
057: if (o == null) {
058: return false;
059: }
060:
061: if (!(o instanceof AtomicData)) {
062: return false;
063: }
064:
065: AtomicData a = (AtomicData) o;
066:
067: if (currentMethod != a.currentMethod) {
068: return false;
069: }
070:
071: if (line != a.line) {
072: return false;
073: }
074:
075: if (inSameMethod != a.inSameMethod) {
076: return false;
077: }
078:
079: return true;
080: }
081:
082: /**
083: * Computes a hash code with the object data.
084: */
085: public void hash(HashData hd) {
086: hd.add(line);
087: hd.add(inSameMethod ? 1 : 0);
088: }
089:
090: /**
091: * Returns a hash code for the object.
092: */
093: public int hashCode() {
094: HashData hd = new HashData();
095:
096: hash(hd);
097:
098: return hd.getValue();
099: }
100: }
|