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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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 __ cmp(left, instr->hydrogen()->right()); 1581 __ cmp(left, 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 int false_block = chunk_->LookupDestination(instr->false_block_id());
1588 1589
1589 // TODO(fsc): If the expression is known to be a smi, then it's 1590 // If the expression is known to be untagged or a smi, then it's definitely
1590 // definitely not null. Jump to the false block. 1591 // not null, and it can't be a an undetectable object.
1592 if (instr->hydrogen()->representation().IsSpecialization() ||
1593 instr->hydrogen()->type().IsSmi()) {
1594 EmitGoto(false_block);
1595 return;
1596 }
1591 1597
1592 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1598 int true_block = chunk_->LookupDestination(instr->true_block_id());
1593 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1599 Handle<Object> nil_value = instr->nil() == kNullValue ?
1594 1600 factory()->null_value() :
1595 __ cmp(reg, factory()->null_value()); 1601 factory()->undefined_value();
1596 if (instr->is_strict()) { 1602 __ cmp(reg, nil_value);
1603 if (instr->kind() == kStrictEquality) {
1597 EmitBranch(true_block, false_block, equal); 1604 EmitBranch(true_block, false_block, equal);
1598 } else { 1605 } else {
1606 Handle<Object> other_nil_value = instr->nil() == kNullValue ?
1607 factory()->undefined_value() :
1608 factory()->null_value();
1599 Label* true_label = chunk_->GetAssemblyLabel(true_block); 1609 Label* true_label = chunk_->GetAssemblyLabel(true_block);
1600 Label* false_label = chunk_->GetAssemblyLabel(false_block); 1610 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1601 __ j(equal, true_label); 1611 __ j(equal, true_label);
1602 __ cmp(reg, factory()->undefined_value()); 1612 __ cmp(reg, other_nil_value);
1603 __ j(equal, true_label); 1613 __ j(equal, true_label);
1604 __ JumpIfSmi(reg, false_label); 1614 __ JumpIfSmi(reg, false_label);
1605 // Check for undetectable objects by looking in the bit field in 1615 // Check for undetectable objects by looking in the bit field in
1606 // the map. The object has already been smi checked. 1616 // the map. The object has already been smi checked.
1607 Register scratch = ToRegister(instr->TempAt(0)); 1617 Register scratch = ToRegister(instr->TempAt(0));
1608 __ mov(scratch, FieldOperand(reg, HeapObject::kMapOffset)); 1618 __ mov(scratch, FieldOperand(reg, HeapObject::kMapOffset));
1609 __ movzx_b(scratch, FieldOperand(scratch, Map::kBitFieldOffset)); 1619 __ movzx_b(scratch, FieldOperand(scratch, Map::kBitFieldOffset));
1610 __ test(scratch, Immediate(1 << Map::kIsUndetectable)); 1620 __ test(scratch, Immediate(1 << Map::kIsUndetectable));
1611 EmitBranch(true_block, false_block, not_zero); 1621 EmitBranch(true_block, false_block, not_zero);
1612 } 1622 }
(...skipping 2771 matching lines...) Expand 10 before | Expand all | Expand 10 after
4384 env->deoptimization_index()); 4394 env->deoptimization_index());
4385 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4395 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4386 } 4396 }
4387 4397
4388 4398
4389 #undef __ 4399 #undef __
4390 4400
4391 } } // namespace v8::internal 4401 } } // namespace v8::internal
4392 4402
4393 #endif // V8_TARGET_ARCH_IA32 4403 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/ia32/lithium-ia32.h » ('j') | src/v8.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698