Bug 1349917 - Outputting parse duration
MozReview-Commit-ID: H4iMVZzMcc1
--- a/js/src/frontend/BinaryAST.cpp
+++ b/js/src/frontend/BinaryAST.cpp
@@ -151,16 +151,17 @@ void serializeAtom(JSContext* cx, JSAtom
JSAutoByteString bs;
if (!bs.encodeUtf8(cx, string)) { // 0 terminated, right?
MOZ_CRASH();
}
out.write(bs.ptr(), bs.length());
} else {
// FIXME: We could magically map this to string identifier 0. Is it worth it?
+ // FIXME: This constant is poorly chosen. Pick something else that's invalid UTF-8.
const char zero[2] = { 0, 0 }; // Magic constant (invalid utf8 string).
out.write((const char*)&zero, sizeof zero);
}
result = Move(out.str());
}
JSAtom* deserializeAtom(JSContext* cx, const std::string& data)
{
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -973,17 +973,21 @@ Parser<ParseHandler, CharT>::parse()
ParseContext globalpc(this, &globalsc, /* newDirectives = */ nullptr);
if (!globalpc.init())
return null();
ParseContext::VarScope varScope(this);
if (!varScope.init(pc))
return null();
+ const mozilla::TimeStamp start = mozilla::TimeStamp::Now();
Node pn = statementList(YieldIsName);
+ const mozilla::TimeStamp stop = mozilla::TimeStamp::Now();
+ fprintf(stderr, "Parser<>::parse() duration: %fms\n", (stop - start).ToMilliseconds());
+
if (!pn)
return null();
TokenKind tt;
if (!tokenStream.getToken(&tt, TokenStream::Operand))
return null();
if (tt != TOK_EOF) {
error(JSMSG_GARBAGE_AFTER_INPUT, "script", TokenKindToDesc(tt));
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -4443,20 +4443,22 @@ ReadBinaryAST(JSContext* cx, unsigned ar
// In a real implementation, we'll probably want to replace istringstream with something better.
std::cerr << "ReadBinaryAST from " << buf_length << " bytes at " << (void*)buf_data << "\n";
std::cerr << "ReadBinaryAST string: " << buf_str.length() << "\n";
std::ostringstream _debug; // Ignored.
// in_stream.exceptions(in_stream.exceptions() | std::istringstream::badbit | std::istringstream::failbit | std::istringstream::eofbit );
ParseNodeAllocator allocator(cx, cx->tempLifoAlloc());
+ const mozilla::TimeStamp start = mozilla::TimeStamp::Now();
if (!binParse(cx, allocator, in_stream, _debug)) {
return false;
}
-
+ const mozilla::TimeStamp stop = mozilla::TimeStamp::Now();
+ std::cerr << "ReadBinaryAST duration: " << (stop-start).ToMilliseconds() << "ms\n";
args.rval().setUndefined();
return true;
}
static bool
ParseAux(JSContext* cx, unsigned argc, Value* vp, ParseOptions& instructions)
{
using namespace js::frontend;