OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
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 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 // if (false) { const x; }; var y = x; | 1510 // if (false) { const x; }; var y = x; |
1511 // | 1511 // |
1512 // The condition on the declaration scopes is a conservative check for | 1512 // The condition on the declaration scopes is a conservative check for |
1513 // nested functions that access a binding and are called before the | 1513 // nested functions that access a binding and are called before the |
1514 // binding is initialized: | 1514 // binding is initialized: |
1515 // function() { f(); let x = 1; function f() { x = 2; } } | 1515 // function() { f(); let x = 1; function f() { x = 2; } } |
1516 // | 1516 // |
1517 bool skip_init_check; | 1517 bool skip_init_check; |
1518 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { | 1518 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { |
1519 skip_init_check = false; | 1519 skip_init_check = false; |
| 1520 } else if (var->is_this()) { |
| 1521 // TODO(dslomov): implement 'this' hole check elimination. |
| 1522 skip_init_check = false; |
1520 } else { | 1523 } else { |
1521 // Check that we always have valid source position. | 1524 // Check that we always have valid source position. |
1522 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); | 1525 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); |
1523 DCHECK(proxy->position() != RelocInfo::kNoPosition); | 1526 DCHECK(proxy->position() != RelocInfo::kNoPosition); |
1524 skip_init_check = var->mode() != CONST_LEGACY && | 1527 skip_init_check = var->mode() != CONST_LEGACY && |
1525 var->initializer_position() < proxy->position(); | 1528 var->initializer_position() < proxy->position(); |
1526 } | 1529 } |
1527 | 1530 |
1528 if (!skip_init_check) { | 1531 if (!skip_init_check) { |
1529 // Let and const need a read barrier. | 1532 // Let and const need a read barrier. |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2936 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2939 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
2937 context()->Plug(x0); | 2940 context()->Plug(x0); |
2938 } | 2941 } |
2939 | 2942 |
2940 | 2943 |
2941 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 2944 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
2942 SuperReference* super_ref = expr->expression()->AsSuperReference(); | 2945 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
2943 EmitLoadSuperConstructor(super_ref); | 2946 EmitLoadSuperConstructor(super_ref); |
2944 __ push(result_register()); | 2947 __ push(result_register()); |
2945 | 2948 |
| 2949 Variable* this_var = super_ref->this_var()->var(); |
| 2950 |
| 2951 GetVar(x0, this_var); |
| 2952 Label uninitialized_this; |
| 2953 __ JumpIfRoot(x0, Heap::kTheHoleValueRootIndex, &uninitialized_this); |
| 2954 __ Mov(x0, Operand(this_var->name())); |
| 2955 __ Push(x0); |
| 2956 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 2957 __ bind(&uninitialized_this); |
| 2958 |
2946 // Push the arguments ("left-to-right") on the stack. | 2959 // Push the arguments ("left-to-right") on the stack. |
2947 ZoneList<Expression*>* args = expr->arguments(); | 2960 ZoneList<Expression*>* args = expr->arguments(); |
2948 int arg_count = args->length(); | 2961 int arg_count = args->length(); |
2949 for (int i = 0; i < arg_count; i++) { | 2962 for (int i = 0; i < arg_count; i++) { |
2950 VisitForStackValue(args->at(i)); | 2963 VisitForStackValue(args->at(i)); |
2951 } | 2964 } |
2952 | 2965 |
2953 // Call the construct call builtin that handles allocation and | 2966 // Call the construct call builtin that handles allocation and |
2954 // constructor invocation. | 2967 // constructor invocation. |
2955 SetSourcePosition(expr->position()); | 2968 SetSourcePosition(expr->position()); |
(...skipping 14 matching lines...) Expand all Loading... |
2970 | 2983 |
2971 __ LoadObject(x2, FeedbackVector()); | 2984 __ LoadObject(x2, FeedbackVector()); |
2972 __ Mov(x3, SmiFromSlot(expr->CallFeedbackSlot())); | 2985 __ Mov(x3, SmiFromSlot(expr->CallFeedbackSlot())); |
2973 | 2986 |
2974 // TODO(dslomov): use a different stub and propagate new.target. | 2987 // TODO(dslomov): use a different stub and propagate new.target. |
2975 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 2988 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
2976 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 2989 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
2977 | 2990 |
2978 RecordJSReturnSite(expr); | 2991 RecordJSReturnSite(expr); |
2979 | 2992 |
2980 // TODO(dslomov): implement TDZ for `this`. | 2993 EmitVariableAssignment(this_var, Token::INIT_CONST); |
2981 EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN); | |
2982 context()->Plug(x0); | 2994 context()->Plug(x0); |
2983 } | 2995 } |
2984 | 2996 |
2985 | 2997 |
2986 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2998 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
2987 ZoneList<Expression*>* args = expr->arguments(); | 2999 ZoneList<Expression*>* args = expr->arguments(); |
2988 DCHECK(args->length() == 1); | 3000 DCHECK(args->length() == 1); |
2989 | 3001 |
2990 VisitForAccumulatorValue(args->at(0)); | 3002 VisitForAccumulatorValue(args->at(0)); |
2991 | 3003 |
(...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5390 return previous_; | 5402 return previous_; |
5391 } | 5403 } |
5392 | 5404 |
5393 | 5405 |
5394 #undef __ | 5406 #undef __ |
5395 | 5407 |
5396 | 5408 |
5397 } } // namespace v8::internal | 5409 } } // namespace v8::internal |
5398 | 5410 |
5399 #endif // V8_TARGET_ARCH_ARM64 | 5411 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |