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 3045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3056 PreservePositionScope scope(masm()->positions_recorder()); | 3056 PreservePositionScope scope(masm()->positions_recorder()); |
3057 VisitForStackValue(property->obj()); | 3057 VisitForStackValue(property->obj()); |
3058 } | 3058 } |
3059 if (is_named_call) { | 3059 if (is_named_call) { |
3060 EmitCallWithLoadIC(expr); | 3060 EmitCallWithLoadIC(expr); |
3061 } else { | 3061 } else { |
3062 EmitKeyedCallWithLoadIC(expr, property->key()); | 3062 EmitKeyedCallWithLoadIC(expr, property->key()); |
3063 } | 3063 } |
3064 } | 3064 } |
3065 } else if (call_type == Call::SUPER_CALL) { | 3065 } else if (call_type == Call::SUPER_CALL) { |
3066 SuperReference* super_ref = callee->AsSuperReference(); | 3066 if (FLAG_experimental_classes) { |
3067 EmitLoadSuperConstructor(super_ref); | 3067 EmitSuperConstructorCall(expr); |
3068 __ Push(result_register()); | 3068 } else { |
3069 VisitForStackValue(super_ref->this_var()); | 3069 SuperReference* super_ref = callee->AsSuperReference(); |
3070 EmitCall(expr, CallICState::METHOD); | 3070 EmitLoadSuperConstructor(super_ref); |
| 3071 __ Push(result_register()); |
| 3072 VisitForStackValue(super_ref->this_var()); |
| 3073 EmitCall(expr, CallICState::METHOD); |
| 3074 } |
3071 } else { | 3075 } else { |
3072 DCHECK(call_type == Call::OTHER_CALL); | 3076 DCHECK(call_type == Call::OTHER_CALL); |
3073 // Call to an arbitrary expression not handled specially above. | 3077 // Call to an arbitrary expression not handled specially above. |
3074 { PreservePositionScope scope(masm()->positions_recorder()); | 3078 { PreservePositionScope scope(masm()->positions_recorder()); |
3075 VisitForStackValue(callee); | 3079 VisitForStackValue(callee); |
3076 } | 3080 } |
3077 __ PushRoot(Heap::kUndefinedValueRootIndex); | 3081 __ PushRoot(Heap::kUndefinedValueRootIndex); |
3078 // Emit function call. | 3082 // Emit function call. |
3079 EmitCall(expr); | 3083 EmitCall(expr); |
3080 } | 3084 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 __ Move(rbx, FeedbackVector()); | 3131 __ Move(rbx, FeedbackVector()); |
3128 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); | 3132 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); |
3129 | 3133 |
3130 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3134 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
3131 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3135 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3132 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3136 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
3133 context()->Plug(rax); | 3137 context()->Plug(rax); |
3134 } | 3138 } |
3135 | 3139 |
3136 | 3140 |
| 3141 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| 3142 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
| 3143 EmitLoadSuperConstructor(super_ref); |
| 3144 __ Push(result_register()); |
| 3145 |
| 3146 // Push the arguments ("left-to-right") on the stack. |
| 3147 ZoneList<Expression*>* args = expr->arguments(); |
| 3148 int arg_count = args->length(); |
| 3149 for (int i = 0; i < arg_count; i++) { |
| 3150 VisitForStackValue(args->at(i)); |
| 3151 } |
| 3152 |
| 3153 // Call the construct call builtin that handles allocation and |
| 3154 // constructor invocation. |
| 3155 SetSourcePosition(expr->position()); |
| 3156 |
| 3157 // Load function and argument count into edi and eax. |
| 3158 __ Set(rax, arg_count); |
| 3159 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
| 3160 |
| 3161 // Record call targets in unoptimized code. |
| 3162 if (FLAG_pretenuring_call_new) { |
| 3163 UNREACHABLE(); |
| 3164 /* TODO(dslomov): support pretenuring. |
| 3165 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| 3166 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
| 3167 expr->CallNewFeedbackSlot().ToInt() + 1); |
| 3168 */ |
| 3169 } |
| 3170 |
| 3171 __ Move(rbx, FeedbackVector()); |
| 3172 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); |
| 3173 |
| 3174 // TODO(dslomov): use a different stub and propagate new.target. |
| 3175 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 3176 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3177 |
| 3178 RecordJSReturnSite(expr); |
| 3179 |
| 3180 // TODO(dslomov): implement TDZ for `this`. |
| 3181 EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN); |
| 3182 context()->Plug(rax); |
| 3183 } |
| 3184 |
| 3185 |
3137 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3186 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3138 ZoneList<Expression*>* args = expr->arguments(); | 3187 ZoneList<Expression*>* args = expr->arguments(); |
3139 DCHECK(args->length() == 1); | 3188 DCHECK(args->length() == 1); |
3140 | 3189 |
3141 VisitForAccumulatorValue(args->at(0)); | 3190 VisitForAccumulatorValue(args->at(0)); |
3142 | 3191 |
3143 Label materialize_true, materialize_false; | 3192 Label materialize_true, materialize_false; |
3144 Label* if_true = NULL; | 3193 Label* if_true = NULL; |
3145 Label* if_false = NULL; | 3194 Label* if_false = NULL; |
3146 Label* fall_through = NULL; | 3195 Label* fall_through = NULL; |
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5253 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5302 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5254 Assembler::target_address_at(call_target_address, | 5303 Assembler::target_address_at(call_target_address, |
5255 unoptimized_code)); | 5304 unoptimized_code)); |
5256 return OSR_AFTER_STACK_CHECK; | 5305 return OSR_AFTER_STACK_CHECK; |
5257 } | 5306 } |
5258 | 5307 |
5259 | 5308 |
5260 } } // namespace v8::internal | 5309 } } // namespace v8::internal |
5261 | 5310 |
5262 #endif // V8_TARGET_ARCH_X64 | 5311 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |