Chromium Code Reviews| 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 3014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3025 Label uninitialized_this; | 3025 Label uninitialized_this; |
| 3026 __ j(equal, &uninitialized_this); | 3026 __ j(equal, &uninitialized_this); |
| 3027 __ Push(this_var->name()); | 3027 __ Push(this_var->name()); |
| 3028 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 3028 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 3029 __ bind(&uninitialized_this); | 3029 __ bind(&uninitialized_this); |
| 3030 | 3030 |
| 3031 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); | 3031 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); |
| 3032 } | 3032 } |
| 3033 | 3033 |
| 3034 | 3034 |
| 3035 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. | |
| 3036 void FullCodeGenerator::PushCalleeAndWithBaseObject(VariableProxy* callee) { | |
| 3037 if (callee->var()->IsLookupSlot()) { | |
| 3038 Label slow, done; | |
| 3039 | |
| 3040 { | |
| 3041 PreservePositionScope scope(masm()->positions_recorder()); | |
| 3042 // Generate code for loading from variables potentially shadowed by | |
| 3043 // eval-introduced variables. | |
| 3044 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); | |
| 3045 } | |
| 3046 __ bind(&slow); | |
| 3047 // Call the runtime to find the function to call (returned in rax) and | |
| 3048 // the object holding it (returned in rdx). | |
| 3049 __ Push(context_register()); | |
| 3050 __ Push(callee->name()); | |
| 3051 __ CallRuntime(Runtime::kLoadLookupSlot, 2); | |
| 3052 __ Push(rax); // Function. | |
| 3053 __ Push(rdx); // Receiver. | |
| 3054 | |
| 3055 // If fast case code has been generated, emit code to push the function | |
| 3056 // and receiver and have the slow path jump around this code. | |
| 3057 if (done.is_linked()) { | |
| 3058 Label call; | |
| 3059 __ jmp(&call, Label::kNear); | |
| 3060 __ bind(&done); | |
| 3061 // Push function. | |
| 3062 __ Push(rax); | |
| 3063 // The receiver is implicitly the global receiver. Indicate this by | |
| 3064 // passing the hole to the call function stub. | |
|
Toon Verwaest
2015/06/24 13:30:43
Seems like you are passing in undefined instead ..
arv (Not doing code reviews)
2015/06/24 13:36:50
Old code had the same comment bug :-)
| |
| 3065 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
| 3066 __ bind(&call); | |
| 3067 } | |
| 3068 } else { | |
| 3069 VisitForStackValue(callee); | |
| 3070 // refEnv.WithBaseObject() | |
| 3071 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
| 3072 } | |
| 3073 } | |
| 3074 | |
| 3075 | |
| 3035 void FullCodeGenerator::VisitCall(Call* expr) { | 3076 void FullCodeGenerator::VisitCall(Call* expr) { |
| 3036 #ifdef DEBUG | 3077 #ifdef DEBUG |
| 3037 // We want to verify that RecordJSReturnSite gets called on all paths | 3078 // We want to verify that RecordJSReturnSite gets called on all paths |
| 3038 // through this function. Avoid early returns. | 3079 // through this function. Avoid early returns. |
| 3039 expr->return_is_recorded_ = false; | 3080 expr->return_is_recorded_ = false; |
| 3040 #endif | 3081 #endif |
| 3041 | 3082 |
| 3042 Comment cmnt(masm_, "[ Call"); | 3083 Comment cmnt(masm_, "[ Call"); |
| 3043 Expression* callee = expr->expression(); | 3084 Expression* callee = expr->expression(); |
| 3044 Call::CallType call_type = expr->GetCallType(isolate()); | 3085 Call::CallType call_type = expr->GetCallType(isolate()); |
| 3045 | 3086 |
| 3046 if (call_type == Call::POSSIBLY_EVAL_CALL) { | 3087 if (call_type == Call::POSSIBLY_EVAL_CALL) { |
| 3047 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 3088 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
| 3048 // to resolve the function we need to call. Then we call the resolved | 3089 // to resolve the function we need to call. Then we call the resolved |
| 3049 // function using the given arguments. | 3090 // function using the given arguments. |
| 3050 ZoneList<Expression*>* args = expr->arguments(); | 3091 ZoneList<Expression*>* args = expr->arguments(); |
| 3051 int arg_count = args->length(); | 3092 int arg_count = args->length(); |
| 3052 { PreservePositionScope pos_scope(masm()->positions_recorder()); | 3093 { PreservePositionScope pos_scope(masm()->positions_recorder()); |
| 3053 VisitForStackValue(callee); | 3094 PushCalleeAndWithBaseObject(callee->AsVariableProxy()); |
| 3054 __ PushRoot(Heap::kUndefinedValueRootIndex); // Reserved receiver slot. | |
| 3055 | 3095 |
| 3056 // Push the arguments. | 3096 // Push the arguments. |
| 3057 for (int i = 0; i < arg_count; i++) { | 3097 for (int i = 0; i < arg_count; i++) { |
| 3058 VisitForStackValue(args->at(i)); | 3098 VisitForStackValue(args->at(i)); |
| 3059 } | 3099 } |
| 3060 | 3100 |
| 3061 // Push a copy of the function (found below the arguments) and resolve | 3101 // Push a copy of the function (found below the arguments) and resolve |
| 3062 // eval. | 3102 // eval. |
| 3063 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); | 3103 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 3064 EmitResolvePossiblyDirectEval(arg_count); | 3104 EmitResolvePossiblyDirectEval(arg_count); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 3075 __ CallStub(&stub); | 3115 __ CallStub(&stub); |
| 3076 RecordJSReturnSite(expr); | 3116 RecordJSReturnSite(expr); |
| 3077 // Restore context register. | 3117 // Restore context register. |
| 3078 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3118 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 3079 context()->DropAndPlug(1, rax); | 3119 context()->DropAndPlug(1, rax); |
| 3080 } else if (call_type == Call::GLOBAL_CALL) { | 3120 } else if (call_type == Call::GLOBAL_CALL) { |
| 3081 EmitCallWithLoadIC(expr); | 3121 EmitCallWithLoadIC(expr); |
| 3082 | 3122 |
| 3083 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | 3123 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
| 3084 // Call to a lookup slot (dynamically introduced variable). | 3124 // Call to a lookup slot (dynamically introduced variable). |
| 3085 VariableProxy* proxy = callee->AsVariableProxy(); | 3125 PushCalleeAndWithBaseObject(callee->AsVariableProxy()); |
| 3086 Label slow, done; | |
| 3087 | |
| 3088 { PreservePositionScope scope(masm()->positions_recorder()); | |
| 3089 // Generate code for loading from variables potentially shadowed by | |
| 3090 // eval-introduced variables. | |
| 3091 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); | |
| 3092 } | |
| 3093 __ bind(&slow); | |
| 3094 // Call the runtime to find the function to call (returned in rax) and | |
| 3095 // the object holding it (returned in rdx). | |
| 3096 __ Push(context_register()); | |
| 3097 __ Push(proxy->name()); | |
| 3098 __ CallRuntime(Runtime::kLoadLookupSlot, 2); | |
| 3099 __ Push(rax); // Function. | |
| 3100 __ Push(rdx); // Receiver. | |
| 3101 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); | 3126 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); |
| 3102 | |
| 3103 // If fast case code has been generated, emit code to push the function | |
| 3104 // and receiver and have the slow path jump around this code. | |
| 3105 if (done.is_linked()) { | |
| 3106 Label call; | |
| 3107 __ jmp(&call, Label::kNear); | |
| 3108 __ bind(&done); | |
| 3109 // Push function. | |
| 3110 __ Push(rax); | |
| 3111 // The receiver is implicitly the global receiver. Indicate this by | |
| 3112 // passing the hole to the call function stub. | |
| 3113 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
| 3114 __ bind(&call); | |
| 3115 } | |
| 3116 | |
| 3117 // The receiver is either the global receiver or an object found by | |
| 3118 // LoadContextSlot. | |
| 3119 EmitCall(expr); | 3127 EmitCall(expr); |
| 3120 } else if (call_type == Call::PROPERTY_CALL) { | 3128 } else if (call_type == Call::PROPERTY_CALL) { |
| 3121 Property* property = callee->AsProperty(); | 3129 Property* property = callee->AsProperty(); |
| 3122 bool is_named_call = property->key()->IsPropertyName(); | 3130 bool is_named_call = property->key()->IsPropertyName(); |
| 3123 if (property->IsSuperAccess()) { | 3131 if (property->IsSuperAccess()) { |
| 3124 if (is_named_call) { | 3132 if (is_named_call) { |
| 3125 EmitSuperCallWithLoadIC(expr); | 3133 EmitSuperCallWithLoadIC(expr); |
| 3126 } else { | 3134 } else { |
| 3127 EmitKeyedSuperCallWithLoadIC(expr); | 3135 EmitKeyedSuperCallWithLoadIC(expr); |
| 3128 } | 3136 } |
| (...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5503 Assembler::target_address_at(call_target_address, | 5511 Assembler::target_address_at(call_target_address, |
| 5504 unoptimized_code)); | 5512 unoptimized_code)); |
| 5505 return OSR_AFTER_STACK_CHECK; | 5513 return OSR_AFTER_STACK_CHECK; |
| 5506 } | 5514 } |
| 5507 | 5515 |
| 5508 | 5516 |
| 5509 } // namespace internal | 5517 } // namespace internal |
| 5510 } // namespace v8 | 5518 } // namespace v8 |
| 5511 | 5519 |
| 5512 #endif // V8_TARGET_ARCH_X64 | 5520 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |