Backed out changeset 3e20fa222424 (bug 913224) for crashes on Android 4.0

This commit is contained in:
Ed Morley 2013-09-30 12:53:32 +01:00
parent e2fa844e98
commit e6ab16d6a2
5 changed files with 21 additions and 60 deletions

View File

@ -827,52 +827,32 @@ FinalizeCount(JSContext *cx, unsigned argc, jsval *vp)
static bool
DumpHeapComplete(JSContext *cx, unsigned argc, jsval *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
DumpHeapNurseryBehaviour nurseryBehaviour = js::IgnoreNurseryObjects;
FILE *dumpFile = NULL;
unsigned i = 0;
if (argc > i) {
Value v = args[i];
const char *fileName = nullptr;
JSAutoByteString fileNameBytes;
if (argc > 0) {
Value v = JS_ARGV(cx, vp)[0];
if (v.isString()) {
JSString *str = v.toString();
bool same = false;
if (!JS_StringEqualsAscii(cx, str, "collectNurseryBeforeDump", &same))
return false;
if (same) {
nurseryBehaviour = js::CollectNurseryBeforeDump;
++i;
}
}
}
if (argc > i) {
Value v = args[i];
if (v.isString()) {
JSString *str = v.toString();
JSAutoByteString fileNameBytes;
if (!fileNameBytes.encodeLatin1(cx, str))
return false;
const char *fileName = fileNameBytes.ptr();
dumpFile = fopen(fileName, "w");
if (!dumpFile) {
JS_ReportError(cx, "can't open %s", fileName);
return false;
}
++i;
fileName = fileNameBytes.ptr();
}
}
if (i != argc) {
JS_ReportError(cx, "bad arguments passed to dumpHeapComplete");
return false;
FILE *dumpFile;
if (!fileName) {
dumpFile = stdout;
} else {
dumpFile = fopen(fileName, "w");
if (!dumpFile) {
JS_ReportError(cx, "can't open %s", fileName);
return false;
}
}
js::DumpHeapComplete(JS_GetRuntime(cx), dumpFile ? dumpFile : stdout, nurseryBehaviour);
js::DumpHeapComplete(JS_GetRuntime(cx), dumpFile);
if (dumpFile)
fclose(dumpFile);
fclose(dumpFile);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return true;
@ -1204,10 +1184,8 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = {
" If true, obj is a proxy of some sort"),
JS_FN_HELP("dumpHeapComplete", DumpHeapComplete, 1, 0,
"dumpHeapComplete(['collectNurseryBeforeDump'], [filename])",
" Dump reachable and unreachable objects to the named file, or to stdout. If\n"
" 'collectNurseryBeforeDump' is specified, a minor GC is performed first,\n"
" otherwise objects in the nursery are ignored."),
"dumpHeapComplete([filename])",
" Dump reachable and unreachable objects to a file."),
JS_FN_HELP("terminate", Terminate, 0, 0,
"terminate()",

View File

@ -1 +0,0 @@
dumpHeapComplete();

View File

@ -753,9 +753,6 @@ DumpHeapVisitCell(JSRuntime *rt, void *data, void *thing,
static void
DumpHeapVisitChild(JSTracer *trc, void **thingp, JSGCTraceKind kind)
{
if (gc::IsInsideNursery(trc->runtime, *thingp))
return;
JSDumpHeapTracer *dtrc = static_cast<JSDumpHeapTracer *>(trc);
char buffer[1024];
fprintf(dtrc->output, "> %p %c %s\n", *thingp, MarkDescriptor(*thingp),
@ -765,9 +762,6 @@ DumpHeapVisitChild(JSTracer *trc, void **thingp, JSGCTraceKind kind)
static void
DumpHeapVisitRoot(JSTracer *trc, void **thingp, JSGCTraceKind kind)
{
if (gc::IsInsideNursery(trc->runtime, *thingp))
return;
JSDumpHeapTracer *dtrc = static_cast<JSDumpHeapTracer *>(trc);
char buffer[1024];
fprintf(dtrc->output, "%p %c %s\n", *thingp, MarkDescriptor(*thingp),
@ -775,15 +769,10 @@ DumpHeapVisitRoot(JSTracer *trc, void **thingp, JSGCTraceKind kind)
}
void
js::DumpHeapComplete(JSRuntime *rt, FILE *fp, js::DumpHeapNurseryBehaviour nurseryBehaviour)
js::DumpHeapComplete(JSRuntime *rt, FILE *fp)
{
JSDumpHeapTracer dtrc(fp);
#ifdef JSGC_GENERATIONAL
if (nurseryBehaviour == js::CollectNurseryBeforeDump)
MinorGC(rt, JS::gcreason::API);
#endif
JS_TracerInit(&dtrc, rt, DumpHeapVisitRoot);
dtrc.eagerlyTraceWeakMaps = TraceWeakMapKeysValues;
TraceRuntime(&dtrc);

View File

@ -255,17 +255,12 @@ GetCompartmentZone(JSCompartment *comp);
typedef bool
(* PreserveWrapperCallback)(JSContext *cx, JSObject *obj);
typedef enum {
CollectNurseryBeforeDump,
IgnoreNurseryObjects
} DumpHeapNurseryBehaviour;
/*
* Dump the complete object graph of heap-allocated things.
* fp is the file for the dump output.
*/
extern JS_FRIEND_API(void)
DumpHeapComplete(JSRuntime *rt, FILE *fp, DumpHeapNurseryBehaviour nurseryBehaviour);
DumpHeapComplete(JSRuntime *rt, FILE *fp);
#ifdef JS_OLD_GETTER_SETTER_METHODS
JS_FRIEND_API(bool) obj_defineGetter(JSContext *cx, unsigned argc, JS::Value *vp);

View File

@ -968,7 +968,7 @@ CycleCollectedJSRuntime::DeferredFinalize(nsISupports* aSupports)
void
CycleCollectedJSRuntime::DumpJSHeap(FILE* file)
{
js::DumpHeapComplete(Runtime(), file, js::CollectNurseryBeforeDump);
js::DumpHeapComplete(Runtime(), file);
}