Bug 1151679 - Stream the property name of getprop and setprop optimization sites. (r=djvj)
authorShu-yu Guo <shu@rfrn.org>
Wed, 08 Apr 2015 20:36:20 -0700
changeset 238273 4fa628562f6fc764c3ac6def7b84d5ee1d97d73d
parent 238272 c758e5c97a6cfd395bd5edd04c080962706a021c
child 238274 9fc22f95a34b0a572c37a161c2b264d2839857e0
push id58171
push usershu@rfrn.org
push dateThu, 09 Apr 2015 03:33:53 +0000
treeherdermozilla-inbound@89c9b9067ed8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdjvj
bugs1151679
milestone40.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
Bug 1151679 - Stream the property name of getprop and setprop optimization sites. (r=djvj)
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
tools/profiler/ProfileEntry.cpp
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -1248,8 +1248,16 @@ JS_StoreStringPostBarrierCallback(JSCont
         rt->gc.storeBuffer.putCallback(callback, key, data);
 }
 
 JS_FRIEND_API(bool)
 js::ForwardToNative(JSContext* cx, JSNative native, const CallArgs& args)
 {
     return native(cx, args.length(), args.base());
 }
+
+JS_FRIEND_API(JSAtom*)
+js::GetPropertyNameFromPC(JSScript* script, jsbytecode* pc)
+{
+    if (!IsGetPropPC(pc) && !IsSetPropPC(pc))
+        return nullptr;
+    return script->getName(pc);
+}
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -181,16 +181,19 @@ JS_FRIEND_API(void)
 ReportOverRecursed(JSContext* maybecx);
 
 JS_FRIEND_API(bool)
 AddRawValueRoot(JSContext* cx, JS::Value* vp, const char* name);
 
 JS_FRIEND_API(void)
 RemoveRawValueRoot(JSContext* cx, JS::Value* vp);
 
+JS_FRIEND_API(JSAtom*)
+GetPropertyNameFromPC(JSScript* script, jsbytecode* pc);
+
 #ifdef JS_DEBUG
 
 /*
  * Routines to print out values during debugging.  These are FRIEND_API to help
  * the debugger find them and to support temporarily hacking js::Dump* calls
  * into other code.
  */
 
@@ -866,16 +869,22 @@ GetTwoByteLinearStringChars(const JS::Au
 }
 
 MOZ_ALWAYS_INLINE JSLinearString*
 AtomToLinearString(JSAtom* atom)
 {
     return reinterpret_cast<JSLinearString*>(atom);
 }
 
+MOZ_ALWAYS_INLINE JSFlatString*
+AtomToFlatString(JSAtom* atom)
+{
+    return reinterpret_cast<JSFlatString*>(atom);
+}
+
 MOZ_ALWAYS_INLINE JSLinearString*
 FlatStringToLinearString(JSFlatString* s)
 {
     return reinterpret_cast<JSLinearString*>(s);
 }
 
 MOZ_ALWAYS_INLINE const JS::Latin1Char*
 GetLatin1AtomChars(const JS::AutoCheckCannotGC& nogc, JSAtom* atom)
--- a/tools/profiler/ProfileEntry.cpp
+++ b/tools/profiler/ProfileEntry.cpp
@@ -6,16 +6,17 @@
 #include <ostream>
 #include <sstream>
 #include "platform.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 
 // JS
 #include "jsapi.h"
+#include "jsfriendapi.h"
 #include "js/ProfilingFrameIterator.h"
 #include "js/TrackedOptimizationInfo.h"
 
 // JSON
 #include "JSStreamWriter.h"
 
 // Self
 #include "ProfileEntry.h"
@@ -364,23 +365,29 @@ void UniqueJITOptimizations::stream(JSSt
     b.BeginArray();
     StreamOptimizationTypeInfoOp typeInfoOp(b);
     JS::ForEachTrackedOptimizationTypeInfo(rt, mOpts[i].mEntryAddr, mOpts[i].mIndex,
                                            typeInfoOp);
     b.EndArray();
 
     b.Name("attempts");
     b.BeginArray();
-    JSScript *script;
-    jsbytecode *pc;
+    JSScript* script;
+    jsbytecode* pc;
     StreamOptimizationAttemptsOp attemptOp(b);
     JS::ForEachTrackedOptimizationAttempt(rt, mOpts[i].mEntryAddr, mOpts[i].mIndex,
                                           attemptOp, &script, &pc);
     b.EndArray();
 
+    if (JSAtom* name = js::GetPropertyNameFromPC(script, pc)) {
+      char buf[512];
+      JS_PutEscapedFlatString(buf, mozilla::ArrayLength(buf), js::AtomToFlatString(name), 0);
+      b.NameValue("propertyName", buf);
+    }
+
     unsigned line, column;
     line = JS_PCToLineNumber(script, pc, &column);
     b.NameValue("line", line);
     b.NameValue("column", column);
     b.EndObject();
   }
 }