RFC: reference counted Throwable

via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 20 11:26:55 PDT 2014


On Saturday, 20 September 2014 at 18:18:05 UTC, Walter Bright 
wrote:
>
> Please show me the inc/dec optimized x86 code.

There's no optimization of the inc/dec, you use regular inc/dec 
within a larger xbegin/xend block.

You amortize the cost over all the lock-prefixed instructions you 
would otherwise have executed in that block. There is no locking, 
there is a transaction instead. Only if the transaction fails do 
you execute the locking fallback code.

> Suppose I pass a pointer to:
>
>    void foo(T* p);
>
> How do I do dataflow?

You mean a separate compilation unit that the compiler don't have 
access to? You don't, obviously.

> The question was about mixing RC'd and non-RC'd objects.

Well, if you are talking about negative offset for ref counts, 
then people do it. E.g. there are examples of systems that 
provide C-compatible strings with length at offset -4 and ref 
count at -8.

If you need to distinguish you can either use address-space info 
or keep a negative int in the non-RC'd object.



More information about the Digitalmars-d mailing list