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