| 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 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/counters.h" | 9 #include "src/counters.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 } | 1832 } |
| 1833 | 1833 |
| 1834 // ----------- S t a t e ------------- | 1834 // ----------- S t a t e ------------- |
| 1835 // -- rbx : argumentsList | 1835 // -- rbx : argumentsList |
| 1836 // -- rdx : new.target | 1836 // -- rdx : new.target |
| 1837 // -- rdi : target | 1837 // -- rdi : target |
| 1838 // -- rsp[0] : return address | 1838 // -- rsp[0] : return address |
| 1839 // -- rsp[8] : receiver (undefined) | 1839 // -- rsp[8] : receiver (undefined) |
| 1840 // ----------------------------------- | 1840 // ----------------------------------- |
| 1841 | 1841 |
| 1842 // 2. Make sure the target is actually a constructor. | 1842 // 2. We don't need to check explicitly for constructor target here, |
| 1843 Label target_not_constructor; | 1843 // since that's the first thing the Construct/ConstructWithArrayLike |
| 1844 __ JumpIfSmi(rdi, &target_not_constructor, Label::kNear); | 1844 // builtins will do. |
| 1845 __ movp(rcx, FieldOperand(rdi, HeapObject::kMapOffset)); | |
| 1846 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | |
| 1847 Immediate(1 << Map::kIsConstructor)); | |
| 1848 __ j(zero, &target_not_constructor, Label::kNear); | |
| 1849 | 1845 |
| 1850 // 3. Make sure the target is actually a constructor. | 1846 // 3. We don't need to check explicitly for constructor new.target here, |
| 1851 Label new_target_not_constructor; | 1847 // since that's the second thing the Construct/ConstructWithArrayLike |
| 1852 __ JumpIfSmi(rdx, &new_target_not_constructor, Label::kNear); | 1848 // builtins will do. |
| 1853 __ movp(rcx, FieldOperand(rdx, HeapObject::kMapOffset)); | |
| 1854 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | |
| 1855 Immediate(1 << Map::kIsConstructor)); | |
| 1856 __ j(zero, &new_target_not_constructor, Label::kNear); | |
| 1857 | 1849 |
| 1858 // 4a. Construct the target with the given new.target and argumentsList. | 1850 // 4. Construct the target with the given new.target and argumentsList. |
| 1859 __ Jump(masm->isolate()->builtins()->ConstructWithArrayLike(), | 1851 __ Jump(masm->isolate()->builtins()->ConstructWithArrayLike(), |
| 1860 RelocInfo::CODE_TARGET); | 1852 RelocInfo::CODE_TARGET); |
| 1861 | |
| 1862 // 4b. The target is not a constructor, throw an appropriate TypeError. | |
| 1863 __ bind(&target_not_constructor); | |
| 1864 { | |
| 1865 StackArgumentsAccessor args(rsp, 0); | |
| 1866 __ movp(args.GetReceiverOperand(), rdi); | |
| 1867 __ TailCallRuntime(Runtime::kThrowNotConstructor); | |
| 1868 } | |
| 1869 | |
| 1870 // 4c. The new.target is not a constructor, throw an appropriate TypeError. | |
| 1871 __ bind(&new_target_not_constructor); | |
| 1872 { | |
| 1873 StackArgumentsAccessor args(rsp, 0); | |
| 1874 __ movp(args.GetReceiverOperand(), rdx); | |
| 1875 __ TailCallRuntime(Runtime::kThrowNotConstructor); | |
| 1876 } | |
| 1877 } | 1853 } |
| 1878 | 1854 |
| 1879 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { | 1855 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
| 1880 // ----------- S t a t e ------------- | 1856 // ----------- S t a t e ------------- |
| 1881 // -- rax : argc | 1857 // -- rax : argc |
| 1882 // -- rsp[0] : return address | 1858 // -- rsp[0] : return address |
| 1883 // -- rsp[8] : last argument | 1859 // -- rsp[8] : last argument |
| 1884 // ----------------------------------- | 1860 // ----------------------------------- |
| 1885 Label generic_array_code; | 1861 Label generic_array_code; |
| 1886 | 1862 |
| (...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3115 // Now jump to the instructions of the returned code object. | 3091 // Now jump to the instructions of the returned code object. |
| 3116 __ jmp(r11); | 3092 __ jmp(r11); |
| 3117 } | 3093 } |
| 3118 | 3094 |
| 3119 #undef __ | 3095 #undef __ |
| 3120 | 3096 |
| 3121 } // namespace internal | 3097 } // namespace internal |
| 3122 } // namespace v8 | 3098 } // namespace v8 |
| 3123 | 3099 |
| 3124 #endif // V8_TARGET_ARCH_X64 | 3100 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |