[M3devel] Re: RTHooks CheckStoreTraced and CheckLoadTraced

Tony Hosking hosking at cs.purdue.edu
Thu Apr 19 04:09:35 CEST 2007


On Apr 18, 2007, at 9:37 PM, Darko wrote:

> Not actually using that code, but I did see your helpful commit on  
> it some time ago. It seems that the problem I described earlier is  
> due to another bug. The code I'm working on does a lot of reading  
> and writing of traced references and I was hoping to get a better  
> understanding of situations I need to be aware of and how to use  
> those RTHooks calls more efficiently.
>
> So say I have two traced objects and I am copying a traced  
> reference from a field in one to the other. What set of calls would  
> be normally required there?

If you have:

VAR source, target: OBJECT field: REFANY END;

then copying field from source to target is written as normal:

target.field := source.field;

The compiler will emit the appropriate calls:

	CheckLoadTracedRef(source.field)
	CheckStoreTraced(target)

Why do you need to call these runtime routines explicitly if the  
compiler will generate them for you?

>
> I'm sure you haven't got time to go into the minutiae of the  
> runtime system, but any hints would be appreciated.
>
> Cheers,
> Darko.
>
>
> On 18/04/2007, at 4:34 PM, Tony Hosking wrote:
>
>> I assume you have an apply method for your RTTypeMap.Visitor that  
>> takes "field: ADDRESS" and treats it as "REF REFANY".   This is  
>> wrong.  When reading a REF field you should use the following idiom:
>>
>> WITH ref = LOOPHOLE(field, UNTRACED REF REFANY) DO
>>   ... access field via ref^ ...
>> END;
>>
>> This will automatically insert a call to the appropriate runtime  
>> routines on accessing the reference field.
>>
>> There should be no need for you to call the runtime routines  
>> directly.
>>
>> On Apr 17, 2007, at 9:51 PM, Darko wrote:
>>
>>> Hi,
>>>
>>> Wondering if you can explain the use of these calls a little  
>>> more. I'm currently using type maps to read and write fields from  
>>> traced objects. Reading a traced reference from inside a traced  
>>> object into a local variable is not working as it should. Should  
>>> I use CheckLoadTraced and if so when and how? Looking at your  
>>> changes to RTTypeMap, writing references into objects means you  
>>> need to call CheckStoreTraced on the object written inside of,  
>>> before it is written?
>>>
>>> Cheers,
>>> Darko.
>>




More information about the M3devel mailing list