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

Side by Side Diff: src/ia32/code-stubs-ia32.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/ia32/builtins-ia32.cc ('k') | src/ia32/frames-ia32.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_IA32 5 #if V8_TARGET_ARCH_IA32
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 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); 2105 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod());
2106 } 2106 }
2107 2107
2108 2108
2109 void CallConstructStub::Generate(MacroAssembler* masm) { 2109 void CallConstructStub::Generate(MacroAssembler* masm) {
2110 // eax : number of arguments 2110 // eax : number of arguments
2111 // ebx : feedback vector 2111 // ebx : feedback vector
2112 // ecx : original constructor (for IsSuperConstructorCall) 2112 // ecx : original constructor (for IsSuperConstructorCall)
2113 // edx : slot in feedback vector (Smi, for RecordCallTarget) 2113 // edx : slot in feedback vector (Smi, for RecordCallTarget)
2114 // edi : constructor function 2114 // edi : constructor function
2115 Label slow, non_function_call;
2116 2115
2117 if (IsSuperConstructorCall()) { 2116 if (IsSuperConstructorCall()) {
2118 __ push(ecx); 2117 __ push(ecx);
2119 } 2118 }
2120 2119
2120 Label non_function;
2121 // Check that function is not a smi. 2121 // Check that function is not a smi.
2122 __ JumpIfSmi(edi, &non_function_call); 2122 __ JumpIfSmi(edi, &non_function);
2123 // Check that function is a JSFunction. 2123 // Check that function is a JSFunction.
2124 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2124 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
2125 __ j(not_equal, &slow); 2125 __ j(not_equal, &non_function);
2126 2126
2127 if (RecordCallTarget()) { 2127 if (RecordCallTarget()) {
2128 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); 2128 GenerateRecordCallTarget(masm, IsSuperConstructorCall());
2129 2129
2130 Label feedback_register_initialized; 2130 Label feedback_register_initialized;
2131 // Put the AllocationSite from the feedback vector into ebx, or undefined. 2131 // Put the AllocationSite from the feedback vector into ebx, or undefined.
2132 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, 2132 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size,
2133 FixedArray::kHeaderSize)); 2133 FixedArray::kHeaderSize));
2134 Handle<Map> allocation_site_map = 2134 Handle<Map> allocation_site_map =
2135 isolate()->factory()->allocation_site_map(); 2135 isolate()->factory()->allocation_site_map();
2136 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map)); 2136 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map));
2137 __ j(equal, &feedback_register_initialized); 2137 __ j(equal, &feedback_register_initialized);
2138 __ mov(ebx, isolate()->factory()->undefined_value()); 2138 __ mov(ebx, isolate()->factory()->undefined_value());
2139 __ bind(&feedback_register_initialized); 2139 __ bind(&feedback_register_initialized);
2140 2140
2141 __ AssertUndefinedOrAllocationSite(ebx); 2141 __ AssertUndefinedOrAllocationSite(ebx);
2142 } 2142 }
2143 2143
2144 if (IsSuperConstructorCall()) { 2144 if (IsSuperConstructorCall()) {
2145 __ pop(edx); 2145 __ pop(edx);
2146 } else { 2146 } else {
2147 // Pass original constructor to construct stub. 2147 // Pass original constructor to construct stub.
2148 __ mov(edx, edi); 2148 __ mov(edx, edi);
2149 } 2149 }
2150 2150
2151 // Jump to the function-specific construct stub. 2151 // Tail call to the function-specific construct stub (still in the caller
2152 Register jmp_reg = ecx; 2152 // context at this point).
2153 __ mov(jmp_reg, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 2153 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2154 __ mov(jmp_reg, FieldOperand(jmp_reg, 2154 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset));
2155 SharedFunctionInfo::kConstructStubOffset)); 2155 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize));
2156 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); 2156 __ jmp(ecx);
2157 __ jmp(jmp_reg);
2158 2157
2159 // edi: called object 2158 __ bind(&non_function);
2160 // eax: number of arguments 2159 if (IsSuperConstructorCall()) __ Drop(1);
2161 // ecx: object map 2160 __ mov(edx, edi);
2162 // esp[0]: original receiver (for IsSuperConstructorCall) 2161 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
2163 __ bind(&slow);
2164 {
2165 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE);
2166 __ j(not_equal, &non_function_call, Label::kNear);
2167 if (IsSuperConstructorCall()) __ Drop(1);
2168 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
2169 __ mov(edi, FieldOperand(edi, JSFunctionProxy::kConstructTrapOffset));
2170 __ Jump(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
2171
2172 __ bind(&non_function_call);
2173 if (IsSuperConstructorCall()) __ Drop(1);
2174 {
2175 // Determine the delegate for the target (if any).
2176 FrameScope scope(masm, StackFrame::INTERNAL);
2177 __ SmiTag(eax);
2178 __ Push(eax);
2179 __ Push(edi);
2180 __ CallRuntime(Runtime::kGetConstructorDelegate, 1);
2181 __ mov(edi, eax);
2182 __ Pop(eax);
2183 __ SmiUntag(eax);
2184 }
2185 // The delegate is always a regular function.
2186 __ AssertFunction(edi);
2187 __ Jump(isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
2188 }
2189 } 2162 }
2190 2163
2191 2164
2192 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { 2165 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) {
2193 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 2166 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
2194 __ mov(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset)); 2167 __ mov(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset));
2195 __ mov(vector, FieldOperand(vector, 2168 __ mov(vector, FieldOperand(vector,
2196 SharedFunctionInfo::kFeedbackVectorOffset)); 2169 SharedFunctionInfo::kFeedbackVectorOffset));
2197 } 2170 }
2198 2171
(...skipping 3606 matching lines...) Expand 10 before | Expand all | Expand 10 after
5805 Operand(ebp, 7 * kPointerSize), NULL); 5778 Operand(ebp, 7 * kPointerSize), NULL);
5806 } 5779 }
5807 5780
5808 5781
5809 #undef __ 5782 #undef __
5810 5783
5811 } // namespace internal 5784 } // namespace internal
5812 } // namespace v8 5785 } // namespace v8
5813 5786
5814 #endif // V8_TARGET_ARCH_IA32 5787 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/ia32/frames-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698