Do not use out of range visitor ids.
authorhpayer <hpayer@chromium.org>
Mon, 22 Dec 2014 11:11:50 +0000 (03:11 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 22 Dec 2014 11:12:17 +0000 (11:12 +0000)
BUG=

Review URL: https://codereview.chromium.org/822693002

Cr-Commit-Position: refs/heads/master@{#25920}

src/heap/objects-visiting.h

index f8c58dd8169f657bd0a223fbc6b4cab2caf2e1ef..a442867569606c1d4471a3ee2720a1fc89cf5b13 100644 (file)
@@ -130,10 +130,11 @@ class StaticVisitorBase : public AllStatic {
 
     if (has_unboxed_fields) return generic;
 
-    const VisitorId specialization = static_cast<VisitorId>(
-        base + (object_size >> kPointerSizeLog2) - kMinObjectSizeInWords);
+    int visitor_id =
+        Min(base + (object_size >> kPointerSizeLog2) - kMinObjectSizeInWords,
+            static_cast<int>(generic));
 
-    return Min(specialization, generic);
+    return static_cast<VisitorId>(visitor_id);
   }
 };