Chromium Code Reviews| Index: src/hydrogen.cc |
| =================================================================== |
| --- src/hydrogen.cc (revision 9957) |
| +++ src/hydrogen.cc (working copy) |
| @@ -5998,14 +5998,27 @@ |
| switch (op) { |
| case Token::EQ: |
| case Token::EQ_STRICT: { |
|
Kevin Millikin (Chromium)
2011/11/10 19:08:42
I guess if EQ_STRICT, then we'll never have a comp
Rico
2011/11/11 08:49:11
Of course we should, nice catch.
|
| - AddInstruction(new(zone()) HCheckNonSmi(left)); |
| - AddInstruction(HCheckInstanceType::NewIsSpecObject(left)); |
| - AddInstruction(new(zone()) HCheckNonSmi(right)); |
| - AddInstruction(HCheckInstanceType::NewIsSpecObject(right)); |
| - HCompareObjectEqAndBranch* result = |
| - new(zone()) HCompareObjectEqAndBranch(left, right); |
| - result->set_position(expr->position()); |
| - return ast_context()->ReturnControl(result, expr->id()); |
| + // Can we get away with map check and not instance type check? |
| + Handle<Map> map = oracle()->GetCompareMap(expr); |
| + if (!map.is_null()) { |
| + AddInstruction(new(zone()) HCheckNonSmi(left)); |
| + AddInstruction(new(zone()) HCheckMap(left, map)); |
| + AddInstruction(new(zone()) HCheckNonSmi(right)); |
| + AddInstruction(new(zone()) HCheckMap(right, map)); |
| + HCompareObjectEqAndBranch* result = |
| + new(zone()) HCompareObjectEqAndBranch(left, right); |
| + result->set_position(expr->position()); |
| + return ast_context()->ReturnControl(result, expr->id()); |
| + } else { |
| + AddInstruction(new(zone()) HCheckNonSmi(left)); |
| + AddInstruction(HCheckInstanceType::NewIsSpecObject(left)); |
| + AddInstruction(new(zone()) HCheckNonSmi(right)); |
| + AddInstruction(HCheckInstanceType::NewIsSpecObject(right)); |
| + HCompareObjectEqAndBranch* result = |
| + new(zone()) HCompareObjectEqAndBranch(left, right); |
| + result->set_position(expr->position()); |
| + return ast_context()->ReturnControl(result, expr->id()); |
| + } |
| } |
| default: |
| return Bailout("Unsupported non-primitive compare"); |