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

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

Issue 1359583002: [builtins] Add support for NewTarget to Execution::New. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Merge mips and mips64 ports. 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/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); 1970 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod());
1971 } 1971 }
1972 1972
1973 1973
1974 void CallConstructStub::Generate(MacroAssembler* masm) { 1974 void CallConstructStub::Generate(MacroAssembler* masm) {
1975 // rax : number of arguments 1975 // rax : number of arguments
1976 // rbx : feedback vector 1976 // rbx : feedback vector
1977 // rcx : original constructor (for IsSuperConstructorCall) 1977 // rcx : original constructor (for IsSuperConstructorCall)
1978 // rdx : slot in feedback vector (Smi, for RecordCallTarget) 1978 // rdx : slot in feedback vector (Smi, for RecordCallTarget)
1979 // rdi : constructor function 1979 // rdi : constructor function
1980 Label slow, non_function_call;
1981 1980
1982 // Check that function is not a smi. 1981 Label non_function;
1983 __ JumpIfSmi(rdi, &non_function_call); 1982 // Check that the constructor is not a smi.
1984 // Check that function is a JSFunction. 1983 __ JumpIfSmi(rdi, &non_function);
1984 // Check that constructor is a JSFunction.
1985 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, r11); 1985 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, r11);
1986 __ j(not_equal, &slow); 1986 __ j(not_equal, &non_function);
1987 1987
1988 if (RecordCallTarget()) { 1988 if (RecordCallTarget()) {
1989 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); 1989 GenerateRecordCallTarget(masm, IsSuperConstructorCall());
1990 1990
1991 __ SmiToInteger32(rdx, rdx); 1991 __ SmiToInteger32(rdx, rdx);
1992 Label feedback_register_initialized; 1992 Label feedback_register_initialized;
1993 // Put the AllocationSite from the feedback vector into rbx, or undefined. 1993 // Put the AllocationSite from the feedback vector into rbx, or undefined.
1994 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size, 1994 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size,
1995 FixedArray::kHeaderSize)); 1995 FixedArray::kHeaderSize));
1996 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex); 1996 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex);
1997 __ j(equal, &feedback_register_initialized); 1997 __ j(equal, &feedback_register_initialized);
1998 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); 1998 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex);
1999 __ bind(&feedback_register_initialized); 1999 __ bind(&feedback_register_initialized);
2000 2000
2001 __ AssertUndefinedOrAllocationSite(rbx); 2001 __ AssertUndefinedOrAllocationSite(rbx);
2002 } 2002 }
2003 2003
2004 // Pass original constructor to construct stub. 2004 // Pass original constructor to construct stub.
2005 if (IsSuperConstructorCall()) { 2005 if (IsSuperConstructorCall()) {
2006 __ movp(rdx, rcx); 2006 __ movp(rdx, rcx);
2007 } else { 2007 } else {
2008 __ movp(rdx, rdi); 2008 __ movp(rdx, rdi);
2009 } 2009 }
2010 2010
2011 // Jump to the function-specific construct stub. 2011 // Tail call to the function-specific construct stub (still in the caller
2012 Register jmp_reg = rcx; 2012 // context at this point).
2013 __ movp(jmp_reg, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 2013 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
2014 __ movp(jmp_reg, FieldOperand(jmp_reg, 2014 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kConstructStubOffset));
2015 SharedFunctionInfo::kConstructStubOffset)); 2015 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize));
2016 __ leap(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); 2016 __ jmp(rcx);
2017 __ jmp(jmp_reg);
2018 2017
2019 // rdi: called object 2018 __ bind(&non_function);
2020 // rax: number of arguments 2019 __ movp(rdx, rdi);
2021 // r11: object map 2020 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
2022 __ bind(&slow);
2023 {
2024 __ CmpInstanceType(r11, JS_FUNCTION_PROXY_TYPE);
2025 __ j(not_equal, &non_function_call, Label::kNear);
2026
2027 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
2028 __ movp(rdi, FieldOperand(rdi, JSFunctionProxy::kConstructTrapOffset));
2029 __ Jump(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
2030
2031 __ bind(&non_function_call);
2032 {
2033 // Determine the delegate for the target (if any).
2034 FrameScope scope(masm, StackFrame::INTERNAL);
2035 __ Integer32ToSmi(rax, rax);
2036 __ Push(rax);
2037 __ Push(rdi);
2038 __ CallRuntime(Runtime::kGetConstructorDelegate, 1);
2039 __ movp(rdi, rax);
2040 __ Pop(rax);
2041 __ SmiToInteger32(rax, rax);
2042 }
2043 // The delegate is always a regular function.
2044 __ AssertFunction(rdi);
2045 __ Jump(isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
2046 }
2047 } 2021 }
2048 2022
2049 2023
2050 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { 2024 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) {
2051 __ movp(vector, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 2025 __ movp(vector, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
2052 __ movp(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset)); 2026 __ movp(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset));
2053 __ movp(vector, FieldOperand(vector, 2027 __ movp(vector, FieldOperand(vector,
2054 SharedFunctionInfo::kFeedbackVectorOffset)); 2028 SharedFunctionInfo::kFeedbackVectorOffset));
2055 } 2029 }
2056 2030
(...skipping 3510 matching lines...) Expand 10 before | Expand all | Expand 10 after
5567 kStackSpace, nullptr, return_value_operand, NULL); 5541 kStackSpace, nullptr, return_value_operand, NULL);
5568 } 5542 }
5569 5543
5570 5544
5571 #undef __ 5545 #undef __
5572 5546
5573 } // namespace internal 5547 } // namespace internal
5574 } // namespace v8 5548 } // namespace v8
5575 5549
5576 #endif // V8_TARGET_ARCH_X64 5550 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698