| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 // -- eax : the number of arguments (not including the receiver) | 1532 // -- eax : the number of arguments (not including the receiver) |
| 1533 // -- edi : the target to call (can be any Object). | 1533 // -- edi : the target to call (can be any Object). |
| 1534 // ----------------------------------- | 1534 // ----------------------------------- |
| 1535 | 1535 |
| 1536 Label non_callable, non_function, non_smi; | 1536 Label non_callable, non_function, non_smi; |
| 1537 __ JumpIfSmi(edi, &non_callable); | 1537 __ JumpIfSmi(edi, &non_callable); |
| 1538 __ bind(&non_smi); | 1538 __ bind(&non_smi); |
| 1539 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 1539 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 1540 __ j(equal, masm->isolate()->builtins()->CallFunction(mode), | 1540 __ j(equal, masm->isolate()->builtins()->CallFunction(mode), |
| 1541 RelocInfo::CODE_TARGET); | 1541 RelocInfo::CODE_TARGET); |
| 1542 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | 1542 __ CmpInstanceType(ecx, JS_PROXY_TYPE); |
| 1543 __ j(not_equal, &non_function); | 1543 __ j(not_equal, &non_function); |
| 1544 | 1544 |
| 1545 // 1. Call to function proxy. | 1545 // 1. Call to Proxy. |
| 1546 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. | 1546 // TODO(neis): Implement [[Call]] on proxies. |
| 1547 __ mov(edi, FieldOperand(edi, JSFunctionProxy::kCallTrapOffset)); | |
| 1548 __ AssertNotSmi(edi); | |
| 1549 __ jmp(&non_smi); | |
| 1550 | 1547 |
| 1551 // 2. Call to something else, which might have a [[Call]] internal method (if | 1548 // 2. Call to something else, which might have a [[Call]] internal method (if |
| 1552 // not we raise an exception). | 1549 // not we raise an exception). |
| 1553 __ bind(&non_function); | 1550 __ bind(&non_function); |
| 1554 // Check if target has a [[Call]] internal method. | 1551 // Check if target has a [[Call]] internal method. |
| 1555 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsCallable); | 1552 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsCallable); |
| 1556 __ j(zero, &non_callable, Label::kNear); | 1553 __ j(zero, &non_callable, Label::kNear); |
| 1557 // Overwrite the original receiver with the (original) target. | 1554 // Overwrite the original receiver with the (original) target. |
| 1558 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); | 1555 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); |
| 1559 // Let the "call_as_function_delegate" take care of the rest. | 1556 // Let the "call_as_function_delegate" take care of the rest. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 __ jmp(ecx); | 1590 __ jmp(ecx); |
| 1594 } | 1591 } |
| 1595 | 1592 |
| 1596 | 1593 |
| 1597 // static | 1594 // static |
| 1598 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { | 1595 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
| 1599 // ----------- S t a t e ------------- | 1596 // ----------- S t a t e ------------- |
| 1600 // -- eax : the number of arguments (not including the receiver) | 1597 // -- eax : the number of arguments (not including the receiver) |
| 1601 // -- edx : the new target (either the same as the constructor or | 1598 // -- edx : the new target (either the same as the constructor or |
| 1602 // the JSFunction on which new was invoked initially) | 1599 // the JSFunction on which new was invoked initially) |
| 1603 // -- edi : the constructor to call (checked to be a JSFunctionProxy) | 1600 // -- edi : the constructor to call (checked to be a JSProxy) |
| 1604 // ----------------------------------- | 1601 // ----------------------------------- |
| 1605 | 1602 |
| 1606 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1603 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| 1607 __ mov(edi, FieldOperand(edi, JSFunctionProxy::kConstructTrapOffset)); | |
| 1608 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1604 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1609 } | 1605 } |
| 1610 | 1606 |
| 1611 | 1607 |
| 1612 // static | 1608 // static |
| 1613 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1609 void Builtins::Generate_Construct(MacroAssembler* masm) { |
| 1614 // ----------- S t a t e ------------- | 1610 // ----------- S t a t e ------------- |
| 1615 // -- eax : the number of arguments (not including the receiver) | 1611 // -- eax : the number of arguments (not including the receiver) |
| 1616 // -- edx : the new target (either the same as the constructor or | 1612 // -- edx : the new target (either the same as the constructor or |
| 1617 // the JSFunction on which new was invoked initially) | 1613 // the JSFunction on which new was invoked initially) |
| 1618 // -- edi : the constructor to call (can be any Object) | 1614 // -- edi : the constructor to call (can be any Object) |
| 1619 // ----------------------------------- | 1615 // ----------------------------------- |
| 1620 | 1616 |
| 1621 // Check if target is a Smi. | 1617 // Check if target is a Smi. |
| 1622 Label non_constructor; | 1618 Label non_constructor; |
| 1623 __ JumpIfSmi(edi, &non_constructor, Label::kNear); | 1619 __ JumpIfSmi(edi, &non_constructor, Label::kNear); |
| 1624 | 1620 |
| 1625 // Dispatch based on instance type. | 1621 // Dispatch based on instance type. |
| 1626 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 1622 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 1627 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), | 1623 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), |
| 1628 RelocInfo::CODE_TARGET); | 1624 RelocInfo::CODE_TARGET); |
| 1629 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | 1625 __ CmpInstanceType(ecx, JS_PROXY_TYPE); |
| 1630 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), | 1626 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), |
| 1631 RelocInfo::CODE_TARGET); | 1627 RelocInfo::CODE_TARGET); |
| 1632 | 1628 |
| 1633 // Check if target has a [[Construct]] internal method. | 1629 // Check if target has a [[Construct]] internal method. |
| 1634 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor); | 1630 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor); |
| 1635 __ j(zero, &non_constructor, Label::kNear); | 1631 __ j(zero, &non_constructor, Label::kNear); |
| 1636 | 1632 |
| 1637 // Called Construct on an exotic Object with a [[Construct]] internal method. | 1633 // Called Construct on an exotic Object with a [[Construct]] internal method. |
| 1638 { | 1634 { |
| 1639 // Overwrite the original receiver with the (original) target. | 1635 // Overwrite the original receiver with the (original) target. |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1962 | 1958 |
| 1963 __ bind(&ok); | 1959 __ bind(&ok); |
| 1964 __ ret(0); | 1960 __ ret(0); |
| 1965 } | 1961 } |
| 1966 | 1962 |
| 1967 #undef __ | 1963 #undef __ |
| 1968 } // namespace internal | 1964 } // namespace internal |
| 1969 } // namespace v8 | 1965 } // namespace v8 |
| 1970 | 1966 |
| 1971 #endif // V8_TARGET_ARCH_IA32 | 1967 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |