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

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

Issue 7042004: Handle all kind of arguments in the ToBooleanStub. While this is not very (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 7 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 | « no previous file | src/arm/full-codegen-arm.cc » ('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 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) 1609 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater)
1610 // tagged as a small integer. 1610 // tagged as a small integer.
1611 __ InvokeBuiltin(native, JUMP_FUNCTION); 1611 __ InvokeBuiltin(native, JUMP_FUNCTION);
1612 } 1612 }
1613 1613
1614 1614
1615 // This stub does not handle the inlined cases (Smis, Booleans, undefined). 1615 // This stub does not handle the inlined cases (Smis, Booleans, undefined).
1616 // The stub returns zero for false, and a non-zero value for true. 1616 // The stub returns zero for false, and a non-zero value for true.
1617 void ToBooleanStub::Generate(MacroAssembler* masm) { 1617 void ToBooleanStub::Generate(MacroAssembler* masm) {
1618 // This stub uses VFP3 instructions. 1618 // This stub uses VFP3 instructions.
1619 ASSERT(CpuFeatures::IsEnabled(VFP3)); 1619 CpuFeatures::Scope scope(VFP3);
1620 1620
1621 Label false_result; 1621 Label false_result;
1622 Label not_heap_number; 1622 Label not_heap_number;
1623 Register scratch = r9.is(tos_) ? r7 : r9; 1623 Register scratch = r9.is(tos_) ? r7 : r9;
1624 1624
1625 // undefined -> false
1626 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
1627 __ cmp(tos_, ip);
1628 __ b(eq, &false_result);
1629
1630 // Boolean -> its value
1631 __ LoadRoot(ip, Heap::kFalseValueRootIndex);
1632 __ cmp(tos_, ip);
1633 __ b(eq, &false_result);
1634 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
1635 __ cmp(tos_, ip);
1636 // "tos_" is a register and contains a non-zero value. Hence we implicitly
1637 // return true if the equal condition is satisfied.
1638 __ Ret(eq);
1639
1640 // Smis: 0 -> false, all other -> true
1641 __ tst(tos_, tos_);
1642 __ b(eq, &false_result);
1643 __ tst(tos_, Operand(kSmiTagMask));
1644 // "tos_" is a register and contains a non-zero value. Hence we implicitly
1645 // return true if the not equal condition is satisfied.
1646 __ Ret(eq);
1647
1648 // 'null' -> false
1625 __ LoadRoot(ip, Heap::kNullValueRootIndex); 1649 __ LoadRoot(ip, Heap::kNullValueRootIndex);
1626 __ cmp(tos_, ip); 1650 __ cmp(tos_, ip);
1627 __ b(eq, &false_result); 1651 __ b(eq, &false_result);
1628 1652
1629 // HeapNumber => false iff +0, -0, or NaN. 1653 // HeapNumber => false iff +0, -0, or NaN.
1630 __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset)); 1654 __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset));
1631 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); 1655 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
1632 __ cmp(scratch, ip); 1656 __ cmp(scratch, ip);
1633 __ b(&not_heap_number, ne); 1657 __ b(&not_heap_number, ne);
1634 1658 __ vldr(d1, FieldMemOperand(tos_, HeapNumber::kValueOffset));
1635 __ sub(ip, tos_, Operand(kHeapObjectTag));
1636 __ vldr(d1, ip, HeapNumber::kValueOffset);
1637 __ VFPCompareAndSetFlags(d1, 0.0); 1659 __ VFPCompareAndSetFlags(d1, 0.0);
1638 // "tos_" is a register, and contains a non zero value by default. 1660 // "tos_" is a register, and contains a non zero value by default.
1639 // Hence we only need to overwrite "tos_" with zero to return false for 1661 // Hence we only need to overwrite "tos_" with zero to return false for
1640 // FP_ZERO or FP_NAN cases. Otherwise, by default it returns true. 1662 // FP_ZERO or FP_NAN cases. Otherwise, by default it returns true.
1641 __ mov(tos_, Operand(0, RelocInfo::NONE), LeaveCC, eq); // for FP_ZERO 1663 __ mov(tos_, Operand(0, RelocInfo::NONE), LeaveCC, eq); // for FP_ZERO
1642 __ mov(tos_, Operand(0, RelocInfo::NONE), LeaveCC, vs); // for FP_NAN 1664 __ mov(tos_, Operand(0, RelocInfo::NONE), LeaveCC, vs); // for FP_NAN
1643 __ Ret(); 1665 __ Ret();
1644 1666
1645 __ bind(&not_heap_number); 1667 __ bind(&not_heap_number);
1646 1668
1647 // Check if the value is 'null'.
1648 // 'null' => false.
1649 __ LoadRoot(ip, Heap::kNullValueRootIndex);
1650 __ cmp(tos_, ip);
1651 __ b(&false_result, eq);
1652
1653 // It can be an undetectable object. 1669 // It can be an undetectable object.
1654 // Undetectable => false. 1670 // Undetectable => false.
1655 __ ldr(ip, FieldMemOperand(tos_, HeapObject::kMapOffset)); 1671 __ ldr(ip, FieldMemOperand(tos_, HeapObject::kMapOffset));
1656 __ ldrb(scratch, FieldMemOperand(ip, Map::kBitFieldOffset)); 1672 __ ldrb(scratch, FieldMemOperand(ip, Map::kBitFieldOffset));
1657 __ and_(scratch, scratch, Operand(1 << Map::kIsUndetectable)); 1673 __ and_(scratch, scratch, Operand(1 << Map::kIsUndetectable));
1658 __ cmp(scratch, Operand(1 << Map::kIsUndetectable)); 1674 __ cmp(scratch, Operand(1 << Map::kIsUndetectable));
1659 __ b(&false_result, eq); 1675 __ b(&false_result, eq);
1660 1676
1661 // JavaScript object => true. 1677 // JavaScript object => true.
1662 __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset)); 1678 __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset));
(...skipping 4706 matching lines...) Expand 10 before | Expand all | Expand 10 after
6369 __ mov(result, Operand(0)); 6385 __ mov(result, Operand(0));
6370 __ Ret(); 6386 __ Ret();
6371 } 6387 }
6372 6388
6373 6389
6374 #undef __ 6390 #undef __
6375 6391
6376 } } // namespace v8::internal 6392 } } // namespace v8::internal
6377 6393
6378 #endif // V8_TARGET_ARCH_ARM 6394 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698