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

Side by Side Diff: src/arm/stub-cache-arm.cc

Issue 3446024: Custom call IC for Math.abs. (Closed)
Patch Set: More review fixes. Created 10 years, 2 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
« no previous file with comments | « no previous file | src/ia32/stub-cache-ia32.cc » ('j') | src/ia32/stub-cache-ia32.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 Object* CallStubCompiler::CompileMathFloorCall(Object* object, 1636 Object* CallStubCompiler::CompileMathFloorCall(Object* object,
1637 JSObject* holder, 1637 JSObject* holder,
1638 JSGlobalPropertyCell* cell, 1638 JSGlobalPropertyCell* cell,
1639 JSFunction* function, 1639 JSFunction* function,
1640 String* name) { 1640 String* name) {
1641 // TODO(872): implement this. 1641 // TODO(872): implement this.
1642 return Heap::undefined_value(); 1642 return Heap::undefined_value();
1643 } 1643 }
1644 1644
1645 1645
1646 Object* CallStubCompiler::CompileMathAbsCall(Object* object,
1647 JSObject* holder,
1648 JSGlobalPropertyCell* cell,
1649 JSFunction* function,
1650 String* name) {
1651 // ----------- S t a t e -------------
1652 // -- r2 : function name
1653 // -- lr : return address
1654 // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
1655 // -- ...
1656 // -- sp[argc * 4] : receiver
1657 // -----------------------------------
1658
1659 const int argc = arguments().immediate();
1660
1661 // If the object is not a JSObject or we got an unexpected number of
1662 // arguments, bail out to the regular call.
1663 if (!object->IsJSObject() || argc != 1) return Heap::undefined_value();
1664
1665 Label miss;
1666 GenerateNameCheck(name, &miss);
1667
1668 if (cell == NULL) {
1669 __ ldr(r1, MemOperand(sp, 1 * kPointerSize));
1670
1671 STATIC_ASSERT(kSmiTag == 0);
antonm 2010/09/28 12:04:17 BranchOnSmi(r1, miss)?
1672 __ tst(r1, Operand(kSmiTagMask));
1673 __ b(eq, &miss);
1674
1675 CheckPrototypes(JSObject::cast(object), r1, holder, r0, r3, r4, name,
1676 &miss);
1677 } else {
1678 ASSERT(cell->value() == function);
1679 GenerateGlobalReceiverCheck(JSObject::cast(object), holder, name, &miss);
1680 GenerateLoadFunctionFromCell(cell, function, &miss);
1681 }
1682
1683 // Load the (only) argument into r0.
1684 __ ldr(r0, MemOperand(sp, 0 * kPointerSize));
1685
1686 // Check if the argument is a smi.
1687 Label not_smi;
1688 STATIC_ASSERT(kSmiTag == 0);
1689 __ BranchOnNotSmi(r0, &not_smi);
1690
1691 // Do bitwise not or do nothing depending on the sign of the
1692 // argument.
1693 __ eor(r1, r0, Operand(r0, ASR, kBitsPerInt - 1));
1694
1695 // Add 1 or do nothing depending on the sign of the argument.
1696 __ sub(r0, r1, Operand(r0, ASR, kBitsPerInt - 1), SetCC);
1697
1698 // If the result is still negative, go to the slow case.
1699 // This only happens for the most negative smi.
1700 Label slow;
1701 __ b(mi, &slow);
1702
1703 // Smi case done.
1704 __ Drop(argc + 1);
1705 __ Ret();
1706
1707 // Check if the argument is a heap number and load its exponent and
1708 // sign.
1709 __ bind(&not_smi);
1710 __ CheckMap(r0, r1, Heap::kHeapNumberMapRootIndex, &slow, true);
1711 __ ldr(r1, FieldMemOperand(r0, HeapNumber::kExponentOffset));
1712
1713 // Check the sign of the argument. If the argument is positive,
1714 // just return it.
1715 Label negative_sign;
1716 __ tst(r1, Operand(HeapNumber::kSignMask));
1717 __ b(ne, &negative_sign);
1718 __ Drop(argc + 1);
1719 __ Ret();
1720
1721 // If the argument is negative, clear the sign, and return a new
1722 // number.
1723 __ bind(&negative_sign);
1724 __ eor(r1, r1, Operand(HeapNumber::kSignMask));
1725 __ ldr(r3, FieldMemOperand(r0, HeapNumber::kMantissaOffset));
1726 __ LoadRoot(r6, Heap::kHeapNumberMapRootIndex);
1727 __ AllocateHeapNumber(r0, r4, r5, r6, &slow);
1728 __ str(r1, FieldMemOperand(r0, HeapNumber::kExponentOffset));
1729 __ str(r3, FieldMemOperand(r0, HeapNumber::kMantissaOffset));
1730 __ Drop(argc + 1);
1731 __ Ret();
1732
1733 // Tail call the full function. We do not have to patch the receiver
1734 // because the function makes no use of it.
1735 __ bind(&slow);
1736 __ InvokeFunction(function, arguments(), JUMP_FUNCTION);
1737
1738 __ bind(&miss);
1739 // r2: function name.
1740 Object* obj = GenerateMissBranch();
1741 if (obj->IsFailure()) return obj;
1742
1743 // Return the generated code.
1744 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
1745 }
1746
1747
1646 Object* CallStubCompiler::CompileCallConstant(Object* object, 1748 Object* CallStubCompiler::CompileCallConstant(Object* object,
1647 JSObject* holder, 1749 JSObject* holder,
1648 JSFunction* function, 1750 JSFunction* function,
1649 String* name, 1751 String* name,
1650 CheckType check) { 1752 CheckType check) {
1651 // ----------- S t a t e ------------- 1753 // ----------- S t a t e -------------
1652 // -- r2 : name 1754 // -- r2 : name
1653 // -- lr : return address 1755 // -- lr : return address
1654 // ----------------------------------- 1756 // -----------------------------------
1655 SharedFunctionInfo* function_info = function->shared(); 1757 SharedFunctionInfo* function_info = function->shared();
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 // Return the generated code. 2694 // Return the generated code.
2593 return GetCode(); 2695 return GetCode();
2594 } 2696 }
2595 2697
2596 2698
2597 #undef __ 2699 #undef __
2598 2700
2599 } } // namespace v8::internal 2701 } } // namespace v8::internal
2600 2702
2601 #endif // V8_TARGET_ARCH_ARM 2703 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ia32/stub-cache-ia32.cc » ('j') | src/ia32/stub-cache-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698