Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: src/x87/code-stubs-x87.cc

Issue 1362573002: X87: [builtins] Add support for NewTarget to Execution::New. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x87/builtins-x87.cc ('k') | src/x87/frames-x87.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); 1812 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod());
1813 } 1813 }
1814 1814
1815 1815
1816 void CallConstructStub::Generate(MacroAssembler* masm) { 1816 void CallConstructStub::Generate(MacroAssembler* masm) {
1817 // eax : number of arguments 1817 // eax : number of arguments
1818 // ebx : feedback vector 1818 // ebx : feedback vector
1819 // ecx : original constructor (for IsSuperConstructorCall) 1819 // ecx : original constructor (for IsSuperConstructorCall)
1820 // edx : slot in feedback vector (Smi, for RecordCallTarget) 1820 // edx : slot in feedback vector (Smi, for RecordCallTarget)
1821 // edi : constructor function 1821 // edi : constructor function
1822 Label slow, non_function_call;
1823 1822
1824 if (IsSuperConstructorCall()) { 1823 if (IsSuperConstructorCall()) {
1825 __ push(ecx); 1824 __ push(ecx);
1826 } 1825 }
1827 1826
1827 Label non_function;
1828 // Check that function is not a smi. 1828 // Check that function is not a smi.
1829 __ JumpIfSmi(edi, &non_function_call); 1829 __ JumpIfSmi(edi, &non_function);
1830 // Check that function is a JSFunction. 1830 // Check that function is a JSFunction.
1831 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 1831 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
1832 __ j(not_equal, &slow); 1832 __ j(not_equal, &non_function);
1833 1833
1834 if (RecordCallTarget()) { 1834 if (RecordCallTarget()) {
1835 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); 1835 GenerateRecordCallTarget(masm, IsSuperConstructorCall());
1836 1836
1837 Label feedback_register_initialized; 1837 Label feedback_register_initialized;
1838 // Put the AllocationSite from the feedback vector into ebx, or undefined. 1838 // Put the AllocationSite from the feedback vector into ebx, or undefined.
1839 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, 1839 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size,
1840 FixedArray::kHeaderSize)); 1840 FixedArray::kHeaderSize));
1841 Handle<Map> allocation_site_map = 1841 Handle<Map> allocation_site_map =
1842 isolate()->factory()->allocation_site_map(); 1842 isolate()->factory()->allocation_site_map();
1843 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map)); 1843 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map));
1844 __ j(equal, &feedback_register_initialized); 1844 __ j(equal, &feedback_register_initialized);
1845 __ mov(ebx, isolate()->factory()->undefined_value()); 1845 __ mov(ebx, isolate()->factory()->undefined_value());
1846 __ bind(&feedback_register_initialized); 1846 __ bind(&feedback_register_initialized);
1847 1847
1848 __ AssertUndefinedOrAllocationSite(ebx); 1848 __ AssertUndefinedOrAllocationSite(ebx);
1849 } 1849 }
1850 1850
1851 if (IsSuperConstructorCall()) { 1851 if (IsSuperConstructorCall()) {
1852 __ pop(edx); 1852 __ pop(edx);
1853 } else { 1853 } else {
1854 // Pass original constructor to construct stub. 1854 // Pass original constructor to construct stub.
1855 __ mov(edx, edi); 1855 __ mov(edx, edi);
1856 } 1856 }
1857 1857
1858 // Jump to the function-specific construct stub. 1858 // Tail call to the function-specific construct stub (still in the caller
1859 Register jmp_reg = ecx; 1859 // context at this point).
1860 __ mov(jmp_reg, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 1860 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
1861 __ mov(jmp_reg, FieldOperand(jmp_reg, 1861 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset));
1862 SharedFunctionInfo::kConstructStubOffset)); 1862 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize));
1863 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); 1863 __ jmp(ecx);
1864 __ jmp(jmp_reg);
1865 1864
1866 // edi: called object 1865 __ bind(&non_function);
1867 // eax: number of arguments 1866 if (IsSuperConstructorCall()) __ Drop(1);
1868 // ecx: object map 1867 __ mov(edx, edi);
1869 // esp[0]: original receiver (for IsSuperConstructorCall) 1868 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1870 __ bind(&slow);
1871 {
1872 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE);
1873 __ j(not_equal, &non_function_call, Label::kNear);
1874 if (IsSuperConstructorCall()) __ Drop(1);
1875 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
1876 __ mov(edi, FieldOperand(edi, JSFunctionProxy::kConstructTrapOffset));
1877 __ Jump(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
1878
1879 __ bind(&non_function_call);
1880 if (IsSuperConstructorCall()) __ Drop(1);
1881 {
1882 // Determine the delegate for the target (if any).
1883 FrameScope scope(masm, StackFrame::INTERNAL);
1884 __ SmiTag(eax);
1885 __ Push(eax);
1886 __ Push(edi);
1887 __ CallRuntime(Runtime::kGetConstructorDelegate, 1);
1888 __ mov(edi, eax);
1889 __ Pop(eax);
1890 __ SmiUntag(eax);
1891 }
1892 // The delegate is always a regular function.
1893 __ AssertFunction(edi);
1894 __ Jump(isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
1895 }
1896 } 1869 }
1897 1870
1898 1871
1899 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { 1872 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) {
1900 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1873 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1901 __ mov(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset)); 1874 __ mov(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset));
1902 __ mov(vector, FieldOperand(vector, 1875 __ mov(vector, FieldOperand(vector,
1903 SharedFunctionInfo::kFeedbackVectorOffset)); 1876 SharedFunctionInfo::kFeedbackVectorOffset));
1904 } 1877 }
1905 1878
(...skipping 3570 matching lines...) Expand 10 before | Expand all | Expand 10 after
5476 Operand(ebp, 7 * kPointerSize), NULL); 5449 Operand(ebp, 7 * kPointerSize), NULL);
5477 } 5450 }
5478 5451
5479 5452
5480 #undef __ 5453 #undef __
5481 5454
5482 } // namespace internal 5455 } // namespace internal
5483 } // namespace v8 5456 } // namespace v8
5484 5457
5485 #endif // V8_TARGET_ARCH_X87 5458 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x87/builtins-x87.cc ('k') | src/x87/frames-x87.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698