[INFER] Don't mark type sets and type objects as unknown when in an inconsistent object/property hash state, bug 674511. Allow compilation logging for specific scripts.
authorBrian Hackett <bhackett1024@gmail.com>
Sun, 31 Jul 2011 08:40:46 -0700
changeset 76085 23dc255291ae9c719b89942192d627cf998bfc92
parent 76084 d43c6dddeb2b599855caca3ac30d05f6b68e85ee
child 76086 e5b57c9ebbe94042069d978567a2ba217eee0670
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
bugs674511
milestone8.0a1
[INFER] Don't mark type sets and type objects as unknown when in an inconsistent object/property hash state, bug 674511. Allow compilation logging for specific scripts.
js/src/jsinferinlines.h
js/src/methodjit/Logging.cpp
js/src/methodjit/Logging.h
--- a/js/src/jsinferinlines.h
+++ b/js/src/jsinferinlines.h
@@ -1004,21 +1004,21 @@ TypeSet::addType(JSContext *cx, Type typ
         uint32 objectCount = baseObjectCount();
         TypeObjectKey *object = type.objectKey();
         TypeObjectKey **pentry = HashSetInsert<TypeObjectKey *,TypeObjectKey,TypeObjectKey>
                                      (cx, objectSet, objectCount, object, intermediate());
         if (!pentry || *pentry)
             return;
         *pentry = object;
 
-        if (objectCount > TYPE_FLAG_OBJECT_COUNT_LIMIT)
+        setBaseObjectCount(objectCount);
+
+        if (objectCount == TYPE_FLAG_OBJECT_COUNT_LIMIT)
             goto unknownObject;
 
-        setBaseObjectCount(objectCount);
-
         if (type.isTypeObject()) {
             TypeObject *nobject = type.typeObject();
             JS_ASSERT(!nobject->singleton);
             if (nobject->unknownProperties())
                 goto unknownObject;
             if (objectCount > 1) {
                 nobject->contribution += (objectCount - 1) * (objectCount - 1);
                 if (nobject->contribution >= TypeObject::CONTRIBUTION_LIMIT) {
@@ -1173,25 +1173,25 @@ TypeObject::getProperty(JSContext *cx, j
 
     uint32 propertyCount = basePropertyCount();
     Property **pprop = HashSetInsert<jsid,Property,Property>
                            (cx, propertySet, propertyCount, id, singleton != NULL);
     if (!pprop)
         return NULL;
 
     if (!*pprop) {
-        if (propertyCount > OBJECT_FLAG_PROPERTY_COUNT_LIMIT) {
+        setBasePropertyCount(propertyCount);
+        if (!addProperty(cx, id, pprop))
+            return NULL;
+        if (propertyCount == OBJECT_FLAG_PROPERTY_COUNT_LIMIT) {
             markUnknown(cx);
             TypeSet *types = TypeSet::make(cx, "propertyOverflow");
             types->addType(cx, Type::UnknownType());
             return types;
         }
-        setBasePropertyCount(propertyCount);
-        if (!addProperty(cx, id, pprop))
-            return NULL;
     }
 
     TypeSet *types = &(*pprop)->types;
 
     if (assign)
         types->setOwnProperty(cx, false);
 
     return types;
--- a/js/src/methodjit/Logging.cpp
+++ b/js/src/methodjit/Logging.cpp
@@ -123,16 +123,28 @@ js::JMCheckLogging()
     if (strstr(env, "recompile"))
         LoggingBits |= (1 << uint32(JSpew_Recompile));
     if (strstr(env, "inlin"))
         LoggingBits |= (1 << uint32(JSpew_Inlining));
     if (strstr(env, "full"))
         LoggingBits |= 0xFFFFFFFF ^ (1 << JSpew_PCProf);
 }
 
+js::ConditionalLog::ConditionalLog(bool logging)
+    : oldBits(LoggingBits), logging(logging)
+{
+    if (logging)
+        LoggingBits = 0xFFFFFFFF ^ (1 << JSpew_PCProf);
+}
+
+js::ConditionalLog::~ConditionalLog() {
+    if (logging)
+        LoggingBits = oldBits;
+}
+
 bool
 js::IsJaegerSpewChannelActive(JaegerSpewChannel channel)
 {
     JS_ASSERT(LoggingChecked);
     return !!(LoggingBits & (1 << uint32(channel)));
 }
 
 void
--- a/js/src/methodjit/Logging.h
+++ b/js/src/methodjit/Logging.h
@@ -73,16 +73,23 @@ enum JaegerSpewChannel {
 #if defined(DEBUG) && !defined(JS_METHODJIT_SPEW)
 # define JS_METHODJIT_SPEW
 #endif
 
 #if defined(JS_METHODJIT_SPEW)
 
 void JMCheckLogging();
 
+struct ConditionalLog {
+    uint32 oldBits;
+    bool logging;
+    ConditionalLog(bool logging);
+    ~ConditionalLog();
+};
+
 bool IsJaegerSpewChannelActive(JaegerSpewChannel channel);
 void JaegerSpew(JaegerSpewChannel channel, const char *fmt, ...);
 
 struct Profiler {
     JSInt64 t_start;
     JSInt64 t_stop;
 
     static inline JSInt64 now() {