Status: Assigned
Owner: [email protected]
Labels: Type-Bug Priority-Medium

New issue 2248 by [email protected]: Wrong type feedback for STRICT_EQ
http://code.google.com/p/v8/issues/detail?id=2248

In the case below a single strict comparison marked (*) sees both objects and smis but when optimizing it selects to optimize for objects and as a result loop immediately deoptimizes:

function eq(a, b) {
  if (a === b) return true; // (*)
  if (typeof a === "object") {
    return a.equals(b);
  }
  return false;
}

Object.prototype.equals = function (other) {
  return (this === other);
};

function test() {
  var i = 0;

  for (var i = 0; !eq(i, 10); i++)
    ;
}

eq({}, {});
eq({}, {});
eq(1, 1);
eq(1, 1);
test();
%OptimizeFunctionOnNextCall(test);
test();

Produced hydrogen makes very little sense:

In block B1:
    0 7 t20 Constant 10  range[10,10,m0=0] type[smi] <|@
    0 0 t66 CheckNonSmi t20 <|@

In block B2:
0 6 t121 Change i14 i to t range[-2147483648,2147483647,m0=0] changes[NewSpacePromotion] type[number] <|@
    0 2 t27 CompareGeneric EQ_STRICT t121 t20 changes[*] type[boolean] <|@


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to