Chromium Code Reviews| 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_ARM | 5 #if V8_TARGET_ARCH_ARM |
| 6 | 6 |
| 7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1578 } | 1578 } |
| 1579 | 1579 |
| 1580 | 1580 |
| 1581 // static | 1581 // static |
| 1582 void Builtins::Generate_Call(MacroAssembler* masm) { | 1582 void Builtins::Generate_Call(MacroAssembler* masm) { |
| 1583 // ----------- S t a t e ------------- | 1583 // ----------- S t a t e ------------- |
| 1584 // -- r0 : the number of arguments (not including the receiver) | 1584 // -- r0 : the number of arguments (not including the receiver) |
| 1585 // -- r1 : the target to call (can be any Object). | 1585 // -- r1 : the target to call (can be any Object). |
| 1586 // ----------------------------------- | 1586 // ----------------------------------- |
| 1587 | 1587 |
| 1588 Label non_smi, non_function; | 1588 Label non_callable, non_function, non_smi; |
| 1589 __ JumpIfSmi(r1, &non_function); | 1589 __ JumpIfSmi(r1, &non_callable); |
| 1590 __ bind(&non_smi); | 1590 __ bind(&non_smi); |
| 1591 __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); | 1591 __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE); |
| 1592 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET, | 1592 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET, |
| 1593 eq); | 1593 eq); |
| 1594 __ cmp(r2, Operand(JS_FUNCTION_PROXY_TYPE)); | 1594 __ cmp(r5, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 1595 __ b(ne, &non_function); | 1595 __ b(ne, &non_function); |
| 1596 | 1596 |
| 1597 // 1. Call to function proxy. | 1597 // 1. Call to function proxy. |
| 1598 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. | 1598 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. |
| 1599 __ ldr(r1, FieldMemOperand(r1, JSFunctionProxy::kCallTrapOffset)); | 1599 __ ldr(r1, FieldMemOperand(r1, JSFunctionProxy::kCallTrapOffset)); |
| 1600 __ AssertNotSmi(r1); | 1600 __ AssertNotSmi(r1); |
| 1601 __ b(&non_smi); | 1601 __ b(&non_smi); |
| 1602 | 1602 |
| 1603 // 2. Call to something else, which might have a [[Call]] internal method (if | 1603 // 2. Call to something else, which might have a [[Call]] internal method (if |
| 1604 // not we raise an exception). | 1604 // not we raise an exception). |
| 1605 __ bind(&non_function); | 1605 __ bind(&non_function); |
| 1606 // TODO(bmeurer): I wonder why we prefer to have slow API calls? This could | 1606 // Check if target has a [[Call]] internal method. |
| 1607 // be awesome instead; i.e. a trivial improvement would be to call into the | 1607 __ ldrb(r4, FieldMemOperand(r4, Map::kBitFieldOffset)); |
| 1608 // runtime and just deal with the API function there instead of returning a | 1608 __ tst(r4, Operand(1 << Map::kIsCallable)); |
| 1609 // delegate from a runtime call that just jumps back to the runtime once | 1609 __ b(eq, &non_callable); |
| 1610 // called. Or, bonus points, call directly into the C API function here, as | 1610 // Overwrite the original receiver the (original) target. |
| 1611 // we do in some Crankshaft fast cases. | |
| 1612 // Overwrite the original receiver with the (original) target. | |
| 1613 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); | 1611 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); |
| 1612 // Let the "call_as_function_delegate" take care of the rest. | |
| 1613 __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, r1); | |
| 1614 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
| 1615 | |
| 1616 // 3. Call to something that is not callable. | |
| 1617 __ bind(&non_callable); | |
| 1614 { | 1618 { |
| 1615 // Determine the delegate for the target (if any). | |
| 1616 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1619 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 1617 __ SmiTag(r0); | 1620 __ Push(r1); |
| 1618 __ Push(r0, r1); | 1621 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
| 1619 __ CallRuntime(Runtime::kGetFunctionDelegate, 1); | |
| 1620 __ mov(r1, r0); | |
| 1621 __ Pop(r0); | |
| 1622 __ SmiUntag(r0); | |
| 1623 } | 1622 } |
| 1624 // The delegate is always a regular function. | |
| 1625 __ AssertFunction(r1); | |
| 1626 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
| 1627 } | 1623 } |
| 1628 | 1624 |
| 1629 | 1625 |
| 1630 // static | 1626 // static |
| 1631 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { | 1627 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { |
| 1632 // ----------- S t a t e ------------- | 1628 // ----------- S t a t e ------------- |
| 1633 // -- r0 : the number of arguments (not including the receiver) | 1629 // -- r0 : the number of arguments (not including the receiver) |
| 1634 // -- r1 : the constructor to call (checked to be a JSFunction) | 1630 // -- r1 : the constructor to call (checked to be a JSFunction) |
| 1635 // -- r3 : the original constructor (checked to be a JSFunction) | 1631 // -- r3 : the original constructor (checked to be a JSFunction) |
| 1636 // ----------------------------------- | 1632 // ----------------------------------- |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1651 | 1647 |
| 1652 // static | 1648 // static |
| 1653 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1649 void Builtins::Generate_Construct(MacroAssembler* masm) { |
| 1654 // ----------- S t a t e ------------- | 1650 // ----------- S t a t e ------------- |
| 1655 // -- r0 : the number of arguments (not including the receiver) | 1651 // -- r0 : the number of arguments (not including the receiver) |
| 1656 // -- r1 : the constructor to call (can be any Object) | 1652 // -- r1 : the constructor to call (can be any Object) |
| 1657 // -- r3 : the original constructor (either the same as the constructor or | 1653 // -- r3 : the original constructor (either the same as the constructor or |
| 1658 // the JSFunction on which new was invoked initially) | 1654 // the JSFunction on which new was invoked initially) |
| 1659 // ----------------------------------- | 1655 // ----------------------------------- |
| 1660 | 1656 |
| 1661 Label slow; | 1657 Label non_callable, non_function; |
| 1662 __ JumpIfSmi(r1, &slow); | 1658 __ JumpIfSmi(r1, &non_callable); |
| 1663 __ CompareObjectType(r1, r5, r5, JS_FUNCTION_TYPE); | 1659 __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE); |
| 1664 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 1660 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
| 1665 RelocInfo::CODE_TARGET, eq); | 1661 RelocInfo::CODE_TARGET, eq); |
| 1666 __ cmp(r5, Operand(JS_FUNCTION_PROXY_TYPE)); | 1662 __ cmp(r5, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 1667 __ b(ne, &slow); | 1663 __ b(ne, &non_function); |
| 1668 | 1664 |
| 1665 // 1. Construct of function proxy. | |
| 1669 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1666 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| 1670 __ ldr(r1, FieldMemOperand(r1, JSFunctionProxy::kConstructTrapOffset)); | 1667 __ ldr(r1, FieldMemOperand(r1, JSFunctionProxy::kConstructTrapOffset)); |
| 1671 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1668 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1672 | 1669 |
| 1673 __ bind(&slow); | 1670 // 2. Construct of something that else, which might have a [[Construct]] |
|
Jarin
2015/09/23 05:40:36
This comment does not make a lot of sense to me.
Benedikt Meurer
2015/09/23 05:41:54
I will fix that in the CL that introduces IsConstr
| |
| 1671 // internal method (if not we raise an exception). | |
| 1672 __ bind(&non_function); | |
| 1673 // Check if target has a [[Call]] internal method. | |
| 1674 // TODO(bmeurer): This shoud use IsConstructor once available. | |
| 1675 __ ldrb(r4, FieldMemOperand(r4, Map::kBitFieldOffset)); | |
| 1676 __ tst(r4, Operand(1 << Map::kIsCallable)); | |
| 1677 __ b(eq, &non_callable); | |
| 1678 // Overwrite the original receiver the (original) target. | |
| 1679 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); | |
| 1680 // Let the "call_as_constructor_delegate" take care of the rest. | |
| 1681 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1); | |
| 1682 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
| 1683 | |
| 1684 // 3. Construct of something that is not callable. | |
| 1685 __ bind(&non_callable); | |
| 1674 { | 1686 { |
| 1675 // Determine the delegate for the target (if any). | |
| 1676 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1687 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 1677 __ SmiTag(r0); | 1688 __ Push(r1); |
| 1678 __ Push(r0, r1); | 1689 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
| 1679 __ CallRuntime(Runtime::kGetConstructorDelegate, 1); | |
| 1680 __ mov(r1, r0); | |
| 1681 __ Pop(r0); | |
| 1682 __ SmiUntag(r0); | |
| 1683 } | 1690 } |
| 1684 // The delegate is always a regular function. | |
| 1685 __ AssertFunction(r1); | |
| 1686 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
| 1687 } | 1691 } |
| 1688 | 1692 |
| 1689 | 1693 |
| 1690 // static | 1694 // static |
| 1691 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { | 1695 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { |
| 1692 // ----------- S t a t e ------------- | 1696 // ----------- S t a t e ------------- |
| 1693 // -- r0 : the number of arguments (not including the receiver) | 1697 // -- r0 : the number of arguments (not including the receiver) |
| 1694 // -- r2 : the address of the first argument to be pushed. Subsequent | 1698 // -- r2 : the address of the first argument to be pushed. Subsequent |
| 1695 // arguments should be consecutive above this, in the same order as | 1699 // arguments should be consecutive above this, in the same order as |
| 1696 // they are to be pushed onto the stack. | 1700 // they are to be pushed onto the stack. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1859 } | 1863 } |
| 1860 } | 1864 } |
| 1861 | 1865 |
| 1862 | 1866 |
| 1863 #undef __ | 1867 #undef __ |
| 1864 | 1868 |
| 1865 } // namespace internal | 1869 } // namespace internal |
| 1866 } // namespace v8 | 1870 } // namespace v8 |
| 1867 | 1871 |
| 1868 #endif // V8_TARGET_ARCH_ARM | 1872 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |