From b7850c06d1822207e8923dc1d15992cbffd01c89 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Mon, 27 Jun 2011 10:45:54 +0000 Subject: [PATCH] MIPS: port Better codegen for ' === void '. Ported r8420 (fd2ddbb) Original commit message: Detect the pattern in both, the full compiler and crankshaft and generate direct pointer comparisons. Along the way I cleaned up 'typeof == ' comparisons as well by lifting platform independent code and checking the symmetric case. BUG=v8:1440 TEST=cctest/test-api.cc Review URL: http://codereview.chromium.org//7262026 Patch from Paul Lind . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8427 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/full-codegen-mips.cc | 43 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 1f1780ec2e..59e2a3601b 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -3983,26 +3983,13 @@ void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { } } - -bool FullCodeGenerator::TryLiteralCompare(Token::Value op, - Expression* left, - Expression* right, - Label* if_true, - Label* if_false, - Label* fall_through) { - if (op != Token::EQ && op != Token::EQ_STRICT) return false; - - // Check for the pattern: typeof == . - Literal* right_literal = right->AsLiteral(); - if (right_literal == NULL) return false; - Handle right_literal_value = right_literal->handle(); - if (!right_literal_value->IsString()) return false; - UnaryOperation* left_unary = left->AsUnaryOperation(); - if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; - Handle check = Handle::cast(right_literal_value); - +void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, + Handle check, + Label* if_true, + Label* if_false, + Label* fall_through) { { AccumulatorValueContext context(this); - VisitForTypeofValue(left_unary->expression()); + VisitForTypeofValue(expr); } PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); @@ -4056,8 +4043,18 @@ bool FullCodeGenerator::TryLiteralCompare(Token::Value op, } else { if (if_false != fall_through) __ jmp(if_false); } +} - return true; + +void FullCodeGenerator::EmitLiteralCompareUndefined(Expression* expr, + Label* if_true, + Label* if_false, + Label* fall_through) { + VisitForAccumulatorValue(expr); + PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); + + __ LoadRoot(at, Heap::kUndefinedValueRootIndex); + Split(eq, v0, Operand(at), if_true, if_false, fall_through); } @@ -4077,14 +4074,12 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { // First we try a fast inlined version of the compare when one of // the operands is a literal. - Token::Value op = expr->op(); - Expression* left = expr->left(); - Expression* right = expr->right(); - if (TryLiteralCompare(op, left, right, if_true, if_false, fall_through)) { + if (TryLiteralCompare(expr, if_true, if_false, fall_through)) { context()->Plug(if_true, if_false); return; } + Token::Value op = expr->op(); VisitForStackValue(expr->left()); switch (op) { case Token::IN: