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 3137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3148 | 3148 |
3149 | 3149 |
3150 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3150 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
3151 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 3151 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); |
3152 GetVar(result_register(), new_target_var); | 3152 GetVar(result_register(), new_target_var); |
3153 __ Push(result_register()); | 3153 __ Push(result_register()); |
3154 | 3154 |
3155 EmitLoadSuperConstructor(); | 3155 EmitLoadSuperConstructor(); |
3156 __ Push(result_register()); | 3156 __ Push(result_register()); |
3157 | 3157 |
3158 SuperReference* super_ref = expr->expression()->AsSuperReference(); | |
3159 Variable* this_var = super_ref->this_var()->var(); | |
3160 | |
3161 GetVar(rax, this_var); | |
3162 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); | |
3163 Label uninitialized_this; | |
3164 __ j(equal, &uninitialized_this); | |
3165 __ Push(this_var->name()); | |
3166 __ CallRuntime(Runtime::kThrowReferenceError, 1); | |
3167 __ bind(&uninitialized_this); | |
3168 | |
3169 | |
3170 // Push the arguments ("left-to-right") on the stack. | 3158 // Push the arguments ("left-to-right") on the stack. |
3171 ZoneList<Expression*>* args = expr->arguments(); | 3159 ZoneList<Expression*>* args = expr->arguments(); |
3172 int arg_count = args->length(); | 3160 int arg_count = args->length(); |
3173 for (int i = 0; i < arg_count; i++) { | 3161 for (int i = 0; i < arg_count; i++) { |
3174 VisitForStackValue(args->at(i)); | 3162 VisitForStackValue(args->at(i)); |
3175 } | 3163 } |
3176 | 3164 |
3177 // Call the construct call builtin that handles allocation and | 3165 // Call the construct call builtin that handles allocation and |
3178 // constructor invocation. | 3166 // constructor invocation. |
3179 SetSourcePosition(expr->position()); | 3167 SetSourcePosition(expr->position()); |
(...skipping 16 matching lines...) Expand all Loading... |
3196 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); | 3184 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); |
3197 | 3185 |
3198 // TODO(dslomov): use a different stub and propagate new.target. | 3186 // TODO(dslomov): use a different stub and propagate new.target. |
3199 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3187 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
3200 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3188 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3201 | 3189 |
3202 __ Drop(1); | 3190 __ Drop(1); |
3203 | 3191 |
3204 RecordJSReturnSite(expr); | 3192 RecordJSReturnSite(expr); |
3205 | 3193 |
| 3194 Variable* this_var = super_ref->this_var()->var(); |
| 3195 GetVar(rcx, this_var); |
| 3196 __ CompareRoot(rcx, Heap::kTheHoleValueRootIndex); |
| 3197 Label uninitialized_this; |
| 3198 __ j(equal, &uninitialized_this); |
| 3199 __ Push(this_var->name()); |
| 3200 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 3201 __ bind(&uninitialized_this); |
3206 | 3202 |
3207 EmitVariableAssignment(this_var, Token::INIT_CONST); | 3203 EmitVariableAssignment(this_var, Token::INIT_CONST); |
3208 context()->Plug(rax); | 3204 context()->Plug(rax); |
3209 } | 3205 } |
3210 | 3206 |
3211 | 3207 |
3212 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3208 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3213 ZoneList<Expression*>* args = expr->arguments(); | 3209 ZoneList<Expression*>* args = expr->arguments(); |
3214 DCHECK(args->length() == 1); | 3210 DCHECK(args->length() == 1); |
3215 | 3211 |
(...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5377 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5373 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5378 Assembler::target_address_at(call_target_address, | 5374 Assembler::target_address_at(call_target_address, |
5379 unoptimized_code)); | 5375 unoptimized_code)); |
5380 return OSR_AFTER_STACK_CHECK; | 5376 return OSR_AFTER_STACK_CHECK; |
5381 } | 5377 } |
5382 | 5378 |
5383 | 5379 |
5384 } } // namespace v8::internal | 5380 } } // namespace v8::internal |
5385 | 5381 |
5386 #endif // V8_TARGET_ARCH_X64 | 5382 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |