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/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 | 2187 |
2188 // result = receiver[f](arg); | 2188 // result = receiver[f](arg); |
2189 __ bind(&l_call); | 2189 __ bind(&l_call); |
2190 __ mov(load_receiver, Operand(esp, kPointerSize)); | 2190 __ mov(load_receiver, Operand(esp, kPointerSize)); |
2191 __ mov(LoadDescriptor::SlotRegister(), | 2191 __ mov(LoadDescriptor::SlotRegister(), |
2192 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | 2192 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); |
2193 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | 2193 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); |
2194 CallIC(ic, TypeFeedbackId::None()); | 2194 CallIC(ic, TypeFeedbackId::None()); |
2195 __ mov(edi, eax); | 2195 __ mov(edi, eax); |
2196 __ mov(Operand(esp, 2 * kPointerSize), edi); | 2196 __ mov(Operand(esp, 2 * kPointerSize), edi); |
| 2197 SetCallPosition(expr, 1); |
2197 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2198 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2198 __ CallStub(&stub); | 2199 __ CallStub(&stub); |
2199 | 2200 |
2200 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2201 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2201 __ Drop(1); // The function is still on the stack; drop it. | 2202 __ Drop(1); // The function is still on the stack; drop it. |
2202 | 2203 |
2203 // if (!result.done) goto l_try; | 2204 // if (!result.done) goto l_try; |
2204 __ bind(&l_loop); | 2205 __ bind(&l_loop); |
2205 __ push(eax); // save result | 2206 __ push(eax); // save result |
2206 __ Move(load_receiver, eax); // result | 2207 __ Move(load_receiver, eax); // result |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 | 2989 |
2989 | 2990 |
2990 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 2991 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { |
2991 // Load the arguments. | 2992 // Load the arguments. |
2992 ZoneList<Expression*>* args = expr->arguments(); | 2993 ZoneList<Expression*>* args = expr->arguments(); |
2993 int arg_count = args->length(); | 2994 int arg_count = args->length(); |
2994 for (int i = 0; i < arg_count; i++) { | 2995 for (int i = 0; i < arg_count; i++) { |
2995 VisitForStackValue(args->at(i)); | 2996 VisitForStackValue(args->at(i)); |
2996 } | 2997 } |
2997 | 2998 |
2998 SetExpressionPosition(expr); | 2999 SetCallPosition(expr, arg_count); |
2999 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); | 3000 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); |
3000 __ Move(edx, Immediate(SmiFromSlot(expr->CallFeedbackICSlot()))); | 3001 __ Move(edx, Immediate(SmiFromSlot(expr->CallFeedbackICSlot()))); |
3001 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 3002 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
3002 // Don't assign a type feedback id to the IC, since type feedback is provided | 3003 // Don't assign a type feedback id to the IC, since type feedback is provided |
3003 // by the vector above. | 3004 // by the vector above. |
3004 CallIC(ic); | 3005 CallIC(ic); |
3005 | 3006 |
3006 RecordJSReturnSite(expr); | 3007 RecordJSReturnSite(expr); |
3007 | 3008 |
3008 // Restore context register. | 3009 // Restore context register. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3119 // Push a copy of the function (found below the arguments) and | 3120 // Push a copy of the function (found below the arguments) and |
3120 // resolve eval. | 3121 // resolve eval. |
3121 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); | 3122 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); |
3122 EmitResolvePossiblyDirectEval(arg_count); | 3123 EmitResolvePossiblyDirectEval(arg_count); |
3123 | 3124 |
3124 // Touch up the stack with the resolved function. | 3125 // Touch up the stack with the resolved function. |
3125 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); | 3126 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
3126 | 3127 |
3127 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 3128 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
3128 | 3129 |
3129 SetExpressionPosition(expr); | 3130 SetCallPosition(expr, arg_count); |
3130 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 3131 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
3131 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 3132 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
3132 __ CallStub(&stub); | 3133 __ CallStub(&stub); |
3133 RecordJSReturnSite(expr); | 3134 RecordJSReturnSite(expr); |
3134 // Restore context register. | 3135 // Restore context register. |
3135 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3136 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
3136 context()->DropAndPlug(1, eax); | 3137 context()->DropAndPlug(1, eax); |
3137 | 3138 |
3138 } else if (call_type == Call::GLOBAL_CALL) { | 3139 } else if (call_type == Call::GLOBAL_CALL) { |
3139 EmitCallWithLoadIC(expr); | 3140 EmitCallWithLoadIC(expr); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3190 | 3191 |
3191 // Push the arguments ("left-to-right") on the stack. | 3192 // Push the arguments ("left-to-right") on the stack. |
3192 ZoneList<Expression*>* args = expr->arguments(); | 3193 ZoneList<Expression*>* args = expr->arguments(); |
3193 int arg_count = args->length(); | 3194 int arg_count = args->length(); |
3194 for (int i = 0; i < arg_count; i++) { | 3195 for (int i = 0; i < arg_count; i++) { |
3195 VisitForStackValue(args->at(i)); | 3196 VisitForStackValue(args->at(i)); |
3196 } | 3197 } |
3197 | 3198 |
3198 // Call the construct call builtin that handles allocation and | 3199 // Call the construct call builtin that handles allocation and |
3199 // constructor invocation. | 3200 // constructor invocation. |
3200 SetExpressionPosition(expr); | 3201 SetConstructCallPosition(expr); |
3201 | 3202 |
3202 // Load function and argument count into edi and eax. | 3203 // Load function and argument count into edi and eax. |
3203 __ Move(eax, Immediate(arg_count)); | 3204 __ Move(eax, Immediate(arg_count)); |
3204 __ mov(edi, Operand(esp, arg_count * kPointerSize)); | 3205 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
3205 | 3206 |
3206 // Record call targets in unoptimized code. | 3207 // Record call targets in unoptimized code. |
3207 if (FLAG_pretenuring_call_new) { | 3208 if (FLAG_pretenuring_call_new) { |
3208 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3209 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
3209 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == | 3210 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
3210 expr->CallNewFeedbackSlot().ToInt() + 1); | 3211 expr->CallNewFeedbackSlot().ToInt() + 1); |
(...skipping 22 matching lines...) Expand all Loading... |
3233 | 3234 |
3234 // Push the arguments ("left-to-right") on the stack. | 3235 // Push the arguments ("left-to-right") on the stack. |
3235 ZoneList<Expression*>* args = expr->arguments(); | 3236 ZoneList<Expression*>* args = expr->arguments(); |
3236 int arg_count = args->length(); | 3237 int arg_count = args->length(); |
3237 for (int i = 0; i < arg_count; i++) { | 3238 for (int i = 0; i < arg_count; i++) { |
3238 VisitForStackValue(args->at(i)); | 3239 VisitForStackValue(args->at(i)); |
3239 } | 3240 } |
3240 | 3241 |
3241 // Call the construct call builtin that handles allocation and | 3242 // Call the construct call builtin that handles allocation and |
3242 // constructor invocation. | 3243 // constructor invocation. |
3243 SetExpressionPosition(expr); | 3244 SetConstructCallPosition(expr); |
3244 | 3245 |
3245 // Load function and argument count into edi and eax. | 3246 // Load function and argument count into edi and eax. |
3246 __ Move(eax, Immediate(arg_count)); | 3247 __ Move(eax, Immediate(arg_count)); |
3247 __ mov(edi, Operand(esp, arg_count * kPointerSize)); | 3248 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
3248 | 3249 |
3249 // Record call targets in unoptimized code. | 3250 // Record call targets in unoptimized code. |
3250 if (FLAG_pretenuring_call_new) { | 3251 if (FLAG_pretenuring_call_new) { |
3251 UNREACHABLE(); | 3252 UNREACHABLE(); |
3252 /* TODO(dslomov): support pretenuring. | 3253 /* TODO(dslomov): support pretenuring. |
3253 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3254 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4656 __ mov(LoadDescriptor::SlotRegister(), | 4657 __ mov(LoadDescriptor::SlotRegister(), |
4657 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | 4658 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); |
4658 CallLoadIC(NOT_CONTEXTUAL); | 4659 CallLoadIC(NOT_CONTEXTUAL); |
4659 } | 4660 } |
4660 | 4661 |
4661 | 4662 |
4662 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4663 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4663 ZoneList<Expression*>* args = expr->arguments(); | 4664 ZoneList<Expression*>* args = expr->arguments(); |
4664 int arg_count = args->length(); | 4665 int arg_count = args->length(); |
4665 | 4666 |
4666 SetExpressionPosition(expr); | 4667 SetCallPosition(expr, arg_count); |
4667 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4668 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
4668 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 4669 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
4669 __ CallStub(&stub); | 4670 __ CallStub(&stub); |
4670 } | 4671 } |
4671 | 4672 |
4672 | 4673 |
4673 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4674 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
4674 ZoneList<Expression*>* args = expr->arguments(); | 4675 ZoneList<Expression*>* args = expr->arguments(); |
4675 int arg_count = args->length(); | 4676 int arg_count = args->length(); |
4676 | 4677 |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5461 Assembler::target_address_at(call_target_address, | 5462 Assembler::target_address_at(call_target_address, |
5462 unoptimized_code)); | 5463 unoptimized_code)); |
5463 return OSR_AFTER_STACK_CHECK; | 5464 return OSR_AFTER_STACK_CHECK; |
5464 } | 5465 } |
5465 | 5466 |
5466 | 5467 |
5467 } // namespace internal | 5468 } // namespace internal |
5468 } // namespace v8 | 5469 } // namespace v8 |
5469 | 5470 |
5470 #endif // V8_TARGET_ARCH_IA32 | 5471 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |