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

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

Issue 8589019: Landing: [hydrogen] optimize switch with string clauses. Patch by Fedor Indutny <fedor.indutny@gm... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1676 int false_block = chunk_->LookupDestination(instr->false_block_id());
1677 Label* true_label = chunk_->GetAssemblyLabel(true_block); 1677 Label* true_label = chunk_->GetAssemblyLabel(true_block);
1678 Label* false_label = chunk_->GetAssemblyLabel(false_block); 1678 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1679 1679
1680 Condition true_cond = EmitIsObject(reg, temp, false_label, true_label); 1680 Condition true_cond = EmitIsObject(reg, temp, false_label, true_label);
1681 1681
1682 EmitBranch(true_block, false_block, true_cond); 1682 EmitBranch(true_block, false_block, true_cond);
1683 } 1683 }
1684 1684
1685 1685
1686 Condition LCodeGen::EmitIsString(Register input,
1687 Register temp1,
1688 Label* is_not_string) {
1689 __ JumpIfSmi(input, is_not_string);
1690
1691 Condition cond = masm_->IsObjectStringType(input, temp1, temp1);
1692
1693 return cond;
1694 }
1695
1696
1697 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) {
1698 Register reg = ToRegister(instr->InputAt(0));
1699 Register temp = ToRegister(instr->TempAt(0));
1700
1701 int true_block = chunk_->LookupDestination(instr->true_block_id());
1702 int false_block = chunk_->LookupDestination(instr->false_block_id());
1703 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1704
1705 Condition true_cond = EmitIsString(reg, temp, false_label);
1706
1707 EmitBranch(true_block, false_block, true_cond);
1708 }
1709
1710
1686 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { 1711 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
1687 Operand input = ToOperand(instr->InputAt(0)); 1712 Operand input = ToOperand(instr->InputAt(0));
1688 1713
1689 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1714 int true_block = chunk_->LookupDestination(instr->true_block_id());
1690 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1715 int false_block = chunk_->LookupDestination(instr->false_block_id());
1691 1716
1692 __ test(input, Immediate(kSmiTagMask)); 1717 __ test(input, Immediate(kSmiTagMask));
1693 EmitBranch(true_block, false_block, zero); 1718 EmitBranch(true_block, false_block, zero);
1694 } 1719 }
1695 1720
1696 1721
1697 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { 1722 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) {
1698 Register input = ToRegister(instr->InputAt(0)); 1723 Register input = ToRegister(instr->InputAt(0));
1699 Register temp = ToRegister(instr->TempAt(0)); 1724 Register temp = ToRegister(instr->TempAt(0));
1700 1725
1701 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1726 int true_block = chunk_->LookupDestination(instr->true_block_id());
1702 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1727 int false_block = chunk_->LookupDestination(instr->false_block_id());
1703 1728
1704 STATIC_ASSERT(kSmiTag == 0); 1729 STATIC_ASSERT(kSmiTag == 0);
1705 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); 1730 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block));
1706 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); 1731 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset));
1707 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), 1732 __ test_b(FieldOperand(temp, Map::kBitFieldOffset),
1708 1 << Map::kIsUndetectable); 1733 1 << Map::kIsUndetectable);
1709 EmitBranch(true_block, false_block, not_zero); 1734 EmitBranch(true_block, false_block, not_zero);
1710 } 1735 }
1711 1736
1712 1737
1738 static Condition ComputeCompareCondition(Token::Value op) {
1739 switch (op) {
1740 case Token::EQ_STRICT:
1741 case Token::EQ:
1742 return equal;
1743 case Token::LT:
1744 return less;
1745 case Token::GT:
1746 return greater;
1747 case Token::LTE:
1748 return less_equal;
1749 case Token::GTE:
1750 return greater_equal;
1751 default:
1752 UNREACHABLE();
1753 return no_condition;
1754 }
1755 }
1756
1757
1758 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
1759 Token::Value op = instr->op();
1760 int true_block = chunk_->LookupDestination(instr->true_block_id());
1761 int false_block = chunk_->LookupDestination(instr->false_block_id());
1762
1763 Handle<Code> ic = CompareIC::GetUninitialized(op);
1764 CallCode(ic, RelocInfo::CODE_TARGET, instr);
1765
1766 Condition condition = ComputeCompareCondition(op);
1767 __ test(eax, Operand(eax));
1768
1769 EmitBranch(true_block, false_block, condition);
1770 }
1771
1772
1713 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { 1773 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) {
1714 InstanceType from = instr->from(); 1774 InstanceType from = instr->from();
1715 InstanceType to = instr->to(); 1775 InstanceType to = instr->to();
1716 if (from == FIRST_TYPE) return to; 1776 if (from == FIRST_TYPE) return to;
1717 ASSERT(from == to || to == LAST_TYPE); 1777 ASSERT(from == to || to == LAST_TYPE);
1718 return from; 1778 return from;
1719 } 1779 }
1720 1780
1721 1781
1722 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { 1782 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); 2040 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS);
1981 ASSERT(instr->HasDeoptimizationEnvironment()); 2041 ASSERT(instr->HasDeoptimizationEnvironment());
1982 LEnvironment* env = instr->deoptimization_environment(); 2042 LEnvironment* env = instr->deoptimization_environment();
1983 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); 2043 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index());
1984 2044
1985 // Put the result value into the eax slot and restore all registers. 2045 // Put the result value into the eax slot and restore all registers.
1986 __ StoreToSafepointRegisterSlot(eax, eax); 2046 __ StoreToSafepointRegisterSlot(eax, eax);
1987 } 2047 }
1988 2048
1989 2049
1990 static Condition ComputeCompareCondition(Token::Value op) {
1991 switch (op) {
1992 case Token::EQ_STRICT:
1993 case Token::EQ:
1994 return equal;
1995 case Token::LT:
1996 return less;
1997 case Token::GT:
1998 return greater;
1999 case Token::LTE:
2000 return less_equal;
2001 case Token::GTE:
2002 return greater_equal;
2003 default:
2004 UNREACHABLE();
2005 return no_condition;
2006 }
2007 }
2008
2009
2010 void LCodeGen::DoCmpT(LCmpT* instr) { 2050 void LCodeGen::DoCmpT(LCmpT* instr) {
2011 Token::Value op = instr->op(); 2051 Token::Value op = instr->op();
2012 2052
2013 Handle<Code> ic = CompareIC::GetUninitialized(op); 2053 Handle<Code> ic = CompareIC::GetUninitialized(op);
2014 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2054 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2015 2055
2016 Condition condition = ComputeCompareCondition(op); 2056 Condition condition = ComputeCompareCondition(op);
2017 Label true_value, done; 2057 Label true_value, done;
2018 __ test(eax, Operand(eax)); 2058 __ test(eax, Operand(eax));
2019 __ j(condition, &true_value, Label::kNear); 2059 __ j(condition, &true_value, Label::kNear);
(...skipping 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after
4570 this, pointers, Safepoint::kLazyDeopt); 4610 this, pointers, Safepoint::kLazyDeopt);
4571 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4611 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4572 } 4612 }
4573 4613
4574 4614
4575 #undef __ 4615 #undef __
4576 4616
4577 } } // namespace v8::internal 4617 } } // namespace v8::internal
4578 4618
4579 #endif // V8_TARGET_ARCH_IA32 4619 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698