| 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 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 | 2179 |
| 2180 // result = receiver[f](arg); | 2180 // result = receiver[f](arg); |
| 2181 __ bind(&l_call); | 2181 __ bind(&l_call); |
| 2182 __ mov(load_receiver, Operand(esp, kPointerSize)); | 2182 __ mov(load_receiver, Operand(esp, kPointerSize)); |
| 2183 __ mov(LoadDescriptor::SlotRegister(), | 2183 __ mov(LoadDescriptor::SlotRegister(), |
| 2184 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | 2184 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); |
| 2185 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | 2185 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); |
| 2186 CallIC(ic, TypeFeedbackId::None()); | 2186 CallIC(ic, TypeFeedbackId::None()); |
| 2187 __ mov(edi, eax); | 2187 __ mov(edi, eax); |
| 2188 __ mov(Operand(esp, 2 * kPointerSize), edi); | 2188 __ mov(Operand(esp, 2 * kPointerSize), edi); |
| 2189 SetCallPosition(expr, 1); |
| 2189 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2190 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
| 2190 __ CallStub(&stub); | 2191 __ CallStub(&stub); |
| 2191 | 2192 |
| 2192 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2193 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2193 __ Drop(1); // The function is still on the stack; drop it. | 2194 __ Drop(1); // The function is still on the stack; drop it. |
| 2194 | 2195 |
| 2195 // if (!result.done) goto l_try; | 2196 // if (!result.done) goto l_try; |
| 2196 __ bind(&l_loop); | 2197 __ bind(&l_loop); |
| 2197 __ push(eax); // save result | 2198 __ push(eax); // save result |
| 2198 __ Move(load_receiver, eax); // result | 2199 __ Move(load_receiver, eax); // result |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2980 | 2981 |
| 2981 | 2982 |
| 2982 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 2983 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { |
| 2983 // Load the arguments. | 2984 // Load the arguments. |
| 2984 ZoneList<Expression*>* args = expr->arguments(); | 2985 ZoneList<Expression*>* args = expr->arguments(); |
| 2985 int arg_count = args->length(); | 2986 int arg_count = args->length(); |
| 2986 for (int i = 0; i < arg_count; i++) { | 2987 for (int i = 0; i < arg_count; i++) { |
| 2987 VisitForStackValue(args->at(i)); | 2988 VisitForStackValue(args->at(i)); |
| 2988 } | 2989 } |
| 2989 | 2990 |
| 2990 SetExpressionPosition(expr); | 2991 SetCallPosition(expr, arg_count); |
| 2991 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); | 2992 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); |
| 2992 __ Move(edx, Immediate(SmiFromSlot(expr->CallFeedbackICSlot()))); | 2993 __ Move(edx, Immediate(SmiFromSlot(expr->CallFeedbackICSlot()))); |
| 2993 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2994 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
| 2994 // Don't assign a type feedback id to the IC, since type feedback is provided | 2995 // Don't assign a type feedback id to the IC, since type feedback is provided |
| 2995 // by the vector above. | 2996 // by the vector above. |
| 2996 CallIC(ic); | 2997 CallIC(ic); |
| 2997 | 2998 |
| 2998 RecordJSReturnSite(expr); | 2999 RecordJSReturnSite(expr); |
| 2999 | 3000 |
| 3000 // Restore context register. | 3001 // Restore context register. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3111 // Push a copy of the function (found below the arguments) and | 3112 // Push a copy of the function (found below the arguments) and |
| 3112 // resolve eval. | 3113 // resolve eval. |
| 3113 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); | 3114 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); |
| 3114 EmitResolvePossiblyDirectEval(arg_count); | 3115 EmitResolvePossiblyDirectEval(arg_count); |
| 3115 | 3116 |
| 3116 // Touch up the stack with the resolved function. | 3117 // Touch up the stack with the resolved function. |
| 3117 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); | 3118 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
| 3118 | 3119 |
| 3119 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 3120 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
| 3120 | 3121 |
| 3121 SetExpressionPosition(expr); | 3122 SetCallPosition(expr, arg_count); |
| 3122 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 3123 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 3123 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 3124 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
| 3124 __ CallStub(&stub); | 3125 __ CallStub(&stub); |
| 3125 RecordJSReturnSite(expr); | 3126 RecordJSReturnSite(expr); |
| 3126 // Restore context register. | 3127 // Restore context register. |
| 3127 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3128 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 3128 context()->DropAndPlug(1, eax); | 3129 context()->DropAndPlug(1, eax); |
| 3129 | 3130 |
| 3130 } else if (call_type == Call::GLOBAL_CALL) { | 3131 } else if (call_type == Call::GLOBAL_CALL) { |
| 3131 EmitCallWithLoadIC(expr); | 3132 EmitCallWithLoadIC(expr); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3182 | 3183 |
| 3183 // Push the arguments ("left-to-right") on the stack. | 3184 // Push the arguments ("left-to-right") on the stack. |
| 3184 ZoneList<Expression*>* args = expr->arguments(); | 3185 ZoneList<Expression*>* args = expr->arguments(); |
| 3185 int arg_count = args->length(); | 3186 int arg_count = args->length(); |
| 3186 for (int i = 0; i < arg_count; i++) { | 3187 for (int i = 0; i < arg_count; i++) { |
| 3187 VisitForStackValue(args->at(i)); | 3188 VisitForStackValue(args->at(i)); |
| 3188 } | 3189 } |
| 3189 | 3190 |
| 3190 // Call the construct call builtin that handles allocation and | 3191 // Call the construct call builtin that handles allocation and |
| 3191 // constructor invocation. | 3192 // constructor invocation. |
| 3192 SetExpressionPosition(expr); | 3193 SetConstructCallPosition(expr); |
| 3193 | 3194 |
| 3194 // Load function and argument count into edi and eax. | 3195 // Load function and argument count into edi and eax. |
| 3195 __ Move(eax, Immediate(arg_count)); | 3196 __ Move(eax, Immediate(arg_count)); |
| 3196 __ mov(edi, Operand(esp, arg_count * kPointerSize)); | 3197 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
| 3197 | 3198 |
| 3198 // Record call targets in unoptimized code. | 3199 // Record call targets in unoptimized code. |
| 3199 if (FLAG_pretenuring_call_new) { | 3200 if (FLAG_pretenuring_call_new) { |
| 3200 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3201 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| 3201 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == | 3202 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
| 3202 expr->CallNewFeedbackSlot().ToInt() + 1); | 3203 expr->CallNewFeedbackSlot().ToInt() + 1); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3225 | 3226 |
| 3226 // Push the arguments ("left-to-right") on the stack. | 3227 // Push the arguments ("left-to-right") on the stack. |
| 3227 ZoneList<Expression*>* args = expr->arguments(); | 3228 ZoneList<Expression*>* args = expr->arguments(); |
| 3228 int arg_count = args->length(); | 3229 int arg_count = args->length(); |
| 3229 for (int i = 0; i < arg_count; i++) { | 3230 for (int i = 0; i < arg_count; i++) { |
| 3230 VisitForStackValue(args->at(i)); | 3231 VisitForStackValue(args->at(i)); |
| 3231 } | 3232 } |
| 3232 | 3233 |
| 3233 // Call the construct call builtin that handles allocation and | 3234 // Call the construct call builtin that handles allocation and |
| 3234 // constructor invocation. | 3235 // constructor invocation. |
| 3235 SetExpressionPosition(expr); | 3236 SetConstructCallPosition(expr); |
| 3236 | 3237 |
| 3237 // Load function and argument count into edi and eax. | 3238 // Load function and argument count into edi and eax. |
| 3238 __ Move(eax, Immediate(arg_count)); | 3239 __ Move(eax, Immediate(arg_count)); |
| 3239 __ mov(edi, Operand(esp, arg_count * kPointerSize)); | 3240 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
| 3240 | 3241 |
| 3241 // Record call targets in unoptimized code. | 3242 // Record call targets in unoptimized code. |
| 3242 if (FLAG_pretenuring_call_new) { | 3243 if (FLAG_pretenuring_call_new) { |
| 3243 UNREACHABLE(); | 3244 UNREACHABLE(); |
| 3244 /* TODO(dslomov): support pretenuring. | 3245 /* TODO(dslomov): support pretenuring. |
| 3245 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3246 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4648 __ mov(LoadDescriptor::SlotRegister(), | 4649 __ mov(LoadDescriptor::SlotRegister(), |
| 4649 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | 4650 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); |
| 4650 CallLoadIC(NOT_CONTEXTUAL); | 4651 CallLoadIC(NOT_CONTEXTUAL); |
| 4651 } | 4652 } |
| 4652 | 4653 |
| 4653 | 4654 |
| 4654 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4655 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
| 4655 ZoneList<Expression*>* args = expr->arguments(); | 4656 ZoneList<Expression*>* args = expr->arguments(); |
| 4656 int arg_count = args->length(); | 4657 int arg_count = args->length(); |
| 4657 | 4658 |
| 4658 SetExpressionPosition(expr); | 4659 SetCallPosition(expr, arg_count); |
| 4659 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4660 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 4660 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 4661 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
| 4661 __ CallStub(&stub); | 4662 __ CallStub(&stub); |
| 4662 } | 4663 } |
| 4663 | 4664 |
| 4664 | 4665 |
| 4665 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4666 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 4666 ZoneList<Expression*>* args = expr->arguments(); | 4667 ZoneList<Expression*>* args = expr->arguments(); |
| 4667 int arg_count = args->length(); | 4668 int arg_count = args->length(); |
| 4668 | 4669 |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5492 Assembler::target_address_at(call_target_address, | 5493 Assembler::target_address_at(call_target_address, |
| 5493 unoptimized_code)); | 5494 unoptimized_code)); |
| 5494 return OSR_AFTER_STACK_CHECK; | 5495 return OSR_AFTER_STACK_CHECK; |
| 5495 } | 5496 } |
| 5496 | 5497 |
| 5497 | 5498 |
| 5498 } // namespace internal | 5499 } // namespace internal |
| 5499 } // namespace v8 | 5500 } // namespace v8 |
| 5500 | 5501 |
| 5501 #endif // V8_TARGET_ARCH_IA32 | 5502 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |