Bug 511695: Fix JS warnings in MSVC8, r=brendan

This commit is contained in:
David Mandelin 2009-09-23 11:16:30 -07:00
Родитель a552e31746
Коммит 882de1b418
19 изменённых файлов: 95 добавлений и 59 удалений

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

@ -401,7 +401,7 @@ IndexToId(JSContext* cx, JSObject* obj, jsdouble index, JSBool* hole, jsid* idp,
JSBool createAtom = JS_FALSE)
{
if (index <= JSVAL_INT_MAX) {
*idp = INT_TO_JSID(index);
*idp = INT_TO_JSID(int(index));
return JS_TRUE;
}
@ -2609,7 +2609,7 @@ array_unshift(JSContext *cx, uintN argc, jsval *vp)
argv = JS_ARGV(cx, vp);
if (length > 0) {
if (OBJ_IS_DENSE_ARRAY(cx, obj) && !js_PrototypeHasIndexedProperties(cx, obj) &&
!INDEX_TOO_SPARSE(obj, newlen + argc)) {
!INDEX_TOO_SPARSE(obj, unsigned(newlen + argc))) {
JS_ASSERT(newlen + argc == length + argc);
if (!EnsureCapacity(cx, obj, length + argc))
return JS_FALSE;

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

@ -123,7 +123,7 @@ struct JSNativeTraceInfo {
#define _JS_PTR_ARGSIZE nanojit::ARGSIZE_P
#define _JS_PTR_RETSIZE nanojit::ARGSIZE_P
class ClosureVarInfo;
struct ClosureVarInfo;
/*
* Supported types for builtin functions.

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

@ -101,7 +101,7 @@ namespace nanojit {
class LabelMap;
#endif
extern "C++" {
template<typename K> class DefaultHash;
template<typename K> struct DefaultHash;
template<typename K, typename V, typename H> class HashMap;
template<typename T> class Seq;
}

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

@ -229,7 +229,7 @@ static intN
DaysInMonth(jsint year, jsint month)
{
JSBool leap = (DaysInYear(year) == 366);
intN result = DayFromMonth(month, leap) - DayFromMonth(month-1, leap);
intN result = intN(DayFromMonth(month, leap) - DayFromMonth(month-1, leap));
return result;
}

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

@ -2312,26 +2312,23 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
JS_ASSERT(op != JSOP_CALLEE);
JS_ASSERT((cg->fun->flags & JSFUN_LAMBDA) && atom == cg->fun->atom);
switch (op) {
default:
/*
* Leave pn->pn_op == JSOP_NAME if cg->fun is heavyweight, as
* we cannot be sure cg->fun is not something of the form:
*
* var ff = (function f(s) { eval(s); return f; });
*
* where a caller invokes ff("var f = 42"). The result returned
* for such an invocation must be 42, since the callee name is
* lexically bound in an outer declarative environment from the
* function's activation. See jsfun.cpp:call_resolve.
*/
JS_ASSERT(op != JSOP_DELNAME);
if (!(cg->flags & TCF_FUN_HEAVYWEIGHT)) {
op = JSOP_CALLEE;
pn->pn_dflags |= PND_CONST;
}
break;
/*
* Leave pn->pn_op == JSOP_NAME if cg->fun is heavyweight, as we
* cannot be sure cg->fun is not something of the form:
*
* var ff = (function f(s) { eval(s); return f; });
*
* where a caller invokes ff("var f = 42"). The result returned for
* such an invocation must be 42, since the callee name is
* lexically bound in an outer declarative environment from the
* function's activation. See jsfun.cpp:call_resolve.
*/
JS_ASSERT(op != JSOP_DELNAME);
if (!(cg->flags & TCF_FUN_HEAVYWEIGHT)) {
op = JSOP_CALLEE;
pn->pn_dflags |= PND_CONST;
}
pn->pn_op = op;
pn->pn_dflags |= PND_BOUND;
return JS_TRUE;

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

@ -429,7 +429,7 @@ struct JSCodeGenerator : public JSTreeContext
~JSCodeGenerator();
bool hasSharps() {
bool rv = flags & TCF_HAS_SHARPS;
bool rv = !!(flags & TCF_HAS_SHARPS);
JS_ASSERT((sharpSlotBase >= 0) == rv);
return rv;
}

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

@ -1555,7 +1555,7 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp)
nupvars = flagsword >> 16;
fun->flags = uint16(flagsword);
fun->u.i.skipmin = uint16(firstword >> 2);
fun->u.i.wrapper = (firstword >> 1) & 1;
fun->u.i.wrapper = JSPackedBool((firstword >> 1) & 1);
}
/* do arguments and local vars */
@ -2920,7 +2920,7 @@ get_local_names_enumerator(JSDHashTable *table, JSDHashEntryHdr *hdr,
entry->localKind == JSLOCAL_CONST ||
entry->localKind == JSLOCAL_UPVAR);
JS_ASSERT(entry->index < args->fun->u.i.nvars + args->fun->u.i.nupvars);
JS_ASSERT(args->nCopiedVars++ < args->fun->u.i.nvars + args->fun->u.i.nupvars);
JS_ASSERT(args->nCopiedVars++ < unsigned(args->fun->u.i.nvars + args->fun->u.i.nupvars));
i = args->fun->nargs;
if (entry->localKind == JSLOCAL_UPVAR)
i += args->fun->u.i.nvars;

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

@ -2554,7 +2554,7 @@ AssertValidPropertyCacheHit(JSContext *cx, JSScript *script, JSFrameRegs& regs,
JSObject *obj, *pobj;
JSProperty *prop;
bool ok;
JSBool ok;
if (JOF_OPMODE(*regs.pc) == JOF_NAME) {
ok = js_FindProperty(cx, ATOM_TO_JSID(atom), &obj, &pobj, &prop);

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

@ -1951,7 +1951,7 @@ obj_getPrototypeOf(JSContext *cx, uintN argc, jsval *vp)
}
if (JSVAL_IS_PRIMITIVE(vp[2])) {
char *bytes = js_DecompileValueGenerator(cx, -argc, vp[2], NULL);
char *bytes = js_DecompileValueGenerator(cx, 0 - argc, vp[2], NULL);
if (!bytes)
return JS_FALSE;
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
@ -2792,7 +2792,7 @@ block_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
JSBool
js_DefineBlockVariable(JSContext *cx, JSObject *obj, jsid id, int16 index)
js_DefineBlockVariable(JSContext *cx, JSObject *obj, jsid id, intN index)
{
JS_ASSERT(obj->getClass() == &js_BlockClass);
JS_ASSERT(!OBJ_IS_CLONED_BLOCK(obj));

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

@ -351,17 +351,25 @@ struct JSObject {
#define STOBJ_NSLOTS(obj) \
((obj)->dslots ? (uint32)(obj)->dslots[-1] : (uint32)JS_INITIAL_NSLOTS)
#define STOBJ_GET_SLOT(obj,slot) \
((slot) < JS_INITIAL_NSLOTS \
? (obj)->fslots[(slot)] \
: (JS_ASSERT((slot) < (uint32)(obj)->dslots[-1]), \
(obj)->dslots[(slot) - JS_INITIAL_NSLOTS]))
inline jsval&
STOBJ_GET_SLOT(JSObject *obj, uintN slot)
{
return (slot < JS_INITIAL_NSLOTS)
? obj->fslots[slot]
: (JS_ASSERT(slot < (uint32)obj->dslots[-1]),
obj->dslots[slot - JS_INITIAL_NSLOTS]);
}
#define STOBJ_SET_SLOT(obj,slot,value) \
((slot) < JS_INITIAL_NSLOTS \
? (obj)->fslots[(slot)] = (value) \
: (JS_ASSERT((slot) < (uint32)(obj)->dslots[-1]), \
(obj)->dslots[(slot) - JS_INITIAL_NSLOTS] = (value)))
inline void
STOBJ_SET_SLOT(JSObject *obj, uintN slot, jsval value)
{
if (slot < JS_INITIAL_NSLOTS) {
obj->fslots[slot] = value;
} else {
JS_ASSERT(slot < (uint32)obj->dslots[-1]);
obj->dslots[slot - JS_INITIAL_NSLOTS] = value;
}
}
inline JSClass*
STOBJ_GET_CLASS(const JSObject* obj)
@ -493,7 +501,7 @@ OBJ_IS_CLONED_BLOCK(JSObject *obj)
}
extern JSBool
js_DefineBlockVariable(JSContext *cx, JSObject *obj, jsid id, int16 index);
js_DefineBlockVariable(JSContext *cx, JSObject *obj, jsid id, intN index);
#define OBJ_BLOCK_COUNT(cx,obj) \
(OBJ_SCOPE(obj)->entryCount)

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

@ -64,6 +64,11 @@
#include "jsatominlines.h"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4351)
#endif
struct JSONParser
{
JSONParser(JSContext *cx)
@ -83,6 +88,10 @@ struct JSONParser
js::Vector<jschar, 8> buffer;
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
JSClass js_JSONClass = {
js_JSON_str,
JSCLASS_HAS_CACHED_PROTO(JSProto_JSON),

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

@ -5830,7 +5830,7 @@ bool
js_ContainsRegExpMetaChars(const jschar *chars, size_t length)
{
for (size_t i = 0; i < length; ++i) {
char c = chars[i];
jschar c = chars[i];
switch (c) {
/* Taken from the PatternCharacter production in 15.10.1. */
case '^': case '$': case '\\': case '.': case '*': case '+':

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

@ -176,12 +176,21 @@ js_IsIdentifier(JSString *str)
return JS_TRUE;
}
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4351)
#endif
/* Initialize members that aren't initialized in |init|. */
JSTokenStream::JSTokenStream(JSContext *cx)
: tokens(), cursor(), lookahead(), ungetpos(), ungetbuf(), flags(), linelen(),
linepos(), file(), listenerTSData(), saveEOL(), tokenbuf(cx)
{}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
bool
JSTokenStream::init(JSContext *cx, const jschar *base, size_t length,
FILE *fp, const char *fn, uintN ln)
@ -656,7 +665,7 @@ static JSBool
GetXMLEntity(JSContext *cx, JSTokenStream *ts)
{
ptrdiff_t offset, length, i;
int32 c, d;
int c, d;
JSBool ispair;
jschar *bp, digit;
char *bytes;
@ -858,7 +867,7 @@ JSTokenType
js_GetToken(JSContext *cx, JSTokenStream *ts)
{
JSTokenType tt;
int32 c, qc;
int c, qc;
JSToken *tp;
JSAtom *atom;
JSBool hadUnicodeEscape;

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

@ -50,6 +50,11 @@
#include "jsprvtd.h"
#include "jspubtd.h"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4800)
#endif
JS_BEGIN_EXTERN_C
/*
@ -837,4 +842,8 @@ js_FinishPropertyTree(JSRuntime *rt);
JS_END_EXTERN_C
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif /* jsscope_h___ */

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

@ -100,6 +100,10 @@ typedef JSUintPtr uintptr_t;
* we would require compiler assistance, and at the moment we don't need
* preprocessor-correctness.
*/
#ifdef _MSC_VER
#undef SIZE_MAX
#endif
#define INTPTR_MAX ((intptr_t) (UINTPTR_MAX >> 1))
#define INTPTR_MIN (intptr_t(uintptr_t(INTPTR_MAX) + uintptr_t(1)))
#define UINTPTR_MAX ((uintptr_t) -1)

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

@ -1452,8 +1452,8 @@ DoMatch(JSContext *cx, jsval *vp, JSString *str, const RegExpGuard &g,
}
} else {
/* single match */
bool testSingle = flags & TEST_SINGLE_BIT,
callbackOnSingle = flags & CALLBACK_ON_SINGLE_BIT;
bool testSingle = !!(flags & TEST_SINGLE_BIT),
callbackOnSingle = !!(flags & CALLBACK_ON_SINGLE_BIT);
size_t i = 0;
if (!js_ExecuteRegExp(cx, g.re(), str, &i, testSingle, vp))
return false;
@ -1494,7 +1494,7 @@ MatchCallback(JSContext *cx, size_t count, void *p)
jsval v = STRING_TO_JSVAL(matchstr);
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING);
return arrayobj->setProperty(cx, INT_TO_JSID(count), &v);
return !!arrayobj->setProperty(cx, INT_TO_JSID(count), &v);
}
static bool

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

@ -222,7 +222,7 @@ jitstats_getProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
if (result < JSVAL_INT_MAX) {
*vp = INT_TO_JSVAL(result);
*vp = INT_TO_JSVAL(jsint(result));
return JS_TRUE;
}
char retstr[64];
@ -967,7 +967,7 @@ isInt32(jsval v)
return false;
jsdouble d = asNumber(v);
jsint i;
return JSDOUBLE_IS_INT(d, i);
return !!JSDOUBLE_IS_INT(d, i);
}
static inline jsint
@ -4905,7 +4905,7 @@ TraceRecorder::emitIf(jsbytecode* pc, bool cond, LIns* x)
* here, so we later know whether to emit a loop edge or a loop end.
*/
if (x->isconst()) {
loop = (x->imm32() == cond);
loop = (x->imm32() == int32(cond));
return;
}
} else {
@ -8193,7 +8193,7 @@ static bool
EvalCmp(LOpcode op, JSString* l, JSString* r)
{
if (op == LIR_feq)
return js_EqualStrings(l, r);
return !!js_EqualStrings(l, r);
return EvalCmp(op, js_CompareStrings(l, r), 0);
}
@ -8214,7 +8214,7 @@ TraceRecorder::strictEquality(bool equal, bool cmpCase)
} else if (ltag == TT_STRING) {
LIns* args[] = { r_ins, l_ins };
x = lir->ins2i(LIR_eq, lir->insCall(&js_EqualStrings_ci, args), equal);
cond = js_EqualStrings(JSVAL_TO_STRING(l), JSVAL_TO_STRING(r));
cond = !!js_EqualStrings(JSVAL_TO_STRING(l), JSVAL_TO_STRING(r));
} else {
LOpcode op;
if (ltag == TT_DOUBLE)
@ -8282,7 +8282,7 @@ TraceRecorder::equalityHelper(jsval l, jsval r, LIns* l_ins, LIns* r_ins,
args[0] = r_ins, args[1] = l_ins;
l_ins = lir->insCall(&js_EqualStrings_ci, args);
r_ins = lir->insImm(1);
cond = js_EqualStrings(JSVAL_TO_STRING(l), JSVAL_TO_STRING(r));
cond = !!js_EqualStrings(JSVAL_TO_STRING(l), JSVAL_TO_STRING(r));
} else {
JS_ASSERT(isNumber(l) && isNumber(r));
cond = (asNumber(l) == asNumber(r));
@ -8306,7 +8306,7 @@ TraceRecorder::equalityHelper(jsval l, jsval r, LIns* l_ins, LIns* r_ins,
op = LIR_feq;
} else {
if (JSVAL_IS_SPECIAL(l)) {
bool isVoid = JSVAL_IS_VOID(l);
bool isVoid = !!JSVAL_IS_VOID(l);
guard(isVoid,
lir->ins2(LIR_eq, l_ins, INS_CONST(JSVAL_TO_SPECIAL(JSVAL_VOID))),
BRANCH_EXIT);
@ -8320,7 +8320,7 @@ TraceRecorder::equalityHelper(jsval l, jsval r, LIns* l_ins, LIns* r_ins,
tryBranchAfterCond, rval);
}
} else if (JSVAL_IS_SPECIAL(r)) {
bool isVoid = JSVAL_IS_VOID(r);
bool isVoid = !!JSVAL_IS_VOID(r);
guard(isVoid,
lir->ins2(LIR_eq, r_ins, INS_CONST(JSVAL_TO_SPECIAL(JSVAL_VOID))),
BRANCH_EXIT);
@ -9886,7 +9886,7 @@ TraceRecorder::emitNativePropertyOp(JSScope* scope, JSScopeProperty* sprop, LIns
JS_REQUIRES_STACK JSRecordingStatus
TraceRecorder::emitNativeCall(JSSpecializedNative* sn, uintN argc, LIns* args[], bool rooted)
{
bool constructing = sn->flags & JSTN_CONSTRUCTOR;
bool constructing = !!(sn->flags & JSTN_CONSTRUCTOR);
if (JSTN_ERRTYPE(sn) == FAIL_STATUS) {
// This needs to capture the pre-call state of the stack. So do not set
@ -10114,7 +10114,7 @@ TraceRecorder::callNative(uintN argc, JSOp mode)
ABORT_TRACE("trying to call native apply or call");
// Allocate the vp vector and emit code to root it.
uintN vplen = 2 + JS_MAX(argc, FUN_MINARGS(fun)) + fun->u.n.extra;
uintN vplen = 2 + JS_MAX(argc, unsigned(FUN_MINARGS(fun))) + fun->u.n.extra;
if (!(fun->flags & JSFUN_FAST_NATIVE))
vplen++; // slow native return value slot
LIns* invokevp_ins = lir->insAlloc(vplen * sizeof(jsval));

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

@ -510,7 +510,7 @@ struct FrameInfo {
void set_argc(uint16 argc, bool constructing) {
this->argc = uint32(argc) | (constructing ? CONSTRUCTING_FLAG: 0);
}
uint16 get_argc() const { return argc & ~CONSTRUCTING_FLAG; }
uint16 get_argc() const { return uint16(argc & ~CONSTRUCTING_FLAG); }
bool is_constructing() const { return (argc & CONSTRUCTING_FLAG) != 0; }
// The typemap just before the callee is called.

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

@ -144,7 +144,7 @@ def check_output(out, err, rc, allow_oom):
if rc != 0:
# Allow a non-zero exit code if we want to allow OOM, but only if we
# actually got OOM.
return allow_oom and ': out of memory\n' in err
return allow_oom and ': out of memory' in err
return True