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

Side by Side 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, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/crankshaft/hydrogen.h" 5 #include "src/crankshaft/hydrogen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/allocation-site-scopes.h" 9 #include "src/allocation-site-scopes.h"
10 #include "src/ast/ast-numbering.h" 10 #include "src/ast/ast-numbering.h"
(...skipping 11575 matching lines...) Expand 10 before | Expand all | Expand 10 after
11586 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, 11586 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
11587 Expression* sub_expr, 11587 Expression* sub_expr,
11588 Handle<String> check) { 11588 Handle<String> check) {
11589 CHECK_ALIVE(VisitForTypeOf(sub_expr)); 11589 CHECK_ALIVE(VisitForTypeOf(sub_expr));
11590 SetSourcePosition(expr->position()); 11590 SetSourcePosition(expr->position());
11591 HValue* value = Pop(); 11591 HValue* value = Pop();
11592 HTypeofIsAndBranch* instr = New<HTypeofIsAndBranch>(value, check); 11592 HTypeofIsAndBranch* instr = New<HTypeofIsAndBranch>(value, check);
11593 return ast_context()->ReturnControl(instr, expr->id()); 11593 return ast_context()->ReturnControl(instr, expr->id());
11594 } 11594 }
11595 11595
11596 namespace {
11596 11597
11597 static bool IsLiteralCompareBool(Isolate* isolate, 11598 bool IsLiteralCompareStrict(Isolate* isolate, HValue* left, Token::Value op,
11598 HValue* left, 11599 HValue* right) {
11599 Token::Value op,
11600 HValue* right) {
11601 return op == Token::EQ_STRICT && 11600 return op == Token::EQ_STRICT &&
11602 ((left->IsConstant() && 11601 ((left->IsConstant() &&
11603 HConstant::cast(left)->handle(isolate)->IsBoolean()) || 11602 !HConstant::cast(left)->handle(isolate)->IsNumber() &&
11604 (right->IsConstant() && 11603 !HConstant::cast(left)->handle(isolate)->IsSimd128Value() &&
11605 HConstant::cast(right)->handle(isolate)->IsBoolean())); 11604 !HConstant::cast(left)->handle(isolate)->IsString()) ||
11605 (right->IsConstant() &&
11606 !HConstant::cast(right)->handle(isolate)->IsNumber() &&
11607 !HConstant::cast(right)->handle(isolate)->IsSimd128Value() &&
11608 !HConstant::cast(right)->handle(isolate)->IsString()));
11606 } 11609 }
11607 11610
11611 } // namespace
11608 11612
11609 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { 11613 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
11610 DCHECK(!HasStackOverflow()); 11614 DCHECK(!HasStackOverflow());
11611 DCHECK(current_block() != NULL); 11615 DCHECK(current_block() != NULL);
11612 DCHECK(current_block()->HasPredecessor()); 11616 DCHECK(current_block()->HasPredecessor());
11613 11617
11614 if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position()); 11618 if (!top_info()->is_tracking_positions()) SetSourcePosition(expr->position());
11615 11619
11616 // Check for a few fast cases. The AST visiting behavior must be in sync 11620 // Check for a few fast cases. The AST visiting behavior must be in sync
11617 // with the full codegen: We don't push both left and right values onto 11621 // with the full codegen: We don't push both left and right values onto
(...skipping 25 matching lines...) Expand all
11643 Type* right_type = bounds_.get(expr->right()).lower; 11647 Type* right_type = bounds_.get(expr->right()).lower;
11644 Type* combined_type = expr->combined_type(); 11648 Type* combined_type = expr->combined_type();
11645 11649
11646 CHECK_ALIVE(VisitForValue(expr->left())); 11650 CHECK_ALIVE(VisitForValue(expr->left()));
11647 CHECK_ALIVE(VisitForValue(expr->right())); 11651 CHECK_ALIVE(VisitForValue(expr->right()));
11648 11652
11649 HValue* right = Pop(); 11653 HValue* right = Pop();
11650 HValue* left = Pop(); 11654 HValue* left = Pop();
11651 Token::Value op = expr->op(); 11655 Token::Value op = expr->op();
11652 11656
11653 if (IsLiteralCompareBool(isolate(), left, op, right)) { 11657 if (IsLiteralCompareStrict(isolate(), left, op, right)) {
11654 HCompareObjectEqAndBranch* result = 11658 HCompareObjectEqAndBranch* result =
11655 New<HCompareObjectEqAndBranch>(left, right); 11659 New<HCompareObjectEqAndBranch>(left, right);
11656 return ast_context()->ReturnControl(result, expr->id()); 11660 return ast_context()->ReturnControl(result, expr->id());
11657 } 11661 }
11658 11662
11659 if (op == Token::INSTANCEOF) { 11663 if (op == Token::INSTANCEOF) {
11660 // Check to see if the rhs of the instanceof is a known function. 11664 // Check to see if the rhs of the instanceof is a known function.
11661 if (right->IsConstant() && 11665 if (right->IsConstant() &&
11662 HConstant::cast(right)->handle(isolate())->IsJSFunction()) { 11666 HConstant::cast(right)->handle(isolate())->IsJSFunction()) {
11663 Handle<JSFunction> function = 11667 Handle<JSFunction> function =
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after
13639 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13643 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13640 } 13644 }
13641 13645
13642 #ifdef DEBUG 13646 #ifdef DEBUG
13643 graph_->Verify(false); // No full verify. 13647 graph_->Verify(false); // No full verify.
13644 #endif 13648 #endif
13645 } 13649 }
13646 13650
13647 } // namespace internal 13651 } // namespace internal
13648 } // namespace v8 13652 } // namespace v8
OLDNEW
« 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