| 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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 // Push the constructor function as callee. | 1129 // Push the constructor function as callee. |
| 1130 __ push(Operand(ebp, kFunctionOffset)); | 1130 __ push(Operand(ebp, kFunctionOffset)); |
| 1131 | 1131 |
| 1132 // Loop over the arguments array, pushing each value to the stack | 1132 // Loop over the arguments array, pushing each value to the stack |
| 1133 Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset, | 1133 Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset, |
| 1134 kIndexOffset, kLimitOffset); | 1134 kIndexOffset, kLimitOffset); |
| 1135 | 1135 |
| 1136 // Use undefined feedback vector | 1136 // Use undefined feedback vector |
| 1137 __ LoadRoot(ebx, Heap::kUndefinedValueRootIndex); | 1137 __ LoadRoot(ebx, Heap::kUndefinedValueRootIndex); |
| 1138 __ mov(edi, Operand(ebp, kFunctionOffset)); | 1138 __ mov(edi, Operand(ebp, kFunctionOffset)); |
| 1139 __ mov(ecx, Operand(ebp, kNewTargetOffset)); | 1139 __ mov(edx, Operand(ebp, kNewTargetOffset)); |
| 1140 | 1140 |
| 1141 // Call the function. | 1141 // Call the function. |
| 1142 CallConstructStub stub(masm->isolate(), SUPER_CONSTRUCTOR_CALL); | 1142 __ Call(masm->isolate()->builtins()->Construct(), |
| 1143 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 1143 RelocInfo::CONSTRUCT_CALL); |
| 1144 | 1144 |
| 1145 // Leave internal frame. | 1145 // Leave internal frame. |
| 1146 } | 1146 } |
| 1147 // remove this, target, arguments, and newTarget | 1147 // remove this, target, arguments, and newTarget |
| 1148 __ ret(kStackSize * kPointerSize); | 1148 __ ret(kStackSize * kPointerSize); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 | 1151 |
| 1152 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 1152 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
| 1153 Generate_ApplyHelper(masm, false); | 1153 Generate_ApplyHelper(masm, false); |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 | 1626 |
| 1627 // static | 1627 // static |
| 1628 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1628 void Builtins::Generate_Construct(MacroAssembler* masm) { |
| 1629 // ----------- S t a t e ------------- | 1629 // ----------- S t a t e ------------- |
| 1630 // -- eax : the number of arguments (not including the receiver) | 1630 // -- eax : the number of arguments (not including the receiver) |
| 1631 // -- edx : the new target (either the same as the constructor or | 1631 // -- edx : the new target (either the same as the constructor or |
| 1632 // the JSFunction on which new was invoked initially) | 1632 // the JSFunction on which new was invoked initially) |
| 1633 // -- edi : the constructor to call (can be any Object) | 1633 // -- edi : the constructor to call (can be any Object) |
| 1634 // ----------------------------------- | 1634 // ----------------------------------- |
| 1635 | 1635 |
| 1636 // Check if target has a [[Construct]] internal method. | 1636 // Check if target is a Smi. |
| 1637 Label non_constructor; | 1637 Label non_constructor; |
| 1638 __ JumpIfSmi(edi, &non_constructor, Label::kNear); | 1638 __ JumpIfSmi(edi, &non_constructor, Label::kNear); |
| 1639 __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset)); | |
| 1640 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor); | |
| 1641 __ j(zero, &non_constructor, Label::kNear); | |
| 1642 | 1639 |
| 1643 // Dispatch based on instance type. | 1640 // Dispatch based on instance type. |
| 1644 __ CmpInstanceType(ecx, JS_FUNCTION_TYPE); | 1641 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 1645 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), | 1642 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), |
| 1646 RelocInfo::CODE_TARGET); | 1643 RelocInfo::CODE_TARGET); |
| 1647 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | 1644 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); |
| 1648 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), | 1645 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), |
| 1649 RelocInfo::CODE_TARGET); | 1646 RelocInfo::CODE_TARGET); |
| 1650 | 1647 |
| 1648 // Check if target has a [[Construct]] internal method. |
| 1649 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor); |
| 1650 __ j(zero, &non_constructor, Label::kNear); |
| 1651 |
| 1651 // Called Construct on an exotic Object with a [[Construct]] internal method. | 1652 // Called Construct on an exotic Object with a [[Construct]] internal method. |
| 1652 { | 1653 { |
| 1653 // Overwrite the original receiver with the (original) target. | 1654 // Overwrite the original receiver with the (original) target. |
| 1654 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); | 1655 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); |
| 1655 // Let the "call_as_constructor_delegate" take care of the rest. | 1656 // Let the "call_as_constructor_delegate" take care of the rest. |
| 1656 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, edi); | 1657 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, edi); |
| 1657 __ Jump(masm->isolate()->builtins()->CallFunction(), | 1658 __ Jump(masm->isolate()->builtins()->CallFunction(), |
| 1658 RelocInfo::CODE_TARGET); | 1659 RelocInfo::CODE_TARGET); |
| 1659 } | 1660 } |
| 1660 | 1661 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1850 | 1851 |
| 1851 __ bind(&ok); | 1852 __ bind(&ok); |
| 1852 __ ret(0); | 1853 __ ret(0); |
| 1853 } | 1854 } |
| 1854 | 1855 |
| 1855 #undef __ | 1856 #undef __ |
| 1856 } // namespace internal | 1857 } // namespace internal |
| 1857 } // namespace v8 | 1858 } // namespace v8 |
| 1858 | 1859 |
| 1859 #endif // V8_TARGET_ARCH_IA32 | 1860 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |