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

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

Issue 8373029: [hydrogen] optimize switch with string clauses (Closed) Base URL: gh:v8/v8@master
Patch Set: remove second pass 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
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 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1673 int false_block = chunk_->LookupDestination(instr->false_block_id());
1674 Label* true_label = chunk_->GetAssemblyLabel(true_block); 1674 Label* true_label = chunk_->GetAssemblyLabel(true_block);
1675 Label* false_label = chunk_->GetAssemblyLabel(false_block); 1675 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1676 1676
1677 Condition true_cond = EmitIsObject(reg, false_label, true_label); 1677 Condition true_cond = EmitIsObject(reg, false_label, true_label);
1678 1678
1679 EmitBranch(true_block, false_block, true_cond); 1679 EmitBranch(true_block, false_block, true_cond);
1680 } 1680 }
1681 1681
1682 1682
1683 Condition LCodeGen::EmitIsString(Register input,
1684 Label* is_not_string,
1685 Label* is_string) {
1686
1687 __ JumpIfSmi(input, is_not_string);
1688 __ CmpObjectType(input, FIRST_NONSTRING_TYPE, rcx);
fschneider 2011/11/08 10:14:37 Here you need to use a temp register like on the o
1689
1690 return below;
1691 }
1692
1693
1694 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) {
1695 Register reg = ToRegister(instr->InputAt(0));
1696
1697 int true_block = chunk_->LookupDestination(instr->true_block_id());
1698 int false_block = chunk_->LookupDestination(instr->false_block_id());
1699 Label* true_label = chunk_->GetAssemblyLabel(true_block);
1700 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1701
1702 Condition true_cond = EmitIsString(reg, false_label, true_label);
1703
1704 EmitBranch(true_block, false_block, true_cond);
1705 }
1706
1707
1683 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { 1708 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
1684 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1709 int true_block = chunk_->LookupDestination(instr->true_block_id());
1685 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1710 int false_block = chunk_->LookupDestination(instr->false_block_id());
1686 1711
1687 Condition is_smi; 1712 Condition is_smi;
1688 if (instr->InputAt(0)->IsRegister()) { 1713 if (instr->InputAt(0)->IsRegister()) {
1689 Register input = ToRegister(instr->InputAt(0)); 1714 Register input = ToRegister(instr->InputAt(0));
1690 is_smi = masm()->CheckSmi(input); 1715 is_smi = masm()->CheckSmi(input);
1691 } else { 1716 } else {
1692 Operand input = ToOperand(instr->InputAt(0)); 1717 Operand input = ToOperand(instr->InputAt(0));
(...skipping 11 matching lines...) Expand all
1704 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1729 int false_block = chunk_->LookupDestination(instr->false_block_id());
1705 1730
1706 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); 1731 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block));
1707 __ movq(temp, FieldOperand(input, HeapObject::kMapOffset)); 1732 __ movq(temp, FieldOperand(input, HeapObject::kMapOffset));
1708 __ testb(FieldOperand(temp, Map::kBitFieldOffset), 1733 __ testb(FieldOperand(temp, Map::kBitFieldOffset),
1709 Immediate(1 << Map::kIsUndetectable)); 1734 Immediate(1 << Map::kIsUndetectable));
1710 EmitBranch(true_block, false_block, not_zero); 1735 EmitBranch(true_block, false_block, not_zero);
1711 } 1736 }
1712 1737
1713 1738
1739 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
1740 Token::Value op = instr->op();
1741 int true_block = chunk_->LookupDestination(instr->true_block_id());
1742 int false_block = chunk_->LookupDestination(instr->false_block_id());
1743
1744 Handle<Code> ic = CompareIC::GetUninitialized(op);
1745 CallCode(ic, RelocInfo::CODE_TARGET, instr);
1746
1747 Condition condition = TokenToCondition(op, false);
1748 __ testq(rax, rax);
1749
1750 EmitBranch(true_block, false_block, condition);
1751 }
1752
1753
1714 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { 1754 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) {
1715 InstanceType from = instr->from(); 1755 InstanceType from = instr->from();
1716 InstanceType to = instr->to(); 1756 InstanceType to = instr->to();
1717 if (from == FIRST_TYPE) return to; 1757 if (from == FIRST_TYPE) return to;
1718 ASSERT(from == to || to == LAST_TYPE); 1758 ASSERT(from == to || to == LAST_TYPE);
1719 return from; 1759 return from;
1720 } 1760 }
1721 1761
1722 1762
1723 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { 1763 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) {
(...skipping 2569 matching lines...) Expand 10 before | Expand all | Expand 10 after
4293 RegisterEnvironmentForDeoptimization(environment); 4333 RegisterEnvironmentForDeoptimization(environment);
4294 ASSERT(osr_pc_offset_ == -1); 4334 ASSERT(osr_pc_offset_ == -1);
4295 osr_pc_offset_ = masm()->pc_offset(); 4335 osr_pc_offset_ = masm()->pc_offset();
4296 } 4336 }
4297 4337
4298 #undef __ 4338 #undef __
4299 4339
4300 } } // namespace v8::internal 4340 } } // namespace v8::internal
4301 4341
4302 #endif // V8_TARGET_ARCH_X64 4342 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | src/x64/lithium-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698