Changeset 392
- Timestamp:
- Jul 16, 2003, 2:05:20 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/emxomf/stabshll.c
-
Property cvs2svn:cvs-rev
changed from
1.15
to1.16
r391 r392 20 20 Boston, MA 02111-1307, USA. */ 21 21 22 #define HASH_DEBUG23 22 24 23 /******************************************************************************* … … 298 297 299 298 static struct type *type_head; 300 #define TYPE_HASH_MAX 128299 #define TYPE_HASH_MAX 211 301 300 static struct type *atype_tag[TYPE_HASH_MAX]; 302 301 #ifdef HASH_DEBUG … … 575 574 * @param t type 576 575 */ 577 static unsigned type_hash (struct type *t)576 static inline unsigned type_hash (struct type *t) 578 577 { 579 578 register unsigned uhash = 0; 580 unsigned uret;581 579 switch (t->tag) 582 580 { … … 591 589 case ty_array: uhash = (unsigned)t->d.array.etype; break; 592 590 case ty_bits: uhash = (unsigned)t->d.bits.type; break; 593 case ty_func: uhash = (unsigned)t->d.func.args ; break;594 case ty_types: uhash = (unsigned)t->d.types.count << 2; break;595 case ty_args: uhash = (unsigned)t->d.args.count << 2; break;596 case ty_fields: uhash = (unsigned)t->d.fields.count << 2; break;597 case ty_member: uhash = (unsigned)t->d.member.type ; break;598 case ty_values: uhash = (unsigned)t->d.values.count << 2; break;591 case ty_func: uhash = (unsigned)t->d.func.args ^ (unsigned)t->d.func.arg_count ^ (unsigned)t->d.func.ret ^ (unsigned)t->d.func.domain; break; 592 case ty_types: uhash = (unsigned)t->d.types.count << 3; break; 593 case ty_args: uhash = (unsigned)t->d.args.count << 3; break; 594 case ty_fields: uhash = (unsigned)t->d.fields.count << 3; break; 595 case ty_member: uhash = (unsigned)t->d.member.type ^ (unsigned)t->d.member.name >> 7; break; 596 case ty_values: uhash = (unsigned)t->d.values.count << 3; break; 599 597 case ty_memfunc: uhash = (unsigned)t->d.memfunc.type; break; 600 598 case ty_baseclass: uhash = (unsigned)t->d.baseclass.type; break; 601 599 } 602 600 uhash += t->tag; 603 uret = uhash ^ (uhash >> 13); 604 return uret & (TYPE_HASH_MAX - 1); 605 } 606 607 608 /* Add a new internal type to the list of internal types. If an 609 identical type already exists, a pointer to that type is returned. 610 Otherwise, a copy of the new type is added to the list and a 611 pointer to that type is returned. It isn't worth my while to 612 improve the speed of this function, for instance by using 613 hashing. 614 615 Actually it is worth while optimizing it as it takes 85% of the 616 time here... or rather it was. */ 617 618 static struct type *type_add (struct type *src) 619 { 620 unsigned ihash; 621 struct type *p; 601 return (uhash ^ uhash >> 13) % TYPE_HASH_MAX; 602 } 603 604 605 /** 606 * Search a list for a type. 607 * @returns pointer to the type we found. 608 * @returns NULL if not found. 609 * @param p Pointer to the head list. 610 * @param src Type to find. 611 * @param fhash Whether or not to follow the hash list or the main list. 612 */ 613 #ifdef HASH_DEBUG 614 static struct type *type_find (struct type *p, const struct type *src, int fhash) 615 #else 616 static struct type *type_find (struct type *p, const struct type *src) 617 #endif 618 { 622 619 int i; 623 624 ihash = type_hash(src); 625 for (p = atype_tag[ihash]; p != NULL; p = p->nexthash) 620 for (; p != NULL; 621 #ifdef HASH_DEBUG 622 p = fhash ? p->nexthash : p->next ) 623 #else 624 p = p->nexthash ) 625 #endif 626 626 if (p->tag == src->tag) 627 627 switch (p->tag) … … 752 752 abort (); 753 753 } 754 754 return NULL; 755 } 756 757 758 /* Add a new internal type to the list of internal types. If an 759 identical type already exists, a pointer to that type is returned. 760 Otherwise, a copy of the new type is added to the list and a 761 pointer to that type is returned. It isn't worth my while to 762 improve the speed of this function, for instance by using 763 hashing. 764 765 Actually it is worth while optimizing it as it takes 85% of the 766 time here... or rather it was. 767 768 ctypes=25301 */ 769 770 static struct type *type_add (struct type *src) 771 { 772 struct type *p; 773 unsigned ihash; 774 int i; 775 776 ihash = type_hash(src); 755 777 #ifdef HASH_DEBUG 778 p = type_find (atype_tag[ihash], src, 1); 779 #else 780 p = type_find (atype_tag[ihash], src); 781 #endif 782 if (p) 783 { 784 return p; 785 } 786 787 #ifdef HASH_DEBUG 788 /* { 789 struct type *pcheck = type_find (type_head, src, 0); 790 if (pcheck) 791 { 792 printf("\n\thash algorithm is borked! tag=%d\n", pcheck->tag); 793 return pcheck; 794 } 795 } */ 796 ctype_tag[ihash]++; 756 797 ctypes++; 757 ctype_tag[ihash]++;758 798 #endif 759 799 … … 1455 1495 static const char *nextcolon(const char *psz) 1456 1496 { 1457 int cNesting; /* <> level */ 1458 1459 for (cNesting = 0;;psz++) 1460 switch (*psz) 1461 { 1462 case '<': 1463 #if 0 1464 /* workaround for "operator<::" and "operator<::" 1465 * */ 1466 if (!cNesting || (psz[1] == ':' && psz[2] == ':')) 1467 return psz + 1; 1468 if (!cNesting || (psz[1] == '<' && psz[2] == ':' && psz[3] == ':')) 1469 return psz + 2; 1470 #else 1471 /* general and faster check: < or > followed by : means the end. */ 1472 #endif 1473 if (psz[1] == ':') 1474 return psz + 1; 1475 cNesting++; 1476 break; 1477 case '>': 1478 if (psz[1] == ':') 1479 return psz + 1; 1480 cNesting--; 1481 break; 1482 case ':': 1483 if (cNesting <= 0) 1484 return psz; 1485 break; 1486 case '\0': 1487 return NULL; 1488 } 1489 psz++; 1490 1491 return NULL; 1497 int cNesting = 0; /* <> level */ 1498 1499 for (;;psz++) 1500 switch (*psz) 1501 { 1502 case '<': 1503 if (psz[1] == ':') 1504 return psz + 1; 1505 cNesting++; 1506 break; 1507 case '>': 1508 if (psz[1] == ':') 1509 return psz + 1; 1510 cNesting--; 1511 break; 1512 case ':': 1513 if (cNesting <= 0) 1514 return psz; 1515 break; 1516 case '\0': 1517 return NULL; 1518 } 1519 return NULL; 1492 1520 } 1493 1521 … … 3594 3622 3595 3623 #ifdef HASH_DEBUG 3624 fprintf(stderr, "\n"); 3596 3625 for (i = 0; i < TYPE_HASH_MAX; i++) 3597 3626 if (i % 7 == 6) … … 3600 3629 fprintf(stderr, "%3d: %4d ", i, ctype_tag[i]); 3601 3630 fprintf(stderr, "\nctypes=%d\n", ctypes); 3631 for (i = 0; i < TYPE_HASH_MAX; i++) 3632 if (ctype_tag[i] > 1000) 3633 { 3634 int j; 3635 unsigned au[ty_max]; 3636 memset(&au[0], 0, sizeof(au)); 3637 for (t1 = atype_tag[i]; t1 != NULL; t1 = t1->nexthash) 3638 au[t1->tag]++; 3639 3640 fprintf(stderr, "\nIndex %d is overpopulated (%d):\n", i, ctype_tag[i]); 3641 for (j = 0; j < 18; j++) 3642 if (j % 7 == 6) 3643 fprintf(stderr, "%2d: %4d\n", j, au[j]); 3644 else 3645 fprintf(stderr, "%2d: %4d ", j, au[j]); 3646 } 3602 3647 #endif 3603 3648 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.