version 1.112, 2003/05/15 18:43:16
|
version 1.113, 2003/08/01 08:11:26
|
Line 637 static char superend[]={
|
Line 637 static char superend[]={
|
|
|
Cell npriminfos=0; |
Cell npriminfos=0; |
|
|
|
int compare_li(const void *pa, const void *pb) |
|
{ |
|
|
|
int a = *(int *)pa; |
|
int b = *(int *)pb; |
|
Cell r = vm_prims[a]-vm_prims[b]; |
|
if (r == 0) |
|
return b - a; /* K labels should be sorted before I labels |
|
for the same address */ |
|
return r; |
|
} |
|
|
void check_prims(Label symbols1[]) |
void check_prims(Label symbols1[]) |
{ |
{ |
int i; |
int i; |
#ifndef NO_DYNAMIC |
#ifndef NO_DYNAMIC |
Label *symbols2, *symbols3, *ends1; |
Label *symbols2, *symbols3, *ends1, *ends1k; |
|
int *labelindexes, *sortindexes, nlabelindexes; |
#endif |
#endif |
|
|
if (debug) |
if (debug) |
Line 666 void check_prims(Label symbols1[])
|
Line 679 void check_prims(Label symbols1[])
|
symbols3=symbols1; |
symbols3=symbols1; |
#endif |
#endif |
ends1 = symbols1+i+1-DOESJUMP; |
ends1 = symbols1+i+1-DOESJUMP; |
|
ends1k = ends1+i+1-DOESJUMP; |
|
|
|
/* produce a sortindexes: sortindexes[i] gives the rank of symbols1[i] */ |
|
nlabelindexes = 3*(i+1-DOESJUMP)+DOESJUMP; |
|
labelindexes = (int *)alloca(nlabelindexes*sizeof(int)); |
|
for (i=0; i<nlabelindexes; i++) |
|
labelindexes[i] = i; |
|
qsort(labelindexes, nlabelindexes, sizeof(int), compare_li); |
|
sortindexes = (int *)alloca(nlabelindexes*sizeof(int)); |
|
for (i=0; i<nlabelindexes; i++) |
|
sortindexes[labelindexes[i]] = i; |
|
|
priminfos = calloc(i,sizeof(PrimInfo)); |
priminfos = calloc(i,sizeof(PrimInfo)); |
for (i=DOESJUMP+1; symbols1[i+1]!=0; i++) { |
for (i=DOESJUMP+1; symbols1[i+1]!=0; i++) { |
int prim_len = ends1[i]-symbols1[i]; |
int prim_len = ends1[i]-symbols1[i]; |
Line 674 void check_prims(Label symbols1[])
|
Line 699 void check_prims(Label symbols1[])
|
char *s1 = (char *)symbols1[i]; |
char *s1 = (char *)symbols1[i]; |
char *s2 = (char *)symbols2[i]; |
char *s2 = (char *)symbols2[i]; |
char *s3 = (char *)symbols3[i]; |
char *s3 = (char *)symbols3[i]; |
|
int endindex = labelindexes[sortindexes[i]+2]; |
|
Label endlabel = symbols1[endindex]; |
|
|
pi->start = s1; |
pi->start = s1; |
pi->superend = superend[i-DOESJUMP-1]|no_super; |
pi->superend = superend[i-DOESJUMP-1]|no_super; |
if (pi->superend) |
if (pi->superend) |
pi->length = symbols1[i+1]-symbols1[i]; |
pi->length = endlabel-symbols1[i]; |
else |
else |
pi->length = prim_len; |
pi->length = prim_len; |
pi->restlength = symbols1[i+1] - symbols1[i] - pi->length; |
pi->restlength = endlabel - symbols1[i] - pi->length; |
pi->nimmargs = 0; |
pi->nimmargs = 0; |
if (debug) |
if (debug) |
fprintf(stderr, "Prim %3d @ %p %p %p, length=%3ld restlength=%2ld superend=%1d", |
fprintf(stderr, "Prim %3d @ %p %p %p, length=%3ld restlength=%2ld superend=%1d", |
i, s1, s2, s3, (long)(pi->length), (long)(pi->restlength), pi->superend); |
i, s1, s2, s3, (long)(pi->length), (long)(pi->restlength), pi->superend); |
|
if (sortindexes[i]+1 != sortindexes[i+npriminfos+1-DOESJUMP]) { |
|
pi->start = NULL; /* not relocatable */ |
|
if (debug) |
|
fprintf(stderr,"\n non_reloc: rank[start] = %d, rank[J] = %d\n", |
|
sortindexes[i], sortindexes[i+npriminfos+1-DOESJUMP]); |
|
continue; |
|
} |
|
if (endindex < (ends1k - symbols1)) { /* is endindex not a K-label? */ |
|
pi->start = NULL; /* not relocatable */ |
|
if (debug) |
|
fprintf(stderr,"\n non_reloc: endindex = %d\n", endindex); |
|
continue; |
|
} |
assert(prim_len>=0); |
assert(prim_len>=0); |
|
assert(pi->restlength >=0); |
while (j<(pi->length+pi->restlength)) { |
while (j<(pi->length+pi->restlength)) { |
if (s1[j]==s3[j]) { |
if (s1[j]==s3[j]) { |
if (s1[j] != s2[j]) { |
if (s1[j] != s2[j]) { |