| 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 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 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2212 | 2212 |
| 2213 // result = receiver[f](arg); | 2213 // result = receiver[f](arg); |
| 2214 __ bind(&l_call); | 2214 __ bind(&l_call); |
| 2215 __ movp(load_receiver, Operand(rsp, kPointerSize)); | 2215 __ movp(load_receiver, Operand(rsp, kPointerSize)); |
| 2216 __ Move(LoadDescriptor::SlotRegister(), | 2216 __ Move(LoadDescriptor::SlotRegister(), |
| 2217 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); | 2217 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); |
| 2218 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | 2218 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); |
| 2219 CallIC(ic, TypeFeedbackId::None()); | 2219 CallIC(ic, TypeFeedbackId::None()); |
| 2220 __ movp(rdi, rax); | 2220 __ movp(rdi, rax); |
| 2221 __ movp(Operand(rsp, 2 * kPointerSize), rdi); | 2221 __ movp(Operand(rsp, 2 * kPointerSize), rdi); |
| 2222 |
| 2223 SetCallPosition(expr, 1); |
| 2222 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2224 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
| 2223 __ CallStub(&stub); | 2225 __ CallStub(&stub); |
| 2224 | 2226 |
| 2225 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2227 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2226 __ Drop(1); // The function is still on the stack; drop it. | 2228 __ Drop(1); // The function is still on the stack; drop it. |
| 2227 | 2229 |
| 2228 // if (!result.done) goto l_try; | 2230 // if (!result.done) goto l_try; |
| 2229 __ bind(&l_loop); | 2231 __ bind(&l_loop); |
| 2230 __ Move(load_receiver, rax); | 2232 __ Move(load_receiver, rax); |
| 2231 __ Push(load_receiver); // save result | 2233 __ Push(load_receiver); // save result |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2980 | 2982 |
| 2981 | 2983 |
| 2982 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 2984 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { |
| 2983 // Load the arguments. | 2985 // Load the arguments. |
| 2984 ZoneList<Expression*>* args = expr->arguments(); | 2986 ZoneList<Expression*>* args = expr->arguments(); |
| 2985 int arg_count = args->length(); | 2987 int arg_count = args->length(); |
| 2986 for (int i = 0; i < arg_count; i++) { | 2988 for (int i = 0; i < arg_count; i++) { |
| 2987 VisitForStackValue(args->at(i)); | 2989 VisitForStackValue(args->at(i)); |
| 2988 } | 2990 } |
| 2989 | 2991 |
| 2990 SetExpressionPosition(expr); | 2992 SetCallPosition(expr, arg_count); |
| 2991 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); | 2993 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); |
| 2992 __ Move(rdx, SmiFromSlot(expr->CallFeedbackICSlot())); | 2994 __ Move(rdx, SmiFromSlot(expr->CallFeedbackICSlot())); |
| 2993 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2995 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2994 // Don't assign a type feedback id to the IC, since type feedback is provided | 2996 // Don't assign a type feedback id to the IC, since type feedback is provided |
| 2995 // by the vector above. | 2997 // by the vector above. |
| 2996 CallIC(ic); | 2998 CallIC(ic); |
| 2997 | 2999 |
| 2998 RecordJSReturnSite(expr); | 3000 RecordJSReturnSite(expr); |
| 2999 | 3001 |
| 3000 // Restore context register. | 3002 // Restore context register. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3092 Comment cmnt(masm_, "[ Call"); | 3094 Comment cmnt(masm_, "[ Call"); |
| 3093 Expression* callee = expr->expression(); | 3095 Expression* callee = expr->expression(); |
| 3094 Call::CallType call_type = expr->GetCallType(isolate()); | 3096 Call::CallType call_type = expr->GetCallType(isolate()); |
| 3095 | 3097 |
| 3096 if (call_type == Call::POSSIBLY_EVAL_CALL) { | 3098 if (call_type == Call::POSSIBLY_EVAL_CALL) { |
| 3097 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 3099 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
| 3098 // to resolve the function we need to call. Then we call the resolved | 3100 // to resolve the function we need to call. Then we call the resolved |
| 3099 // function using the given arguments. | 3101 // function using the given arguments. |
| 3100 ZoneList<Expression*>* args = expr->arguments(); | 3102 ZoneList<Expression*>* args = expr->arguments(); |
| 3101 int arg_count = args->length(); | 3103 int arg_count = args->length(); |
| 3102 PushCalleeAndWithBaseObject(expr); | 3104 PushCalleeAndWithBaseObject(expr); |
| 3103 | 3105 |
| 3104 // Push the arguments. | 3106 // Push the arguments. |
| 3105 for (int i = 0; i < arg_count; i++) { | 3107 for (int i = 0; i < arg_count; i++) { |
| 3106 VisitForStackValue(args->at(i)); | 3108 VisitForStackValue(args->at(i)); |
| 3107 } | 3109 } |
| 3108 | 3110 |
| 3109 // Push a copy of the function (found below the arguments) and resolve | 3111 // Push a copy of the function (found below the arguments) and resolve |
| 3110 // eval. | 3112 // eval. |
| 3111 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); | 3113 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 3112 EmitResolvePossiblyDirectEval(arg_count); | 3114 EmitResolvePossiblyDirectEval(arg_count); |
| 3113 | 3115 |
| 3114 // Touch up the callee. | 3116 // Touch up the callee. |
| 3115 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); | 3117 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); |
| 3116 | 3118 |
| 3117 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 3119 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
| 3118 // Record source position for debugger. | 3120 |
| 3119 SetExpressionPosition(expr); | 3121 SetCallPosition(expr, arg_count); |
| 3120 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 3122 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 3121 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 3123 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 3122 __ CallStub(&stub); | 3124 __ CallStub(&stub); |
| 3123 RecordJSReturnSite(expr); | 3125 RecordJSReturnSite(expr); |
| 3124 // Restore context register. | 3126 // Restore context register. |
| 3125 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3127 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 3126 context()->DropAndPlug(1, rax); | 3128 context()->DropAndPlug(1, rax); |
| 3127 } else if (call_type == Call::GLOBAL_CALL) { | 3129 } else if (call_type == Call::GLOBAL_CALL) { |
| 3128 EmitCallWithLoadIC(expr); | 3130 EmitCallWithLoadIC(expr); |
| 3129 | 3131 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3180 | 3182 |
| 3181 // Push the arguments ("left-to-right") on the stack. | 3183 // Push the arguments ("left-to-right") on the stack. |
| 3182 ZoneList<Expression*>* args = expr->arguments(); | 3184 ZoneList<Expression*>* args = expr->arguments(); |
| 3183 int arg_count = args->length(); | 3185 int arg_count = args->length(); |
| 3184 for (int i = 0; i < arg_count; i++) { | 3186 for (int i = 0; i < arg_count; i++) { |
| 3185 VisitForStackValue(args->at(i)); | 3187 VisitForStackValue(args->at(i)); |
| 3186 } | 3188 } |
| 3187 | 3189 |
| 3188 // Call the construct call builtin that handles allocation and | 3190 // Call the construct call builtin that handles allocation and |
| 3189 // constructor invocation. | 3191 // constructor invocation. |
| 3190 SetExpressionPosition(expr); | 3192 SetConstructCallPosition(expr); |
| 3191 | 3193 |
| 3192 // Load function and argument count into rdi and rax. | 3194 // Load function and argument count into rdi and rax. |
| 3193 __ Set(rax, arg_count); | 3195 __ Set(rax, arg_count); |
| 3194 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 3196 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
| 3195 | 3197 |
| 3196 // Record call targets in unoptimized code, but not in the snapshot. | 3198 // Record call targets in unoptimized code, but not in the snapshot. |
| 3197 if (FLAG_pretenuring_call_new) { | 3199 if (FLAG_pretenuring_call_new) { |
| 3198 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3200 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| 3199 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == | 3201 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
| 3200 expr->CallNewFeedbackSlot().ToInt() + 1); | 3202 expr->CallNewFeedbackSlot().ToInt() + 1); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3223 | 3225 |
| 3224 // Push the arguments ("left-to-right") on the stack. | 3226 // Push the arguments ("left-to-right") on the stack. |
| 3225 ZoneList<Expression*>* args = expr->arguments(); | 3227 ZoneList<Expression*>* args = expr->arguments(); |
| 3226 int arg_count = args->length(); | 3228 int arg_count = args->length(); |
| 3227 for (int i = 0; i < arg_count; i++) { | 3229 for (int i = 0; i < arg_count; i++) { |
| 3228 VisitForStackValue(args->at(i)); | 3230 VisitForStackValue(args->at(i)); |
| 3229 } | 3231 } |
| 3230 | 3232 |
| 3231 // Call the construct call builtin that handles allocation and | 3233 // Call the construct call builtin that handles allocation and |
| 3232 // constructor invocation. | 3234 // constructor invocation. |
| 3233 SetExpressionPosition(expr); | 3235 SetConstructCallPosition(expr); |
| 3234 | 3236 |
| 3235 // Load function and argument count into edi and eax. | 3237 // Load function and argument count into edi and eax. |
| 3236 __ Set(rax, arg_count); | 3238 __ Set(rax, arg_count); |
| 3237 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 3239 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
| 3238 | 3240 |
| 3239 // Record call targets in unoptimized code. | 3241 // Record call targets in unoptimized code. |
| 3240 if (FLAG_pretenuring_call_new) { | 3242 if (FLAG_pretenuring_call_new) { |
| 3241 UNREACHABLE(); | 3243 UNREACHABLE(); |
| 3242 /* TODO(dslomov): support pretenuring. | 3244 /* TODO(dslomov): support pretenuring. |
| 3243 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3245 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| (...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4672 __ Move(LoadDescriptor::SlotRegister(), | 4674 __ Move(LoadDescriptor::SlotRegister(), |
| 4673 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); | 4675 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); |
| 4674 CallLoadIC(NOT_CONTEXTUAL); | 4676 CallLoadIC(NOT_CONTEXTUAL); |
| 4675 } | 4677 } |
| 4676 | 4678 |
| 4677 | 4679 |
| 4678 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4680 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
| 4679 ZoneList<Expression*>* args = expr->arguments(); | 4681 ZoneList<Expression*>* args = expr->arguments(); |
| 4680 int arg_count = args->length(); | 4682 int arg_count = args->length(); |
| 4681 | 4683 |
| 4682 SetExpressionPosition(expr); | 4684 SetCallPosition(expr, arg_count); |
| 4683 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4685 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 4684 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 4686 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 4685 __ CallStub(&stub); | 4687 __ CallStub(&stub); |
| 4686 } | 4688 } |
| 4687 | 4689 |
| 4688 | 4690 |
| 4689 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4691 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 4690 ZoneList<Expression*>* args = expr->arguments(); | 4692 ZoneList<Expression*>* args = expr->arguments(); |
| 4691 int arg_count = args->length(); | 4693 int arg_count = args->length(); |
| 4692 | 4694 |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5513 Assembler::target_address_at(call_target_address, | 5515 Assembler::target_address_at(call_target_address, |
| 5514 unoptimized_code)); | 5516 unoptimized_code)); |
| 5515 return OSR_AFTER_STACK_CHECK; | 5517 return OSR_AFTER_STACK_CHECK; |
| 5516 } | 5518 } |
| 5517 | 5519 |
| 5518 | 5520 |
| 5519 } // namespace internal | 5521 } // namespace internal |
| 5520 } // namespace v8 | 5522 } // namespace v8 |
| 5521 | 5523 |
| 5522 #endif // V8_TARGET_ARCH_X64 | 5524 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |