[M3devel] fetch_and_op?

Jay K jay.krell at cornell.edu
Thu Jan 21 14:29:12 CET 2010


(* tmp := Mem [s1.A].t;
   Mem [s1.A].t := tmp op s0.u;
   s1.u := tmp; pop *)



Tony, are you sure you want to return the old value, not the new value?

That's not great on x86.

I believe for "or" and "and", you end up having to do a compare exchange loops.

 

 

For xor, add, sub, you can compute the old value, ok.

But if caller wanted the old value, he can do that himself also.

Caller can also write a compare_exchange loop.

 

 

Therefore, I think it should be:

 

(* tmp := Mem [s1.A].t;
   Mem [s1.A].t := tmp op s0.u;
   s1.u := tmp op s0.u; pop *)


There is of course value in storing the value in mem and stack, since mem

can change right away.

 

 

 - Jay

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100121/5268cabb/attachment-0001.html>


More information about the M3devel mailing list