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

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 7218012: Make ToBooleanStub more consistent across platforms. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 6 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/mips/code-stubs-mips.h ('k') | src/x64/code-stubs-x64.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 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 __ li(a0, Operand(Smi::FromInt(ncr))); 1711 __ li(a0, Operand(Smi::FromInt(ncr)));
1712 __ push(a0); 1712 __ push(a0);
1713 } 1713 }
1714 1714
1715 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) 1715 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater)
1716 // tagged as a small integer. 1716 // tagged as a small integer.
1717 __ InvokeBuiltin(native, JUMP_FUNCTION); 1717 __ InvokeBuiltin(native, JUMP_FUNCTION);
1718 } 1718 }
1719 1719
1720 1720
1721 // This stub does not handle the inlined cases (Smis, Booleans, undefined).
1722 // The stub returns zero for false, and a non-zero value for true. 1721 // The stub returns zero for false, and a non-zero value for true.
1723 void ToBooleanStub::Generate(MacroAssembler* masm) { 1722 void ToBooleanStub::Generate(MacroAssembler* masm) {
1724 // This stub uses FPU instructions. 1723 // This stub uses FPU instructions.
1725 CpuFeatures::Scope scope(FPU); 1724 CpuFeatures::Scope scope(FPU);
1726 1725
1727 Label false_result; 1726 Label false_result;
1728 Label not_heap_number; 1727 Label not_heap_number;
1729 Register scratch0 = t5.is(tos_) ? t3 : t5; 1728 Register scratch0 = t5.is(tos_) ? t3 : t5;
1730 1729
1731 // undefined -> false 1730 // undefined -> false
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 __ And(scratch0, scratch0, Operand(1 << Map::kIsUndetectable)); 1774 __ And(scratch0, scratch0, Operand(1 << Map::kIsUndetectable));
1776 __ Branch(&false_result, eq, scratch0, Operand(1 << Map::kIsUndetectable)); 1775 __ Branch(&false_result, eq, scratch0, Operand(1 << Map::kIsUndetectable));
1777 1776
1778 // JavaScript object => true. 1777 // JavaScript object => true.
1779 __ lw(scratch0, FieldMemOperand(tos_, HeapObject::kMapOffset)); 1778 __ lw(scratch0, FieldMemOperand(tos_, HeapObject::kMapOffset));
1780 __ lbu(scratch0, FieldMemOperand(scratch0, Map::kInstanceTypeOffset)); 1779 __ lbu(scratch0, FieldMemOperand(scratch0, Map::kInstanceTypeOffset));
1781 1780
1782 // "tos_" is a register and contains a non-zero value. 1781 // "tos_" is a register and contains a non-zero value.
1783 // Hence we implicitly return true if the greater than 1782 // Hence we implicitly return true if the greater than
1784 // condition is satisfied. 1783 // condition is satisfied.
1785 __ Ret(gt, scratch0, Operand(FIRST_SPEC_OBJECT_TYPE)); 1784 __ Ret(ge, scratch0, Operand(FIRST_SPEC_OBJECT_TYPE));
1786 1785
1787 // Check for string. 1786 // Check for string.
1788 __ lw(scratch0, FieldMemOperand(tos_, HeapObject::kMapOffset)); 1787 __ lw(scratch0, FieldMemOperand(tos_, HeapObject::kMapOffset));
1789 __ lbu(scratch0, FieldMemOperand(scratch0, Map::kInstanceTypeOffset)); 1788 __ lbu(scratch0, FieldMemOperand(scratch0, Map::kInstanceTypeOffset));
1790 // "tos_" is a register and contains a non-zero value. 1789 // "tos_" is a register and contains a non-zero value.
1791 // Hence we implicitly return true if the greater than 1790 // Hence we implicitly return true if the greater than
1792 // condition is satisfied. 1791 // condition is satisfied.
1793 __ Ret(gt, scratch0, Operand(FIRST_NONSTRING_TYPE)); 1792 __ Ret(ge, scratch0, Operand(FIRST_NONSTRING_TYPE));
1794 1793
1795 // String value => false iff empty, i.e., length is zero. 1794 // String value => false iff empty, i.e., length is zero.
1796 __ lw(tos_, FieldMemOperand(tos_, String::kLengthOffset)); 1795 __ lw(tos_, FieldMemOperand(tos_, String::kLengthOffset));
1797 // If length is zero, "tos_" contains zero ==> false. 1796 // If length is zero, "tos_" contains zero ==> false.
1798 // If length is not zero, "tos_" contains a non-zero value ==> true. 1797 // If length is not zero, "tos_" contains a non-zero value ==> true.
1799 __ Ret(); 1798 __ Ret();
1800 1799
1801 // Return 0 in "tos_" for false. 1800 // Return 0 in "tos_" for false.
1802 __ bind(&false_result); 1801 __ bind(&false_result);
1803 __ mov(tos_, zero_reg); 1802 __ mov(tos_, zero_reg);
(...skipping 5084 matching lines...) Expand 10 before | Expand all | Expand 10 after
6888 __ mov(result, zero_reg); 6887 __ mov(result, zero_reg);
6889 __ Ret(); 6888 __ Ret();
6890 } 6889 }
6891 6890
6892 6891
6893 #undef __ 6892 #undef __
6894 6893
6895 } } // namespace v8::internal 6894 } } // namespace v8::internal
6896 6895
6897 #endif // V8_TARGET_ARCH_MIPS 6896 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.h ('k') | src/x64/code-stubs-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698