How do you detect accesses?

25 views
Skip to first unread message

Alix

unread,
Apr 9, 2010, 9:15:17 AM4/9/10
to Deuce-STM
Hi.
I'm currently translating an STM from Java to C# and I'd appreciate
some insight. I'm having trouble translating it because it relies
heavily on deuce for the low-level stuff, but I don't have anything
like deuce in C# so I have to take care of all that myself :$.

I've been browsing through your code and it's way more complex than
what I have time for, but there a couple of points that interest me in
particular. I'll post one here and the other in another message.

My first question: How do you detect accesses to the protected data
(atomic objects)? I can see that you analyse the byte code and invoke
the Context every time a field, parameter, local variable, etc, is
visited, but how can you know whether it "belongs" to an atomic
object? I'll explain with an example. Say you have the following
class:

@Atomic
public class MyAtomicObject {
private SomeClass someField;
}

and you have a MyAtomicObject myAtomicObject, on which you do this:
SomeClass referenceToSomeField = myAtomicObject.someField;
Unless I'm mistaken, myAtomicObject.someField is detected as a read
access and results in an invocation of:
public Object onReadAccess(Object obj, Object value, long field)
(of the class Context).

So far so good. But now I have a reference to the field, and I can do
this:
referenceToSomeField.someMethod()
Is this detected at all? And if so, how? I can see how you could
detect this pretty simple case by analysing the byte code, but there
are more complex scenarios in which you can't (or I can't see how):
say you have a Map<Integer, SomeClass> and you add the reference to
it:
Map<Integer, SomeClass> map;
...
map.put(new Random().nextInt(), referenceToSomeField);
And then later you retrieve it like this:
SomeClass anotherReferenceToSomeField = map.get(new
Random().nextInt());

You obviously cannot know that what you have retrieved is a field of
an atomic object unless you've added some tracking info to it, for
example by putting it into a wrapper and tweaking its methods to
detect accesses to it. Is this what you do? If so, could you point me
to the code that handles of that? And how do you handle cases in which
SomeClass is final and you can't extend it?

I realise this may require a pretty long explanation -- which I'd
love, but if you don't have the time I'd appreciate any pointers you
can give me. For example if you could refer me to where you handle
this in your code it would be great.

Thanks so much.

Guy Korland

unread,
Apr 9, 2010, 4:44:12 PM4/9/10
to deuce-stm
Hi,


> translating an STM from Java to C#
Which STM? Deuce?

>My first question: How do you detect accesses to the protected data
>(atomic objects)? I can see that you analyse the byte code and invoke
>the Context every time a field, parameter, local variable, etc, is
>visited, but how can you know whether it "belongs" to an atomic
>object? I'll explain with an example. Say you have the following
The thing is that there's no such thing as Atomic Object in Deuce but Atomic method.
So each access to any field under this method context is logged.

Guy


--
You received this message because you are subscribed to the Google Groups "Deuce-STM" group.
To post to this group, send email to deuc...@googlegroups.com.
To unsubscribe from this group, send email to deuce-stm+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/deuce-stm?hl=en.


Alix

unread,
Apr 11, 2010, 1:11:43 PM4/11/10
to Deuce-STM
Hi,

> > translating an STM from Java to C#
>
> Which STM? Deuce?

SwissTM. After posting I saw Mihai also belongs to the group, I didn't
know that :). As I imagine you know he's translating SwissTM from C++
to Java. I'm translating his version to C#.

> The thing is that there's no such thing as Atomic Object in Deuce but Atomic
> method.
> So each access to any field under this method context is logged.

Ah, of course. My confusion comes from analysing several STMs and
frameworks in parallel ^^. I was checking out SXM simultaneously and I
must've mixed them up. Admittedly, your approach is much better. I'll
investigate how to do this in C# (or whether it's possible; I see you
use ClassFileTransformer; there's nothing similar in C#, AFAIK).

Thanks so much for answering so quickly :)

Reply all
Reply to author
Forward
0 new messages