author | Benjamin Peterson <benjamin@python.org> |
Fri, 01 Feb 2013 00:10:17 -0500 | |
changeset 120549 | 050a0a27024a47c81a07942cdcf3f8a85c00c26e |
parent 120548 | 41075512e6528af980d138f4cbfdaea57ac947f5 |
child 120550 | fa772ccdf19d995b446324e88b2c5b7383b90e94 |
push id | 24256 |
push user | ryanvm@gmail.com |
push date | Fri, 01 Feb 2013 20:50:01 +0000 |
treeherder | mozilla-central@4e7c92906a79 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bhackket |
bugs | 777474 |
milestone | 21.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -6805,39 +6805,17 @@ struct AutoDestroyPrinter static bool GetPCCountJSON(JSContext *cx, const ScriptAndCounts &sac, StringBuffer &buf) { RootedScript script(cx, sac.script); buf.append('{'); AppendJSONProperty(buf, "text", NO_COMMA); - Vector<DecompiledOpcode> decompiledOpcodes(cx); - if (!decompiledOpcodes.reserve(script->length)) - return false; - - for (unsigned i = 0; i < script->length; i++) - decompiledOpcodes.infallibleAppend(DecompiledOpcode()); - - JSFunction *fun = script->function(); - JSPrinter *jp = js_NewPrinter(cx, "", fun, 4, true, false, false); - if (!jp) - return false; - AutoDestroyPrinter destroy(jp); - - jp->decompiledOpcodes = &decompiledOpcodes; - - if (fun) { - if (!DecompileFunction(jp)) - return false; - } else { - if (!DecompileScript(jp, script)) - return false; - } - JSString *str = js_GetPrinterOutput(jp); + JSString *str = JS_DecompileScript(cx, script, NULL, 0); if (!str || !(str = ValueToSource(cx, StringValue(str)))) return false; buf.append(str); AppendJSONProperty(buf, "opcodes"); buf.append('['); bool comma = false; @@ -6869,38 +6847,28 @@ GetPCCountJSON(JSContext *cx, const Scri { const char *name = js_CodeName[op]; AppendJSONProperty(buf, "name"); buf.append('\"'); buf.appendInflated(name, strlen(name)); buf.append('\"'); } - DecompiledOpcode *search = &decompiledOpcodes[offset]; - size_t textBias = 0; - while (search->parent) { - textBias += search->parentOffset; - if (search->parenthesized) - textBias++; - search = &decompiledOpcodes[search->parent - script->code]; - } - - int32_t printedOffset = search->parentOffset; - if (printedOffset != -1) { - printedOffset += textBias; - if (search->parenthesized) - printedOffset++; - AppendJSONProperty(buf, "textOffset"); - NumberValueToStringBuffer(cx, Int32Value(printedOffset), buf); - } - - const char *text = decompiledOpcodes[offset].text; - if (text && *text != 0) { + { + ExpressionDecompiler ed(cx, script, script->function()); + if (!ed.init()) + return false; + if (!ed.decompilePC(pc)) + return false; + char *text; + if (!ed.getOutput(&text)) + return false; AppendJSONProperty(buf, "text"); JSString *str = JS_NewStringCopyZ(cx, text); + js_free(text); if (!str || !(str = ValueToSource(cx, StringValue(str)))) return false; buf.append(str); } PCCounts &counts = sac.getPCCounts(pc); unsigned numCounts = PCCounts::numCounts(op);