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

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

Issue 7918012: Unify the handling of comparinsons against null and undefined. (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
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ast.h » ('j') | src/v8.h » ('J')
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 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 void LCodeGen::DoCmpConstantEqAndBranch(LCmpConstantEqAndBranch* instr) { 1742 void LCodeGen::DoCmpConstantEqAndBranch(LCmpConstantEqAndBranch* instr) {
1743 Register left = ToRegister(instr->InputAt(0)); 1743 Register left = ToRegister(instr->InputAt(0));
1744 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1744 int true_block = chunk_->LookupDestination(instr->true_block_id());
1745 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1745 int false_block = chunk_->LookupDestination(instr->false_block_id());
1746 1746
1747 __ cmp(left, Operand(instr->hydrogen()->right())); 1747 __ cmp(left, Operand(instr->hydrogen()->right()));
1748 EmitBranch(true_block, false_block, eq); 1748 EmitBranch(true_block, false_block, eq);
1749 } 1749 }
1750 1750
1751 1751
1752 void LCodeGen::DoIsNullAndBranch(LIsNullAndBranch* instr) { 1752 void LCodeGen::DoIsNilAndBranch(LIsNilAndBranch* instr) {
1753 Register scratch = scratch0(); 1753 Register scratch = scratch0();
1754 Register reg = ToRegister(instr->InputAt(0)); 1754 Register reg = ToRegister(instr->InputAt(0));
1755 int false_block = chunk_->LookupDestination(instr->false_block_id());
1755 1756
1756 // TODO(fsc): If the expression is known to be a smi, then it's 1757 // If the expression is known to be untagged or a smi, then it's definitely
1757 // definitely not null. Jump to the false block. 1758 // not null, and it can't be a an undetectable object.
1759 if (instr->hydrogen()->representation().IsSpecialization() ||
1760 instr->hydrogen()->type().IsSmi()) {
1761 EmitGoto(false_block);
1762 return;
1763 }
1758 1764
1759 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1765 int true_block = chunk_->LookupDestination(instr->true_block_id());
1760 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1766 Heap::RootListIndex nil_value = instr->nil() == kNullValue ?
1761 1767 Heap::kNullValueRootIndex :
1762 __ LoadRoot(ip, Heap::kNullValueRootIndex); 1768 Heap::kUndefinedValueRootIndex;
1769 __ LoadRoot(ip, nil_value);
1763 __ cmp(reg, ip); 1770 __ cmp(reg, ip);
1764 if (instr->is_strict()) { 1771 if (instr->kind() == kStrictEquality) {
1765 EmitBranch(true_block, false_block, eq); 1772 EmitBranch(true_block, false_block, eq);
1766 } else { 1773 } else {
1774 Heap::RootListIndex other_nil_value = instr->nil() == kNullValue ?
1775 Heap::kUndefinedValueRootIndex :
1776 Heap::kNullValueRootIndex;
1767 Label* true_label = chunk_->GetAssemblyLabel(true_block); 1777 Label* true_label = chunk_->GetAssemblyLabel(true_block);
1768 Label* false_label = chunk_->GetAssemblyLabel(false_block); 1778 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1769 __ b(eq, true_label); 1779 __ b(eq, true_label);
1770 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 1780 __ LoadRoot(ip, other_nil_value);
1771 __ cmp(reg, ip); 1781 __ cmp(reg, ip);
1772 __ b(eq, true_label); 1782 __ b(eq, true_label);
1773 __ JumpIfSmi(reg, false_label); 1783 __ JumpIfSmi(reg, false_label);
1774 // Check for undetectable objects by looking in the bit field in 1784 // Check for undetectable objects by looking in the bit field in
1775 // the map. The object has already been smi checked. 1785 // the map. The object has already been smi checked.
1776 __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset)); 1786 __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset));
1777 __ ldrb(scratch, FieldMemOperand(scratch, Map::kBitFieldOffset)); 1787 __ ldrb(scratch, FieldMemOperand(scratch, Map::kBitFieldOffset));
1778 __ tst(scratch, Operand(1 << Map::kIsUndetectable)); 1788 __ tst(scratch, Operand(1 << Map::kIsUndetectable));
1779 EmitBranch(true_block, false_block, ne); 1789 EmitBranch(true_block, false_block, ne);
1780 } 1790 }
(...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after
4516 ASSERT(osr_pc_offset_ == -1); 4526 ASSERT(osr_pc_offset_ == -1);
4517 osr_pc_offset_ = masm()->pc_offset(); 4527 osr_pc_offset_ = masm()->pc_offset();
4518 } 4528 }
4519 4529
4520 4530
4521 4531
4522 4532
4523 #undef __ 4533 #undef __
4524 4534
4525 } } // namespace v8::internal 4535 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ast.h » ('j') | src/v8.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698