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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 | 2137 |
2138 | 2138 |
2139 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2139 void CallFunctionStub::Generate(MacroAssembler* masm) { |
2140 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); | 2140 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); |
2141 } | 2141 } |
2142 | 2142 |
2143 | 2143 |
2144 void CallConstructStub::Generate(MacroAssembler* masm) { | 2144 void CallConstructStub::Generate(MacroAssembler* masm) { |
2145 // eax : number of arguments | 2145 // eax : number of arguments |
2146 // ebx : feedback vector | 2146 // ebx : feedback vector |
2147 // edx : (only if ebx is not the megamorphic symbol) slot in feedback | 2147 // ecx : original constructor (for IsSuperConstructorCall) |
2148 // vector (Smi) | 2148 // edx : slot in feedback vector (Smi, for RecordCallTarget) |
2149 // edi : constructor function | 2149 // edi : constructor function |
2150 Label slow, non_function_call; | 2150 Label slow, non_function_call; |
2151 | 2151 |
| 2152 if (IsSuperConstructorCall()) { |
| 2153 __ push(ecx); |
| 2154 } |
| 2155 |
2152 // Check that function is not a smi. | 2156 // Check that function is not a smi. |
2153 __ JumpIfSmi(edi, &non_function_call); | 2157 __ JumpIfSmi(edi, &non_function_call); |
2154 // Check that function is a JSFunction. | 2158 // Check that function is a JSFunction. |
2155 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 2159 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
2156 __ j(not_equal, &slow); | 2160 __ j(not_equal, &slow); |
2157 | 2161 |
2158 if (RecordCallTarget()) { | 2162 if (RecordCallTarget()) { |
2159 GenerateRecordCallTarget(masm); | 2163 GenerateRecordCallTarget(masm); |
2160 | 2164 |
2161 if (FLAG_pretenuring_call_new) { | 2165 if (FLAG_pretenuring_call_new) { |
(...skipping 12 matching lines...) Expand all Loading... |
2174 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map)); | 2178 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map)); |
2175 __ j(equal, &feedback_register_initialized); | 2179 __ j(equal, &feedback_register_initialized); |
2176 __ mov(ebx, isolate()->factory()->undefined_value()); | 2180 __ mov(ebx, isolate()->factory()->undefined_value()); |
2177 __ bind(&feedback_register_initialized); | 2181 __ bind(&feedback_register_initialized); |
2178 } | 2182 } |
2179 | 2183 |
2180 __ AssertUndefinedOrAllocationSite(ebx); | 2184 __ AssertUndefinedOrAllocationSite(ebx); |
2181 } | 2185 } |
2182 | 2186 |
2183 if (IsSuperConstructorCall()) { | 2187 if (IsSuperConstructorCall()) { |
2184 __ mov(edx, Operand(esp, eax, times_pointer_size, 2 * kPointerSize)); | 2188 __ pop(edx); |
2185 } else { | 2189 } else { |
2186 // Pass original constructor to construct stub. | 2190 // Pass original constructor to construct stub. |
2187 __ mov(edx, edi); | 2191 __ mov(edx, edi); |
2188 } | 2192 } |
2189 | 2193 |
2190 // Jump to the function-specific construct stub. | 2194 // Jump to the function-specific construct stub. |
2191 Register jmp_reg = ecx; | 2195 Register jmp_reg = ecx; |
2192 __ mov(jmp_reg, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 2196 __ mov(jmp_reg, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
2193 __ mov(jmp_reg, FieldOperand(jmp_reg, | 2197 __ mov(jmp_reg, FieldOperand(jmp_reg, |
2194 SharedFunctionInfo::kConstructStubOffset)); | 2198 SharedFunctionInfo::kConstructStubOffset)); |
2195 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); | 2199 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); |
2196 __ jmp(jmp_reg); | 2200 __ jmp(jmp_reg); |
2197 | 2201 |
2198 // edi: called object | 2202 // edi: called object |
2199 // eax: number of arguments | 2203 // eax: number of arguments |
2200 // ecx: object map | 2204 // ecx: object map |
| 2205 // esp[0]: original receiver |
2201 Label do_call; | 2206 Label do_call; |
2202 __ bind(&slow); | 2207 __ bind(&slow); |
2203 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | 2208 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); |
2204 __ j(not_equal, &non_function_call); | 2209 __ j(not_equal, &non_function_call); |
2205 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | 2210 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
2206 __ jmp(&do_call); | 2211 __ jmp(&do_call); |
2207 | 2212 |
2208 __ bind(&non_function_call); | 2213 __ bind(&non_function_call); |
2209 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 2214 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
2210 __ bind(&do_call); | 2215 __ bind(&do_call); |
| 2216 if (IsSuperConstructorCall()) { |
| 2217 __ Drop(1); |
| 2218 } |
2211 // Set expected number of arguments to zero (not changing eax). | 2219 // Set expected number of arguments to zero (not changing eax). |
2212 __ Move(ebx, Immediate(0)); | 2220 __ Move(ebx, Immediate(0)); |
2213 Handle<Code> arguments_adaptor = | 2221 Handle<Code> arguments_adaptor = |
2214 isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 2222 isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
2215 __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET); | 2223 __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET); |
2216 } | 2224 } |
2217 | 2225 |
2218 | 2226 |
2219 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { | 2227 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { |
2220 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 2228 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
(...skipping 3254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5475 Operand(ebp, 7 * kPointerSize), NULL); | 5483 Operand(ebp, 7 * kPointerSize), NULL); |
5476 } | 5484 } |
5477 | 5485 |
5478 | 5486 |
5479 #undef __ | 5487 #undef __ |
5480 | 5488 |
5481 } // namespace internal | 5489 } // namespace internal |
5482 } // namespace v8 | 5490 } // namespace v8 |
5483 | 5491 |
5484 #endif // V8_TARGET_ARCH_IA32 | 5492 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |