Generate faster compares for === and !== with boolean constants.
Review URL: http://codereview.chromium.org/9195005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10435 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
704c92ce95
commit
ed5f9a4c77
@ -6172,6 +6172,15 @@ static bool IsLiteralCompareNil(HValue* left,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool IsLiteralCompareBool(HValue* left,
|
||||||
|
Token::Value op,
|
||||||
|
HValue* right) {
|
||||||
|
return op == Token::EQ_STRICT &&
|
||||||
|
((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) ||
|
||||||
|
(right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
|
void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
|
||||||
ASSERT(!HasStackOverflow());
|
ASSERT(!HasStackOverflow());
|
||||||
ASSERT(current_block() != NULL);
|
ASSERT(current_block() != NULL);
|
||||||
@ -6219,6 +6228,12 @@ void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
|
|||||||
if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) {
|
if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) {
|
||||||
return HandleLiteralCompareNil(expr, sub_expr, kNullValue);
|
return HandleLiteralCompareNil(expr, sub_expr, kNullValue);
|
||||||
}
|
}
|
||||||
|
if (IsLiteralCompareBool(left, op, right)) {
|
||||||
|
HCompareObjectEqAndBranch* result =
|
||||||
|
new(zone()) HCompareObjectEqAndBranch(left, right);
|
||||||
|
result->set_position(expr->position());
|
||||||
|
return ast_context()->ReturnControl(result, expr->id());
|
||||||
|
}
|
||||||
|
|
||||||
if (op == Token::INSTANCEOF) {
|
if (op == Token::INSTANCEOF) {
|
||||||
// Check to see if the rhs of the instanceof is a global function not
|
// Check to see if the rhs of the instanceof is a global function not
|
||||||
|
Loading…
Reference in New Issue
Block a user