Bug 384104: Fixing ALE macros to quell GCC strict-aliasing warnings. r=brendan

This commit is contained in:
igor%mir2.org 2007-06-12 07:27:23 +00:00
Родитель 99a09cc0b0
Коммит 572c2325e9
3 изменённых файлов: 13 добавлений и 15 удалений

Просмотреть файл

@ -877,8 +877,8 @@ js_IndexAtom(JSContext *cx, JSAtom *atom, JSAtomList *al)
if (!ale)
return NULL;
ALE_SET_ATOM(ale, atom);
ALE_SET_NEXT(ale, al->list);
al->list = ale;
ale->entry.next = al->list;
al->list = &ale->entry;
} else {
/* We want to hash. Have we already made a hash table? */
if (!al->table) {
@ -897,12 +897,12 @@ js_IndexAtom(JSContext *cx, JSAtom *atom, JSAtomList *al)
al->table->nentries = al->count;
/* Insert each ale on al->list into the new hash table. */
for (ale2 = al->list; ale2; ale2 = next) {
for (ale2 = (JSAtomListElement *)al->list; ale2; ale2 = next) {
next = ALE_NEXT(ale2);
ale2->entry.keyHash = ALE_ATOM(ale2)->number;
hep = JS_HashTableRawLookup(al->table, ale2->entry.keyHash,
ale2->entry.key);
ALE_SET_NEXT(ale2, *hep);
ale2->entry.next = *hep;
*hep = &ale2->entry;
}
al->list = NULL;
@ -967,7 +967,7 @@ js_InitAtomMap(JSContext *cx, JSAtomMap *map, JSAtomList *al)
#ifdef DEBUG
JS_ATOMIC_INCREMENT(&js_atom_map_count);
#endif
ale = al->list;
ale = (JSAtomListElement *)al->list;
if (!ale && !al->table) {
map->vector = NULL;
map->length = 0;

Просмотреть файл

@ -102,11 +102,9 @@ struct JSAtomListElement {
#define ALE_SET_ATOM(ale,atom) ((ale)->entry.key = (const void *)(atom))
#define ALE_SET_INDEX(ale,index)((ale)->entry.value = JS_UINT32_TO_PTR(index))
#define ALE_SET_JSOP(ale,op) ((ale)->entry.value = JS_UINT32_TO_PTR(op))
#define ALE_SET_VALUE(ale,val) ((ale)->entry.value = (JSHashEntry *)(val))
#define ALE_SET_NEXT(ale,link) ((ale)->entry.next = (JSHashEntry *)(link))
struct JSAtomList {
JSAtomListElement *list; /* literals indexed for mapping */
JSHashEntry *list; /* literals indexed for mapping */
JSHashTable *table; /* hash table if list gets too long */
jsuint count; /* count of indexed literals */
};
@ -126,17 +124,17 @@ struct JSAtomList {
_hep = JS_HashTableRawLookup((_al)->table, _atom->number, _atom); \
_ale = *_hep ? (JSAtomListElement *) *_hep : NULL; \
} else { \
JSAtomListElement **_alep = &(_al)->list; \
JSHashEntry **_alep = &(_al)->list; \
_hep = NULL; \
while ((_ale = *_alep) != NULL) { \
while ((_ale = (JSAtomListElement *)*_alep) != NULL) { \
if (ALE_ATOM(_ale) == (_atom)) { \
/* Hit, move atom's element to the front of the list. */ \
*_alep = ALE_NEXT(_ale); \
ALE_SET_NEXT(_ale, (_al)->list); \
(_al)->list = _ale; \
*_alep = (_ale)->entry.next; \
(_ale)->entry.next = (_al)->list; \
(_al)->list = &_ale->entry; \
break; \
} \
_alep = (JSAtomListElement **)&_ale->entry.next; \
_alep = &_ale->entry.next; \
} \
} \
JS_END_MACRO

Просмотреть файл

@ -1538,7 +1538,7 @@ js_DefineCompileTimeConstant(JSContext *cx, JSCodeGenerator *cg, JSAtom *atom,
ale = js_IndexAtom(cx, atom, &cg->constList);
if (!ale)
return JS_FALSE;
ALE_SET_VALUE(ale, ATOM_KEY(valueAtom));
ale->entry.value = (void *)ATOM_KEY(valueAtom);
}
return JS_TRUE;
}