On 12/02/2011, at 1:22 PM, Bisht, Pradeep wrote:

> Thanks John. I was using JudyL and was wondering if there is any clever way 
> of avoiding that back and forth search.

but you only need to do that once at the start.

My GC code looks like this:


void flx_collector_t::scan_object(void *p, int reclimit)
{
  Word_t reachable = (parity & 1UL) ^ 1UL;
  Word_t cand = (Word_t)p;
  Word_t fp=cand;
  Word_t *w = (Word_t*)JudyLLast(j_shape,&fp,&je);
  if(w==(Word_t*)PPJERR)judyerror("scan_object");
  if(w == NULL) return; // no lower object
  if( (*w & 1UL) == reachable) return;   // already handled

  gc_shape_t *shape = (gc_shape_t*)(*w & ~1UL);
  unsigned long n = get_count((void*)fp) * shape->count * shape->amt;
  if(cand >= (Word_t)(void*)((unsigned char*)(void*)fp+n)) return; // not 
interior

  *w = (*w & ~1uL) | reachable;
...


This take a pointer which may be interior to an object, and looks it up.
The shape contains a length which is added to the adjusted pointer then
the original pointer is compare to see if it sits higher than that. If so,
it's between the start and end of the object.

Your code would be the same, but only for the first range.
After that you can just scan sequentially for the rest of the
ranges.

--
john skaller
[email protected]





------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel

Reply via email to