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

Side by Side Diff: src/x64/lithium-codegen-x64.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
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 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 void LCodeGen::DoCmpConstantEqAndBranch(LCmpConstantEqAndBranch* instr) { 1576 void LCodeGen::DoCmpConstantEqAndBranch(LCmpConstantEqAndBranch* instr) {
1577 Register left = ToRegister(instr->InputAt(0)); 1577 Register left = ToRegister(instr->InputAt(0));
1578 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1578 int true_block = chunk_->LookupDestination(instr->true_block_id());
1579 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1579 int false_block = chunk_->LookupDestination(instr->false_block_id());
1580 1580
1581 __ cmpq(left, Immediate(instr->hydrogen()->right())); 1581 __ cmpq(left, Immediate(instr->hydrogen()->right()));
1582 EmitBranch(true_block, false_block, equal); 1582 EmitBranch(true_block, false_block, equal);
1583 } 1583 }
1584 1584
1585 1585
1586 void LCodeGen::DoIsNullAndBranch(LIsNullAndBranch* instr) { 1586 void LCodeGen::DoIsNilAndBranch(LIsNilAndBranch* instr) {
1587 Register reg = ToRegister(instr->InputAt(0)); 1587 Register reg = ToRegister(instr->InputAt(0));
1588
1589 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1588 int false_block = chunk_->LookupDestination(instr->false_block_id());
1590 1589
1590 // If the expression is known to be untagged or a smi, then it's definitely
1591 // not null, and it can't be a an undetectable object.
1591 if (instr->hydrogen()->representation().IsSpecialization() || 1592 if (instr->hydrogen()->representation().IsSpecialization() ||
1592 instr->hydrogen()->type().IsSmi()) { 1593 instr->hydrogen()->type().IsSmi()) {
1593 // If the expression is known to untagged or smi, then it's definitely
1594 // not null, and it can't be a an undetectable object.
1595 // Jump directly to the false block.
1596 EmitGoto(false_block); 1594 EmitGoto(false_block);
1597 return; 1595 return;
1598 } 1596 }
1599 1597
1600 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1598 int true_block = chunk_->LookupDestination(instr->true_block_id());
1601 1599 Heap::RootListIndex nil_value = instr->nil() == kNullValue ?
1602 __ CompareRoot(reg, Heap::kNullValueRootIndex); 1600 Heap::kNullValueRootIndex :
1603 if (instr->is_strict()) { 1601 Heap::kUndefinedValueRootIndex;
1602 __ CompareRoot(reg, nil_value);
1603 if (instr->kind() == kStrictEquality) {
1604 EmitBranch(true_block, false_block, equal); 1604 EmitBranch(true_block, false_block, equal);
1605 } else { 1605 } else {
1606 Heap::RootListIndex other_nil_value = instr->nil() == kNullValue ?
1607 Heap::kUndefinedValueRootIndex :
1608 Heap::kNullValueRootIndex;
1606 Label* true_label = chunk_->GetAssemblyLabel(true_block); 1609 Label* true_label = chunk_->GetAssemblyLabel(true_block);
1607 Label* false_label = chunk_->GetAssemblyLabel(false_block); 1610 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1608 __ j(equal, true_label); 1611 __ j(equal, true_label);
1609 __ CompareRoot(reg, Heap::kUndefinedValueRootIndex); 1612 __ CompareRoot(reg, other_nil_value);
1610 __ j(equal, true_label); 1613 __ j(equal, true_label);
1611 __ JumpIfSmi(reg, false_label); 1614 __ JumpIfSmi(reg, false_label);
1612 // Check for undetectable objects by looking in the bit field in 1615 // Check for undetectable objects by looking in the bit field in
1613 // the map. The object has already been smi checked. 1616 // the map. The object has already been smi checked.
1614 Register scratch = ToRegister(instr->TempAt(0)); 1617 Register scratch = ToRegister(instr->TempAt(0));
1615 __ movq(scratch, FieldOperand(reg, HeapObject::kMapOffset)); 1618 __ movq(scratch, FieldOperand(reg, HeapObject::kMapOffset));
1616 __ testb(FieldOperand(scratch, Map::kBitFieldOffset), 1619 __ testb(FieldOperand(scratch, Map::kBitFieldOffset),
1617 Immediate(1 << Map::kIsUndetectable)); 1620 Immediate(1 << Map::kIsUndetectable));
1618 EmitBranch(true_block, false_block, not_zero); 1621 EmitBranch(true_block, false_block, not_zero);
1619 } 1622 }
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4154 RegisterEnvironmentForDeoptimization(environment); 4157 RegisterEnvironmentForDeoptimization(environment);
4155 ASSERT(osr_pc_offset_ == -1); 4158 ASSERT(osr_pc_offset_ == -1);
4156 osr_pc_offset_ = masm()->pc_offset(); 4159 osr_pc_offset_ = masm()->pc_offset();
4157 } 4160 }
4158 4161
4159 #undef __ 4162 #undef __
4160 4163
4161 } } // namespace v8::internal 4164 } } // namespace v8::internal
4162 4165
4163 #endif // V8_TARGET_ARCH_X64 4166 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/v8.h ('K') | « src/x64/full-codegen-x64.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698