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

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 7489045: ARM: Fast path for compare against constant. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 int LCodeGen::ToInteger32(LConstantOperand* op) const { 395 int LCodeGen::ToInteger32(LConstantOperand* op) const {
396 Handle<Object> value = chunk_->LookupLiteral(op); 396 Handle<Object> value = chunk_->LookupLiteral(op);
397 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32()); 397 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32());
398 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) == 398 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) ==
399 value->Number()); 399 value->Number());
400 return static_cast<int32_t>(value->Number()); 400 return static_cast<int32_t>(value->Number());
401 } 401 }
402 402
403 403
404 double LCodeGen::ToDouble(LConstantOperand* op) const {
405 Handle<Object> value = chunk_->LookupLiteral(op);
406 return value->Number();
407 }
408
409
404 Operand LCodeGen::ToOperand(LOperand* op) { 410 Operand LCodeGen::ToOperand(LOperand* op) {
405 if (op->IsConstantOperand()) { 411 if (op->IsConstantOperand()) {
406 LConstantOperand* const_op = LConstantOperand::cast(op); 412 LConstantOperand* const_op = LConstantOperand::cast(op);
407 Handle<Object> literal = chunk_->LookupLiteral(const_op); 413 Handle<Object> literal = chunk_->LookupLiteral(const_op);
408 Representation r = chunk_->LookupLiteralRepresentation(const_op); 414 Representation r = chunk_->LookupLiteralRepresentation(const_op);
409 if (r.IsInteger32()) { 415 if (r.IsInteger32()) {
410 ASSERT(literal->IsNumber()); 416 ASSERT(literal->IsNumber());
411 return Operand(static_cast<int32_t>(literal->Number())); 417 return Operand(static_cast<int32_t>(literal->Number()));
412 } else if (r.IsDouble()) { 418 } else if (r.IsDouble()) {
413 Abort("ToOperand Unsupported double immediate."); 419 Abort("ToOperand Unsupported double immediate.");
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 break; 1694 break;
1689 case Token::IN: 1695 case Token::IN:
1690 case Token::INSTANCEOF: 1696 case Token::INSTANCEOF:
1691 default: 1697 default:
1692 UNREACHABLE(); 1698 UNREACHABLE();
1693 } 1699 }
1694 return cond; 1700 return cond;
1695 } 1701 }
1696 1702
1697 1703
1698 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) {
1699 __ cmp(ToRegister(left), ToRegister(right));
1700 }
1701
1702
1703 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { 1704 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
1704 LOperand* left = instr->InputAt(0); 1705 LOperand* left = instr->InputAt(0);
1705 LOperand* right = instr->InputAt(1); 1706 LOperand* right = instr->InputAt(1);
1706 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1707 int false_block = chunk_->LookupDestination(instr->false_block_id());
1707 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1708 int true_block = chunk_->LookupDestination(instr->true_block_id());
1709 Condition cond = TokenToCondition(instr->op(), false);
1708 1710
1709 if (instr->is_double()) { 1711 if (left->IsConstantOperand() && right->IsConstantOperand()) {
1710 // Compare left and right as doubles and load the 1712 // We can statically evaluate the comparison.
1711 // resulting flags into the normal status register. 1713 double left_val = ToDouble(LConstantOperand::cast(left));
1712 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); 1714 double right_val = ToDouble(LConstantOperand::cast(right));
1713 // If a NaN is involved, i.e. the result is unordered (V set), 1715 int next_block =
1714 // jump to false block label. 1716 EvalComparison(instr->op(), left_val, right_val) ? true_block
1715 __ b(vs, chunk_->GetAssemblyLabel(false_block)); 1717 : false_block;
1718 EmitGoto(next_block);
1716 } else { 1719 } else {
1717 EmitCmpI(left, right); 1720 if (instr->is_double()) {
1721 // Compare left and right operands as doubles and load the
1722 // resulting flags into the normal status register.
1723 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right));
1724 // If a NaN is involved, i.e. the result is unordered (V set),
1725 // jump to false block label.
1726 __ b(vs, chunk_->GetAssemblyLabel(false_block));
1727 } else {
1728 if (right->IsConstantOperand()) {
1729 __ cmp(ToRegister(left),
1730 Operand(ToInteger32(LConstantOperand::cast(right))));
1731 } else if (left->IsConstantOperand()) {
1732 __ cmp(ToRegister(right),
1733 Operand(ToInteger32(LConstantOperand::cast(left))));
1734 // We transposed the operands. Reverse the condition.
1735 cond = ReverseCondition(cond);
1736 } else {
1737 __ cmp(ToRegister(left), ToRegister(right));
1738 }
1739 }
1740 EmitBranch(true_block, false_block, cond);
1718 } 1741 }
1719
1720 Condition cc = TokenToCondition(instr->op(), instr->is_double());
1721 EmitBranch(true_block, false_block, cc);
1722 } 1742 }
1723 1743
1724 1744
1725 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) { 1745 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) {
1726 Register left = ToRegister(instr->InputAt(0)); 1746 Register left = ToRegister(instr->InputAt(0));
1727 Register right = ToRegister(instr->InputAt(1)); 1747 Register right = ToRegister(instr->InputAt(1));
1728 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1748 int false_block = chunk_->LookupDestination(instr->false_block_id());
1729 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1749 int true_block = chunk_->LookupDestination(instr->true_block_id());
1730 1750
1731 __ cmp(left, Operand(right)); 1751 __ cmp(left, Operand(right));
(...skipping 2778 matching lines...) Expand 10 before | Expand all | Expand 10 after
4510 ASSERT(osr_pc_offset_ == -1); 4530 ASSERT(osr_pc_offset_ == -1);
4511 osr_pc_offset_ = masm()->pc_offset(); 4531 osr_pc_offset_ = masm()->pc_offset();
4512 } 4532 }
4513 4533
4514 4534
4515 4535
4516 4536
4517 #undef __ 4537 #undef __
4518 4538
4519 } } // namespace v8::internal 4539 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.h ('k') | src/assembler.h » ('j') | src/ia32/lithium-codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698