Bug 912079 part 1 - Remove SuppressDeletedPropertyHelper predicate argument. r=anba
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 26 Apr 2018 18:36:55 +0200
changeset 471937 083e486636229751d66f774e84da73ce1c500808
parent 471936 ea92acbc6e59ddfa2569b161b31f45027a5d85f0
child 471938 826aeeda8a929371bafed8e1fee4f348a5468427
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanba
bugs912079
milestone61.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 912079 part 1 - Remove SuppressDeletedPropertyHelper predicate argument. r=anba
js/src/vm/Iteration.cpp
--- a/js/src/vm/Iteration.cpp
+++ b/js/src/vm/Iteration.cpp
@@ -1204,37 +1204,31 @@ js::UnwindIteratorForUncatchableExceptio
  *
  * We maintain a list of active non-escaping for-in enumerators. To suppress
  * a property, we check whether each active enumerator contains the (obj, id)
  * pair and has not yet enumerated |id|. If so, and |id| is the next property,
  * we simply advance the cursor. Otherwise, we delete |id| from the list.
  *
  * We do not suppress enumeration of a property deleted along an object's
  * prototype chain. Only direct deletions on the object are handled.
- *
- * This function can suppress multiple properties at once. The |predicate|
- * argument is an object which can be called on an id and returns true or
- * false. It also must have a method |matchesAtMostOne| which allows us to
- * stop searching after the first deletion if true.
  */
-template<typename StringPredicate>
 static bool
-SuppressDeletedPropertyHelper(JSContext* cx, HandleObject obj, StringPredicate predicate)
+SuppressDeletedPropertyHelper(JSContext* cx, HandleObject obj, Handle<JSFlatString*> str)
 {
     NativeIterator* enumeratorList = cx->compartment()->enumerators;
     NativeIterator* ni = enumeratorList->next();
 
     while (ni != enumeratorList) {
       again:
         if (ni->obj == obj && ni->props_cursor < ni->props_end) {
             /* Check whether id is still to come. */
             GCPtrFlatString* props_cursor = ni->current();
             GCPtrFlatString* props_end = ni->end();
             for (GCPtrFlatString* idp = props_cursor; idp < props_end; ++idp) {
-                if (predicate(*idp)) {
+                if (EqualStrings(*idp, str)) {
                     /*
                      * Check whether another property along the prototype chain
                      * became visible as a result of this deletion.
                      */
                     RootedObject proto(cx);
                     if (!GetPrototype(cx, obj, &proto))
                         return false;
                     if (proto) {
@@ -1277,69 +1271,54 @@ SuppressDeletedPropertyHelper(JSContext*
                          * it's no longer going to be marked, and ensures that
                          * any existing remembered set entry will be dropped.
                          */
                         *ni->props_end = nullptr;
                     }
 
                     /* Don't reuse modified native iterators. */
                     ni->flags |= JSITER_UNREUSABLE;
-
-                    if (predicate.matchesAtMostOne())
-                        break;
+                    break;
                 }
             }
         }
         ni = ni->next();
     }
     return true;
 }
 
-namespace {
-
-class SingleStringPredicate {
-    Handle<JSFlatString*> str;
-public:
-    explicit SingleStringPredicate(Handle<JSFlatString*> str) : str(str) {}
-
-    bool operator()(JSFlatString* str) { return EqualStrings(str, this->str); }
-    bool matchesAtMostOne() { return true; }
-};
-
-} /* anonymous namespace */
-
 bool
 js::SuppressDeletedProperty(JSContext* cx, HandleObject obj, jsid id)
 {
     if (MOZ_LIKELY(!cx->compartment()->objectMaybeInIteration(obj)))
         return true;
 
     if (JSID_IS_SYMBOL(id))
         return true;
 
     Rooted<JSFlatString*> str(cx, IdToString(cx, id));
     if (!str)
         return false;
-    return SuppressDeletedPropertyHelper(cx, obj, SingleStringPredicate(str));
+    return SuppressDeletedPropertyHelper(cx, obj, str);
 }
 
 bool
 js::SuppressDeletedElement(JSContext* cx, HandleObject obj, uint32_t index)
 {
     if (MOZ_LIKELY(!cx->compartment()->objectMaybeInIteration(obj)))
         return true;
 
     RootedId id(cx);
     if (!IndexToId(cx, index, &id))
         return false;
 
     Rooted<JSFlatString*> str(cx, IdToString(cx, id));
     if (!str)
         return false;
-    return SuppressDeletedPropertyHelper(cx, obj, SingleStringPredicate(str));
+    return SuppressDeletedPropertyHelper(cx, obj, str);
 }
 
 bool
 js::IteratorMore(JSContext* cx, HandleObject iterobj, MutableHandleValue rval)
 {
     // Fast path for native iterators.
     if (MOZ_LIKELY(iterobj->is<PropertyIteratorObject>())) {
         NativeIterator* ni = iterobj->as<PropertyIteratorObject>().getNativeIterator();