mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 12:32:55 +00:00
Bug 933810 - Really remove JS_ValueToECMAUint32. r=terrence f=mccr8
This commit is contained in:
parent
67d774a820
commit
37ee9de83c
@ -258,14 +258,12 @@ GC(JSContext *cx,
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
static bool
|
||||
GCZeal(JSContext *cx,
|
||||
unsigned argc,
|
||||
JS::Value *vp)
|
||||
GCZeal(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
JS::Value* argv = JS_ARGV(cx, vp);
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
uint32_t zeal;
|
||||
if (!JS_ValueToECMAUint32(cx, argv[0], &zeal))
|
||||
if (!ToUint32(cx, args.get(0), &zeal))
|
||||
return false;
|
||||
|
||||
JS_SetGCZeal(cx, uint8_t(zeal), JS_DEFAULT_ZEAL_FREQ);
|
||||
@ -273,96 +271,6 @@ GCZeal(JSContext *cx,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static bool
|
||||
DumpHeap(JSContext *cx,
|
||||
unsigned argc,
|
||||
JS::Value *vp)
|
||||
{
|
||||
JSAutoByteString fileName;
|
||||
void* startThing = nullptr;
|
||||
JSGCTraceKind startTraceKind = JSTRACE_OBJECT;
|
||||
void *thingToFind = nullptr;
|
||||
size_t maxDepth = (size_t)-1;
|
||||
void *thingToIgnore = nullptr;
|
||||
FILE *dumpFile;
|
||||
bool ok;
|
||||
|
||||
JS::Value *argv = JS_ARGV(cx, vp);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
vp = argv + 0;
|
||||
if (argc > 0 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
JSString *str;
|
||||
|
||||
str = JS_ValueToString(cx, *vp);
|
||||
if (!str)
|
||||
return false;
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
if (!fileName.encodeLatin1(cx, str))
|
||||
return false;
|
||||
}
|
||||
|
||||
vp = argv + 1;
|
||||
if (argc > 1 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
if (!JSVAL_IS_TRACEABLE(*vp))
|
||||
goto not_traceable_arg;
|
||||
startThing = JSVAL_TO_TRACEABLE(*vp);
|
||||
startTraceKind = JSVAL_TRACE_KIND(*vp);
|
||||
}
|
||||
|
||||
vp = argv + 2;
|
||||
if (argc > 2 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
if (!JSVAL_IS_TRACEABLE(*vp))
|
||||
goto not_traceable_arg;
|
||||
thingToFind = JSVAL_TO_TRACEABLE(*vp);
|
||||
}
|
||||
|
||||
vp = argv + 3;
|
||||
if (argc > 3 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
uint32_t depth;
|
||||
|
||||
if (!JS_ValueToECMAUint32(cx, *vp, &depth))
|
||||
return false;
|
||||
maxDepth = depth;
|
||||
}
|
||||
|
||||
vp = argv + 4;
|
||||
if (argc > 4 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
if (!JSVAL_IS_TRACEABLE(*vp))
|
||||
goto not_traceable_arg;
|
||||
thingToIgnore = JSVAL_TO_TRACEABLE(*vp);
|
||||
}
|
||||
|
||||
if (!fileName) {
|
||||
dumpFile = stdout;
|
||||
} else {
|
||||
dumpFile = fopen(fileName.ptr(), "w");
|
||||
if (!dumpFile) {
|
||||
fprintf(stderr, "dumpHeap: can't open %s: %s\n",
|
||||
fileName.ptr(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ok = JS_DumpHeap(JS_GetRuntime(cx), dumpFile, startThing, startTraceKind, thingToFind,
|
||||
maxDepth, thingToIgnore);
|
||||
if (dumpFile != stdout)
|
||||
fclose(dumpFile);
|
||||
if (!ok)
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return ok;
|
||||
|
||||
not_traceable_arg:
|
||||
fprintf(stderr,
|
||||
"dumpHeap: argument %u is not null or a heap-allocated thing\n",
|
||||
(unsigned)(vp - argv));
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
const JSFunctionSpec gGlobalFunctions[] =
|
||||
{
|
||||
JS_FS("print", Print, 0,0),
|
||||
@ -375,9 +283,6 @@ const JSFunctionSpec gGlobalFunctions[] =
|
||||
JS_FS("gc", GC, 0,0),
|
||||
#ifdef JS_GC_ZEAL
|
||||
JS_FS("gczeal", GCZeal, 1,0),
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
JS_FS("dumpHeap", DumpHeap, 5,0),
|
||||
#endif
|
||||
JS_FS_END
|
||||
};
|
||||
|
@ -269,18 +269,13 @@ static const struct ParamPair {
|
||||
};
|
||||
|
||||
static bool
|
||||
GCParameter(JSContext *cx, unsigned argc, jsval *vp)
|
||||
GCParameter(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
JSString *str;
|
||||
if (argc == 0) {
|
||||
str = JS_ValueToString(cx, JSVAL_VOID);
|
||||
JS_ASSERT(str);
|
||||
} else {
|
||||
str = JS_ValueToString(cx, vp[2]);
|
||||
if (!str)
|
||||
return false;
|
||||
vp[2] = STRING_TO_JSVAL(str);
|
||||
}
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
JSString *str = JS_ValueToString(cx, args.get(0));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
JSFlatString *flatStr = JS_FlattenString(cx, str);
|
||||
if (!flatStr)
|
||||
@ -300,24 +295,23 @@ GCParameter(JSContext *cx, unsigned argc, jsval *vp)
|
||||
}
|
||||
JSGCParamKey param = paramMap[paramIndex].param;
|
||||
|
||||
if (argc == 1) {
|
||||
// Request mode.
|
||||
if (args.length() == 1) {
|
||||
uint32_t value = JS_GetGCParameter(cx->runtime(), param);
|
||||
vp[0] = JS_NumberValue(value);
|
||||
args.rval().setNumber(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (param == JSGC_NUMBER ||
|
||||
param == JSGC_BYTES) {
|
||||
if (param == JSGC_NUMBER || param == JSGC_BYTES) {
|
||||
JS_ReportError(cx, "Attempt to change read-only parameter %s",
|
||||
paramMap[paramIndex].name);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t value;
|
||||
if (!JS_ValueToECMAUint32(cx, vp[3], &value)) {
|
||||
JS_ReportError(cx,
|
||||
"the second argument must be convertable to uint32_t "
|
||||
"with non-zero value");
|
||||
if (!ToUint32(cx, args[1], &value)) {
|
||||
JS_ReportError(cx, "the second argument must be convertable to uint32_t "
|
||||
"with non-zero value");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -333,12 +327,12 @@ GCParameter(JSContext *cx, unsigned argc, jsval *vp)
|
||||
}
|
||||
|
||||
JS_SetGCParameter(cx->runtime(), param, value);
|
||||
*vp = JSVAL_VOID;
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
IsProxy(JSContext *cx, unsigned argc, jsval *vp)
|
||||
IsProxy(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (argc != 1) {
|
||||
@ -396,29 +390,33 @@ GCPreserveCode(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
static bool
|
||||
GCZeal(JSContext *cx, unsigned argc, jsval *vp)
|
||||
GCZeal(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
uint32_t zeal, frequency = JS_DEFAULT_ZEAL_FREQ;
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (argc > 2) {
|
||||
if (args.length() > 2) {
|
||||
RootedObject callee(cx, &args.callee());
|
||||
ReportUsageError(cx, callee, "Too many arguments");
|
||||
return false;
|
||||
}
|
||||
if (!JS_ValueToECMAUint32(cx, argc < 1 ? JSVAL_VOID : args[0], &zeal))
|
||||
|
||||
uint32_t zeal;
|
||||
if (!ToUint32(cx, args.get(0), &zeal))
|
||||
return false;
|
||||
if (argc >= 2)
|
||||
if (!JS_ValueToECMAUint32(cx, args[1], &frequency))
|
||||
|
||||
uint32_t frequency = JS_DEFAULT_ZEAL_FREQ;
|
||||
if (args.length() >= 2) {
|
||||
if (!ToUint32(cx, args.get(1), &frequency))
|
||||
return false;
|
||||
}
|
||||
|
||||
JS_SetGCZeal(cx, (uint8_t)zeal, frequency);
|
||||
*vp = JSVAL_VOID;
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
ScheduleGC(JSContext *cx, unsigned argc, jsval *vp)
|
||||
ScheduleGC(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
@ -440,24 +438,24 @@ ScheduleGC(JSContext *cx, unsigned argc, jsval *vp)
|
||||
PrepareZoneForGC(args[0].toString()->zone());
|
||||
}
|
||||
|
||||
*vp = JSVAL_VOID;
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
SelectForGC(JSContext *cx, unsigned argc, jsval *vp)
|
||||
SelectForGC(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
JSRuntime *rt = cx->runtime();
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
for (unsigned i = 0; i < argc; i++) {
|
||||
Value arg(JS_ARGV(cx, vp)[i]);
|
||||
if (arg.isObject()) {
|
||||
if (!rt->gcSelectedForMarking.append(&arg.toObject()))
|
||||
JSRuntime *rt = cx->runtime();
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
if (args[i].isObject()) {
|
||||
if (!rt->gcSelectedForMarking.append(&args[i].toObject()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*vp = JSVAL_VOID;
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -466,13 +464,14 @@ VerifyPreBarriers(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (argc) {
|
||||
if (args.length() > 0) {
|
||||
RootedObject callee(cx, &args.callee());
|
||||
ReportUsageError(cx, callee, "Too many arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
gc::VerifyBarriers(cx->runtime(), gc::PreBarrierVerifier);
|
||||
*vp = JSVAL_VOID;
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -536,27 +535,27 @@ DeterministicGC(JSContext *cx, unsigned argc, jsval *vp)
|
||||
#endif /* JS_GC_ZEAL */
|
||||
|
||||
static bool
|
||||
GCSlice(JSContext *cx, unsigned argc, jsval *vp)
|
||||
GCSlice(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
bool limit = true;
|
||||
uint32_t budget = 0;
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (argc > 1) {
|
||||
if (args.length() > 1) {
|
||||
RootedObject callee(cx, &args.callee());
|
||||
ReportUsageError(cx, callee, "Wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
if (!JS_ValueToECMAUint32(cx, args[0], &budget))
|
||||
bool limit = true;
|
||||
uint32_t budget = 0;
|
||||
if (args.length() == 1) {
|
||||
if (!ToUint32(cx, args[0], &budget))
|
||||
return false;
|
||||
} else {
|
||||
limit = false;
|
||||
}
|
||||
|
||||
GCDebugSlice(cx->runtime(), limit, budget);
|
||||
*vp = JSVAL_VOID;
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -565,14 +564,14 @@ ValidateGC(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (argc != 1) {
|
||||
if (args.length() != 1) {
|
||||
RootedObject callee(cx, &args.callee());
|
||||
ReportUsageError(cx, callee, "Wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
gc::SetValidateGC(cx, ToBoolean(vp[2]));
|
||||
*vp = JSVAL_VOID;
|
||||
gc::SetValidateGC(cx, ToBoolean(args[0]));
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -581,14 +580,14 @@ FullCompartmentChecks(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (argc != 1) {
|
||||
if (args.length() != 1) {
|
||||
RootedObject callee(cx, &args.callee());
|
||||
ReportUsageError(cx, callee, "Wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
gc::SetFullCompartmentChecks(cx, ToBoolean(vp[2]));
|
||||
*vp = JSVAL_VOID;
|
||||
gc::SetFullCompartmentChecks(cx, ToBoolean(args[0]));
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *for
|
||||
return false;
|
||||
break;
|
||||
case 'u':
|
||||
if (!JS_ValueToECMAUint32(cx, *sp, va_arg(ap, uint32_t *)))
|
||||
if (!ToUint32(cx, arg, va_arg(ap, uint32_t *)))
|
||||
return false;
|
||||
break;
|
||||
case 'j':
|
||||
@ -447,14 +447,6 @@ JS_DoubleToUint32(double d)
|
||||
return ToUint32(d);
|
||||
}
|
||||
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_ValueToECMAUint32(JSContext *cx, jsval valueArg, uint32_t *ip)
|
||||
{
|
||||
RootedValue value(cx, valueArg);
|
||||
return JS::ToUint32(cx, value, ip);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_ValueToInt64(JSContext *cx, jsval valueArg, int64_t *ip)
|
||||
{
|
||||
|
@ -1107,13 +1107,6 @@ JS_DoubleToInt32(double d);
|
||||
extern JS_PUBLIC_API(uint32_t)
|
||||
JS_DoubleToUint32(double d);
|
||||
|
||||
/*
|
||||
* Convert a value to a number, then to an int32_t, according to the ECMA rules
|
||||
* for ToInt32.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_ValueToECMAInt32(JSContext *cx, jsval v, int32_t *ip);
|
||||
|
||||
/*
|
||||
* Convert a value to a number, then to an int64_t, according to the WebIDL
|
||||
* rules for ToInt64: http://dev.w3.org/2006/webapi/WebIDL/#es-long-long
|
||||
@ -1223,13 +1216,6 @@ ToUint64(JSContext *cx, JS::Handle<JS::Value> v, uint64_t *out)
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
/*
|
||||
* Convert a value to a number, then to a uint32_t, according to the ECMA rules
|
||||
* for ToUint32.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32_t *ip);
|
||||
|
||||
/*
|
||||
* Convert a value to a number, then to an int32_t if it fits by rounding to
|
||||
* nearest; but failing with an error report if the double is out of range
|
||||
|
@ -978,7 +978,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
if (!JSVAL_IS_VOID(v)) {
|
||||
uint32_t u;
|
||||
if (!JS_ValueToECMAUint32(cx, v, &u))
|
||||
if (!ToUint32(cx, v, &u))
|
||||
return false;
|
||||
lineNumber = u;
|
||||
}
|
||||
@ -1663,28 +1663,26 @@ static bool
|
||||
LineToPC(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
RootedScript script(cx);
|
||||
int32_t lineArg = 0;
|
||||
uint32_t lineno;
|
||||
jsbytecode *pc;
|
||||
|
||||
if (args.length() == 0) {
|
||||
JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_LINE2PC_USAGE);
|
||||
return false;
|
||||
}
|
||||
script = GetTopScript(cx);
|
||||
jsval v = args[0];
|
||||
if (!JSVAL_IS_PRIMITIVE(v) &&
|
||||
JS_GetClass(&v.toObject()) == Jsvalify(&JSFunction::class_))
|
||||
{
|
||||
script = ValueToScript(cx, v);
|
||||
|
||||
RootedScript script(cx, GetTopScript(cx));
|
||||
int32_t lineArg = 0;
|
||||
if (args[0].isObject() && args[0].toObject().is<JSFunction>()) {
|
||||
script = ValueToScript(cx, args[0]);
|
||||
if (!script)
|
||||
return false;
|
||||
lineArg++;
|
||||
}
|
||||
if (!JS_ValueToECMAUint32(cx, args[lineArg], &lineno))
|
||||
return false;
|
||||
pc = JS_LineNumberToPC(cx, script, lineno);
|
||||
|
||||
uint32_t lineno;
|
||||
if (!ToUint32(cx, args.get(lineArg), &lineno))
|
||||
return false;
|
||||
|
||||
jsbytecode *pc = JS_LineNumberToPC(cx, script, lineno);
|
||||
if (!pc)
|
||||
return false;
|
||||
args.rval().setInt32(pc - script->code);
|
||||
@ -2190,107 +2188,76 @@ DumpHeap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
jsval v;
|
||||
void* startThing;
|
||||
JSGCTraceKind startTraceKind;
|
||||
const char *badTraceArg;
|
||||
void *thingToFind;
|
||||
size_t maxDepth;
|
||||
void *thingToIgnore;
|
||||
FILE *dumpFile;
|
||||
bool ok;
|
||||
JSAutoByteString fileName;
|
||||
if (args.hasDefined(0)) {
|
||||
RootedString str(cx, JS_ValueToString(cx, args[0]));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
const char *fileName = nullptr;
|
||||
JSAutoByteString fileNameBytes;
|
||||
if (args.length() > 0) {
|
||||
v = args[0];
|
||||
if (!v.isNull()) {
|
||||
JSString *str;
|
||||
|
||||
str = JS_ValueToString(cx, v);
|
||||
if (!str)
|
||||
return false;
|
||||
args[0].setString(str);
|
||||
if (!fileNameBytes.encodeLatin1(cx, str))
|
||||
return false;
|
||||
fileName = fileNameBytes.ptr();
|
||||
}
|
||||
if (!fileName.encodeLatin1(cx, str))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Grab the depth param first, because JS_ValueToECMAUint32 can GC, and
|
||||
// there's no easy way to root the traceable void* parameters below.
|
||||
maxDepth = (size_t)-1;
|
||||
if (args.length() > 3) {
|
||||
v = args[3];
|
||||
if (!v.isNull()) {
|
||||
uint32_t depth;
|
||||
|
||||
if (!JS_ValueToECMAUint32(cx, v, &depth))
|
||||
return false;
|
||||
maxDepth = depth;
|
||||
RootedValue startThing(cx);
|
||||
if (args.hasDefined(1)) {
|
||||
if (!args[1].isGCThing()) {
|
||||
JS_ReportError(cx, "dumpHeap: Second argument not a GC thing!");
|
||||
return false;
|
||||
}
|
||||
startThing = args[1];
|
||||
}
|
||||
|
||||
startThing = nullptr;
|
||||
startTraceKind = JSTRACE_OBJECT;
|
||||
if (args.length() > 1) {
|
||||
v = args[1];
|
||||
if (v.isMarkable()) {
|
||||
startThing = JSVAL_TO_TRACEABLE(v);
|
||||
startTraceKind = v.gcKind();
|
||||
} else if (!v.isNull()) {
|
||||
badTraceArg = "start";
|
||||
goto not_traceable_arg;
|
||||
RootedValue thingToFind(cx);
|
||||
if (args.hasDefined(2)) {
|
||||
if (!args[2].isGCThing()) {
|
||||
JS_ReportError(cx, "dumpHeap: Third argument not a GC thing!");
|
||||
return false;
|
||||
}
|
||||
thingToFind = args[2];
|
||||
}
|
||||
|
||||
thingToFind = nullptr;
|
||||
if (args.length() > 2) {
|
||||
v = args[2];
|
||||
if (v.isMarkable()) {
|
||||
thingToFind = JSVAL_TO_TRACEABLE(v);
|
||||
} else if (!v.isNull()) {
|
||||
badTraceArg = "toFind";
|
||||
goto not_traceable_arg;
|
||||
}
|
||||
size_t maxDepth = size_t(-1);
|
||||
if (args.hasDefined(3)) {
|
||||
uint32_t depth;
|
||||
if (!ToUint32(cx, args[3], &depth))
|
||||
return false;
|
||||
maxDepth = depth;
|
||||
}
|
||||
|
||||
thingToIgnore = nullptr;
|
||||
if (args.length() > 4) {
|
||||
v = args[4];
|
||||
if (v.isMarkable()) {
|
||||
thingToIgnore = JSVAL_TO_TRACEABLE(v);
|
||||
} else if (!v.isNull()) {
|
||||
badTraceArg = "toIgnore";
|
||||
goto not_traceable_arg;
|
||||
RootedValue thingToIgnore(cx);
|
||||
if (args.hasDefined(4)) {
|
||||
if (!args[2].isGCThing()) {
|
||||
JS_ReportError(cx, "dumpHeap: Fifth argument not a GC thing!");
|
||||
return false;
|
||||
}
|
||||
thingToIgnore = args[4];
|
||||
}
|
||||
|
||||
if (!fileName) {
|
||||
dumpFile = stdout;
|
||||
} else {
|
||||
dumpFile = fopen(fileName, "w");
|
||||
|
||||
FILE *dumpFile = stdout;
|
||||
if (fileName.length()) {
|
||||
dumpFile = fopen(fileName.ptr(), "w");
|
||||
if (!dumpFile) {
|
||||
JS_ReportError(cx, "can't open %s: %s", fileName, strerror(errno));
|
||||
JS_ReportError(cx, "dumpHeap: can't open %s: %s\n",
|
||||
fileName.ptr(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ok = JS_DumpHeap(JS_GetRuntime(cx), dumpFile, startThing, startTraceKind, thingToFind,
|
||||
maxDepth, thingToIgnore);
|
||||
bool ok = JS_DumpHeap(JS_GetRuntime(cx), dumpFile,
|
||||
startThing.isUndefined() ? nullptr : startThing.toGCThing(),
|
||||
startThing.isUndefined() ? JSTRACE_OBJECT : startThing.get().gcKind(),
|
||||
thingToFind.isUndefined() ? nullptr : thingToFind.toGCThing(),
|
||||
maxDepth,
|
||||
thingToIgnore.isUndefined() ? nullptr : thingToIgnore.toGCThing());
|
||||
|
||||
if (dumpFile != stdout)
|
||||
fclose(dumpFile);
|
||||
if (!ok) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
|
||||
not_traceable_arg:
|
||||
JS_ReportError(cx, "argument '%s' is not null or a heap-allocated thing",
|
||||
badTraceArg);
|
||||
return false;
|
||||
if (!ok)
|
||||
JS_ReportOutOfMemory(cx);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -4305,7 +4305,7 @@ DebuggerGenericEval(JSContext *cx, const char *fullMethodName, const Value &code
|
||||
return false;
|
||||
if (!v.isUndefined()) {
|
||||
uint32_t lineno;
|
||||
if (!JS_ValueToECMAUint32(cx, v, &lineno))
|
||||
if (!ToUint32(cx, v, &lineno))
|
||||
return false;
|
||||
lineNumber = lineno;
|
||||
}
|
||||
|
@ -1845,7 +1845,7 @@ struct MOZ_STACK_CLASS ExceptionArgParser
|
||||
}
|
||||
|
||||
bool parseResult(HandleValue v) {
|
||||
return JS_ValueToECMAUint32(cx, v, (uint32_t*) &eResult);
|
||||
return JS::ToUint32(cx, v, (uint32_t*) &eResult);
|
||||
}
|
||||
|
||||
bool parseStack(HandleValue v) {
|
||||
@ -3687,8 +3687,9 @@ nsXPCComponents::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE)) {
|
||||
RootedValue v(cx, *vp);
|
||||
nsresult rv;
|
||||
if (JS_ValueToECMAUint32(cx, *vp, (uint32_t*)&rv)) {
|
||||
if (ToUint32(cx, v, (uint32_t*)&rv)) {
|
||||
xpcc->SetPendingResult(rv);
|
||||
xpcc->SetLastResult(rv);
|
||||
return NS_SUCCESS_I_DID_SOMETHING;
|
||||
|
@ -417,104 +417,17 @@ GC(JSContext *cx, unsigned argc, jsval *vp)
|
||||
static bool
|
||||
GCZeal(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
uint32_t zeal;
|
||||
if (!JS_ValueToECMAUint32(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID, &zeal))
|
||||
if (!ToUint32(cx, args.get(0), &zeal))
|
||||
return false;
|
||||
|
||||
JS_SetGCZeal(cx, uint8_t(zeal), JS_DEFAULT_ZEAL_FREQ);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static bool
|
||||
DumpHeap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
void* startThing = nullptr;
|
||||
JSGCTraceKind startTraceKind = JSTRACE_OBJECT;
|
||||
void *thingToFind = nullptr;
|
||||
size_t maxDepth = (size_t)-1;
|
||||
void *thingToIgnore = nullptr;
|
||||
FILE *dumpFile;
|
||||
bool ok;
|
||||
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
||||
vp = argv + 0;
|
||||
JSAutoByteString fileName;
|
||||
if (argc > 0 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
JSString *str;
|
||||
|
||||
str = JS_ValueToString(cx, *vp);
|
||||
if (!str)
|
||||
return false;
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
if (!fileName.encodeLatin1(cx, str))
|
||||
return false;
|
||||
}
|
||||
|
||||
vp = argv + 1;
|
||||
if (argc > 1 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
if (!JSVAL_IS_TRACEABLE(*vp))
|
||||
goto not_traceable_arg;
|
||||
startThing = JSVAL_TO_TRACEABLE(*vp);
|
||||
startTraceKind = JSVAL_TRACE_KIND(*vp);
|
||||
}
|
||||
|
||||
vp = argv + 2;
|
||||
if (argc > 2 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
if (!JSVAL_IS_TRACEABLE(*vp))
|
||||
goto not_traceable_arg;
|
||||
thingToFind = JSVAL_TO_TRACEABLE(*vp);
|
||||
}
|
||||
|
||||
vp = argv + 3;
|
||||
if (argc > 3 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
uint32_t depth;
|
||||
|
||||
if (!JS_ValueToECMAUint32(cx, *vp, &depth))
|
||||
return false;
|
||||
maxDepth = depth;
|
||||
}
|
||||
|
||||
vp = argv + 4;
|
||||
if (argc > 4 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) {
|
||||
if (!JSVAL_IS_TRACEABLE(*vp))
|
||||
goto not_traceable_arg;
|
||||
thingToIgnore = JSVAL_TO_TRACEABLE(*vp);
|
||||
}
|
||||
|
||||
if (!fileName) {
|
||||
dumpFile = gOutFile;
|
||||
} else {
|
||||
dumpFile = fopen(fileName.ptr(), "w");
|
||||
if (!dumpFile) {
|
||||
fprintf(gErrFile, "dumpHeap: can't open %s: %s\n",
|
||||
fileName.ptr(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ok = JS_DumpHeap(JS_GetRuntime(cx), dumpFile, startThing, startTraceKind, thingToFind,
|
||||
maxDepth, thingToIgnore);
|
||||
if (dumpFile != gOutFile)
|
||||
fclose(dumpFile);
|
||||
if (!ok)
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return ok;
|
||||
|
||||
not_traceable_arg:
|
||||
fprintf(gErrFile,
|
||||
"dumpHeap: argument %u is not null or a heap-allocated thing\n",
|
||||
(unsigned)(vp - argv));
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
static bool
|
||||
SendCommand(JSContext* cx,
|
||||
unsigned argc,
|
||||
@ -798,9 +711,6 @@ static const JSFunctionSpec glob_functions[] = {
|
||||
#endif
|
||||
JS_FS("options", Options, 0,0),
|
||||
JS_FN("parent", Parent, 1,0),
|
||||
#ifdef DEBUG
|
||||
JS_FS("dumpHeap", DumpHeap, 5,0),
|
||||
#endif
|
||||
JS_FS("sendCommand", SendCommand, 1,0),
|
||||
JS_FS("atob", Atob, 1,0),
|
||||
JS_FS("btoa", Btoa, 1,0),
|
||||
|
@ -287,14 +287,14 @@ def write_getter(a, iface, fd):
|
||||
fd.write(" aDict.%s = b;\n" % a.name)
|
||||
elif realtype.count("uint16_t"):
|
||||
fd.write(" uint32_t u;\n")
|
||||
fd.write(" NS_ENSURE_STATE(JS_ValueToECMAUint32(aCx, v, &u));\n")
|
||||
fd.write(" NS_ENSURE_STATE(JS::ToUint32(aCx, v, &u));\n")
|
||||
fd.write(" aDict.%s = u;\n" % a.name)
|
||||
elif realtype.count("int16_t"):
|
||||
fd.write(" int32_t i;\n")
|
||||
fd.write(" NS_ENSURE_STATE(JS::ToInt32(aCx, v, &i));\n")
|
||||
fd.write(" aDict.%s = i;\n" % a.name)
|
||||
elif realtype.count("uint32_t"):
|
||||
fd.write(" NS_ENSURE_STATE(JS_ValueToECMAUint32(aCx, v, &aDict.%s));\n" % a.name)
|
||||
fd.write(" NS_ENSURE_STATE(JS::ToUint32(aCx, v, &aDict.%s));\n" % a.name)
|
||||
elif realtype.count("int32_t"):
|
||||
fd.write(" NS_ENSURE_STATE(JS::ToInt32(aCx, v, &aDict.%s));\n" % a.name)
|
||||
elif realtype.count("uint64_t"):
|
||||
|
@ -385,7 +385,7 @@ def substitute(template, vals):
|
||||
argumentUnboxingTemplates = {
|
||||
'octet':
|
||||
" uint32_t ${name}_u32;\n"
|
||||
" if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n"
|
||||
" if (!JS::ToUint32(cx, ${argVal}, &${name}_u32))\n"
|
||||
" return false;\n"
|
||||
" uint8_t ${name} = (uint8_t) ${name}_u32;\n",
|
||||
|
||||
@ -397,7 +397,7 @@ argumentUnboxingTemplates = {
|
||||
|
||||
'unsigned short':
|
||||
" uint32_t ${name}_u32;\n"
|
||||
" if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n"
|
||||
" if (!JS::ToUint32(cx, ${argVal}, &${name}_u32))\n"
|
||||
" return false;\n"
|
||||
" uint16_t ${name} = (uint16_t) ${name}_u32;\n",
|
||||
|
||||
@ -408,7 +408,7 @@ argumentUnboxingTemplates = {
|
||||
|
||||
'unsigned long':
|
||||
" uint32_t ${name};\n"
|
||||
" if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}))\n"
|
||||
" if (!JS::ToUint32(cx, ${argVal}, &${name}))\n"
|
||||
" return false;\n",
|
||||
|
||||
'long long':
|
||||
|
Loading…
x
Reference in New Issue
Block a user