OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 __ j(less, &too_few); | 1636 __ j(less, &too_few); |
1637 __ cmp(ebx, SharedFunctionInfo::kDontAdaptArgumentsSentinel); | 1637 __ cmp(ebx, SharedFunctionInfo::kDontAdaptArgumentsSentinel); |
1638 __ j(equal, &dont_adapt_arguments); | 1638 __ j(equal, &dont_adapt_arguments); |
1639 | 1639 |
1640 { // Enough parameters: Actual >= expected. | 1640 { // Enough parameters: Actual >= expected. |
1641 __ bind(&enough); | 1641 __ bind(&enough); |
1642 EnterArgumentsAdaptorFrame(masm); | 1642 EnterArgumentsAdaptorFrame(masm); |
1643 | 1643 |
1644 // Copy receiver and all expected arguments. | 1644 // Copy receiver and all expected arguments. |
1645 const int offset = StandardFrameConstants::kCallerSPOffset; | 1645 const int offset = StandardFrameConstants::kCallerSPOffset; |
1646 __ lea(eax, Operand(ebp, eax, times_4, offset)); | 1646 __ lea(edi, Operand(ebp, eax, times_4, offset)); |
1647 __ mov(edi, -1); // account for receiver | 1647 __ mov(eax, -1); // account for receiver |
1648 | 1648 |
1649 Label copy; | 1649 Label copy; |
1650 __ bind(©); | 1650 __ bind(©); |
1651 __ inc(edi); | 1651 __ inc(eax); |
1652 __ push(Operand(eax, 0)); | 1652 __ push(Operand(edi, 0)); |
1653 __ sub(eax, Immediate(kPointerSize)); | 1653 __ sub(edi, Immediate(kPointerSize)); |
1654 __ cmp(edi, ebx); | 1654 __ cmp(eax, ebx); |
1655 __ j(less, ©); | 1655 __ j(less, ©); |
| 1656 // eax now contains the expected number of arguments. |
1656 __ jmp(&invoke); | 1657 __ jmp(&invoke); |
1657 } | 1658 } |
1658 | 1659 |
1659 { // Too few parameters: Actual < expected. | 1660 { // Too few parameters: Actual < expected. |
1660 __ bind(&too_few); | 1661 __ bind(&too_few); |
1661 | 1662 |
1662 // If the function is strong we need to throw an error. | 1663 // If the function is strong we need to throw an error. |
1663 Label no_strong_error; | 1664 Label no_strong_error; |
1664 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 1665 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
1665 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrongModeByteOffset), | 1666 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrongModeByteOffset), |
1666 1 << SharedFunctionInfo::kStrongModeBitWithinByte); | 1667 1 << SharedFunctionInfo::kStrongModeBitWithinByte); |
1667 __ j(equal, &no_strong_error, Label::kNear); | 1668 __ j(equal, &no_strong_error, Label::kNear); |
1668 | 1669 |
1669 // What we really care about is the required number of arguments. | 1670 // What we really care about is the required number of arguments. |
1670 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kLengthOffset)); | 1671 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kLengthOffset)); |
1671 __ SmiUntag(ecx); | 1672 __ SmiUntag(ecx); |
1672 __ cmp(eax, ecx); | 1673 __ cmp(eax, ecx); |
1673 __ j(greater_equal, &no_strong_error, Label::kNear); | 1674 __ j(greater_equal, &no_strong_error, Label::kNear); |
1674 | 1675 |
1675 { | 1676 { |
1676 FrameScope frame(masm, StackFrame::MANUAL); | 1677 FrameScope frame(masm, StackFrame::MANUAL); |
1677 EnterArgumentsAdaptorFrame(masm); | 1678 EnterArgumentsAdaptorFrame(masm); |
1678 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0); | 1679 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0); |
1679 } | 1680 } |
1680 | 1681 |
1681 __ bind(&no_strong_error); | 1682 __ bind(&no_strong_error); |
1682 EnterArgumentsAdaptorFrame(masm); | 1683 EnterArgumentsAdaptorFrame(masm); |
1683 | 1684 |
| 1685 // Remember expected arguments in ecx. |
| 1686 __ mov(ecx, ebx); |
| 1687 |
1684 // Copy receiver and all actual arguments. | 1688 // Copy receiver and all actual arguments. |
1685 const int offset = StandardFrameConstants::kCallerSPOffset; | 1689 const int offset = StandardFrameConstants::kCallerSPOffset; |
1686 __ lea(edi, Operand(ebp, eax, times_4, offset)); | 1690 __ lea(edi, Operand(ebp, eax, times_4, offset)); |
1687 // ebx = expected - actual. | 1691 // ebx = expected - actual. |
1688 __ sub(ebx, eax); | 1692 __ sub(ebx, eax); |
1689 // eax = -actual - 1 | 1693 // eax = -actual - 1 |
1690 __ neg(eax); | 1694 __ neg(eax); |
1691 __ sub(eax, Immediate(1)); | 1695 __ sub(eax, Immediate(1)); |
1692 | 1696 |
1693 Label copy; | 1697 Label copy; |
1694 __ bind(©); | 1698 __ bind(©); |
1695 __ inc(eax); | 1699 __ inc(eax); |
1696 __ push(Operand(edi, 0)); | 1700 __ push(Operand(edi, 0)); |
1697 __ sub(edi, Immediate(kPointerSize)); | 1701 __ sub(edi, Immediate(kPointerSize)); |
1698 __ test(eax, eax); | 1702 __ test(eax, eax); |
1699 __ j(not_zero, ©); | 1703 __ j(not_zero, ©); |
1700 | 1704 |
1701 // Fill remaining expected arguments with undefined values. | 1705 // Fill remaining expected arguments with undefined values. |
1702 Label fill; | 1706 Label fill; |
1703 __ bind(&fill); | 1707 __ bind(&fill); |
1704 __ inc(eax); | 1708 __ inc(eax); |
1705 __ push(Immediate(masm->isolate()->factory()->undefined_value())); | 1709 __ push(Immediate(masm->isolate()->factory()->undefined_value())); |
1706 __ cmp(eax, ebx); | 1710 __ cmp(eax, ebx); |
1707 __ j(less, &fill); | 1711 __ j(less, &fill); |
| 1712 |
| 1713 // Restore expected arguments. |
| 1714 __ mov(eax, ecx); |
1708 } | 1715 } |
1709 | 1716 |
1710 // Call the entry point. | 1717 // Call the entry point. |
1711 __ bind(&invoke); | 1718 __ bind(&invoke); |
1712 // Restore function pointer. | 1719 // Restore function pointer. |
1713 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1720 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1721 // eax : expected number of arguments |
| 1722 // edi : function (passed through to callee) |
1714 __ call(edx); | 1723 __ call(edx); |
1715 | 1724 |
1716 // Store offset of return address for deoptimizer. | 1725 // Store offset of return address for deoptimizer. |
1717 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); | 1726 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); |
1718 | 1727 |
1719 // Leave frame and return. | 1728 // Leave frame and return. |
1720 LeaveArgumentsAdaptorFrame(masm); | 1729 LeaveArgumentsAdaptorFrame(masm); |
1721 __ ret(0); | 1730 __ ret(0); |
1722 | 1731 |
1723 // ------------------------------------------- | 1732 // ------------------------------------------- |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 | 1798 |
1790 __ bind(&ok); | 1799 __ bind(&ok); |
1791 __ ret(0); | 1800 __ ret(0); |
1792 } | 1801 } |
1793 | 1802 |
1794 #undef __ | 1803 #undef __ |
1795 } // namespace internal | 1804 } // namespace internal |
1796 } // namespace v8 | 1805 } // namespace v8 |
1797 | 1806 |
1798 #endif // V8_TARGET_ARCH_X87 | 1807 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |