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

Unified Diff: src/crankshaft/hydrogen.cc

Issue 2027603002: [crankshaft] Properly optimize strict equality with constants. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | no next file » | 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 4c36662a59d6c2b1b45be30e82ad25f9d161aace..ca84e747d4800e0d4624e15affd0743b1d4929f9 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -11593,18 +11593,22 @@ void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
return ast_context()->ReturnControl(instr, expr->id());
}
+namespace {
-static bool IsLiteralCompareBool(Isolate* isolate,
- HValue* left,
- Token::Value op,
- HValue* right) {
+bool IsLiteralCompareStrict(Isolate* isolate, HValue* left, Token::Value op,
+ HValue* right) {
return op == Token::EQ_STRICT &&
- ((left->IsConstant() &&
- HConstant::cast(left)->handle(isolate)->IsBoolean()) ||
- (right->IsConstant() &&
- HConstant::cast(right)->handle(isolate)->IsBoolean()));
+ ((left->IsConstant() &&
+ !HConstant::cast(left)->handle(isolate)->IsNumber() &&
+ !HConstant::cast(left)->handle(isolate)->IsSimd128Value() &&
+ !HConstant::cast(left)->handle(isolate)->IsString()) ||
+ (right->IsConstant() &&
+ !HConstant::cast(right)->handle(isolate)->IsNumber() &&
+ !HConstant::cast(right)->handle(isolate)->IsSimd128Value() &&
+ !HConstant::cast(right)->handle(isolate)->IsString()));
}
+} // namespace
void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
DCHECK(!HasStackOverflow());
@@ -11650,7 +11654,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
HValue* left = Pop();
Token::Value op = expr->op();
- if (IsLiteralCompareBool(isolate(), left, op, right)) {
+ if (IsLiteralCompareStrict(isolate(), left, op, right)) {
HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right);
return ast_context()->ReturnControl(result, expr->id());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698