Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Unified Diff: src/crankshaft/hydrogen.cc

Issue 2612213002: [crankshaft] Fix abstract equality for receivers. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-5802.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index 1a647b862263c95c6ac6310b139eaca12e3f833d..69daeb4c57d36e53b77927a94aa13a31ac1ba1db 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -11286,23 +11286,35 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
// The caller expects a branch instruction, so make it happy.
return New<HBranch>(graph()->GetConstantTrue());
}
- // Can we get away with map check and not instance type check?
- HValue* operand_to_check =
- left->block()->block_id() < right->block()->block_id() ? left : right;
- if (combined_type->IsClass()) {
- Handle<Map> map = combined_type->AsClass()->Map();
- AddCheckMap(operand_to_check, map);
- HCompareObjectEqAndBranch* result =
- New<HCompareObjectEqAndBranch>(left, right);
- return result;
+ if (op == Token::EQ) {
+ // For abstract equality we need to check both sides are receivers.
+ if (combined_type->IsClass()) {
+ Handle<Map> map = combined_type->AsClass()->Map();
+ AddCheckMap(left, map);
+ AddCheckMap(right, map);
+ } else {
+ BuildCheckHeapObject(left);
+ Add<HCheckInstanceType>(left, HCheckInstanceType::IS_JS_RECEIVER);
+ BuildCheckHeapObject(right);
+ Add<HCheckInstanceType>(right, HCheckInstanceType::IS_JS_RECEIVER);
+ }
} else {
- BuildCheckHeapObject(operand_to_check);
- Add<HCheckInstanceType>(operand_to_check,
- HCheckInstanceType::IS_JS_RECEIVER);
- HCompareObjectEqAndBranch* result =
- New<HCompareObjectEqAndBranch>(left, right);
- return result;
+ // For strict equality we only need to check one side.
+ HValue* operand_to_check =
+ left->block()->block_id() < right->block()->block_id() ? left
+ : right;
+ if (combined_type->IsClass()) {
+ Handle<Map> map = combined_type->AsClass()->Map();
+ AddCheckMap(operand_to_check, map);
+ } else {
+ BuildCheckHeapObject(operand_to_check);
+ Add<HCheckInstanceType>(operand_to_check,
+ HCheckInstanceType::IS_JS_RECEIVER);
+ }
}
+ HCompareObjectEqAndBranch* result =
+ New<HCompareObjectEqAndBranch>(left, right);
+ return result;
} else {
if (combined_type->IsClass()) {
// TODO(bmeurer): This is an optimized version of an x < y, x > y,
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-5802.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698