зеркало из https://github.com/mozilla/pjs.git
Fix C++ portability and AIX compilation problem due to last C++ porting attempt (48976, r=jdunn@netscape.com).
This commit is contained in:
Родитель
f1c81d2980
Коммит
4b88e28559
|
@ -104,6 +104,12 @@ struct JSArenaPool {
|
|||
#endif
|
||||
|
||||
#define JS_ARENA_ALLOCATE(p, pool, nb) \
|
||||
JS_ARENA_ALLOCATE_CAST(p, void *, pool, nb)
|
||||
|
||||
#define JS_ARENA_ALLOCATE_TYPE(p, type, pool) \
|
||||
JS_ARENA_ALLOCATE_CAST(p, type *, pool, sizeof(type))
|
||||
|
||||
#define JS_ARENA_ALLOCATE_CAST(p, type, pool, nb) \
|
||||
JS_BEGIN_MACRO \
|
||||
JSArena *_a = (pool)->current; \
|
||||
size_t _nb = JS_ARENA_ALIGN(pool, nb); \
|
||||
|
@ -113,11 +119,14 @@ struct JSArenaPool {
|
|||
_p = (jsuword)JS_ArenaAllocate(pool, _nb); \
|
||||
else \
|
||||
_a->avail = _q; \
|
||||
*(void**)&p = (void *)_p; \
|
||||
p = (type) _p; \
|
||||
JS_ArenaCountAllocation(pool, nb); \
|
||||
JS_END_MACRO
|
||||
|
||||
#define JS_ARENA_GROW(p, pool, size, incr) \
|
||||
JS_ARENA_GROW_CAST(p, void *, pool, size, incr)
|
||||
|
||||
#define JS_ARENA_GROW_CAST(p, type, pool, size, incr) \
|
||||
JS_BEGIN_MACRO \
|
||||
JSArena *_a = (pool)->current; \
|
||||
size_t _incr = JS_ARENA_ALIGN(pool, incr); \
|
||||
|
@ -128,7 +137,7 @@ struct JSArenaPool {
|
|||
_a->avail = _q; \
|
||||
JS_ArenaCountInplaceGrowth(pool, size, incr); \
|
||||
} else { \
|
||||
*(void**)&p = JS_ArenaGrow(pool, p, size, incr); \
|
||||
p = (type) JS_ArenaGrow(pool, p, size, incr); \
|
||||
} \
|
||||
JS_ArenaCountGrowth(pool, size, incr); \
|
||||
JS_END_MACRO
|
||||
|
|
|
@ -662,7 +662,7 @@ js_alloc_temp_entry(void *priv, const void *key)
|
|||
JSContext *cx = priv;
|
||||
JSAtomListElement *ale;
|
||||
|
||||
JS_ARENA_ALLOCATE(ale, &cx->tempPool, sizeof(JSAtomListElement));
|
||||
JS_ARENA_ALLOCATE_TYPE(ale, JSAtomListElement, &cx->tempPool);
|
||||
if (!ale) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return NULL;
|
||||
|
|
|
@ -107,9 +107,10 @@ EmitCheck(JSContext *cx, JSCodeGenerator *cg, JSOp op, ptrdiff_t delta)
|
|||
cgincr = delta * sizeof(jsbytecode);
|
||||
if (base) {
|
||||
cgsize = length * sizeof(jsbytecode);
|
||||
JS_ARENA_GROW(base, &cx->codePool, cgsize, cgincr);
|
||||
JS_ARENA_GROW_CAST(base, jsbytecode *, &cx->codePool, cgsize,
|
||||
cgincr);
|
||||
} else {
|
||||
JS_ARENA_ALLOCATE(base, &cx->codePool, cgincr);
|
||||
JS_ARENA_ALLOCATE_CAST(base, jsbytecode *, &cx->codePool, cgincr);
|
||||
}
|
||||
if (!base) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
|
@ -1108,7 +1109,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||
/* Avoid bloat for a compilation unit with many switches. */
|
||||
mark = JS_ARENA_MARK(&cx->tempPool);
|
||||
tablesize = (size_t)tablen * sizeof *table;
|
||||
JS_ARENA_ALLOCATE(table, &cx->tempPool, tablesize);
|
||||
JS_ARENA_ALLOCATE_CAST(table, JSParseNode **, &cx->tempPool,
|
||||
tablesize);
|
||||
if (!table) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
@ -2527,10 +2529,10 @@ AllocSrcNote(JSContext *cx, JSCodeGenerator *cg)
|
|||
pool = &cx->notePool;
|
||||
incr = SNINCR_SIZE;
|
||||
if (!cg->notes) {
|
||||
JS_ARENA_ALLOCATE(cg->notes, pool, incr);
|
||||
JS_ARENA_ALLOCATE_CAST(cg->notes, jssrcnote *, pool, incr);
|
||||
} else {
|
||||
size = cg->noteCount * sizeof(jssrcnote);
|
||||
JS_ARENA_GROW(cg->notes, pool, size, incr);
|
||||
JS_ARENA_GROW_CAST(cg->notes, jssrcnote *, pool, size, incr);
|
||||
}
|
||||
if (!cg->notes) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
|
@ -2628,7 +2630,7 @@ GrowSrcNotes(JSContext *cx, JSCodeGenerator *cg)
|
|||
incr = SNINCR_SIZE;
|
||||
size = cg->noteCount * sizeof(jssrcnote);
|
||||
size = JS_ROUNDUP(size, incr);
|
||||
JS_ARENA_GROW(cg->notes, pool, size, incr);
|
||||
JS_ARENA_GROW_CAST(cg->notes, jssrcnote *, pool, size, incr);
|
||||
if (!cg->notes) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
@ -2752,7 +2754,7 @@ js_AllocTryNotes(JSContext *cx, JSCodeGenerator *cg)
|
|||
*/
|
||||
if (!cg->tryBase) {
|
||||
size = JS_ROUNDUP(size, TNINCR_SIZE);
|
||||
JS_ARENA_ALLOCATE(cg->tryBase, &cx->tempPool, size);
|
||||
JS_ARENA_ALLOCATE_CAST(cg->tryBase, JSTryNote *, &cx->tempPool, size);
|
||||
if (!cg->tryBase)
|
||||
return JS_FALSE;
|
||||
cg->tryNoteSpace = size;
|
||||
|
@ -2762,7 +2764,7 @@ js_AllocTryNotes(JSContext *cx, JSCodeGenerator *cg)
|
|||
incr = size - cg->tryNoteSpace;
|
||||
incr = JS_ROUNDUP(incr, TNINCR_SIZE);
|
||||
size = cg->tryNoteSpace;
|
||||
JS_ARENA_GROW(cg->tryBase, &cx->tempPool, size, incr);
|
||||
JS_ARENA_GROW_CAST(cg->tryBase, JSTryNote *, &cx->tempPool, size, incr);
|
||||
if (!cg->tryBase)
|
||||
return JS_FALSE;
|
||||
cg->tryNoteSpace = size + incr;
|
||||
|
|
|
@ -1403,7 +1403,8 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
* collected_args and its tokenstream in one swoop.
|
||||
*/
|
||||
mark = JS_ARENA_MARK(&cx->tempPool);
|
||||
JS_ARENA_ALLOCATE(cp, &cx->tempPool, (args_length+1) * sizeof(jschar));
|
||||
JS_ARENA_ALLOCATE_CAST(cp, jschar *, &cx->tempPool,
|
||||
(args_length+1) * sizeof(jschar));
|
||||
if (!cp)
|
||||
return JS_FALSE;
|
||||
collected_args = cp;
|
||||
|
|
|
@ -234,9 +234,9 @@ retry:
|
|||
if (rt->gcBytes < rt->gcMaxBytes &&
|
||||
(tried_gc || rt->gcMallocBytes < rt->gcMaxBytes))
|
||||
{
|
||||
JS_ARENA_ALLOCATE(thing, &rt->gcArenaPool, sizeof(JSGCThing));
|
||||
JS_ARENA_ALLOCATE_TYPE(thing, JSGCThing, &rt->gcArenaPool);
|
||||
if (thing)
|
||||
JS_ARENA_ALLOCATE(flagp, &rt->gcFlagsPool, sizeof(uint8));
|
||||
JS_ARENA_ALLOCATE_TYPE(flagp, uint8, &rt->gcFlagsPool);
|
||||
}
|
||||
if (!thing || !flagp) {
|
||||
if (thing)
|
||||
|
@ -969,7 +969,7 @@ restart:
|
|||
if (flags & GCF_MARK) {
|
||||
*flagp &= ~GCF_MARK;
|
||||
} else if (!(flags & (GCF_LOCKMASK | GCF_FINAL))) {
|
||||
JS_ARENA_ALLOCATE(final, &cx->tempPool, sizeof(JSGCThing));
|
||||
JS_ARENA_ALLOCATE_TYPE(final, JSGCThing, &cx->tempPool);
|
||||
if (!final)
|
||||
goto finalize_phase;
|
||||
final->next = thing;
|
||||
|
|
|
@ -339,7 +339,7 @@ js_AllocStack(JSContext *cx, uintN nslots, void **markp)
|
|||
|
||||
if (markp)
|
||||
*markp = JS_ARENA_MARK(&cx->stackPool);
|
||||
JS_ARENA_ALLOCATE(sp, &cx->stackPool, nslots * sizeof(jsval));
|
||||
JS_ARENA_ALLOCATE_CAST(sp, jsval *, &cx->stackPool, nslots * sizeof(jsval));
|
||||
if (!sp) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_STACK_OVERFLOW,
|
||||
(cx->fp && cx->fp->fun)
|
||||
|
|
|
@ -283,9 +283,9 @@ static JSBool
|
|||
SprintAlloc(Sprinter *sp, size_t nb)
|
||||
{
|
||||
if (!sp->base) {
|
||||
JS_ARENA_ALLOCATE(sp->base, sp->pool, nb);
|
||||
JS_ARENA_ALLOCATE_CAST(sp->base, char *, sp->pool, nb);
|
||||
} else {
|
||||
JS_ARENA_GROW(sp->base, sp->pool, sp->size, nb);
|
||||
JS_ARENA_GROW_CAST(sp->base, char *, sp->pool, sp->size, nb);
|
||||
}
|
||||
if (!sp->base) {
|
||||
JS_ReportOutOfMemory(sp->context);
|
||||
|
|
|
@ -131,7 +131,7 @@ NewParseNode(JSContext *cx, JSToken *tok, JSParseNodeArity arity)
|
|||
{
|
||||
JSParseNode *pn;
|
||||
|
||||
JS_ARENA_ALLOCATE(pn, &cx->tempPool, sizeof(JSParseNode));
|
||||
JS_ARENA_ALLOCATE_TYPE(pn, JSParseNode, &cx->tempPool);
|
||||
if (!pn)
|
||||
return NULL;
|
||||
pn->pn_type = tok->type;
|
||||
|
@ -150,7 +150,7 @@ NewBinary(JSContext *cx, JSTokenType tt,
|
|||
|
||||
if (!left || !right)
|
||||
return NULL;
|
||||
JS_ARENA_ALLOCATE(pn, &cx->tempPool, sizeof(JSParseNode));
|
||||
JS_ARENA_ALLOCATE_TYPE(pn, JSParseNode, &cx->tempPool);
|
||||
if (!pn)
|
||||
return NULL;
|
||||
pn->pn_type = tt;
|
||||
|
@ -2812,7 +2812,7 @@ js_FoldConstants(JSContext *cx, JSParseNode *pn)
|
|||
length = length1 + length2;
|
||||
nbytes = (length + 1) * sizeof(jschar);
|
||||
mark = JS_ARENA_MARK(&cx->tempPool);
|
||||
JS_ARENA_ALLOCATE(chars, &cx->tempPool, nbytes);
|
||||
JS_ARENA_ALLOCATE_CAST(chars, jschar *, &cx->tempPool, nbytes);
|
||||
if (!chars) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
|
|
@ -2027,7 +2027,7 @@ js_ExecuteRegExp(JSContext *cx, JSRegExp *re, JSString *str, size_t *indexp,
|
|||
*/
|
||||
length = 2 * sizeof(JSSubString) * re->parenCount;
|
||||
mark = JS_ARENA_MARK(&cx->tempPool);
|
||||
JS_ARENA_ALLOCATE(parsub, &cx->tempPool, length);
|
||||
JS_ARENA_ALLOCATE_CAST(parsub, JSSubString *, &cx->tempPool, length);
|
||||
if (!parsub) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
|
|
@ -223,7 +223,7 @@ js_NewBufferTokenStream(JSContext *cx, const jschar *base, size_t length)
|
|||
}
|
||||
|
||||
nb = sizeof(JSTokenStream) + JS_LINE_LIMIT * sizeof(jschar);
|
||||
JS_ARENA_ALLOCATE(ts, &cx->tempPool, nb);
|
||||
JS_ARENA_ALLOCATE_CAST(ts, JSTokenStream *, &cx->tempPool, nb);
|
||||
if (!ts) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return NULL;
|
||||
|
@ -246,7 +246,8 @@ js_NewFileTokenStream(JSContext *cx, const char *filename, FILE *defaultfp)
|
|||
JSTokenStream *ts;
|
||||
FILE *file;
|
||||
|
||||
JS_ARENA_ALLOCATE(base, &cx->tempPool, JS_LINE_LIMIT * sizeof(jschar));
|
||||
JS_ARENA_ALLOCATE_CAST(base, jschar *, &cx->tempPool,
|
||||
JS_LINE_LIMIT * sizeof(jschar));
|
||||
if (!base)
|
||||
return NULL;
|
||||
ts = js_NewBufferTokenStream(cx, base, JS_LINE_LIMIT);
|
||||
|
@ -643,10 +644,10 @@ GrowTokenBuf(JSContext *cx, JSTokenBuf *tb)
|
|||
tbincr = (length + TBINCR) * sizeof(jschar);
|
||||
pool = &cx->tempPool;
|
||||
if (!base) {
|
||||
JS_ARENA_ALLOCATE(base, pool, tbincr);
|
||||
JS_ARENA_ALLOCATE_CAST(base, jschar *, pool, tbincr);
|
||||
} else {
|
||||
tbsize = (size_t)(length * sizeof(jschar));
|
||||
JS_ARENA_GROW(base, pool, tbsize, tbincr);
|
||||
JS_ARENA_GROW_CAST(base, jschar *, pool, tbsize, tbincr);
|
||||
}
|
||||
if (!base) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
|
|
|
@ -293,7 +293,7 @@ XDRAtomMap(JSXDRState *xdr, JSAtomMap *map)
|
|||
mark = JS_ARENA_MARK(&cx->tempPool);
|
||||
ATOM_LIST_INIT(&al);
|
||||
for (i = 0; i < length; i++) {
|
||||
JS_ARENA_ALLOCATE(ale, &cx->tempPool, sizeof(*ale));
|
||||
JS_ARENA_ALLOCATE_TYPE(ale, JSAtomListElement, &cx->tempPool);
|
||||
if (!ale ||
|
||||
!XDRAtom1(xdr, ale)) {
|
||||
if (!ale)
|
||||
|
|
Загрузка…
Ссылка в новой задаче