- Timestamp:
- 08/25/08 07:18:20 (15 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/src/com/sun/fortress/interpreter/env/ReferenceCell.java
r2700 r2738 44 44 public ReferenceCell() { 45 45 super(); 46 node = new ValueNode(); 46 node = ValueNode.nullValueNode; 47 id = counter.getAndIncrement(); 48 } 49 50 public ReferenceCell(FType t) { 51 super(); 52 theType = t; 53 node = ValueNode.nullValueNode; 47 54 id = counter.getAndIncrement(); 48 55 } … … 51 58 super(); 52 59 theType = t; 53 node = new ValueNode(v); 54 id = counter.getAndIncrement(); 55 } 56 57 public ReferenceCell(FType t) { 58 super(); 59 theType = t; 60 node = new ValueNode(); 60 node = new ValueNode(v, FortressTaskRunner.getTransaction(), null, null); 61 61 id = counter.getAndIncrement(); 62 62 } … … 64 64 public FType getType() { return theType;} 65 65 public String toString() { return "ReferenceCell" + id;} 66 67 66 68 67 private boolean transactionIsCommitted(Transaction w) { … … 90 89 private synchronized void cleanup() { 91 90 Transaction w = node.getWriter(); 91 if (Transaction.debug) 92 FortressTaskRunner.debugPrintln("Cleanup:" + this + " start with node = " + node); 92 93 while (w != null && transactionIsNotActive(w)) { 93 94 if (transactionIsAbortedOrOrphaned(w)) { … … 96 97 assert(transactionIsCommitted(w)); 97 98 Transaction p = w.getParent(); 98 if (p == null) { 99 node = new ValueNode(node.getValue(), node.getOld().getReaders()); 100 } else { 101 node = new ValueNode(node.getValue(), p, node.getOld()); 99 ValueNode old = node.getOld(); 100 if (p == null && old == null) { 101 // Committed to top level, with no previous value. 102 node = new ValueNode(node.getValue(), null, null, null); 103 } else if (p == null) { 104 // Committed to top level. Any readers of the committed transaction 105 // must be preserved. 106 node = new ValueNode(node.getValue(), null, old.getReaders(), null); 107 } else if (old != null) { 108 // Committed to a parent transaction, must preserve readers and 109 // old transaction. 110 node = new ValueNode(node.getValue(), p, old.getReaders(), old); 111 } else { 112 node = new ValueNode(node.getValue(), p, null, null); 102 113 } 103 114 } … … 105 116 w = node.getWriter(); 106 117 } else { 107 node = new ValueNode(); 118 node = ValueNode.nullValueNode; 119 if (Transaction.debug) 120 FortressTaskRunner.debugPrintln("Cleanup:" + this + " end with " + node); 108 121 return; 109 122 } 110 123 } 124 if (Transaction.debug) 125 FortressTaskRunner.debugPrintln("Cleanup:" + this + " end with " + node); 111 126 } 112 127 … … 114 129 Transaction me = FortressTaskRunner.getTransaction(); 115 130 cleanup(); 131 if (Transaction.debug) 132 FortressTaskRunner.debugPrintln(this + " assignValue start = " + node + " value = " + f2); 133 134 if (node == ValueNode.nullValueNode) { 135 node = new ValueNode(f2, me, null, null); 136 } 137 116 138 // writer is either active, or null 117 139 if (me == null) { // top level assignment 118 ValueNode temp = node; 119 node = new ValueNode(f2); 120 temp.AbortAllReadersAndWriters(); 140 if (node == ValueNode.nullValueNode) 141 node = new ValueNode(f2, me, null, null); 142 else { 143 ValueNode temp = node; 144 node = new ValueNode(f2, null, null, null); 145 temp.AbortAllReadersAndWriters(); 146 } 121 147 } else if (!me.isActive()) { 122 148 throw new AbortedException(me, "Somebody killed me "); … … 128 154 129 155 Transaction w = node.getWriter(); 156 ValueNode old = node.getOld(); 130 157 131 158 if (w == null || w.isAncestorOf(me)) { 132 node = new ValueNode(f2, me, node );159 node = new ValueNode(f2, me, node.getReaders(), node); 133 160 if (Transaction.debug) me.addWrite(this, f2); 161 134 162 } else if (w.isActive()) { 135 163 // Cleanup got us to a parent node with an active writer … … 137 165 } 138 166 } 167 if (Transaction.debug) 168 FortressTaskRunner.debugPrintln(this + " assignValue finish = " + node); 139 169 } 140 170

