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 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2221 | 2221 |
2222 // result = receiver[f](arg); | 2222 // result = receiver[f](arg); |
2223 __ bind(&l_call); | 2223 __ bind(&l_call); |
2224 __ movp(load_receiver, Operand(rsp, kPointerSize)); | 2224 __ movp(load_receiver, Operand(rsp, kPointerSize)); |
2225 __ Move(LoadDescriptor::SlotRegister(), | 2225 __ Move(LoadDescriptor::SlotRegister(), |
2226 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); | 2226 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); |
2227 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | 2227 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); |
2228 CallIC(ic, TypeFeedbackId::None()); | 2228 CallIC(ic, TypeFeedbackId::None()); |
2229 __ movp(rdi, rax); | 2229 __ movp(rdi, rax); |
2230 __ movp(Operand(rsp, 2 * kPointerSize), rdi); | 2230 __ movp(Operand(rsp, 2 * kPointerSize), rdi); |
| 2231 |
| 2232 SetCallPosition(expr, 1); |
2231 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2233 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2232 __ CallStub(&stub); | 2234 __ CallStub(&stub); |
2233 | 2235 |
2234 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2236 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
2235 __ Drop(1); // The function is still on the stack; drop it. | 2237 __ Drop(1); // The function is still on the stack; drop it. |
2236 | 2238 |
2237 // if (!result.done) goto l_try; | 2239 // if (!result.done) goto l_try; |
2238 __ bind(&l_loop); | 2240 __ bind(&l_loop); |
2239 __ Move(load_receiver, rax); | 2241 __ Move(load_receiver, rax); |
2240 __ Push(load_receiver); // save result | 2242 __ Push(load_receiver); // save result |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2989 | 2991 |
2990 | 2992 |
2991 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 2993 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { |
2992 // Load the arguments. | 2994 // Load the arguments. |
2993 ZoneList<Expression*>* args = expr->arguments(); | 2995 ZoneList<Expression*>* args = expr->arguments(); |
2994 int arg_count = args->length(); | 2996 int arg_count = args->length(); |
2995 for (int i = 0; i < arg_count; i++) { | 2997 for (int i = 0; i < arg_count; i++) { |
2996 VisitForStackValue(args->at(i)); | 2998 VisitForStackValue(args->at(i)); |
2997 } | 2999 } |
2998 | 3000 |
2999 SetExpressionPosition(expr); | 3001 SetCallPosition(expr, arg_count); |
3000 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); | 3002 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, call_type).code(); |
3001 __ Move(rdx, SmiFromSlot(expr->CallFeedbackICSlot())); | 3003 __ Move(rdx, SmiFromSlot(expr->CallFeedbackICSlot())); |
3002 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 3004 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
3003 // Don't assign a type feedback id to the IC, since type feedback is provided | 3005 // Don't assign a type feedback id to the IC, since type feedback is provided |
3004 // by the vector above. | 3006 // by the vector above. |
3005 CallIC(ic); | 3007 CallIC(ic); |
3006 | 3008 |
3007 RecordJSReturnSite(expr); | 3009 RecordJSReturnSite(expr); |
3008 | 3010 |
3009 // Restore context register. | 3011 // Restore context register. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3101 Comment cmnt(masm_, "[ Call"); | 3103 Comment cmnt(masm_, "[ Call"); |
3102 Expression* callee = expr->expression(); | 3104 Expression* callee = expr->expression(); |
3103 Call::CallType call_type = expr->GetCallType(isolate()); | 3105 Call::CallType call_type = expr->GetCallType(isolate()); |
3104 | 3106 |
3105 if (call_type == Call::POSSIBLY_EVAL_CALL) { | 3107 if (call_type == Call::POSSIBLY_EVAL_CALL) { |
3106 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 3108 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
3107 // to resolve the function we need to call. Then we call the resolved | 3109 // to resolve the function we need to call. Then we call the resolved |
3108 // function using the given arguments. | 3110 // function using the given arguments. |
3109 ZoneList<Expression*>* args = expr->arguments(); | 3111 ZoneList<Expression*>* args = expr->arguments(); |
3110 int arg_count = args->length(); | 3112 int arg_count = args->length(); |
3111 PushCalleeAndWithBaseObject(expr); | 3113 PushCalleeAndWithBaseObject(expr); |
3112 | 3114 |
3113 // Push the arguments. | 3115 // Push the arguments. |
3114 for (int i = 0; i < arg_count; i++) { | 3116 for (int i = 0; i < arg_count; i++) { |
3115 VisitForStackValue(args->at(i)); | 3117 VisitForStackValue(args->at(i)); |
3116 } | 3118 } |
3117 | 3119 |
3118 // Push a copy of the function (found below the arguments) and resolve | 3120 // Push a copy of the function (found below the arguments) and resolve |
3119 // eval. | 3121 // eval. |
3120 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); | 3122 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); |
3121 EmitResolvePossiblyDirectEval(arg_count); | 3123 EmitResolvePossiblyDirectEval(arg_count); |
3122 | 3124 |
3123 // Touch up the callee. | 3125 // Touch up the callee. |
3124 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); | 3126 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); |
3125 | 3127 |
3126 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 3128 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
3127 // Record source position for debugger. | 3129 |
3128 SetExpressionPosition(expr); | 3130 SetCallPosition(expr, arg_count); |
3129 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 3131 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
3130 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 3132 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
3131 __ CallStub(&stub); | 3133 __ CallStub(&stub); |
3132 RecordJSReturnSite(expr); | 3134 RecordJSReturnSite(expr); |
3133 // Restore context register. | 3135 // Restore context register. |
3134 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3136 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
3135 context()->DropAndPlug(1, rax); | 3137 context()->DropAndPlug(1, rax); |
3136 } else if (call_type == Call::GLOBAL_CALL) { | 3138 } else if (call_type == Call::GLOBAL_CALL) { |
3137 EmitCallWithLoadIC(expr); | 3139 EmitCallWithLoadIC(expr); |
3138 | 3140 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3189 | 3191 |
3190 // Push the arguments ("left-to-right") on the stack. | 3192 // Push the arguments ("left-to-right") on the stack. |
3191 ZoneList<Expression*>* args = expr->arguments(); | 3193 ZoneList<Expression*>* args = expr->arguments(); |
3192 int arg_count = args->length(); | 3194 int arg_count = args->length(); |
3193 for (int i = 0; i < arg_count; i++) { | 3195 for (int i = 0; i < arg_count; i++) { |
3194 VisitForStackValue(args->at(i)); | 3196 VisitForStackValue(args->at(i)); |
3195 } | 3197 } |
3196 | 3198 |
3197 // Call the construct call builtin that handles allocation and | 3199 // Call the construct call builtin that handles allocation and |
3198 // constructor invocation. | 3200 // constructor invocation. |
3199 SetExpressionPosition(expr); | 3201 SetConstructCallPosition(expr); |
3200 | 3202 |
3201 // Load function and argument count into rdi and rax. | 3203 // Load function and argument count into rdi and rax. |
3202 __ Set(rax, arg_count); | 3204 __ Set(rax, arg_count); |
3203 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 3205 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
3204 | 3206 |
3205 // Record call targets in unoptimized code, but not in the snapshot. | 3207 // Record call targets in unoptimized code, but not in the snapshot. |
3206 if (FLAG_pretenuring_call_new) { | 3208 if (FLAG_pretenuring_call_new) { |
3207 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3209 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
3208 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == | 3210 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
3209 expr->CallNewFeedbackSlot().ToInt() + 1); | 3211 expr->CallNewFeedbackSlot().ToInt() + 1); |
(...skipping 22 matching lines...) Expand all Loading... |
3232 | 3234 |
3233 // Push the arguments ("left-to-right") on the stack. | 3235 // Push the arguments ("left-to-right") on the stack. |
3234 ZoneList<Expression*>* args = expr->arguments(); | 3236 ZoneList<Expression*>* args = expr->arguments(); |
3235 int arg_count = args->length(); | 3237 int arg_count = args->length(); |
3236 for (int i = 0; i < arg_count; i++) { | 3238 for (int i = 0; i < arg_count; i++) { |
3237 VisitForStackValue(args->at(i)); | 3239 VisitForStackValue(args->at(i)); |
3238 } | 3240 } |
3239 | 3241 |
3240 // Call the construct call builtin that handles allocation and | 3242 // Call the construct call builtin that handles allocation and |
3241 // constructor invocation. | 3243 // constructor invocation. |
3242 SetExpressionPosition(expr); | 3244 SetConstructCallPosition(expr); |
3243 | 3245 |
3244 // Load function and argument count into edi and eax. | 3246 // Load function and argument count into edi and eax. |
3245 __ Set(rax, arg_count); | 3247 __ Set(rax, arg_count); |
3246 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 3248 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
3247 | 3249 |
3248 // Record call targets in unoptimized code. | 3250 // Record call targets in unoptimized code. |
3249 if (FLAG_pretenuring_call_new) { | 3251 if (FLAG_pretenuring_call_new) { |
3250 UNREACHABLE(); | 3252 UNREACHABLE(); |
3251 /* TODO(dslomov): support pretenuring. | 3253 /* TODO(dslomov): support pretenuring. |
3252 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3254 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4681 __ Move(LoadDescriptor::SlotRegister(), | 4683 __ Move(LoadDescriptor::SlotRegister(), |
4682 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); | 4684 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); |
4683 CallLoadIC(NOT_CONTEXTUAL); | 4685 CallLoadIC(NOT_CONTEXTUAL); |
4684 } | 4686 } |
4685 | 4687 |
4686 | 4688 |
4687 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4689 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4688 ZoneList<Expression*>* args = expr->arguments(); | 4690 ZoneList<Expression*>* args = expr->arguments(); |
4689 int arg_count = args->length(); | 4691 int arg_count = args->length(); |
4690 | 4692 |
4691 SetExpressionPosition(expr); | 4693 SetCallPosition(expr, arg_count); |
4692 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4694 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
4693 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 4695 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
4694 __ CallStub(&stub); | 4696 __ CallStub(&stub); |
4695 } | 4697 } |
4696 | 4698 |
4697 | 4699 |
4698 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4700 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
4699 ZoneList<Expression*>* args = expr->arguments(); | 4701 ZoneList<Expression*>* args = expr->arguments(); |
4700 int arg_count = args->length(); | 4702 int arg_count = args->length(); |
4701 | 4703 |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5483 Assembler::target_address_at(call_target_address, | 5485 Assembler::target_address_at(call_target_address, |
5484 unoptimized_code)); | 5486 unoptimized_code)); |
5485 return OSR_AFTER_STACK_CHECK; | 5487 return OSR_AFTER_STACK_CHECK; |
5486 } | 5488 } |
5487 | 5489 |
5488 | 5490 |
5489 } // namespace internal | 5491 } // namespace internal |
5490 } // namespace v8 | 5492 } // namespace v8 |
5491 | 5493 |
5492 #endif // V8_TARGET_ARCH_X64 | 5494 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |