| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/interpreter/bytecode-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" |
| (...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2754 // and strict modes. | 2754 // and strict modes. |
| 2755 Property* property = expr->expression()->AsProperty(); | 2755 Property* property = expr->expression()->AsProperty(); |
| 2756 Register object = VisitForRegisterValue(property->obj()); | 2756 Register object = VisitForRegisterValue(property->obj()); |
| 2757 VisitForAccumulatorValue(property->key()); | 2757 VisitForAccumulatorValue(property->key()); |
| 2758 builder()->Delete(object, language_mode()); | 2758 builder()->Delete(object, language_mode()); |
| 2759 } else if (expr->expression()->IsVariableProxy()) { | 2759 } else if (expr->expression()->IsVariableProxy()) { |
| 2760 // Delete of an unqualified identifier is allowed in sloppy mode but is | 2760 // Delete of an unqualified identifier is allowed in sloppy mode but is |
| 2761 // not allowed in strict mode. Deleting 'this' is allowed in both modes. | 2761 // not allowed in strict mode. Deleting 'this' is allowed in both modes. |
| 2762 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 2762 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 2763 Variable* variable = proxy->var(); | 2763 Variable* variable = proxy->var(); |
| 2764 DCHECK( | 2764 DCHECK(is_sloppy(language_mode()) || variable->is_this()); |
| 2765 is_sloppy(language_mode()) || | |
| 2766 variable->HasThisName(isolate(), HandleDereferenceMode::kDisallowed)); | |
| 2767 switch (variable->location()) { | 2765 switch (variable->location()) { |
| 2768 case VariableLocation::GLOBAL: | 2766 case VariableLocation::GLOBAL: |
| 2769 case VariableLocation::UNALLOCATED: { | 2767 case VariableLocation::UNALLOCATED: { |
| 2770 // Global var, let, const or variables not explicitly declared. | 2768 // Global var, let, const or variables not explicitly declared. |
| 2771 Register native_context = register_allocator()->NewRegister(); | 2769 Register native_context = register_allocator()->NewRegister(); |
| 2772 Register global_object = register_allocator()->NewRegister(); | 2770 Register global_object = register_allocator()->NewRegister(); |
| 2773 builder() | 2771 builder() |
| 2774 ->LoadContextSlot(execution_context()->reg(), | 2772 ->LoadContextSlot(execution_context()->reg(), |
| 2775 Context::NATIVE_CONTEXT_INDEX) | 2773 Context::NATIVE_CONTEXT_INDEX) |
| 2776 .StoreAccumulatorInRegister(native_context) | 2774 .StoreAccumulatorInRegister(native_context) |
| 2777 .LoadContextSlot(native_context, Context::EXTENSION_INDEX) | 2775 .LoadContextSlot(native_context, Context::EXTENSION_INDEX) |
| 2778 .StoreAccumulatorInRegister(global_object) | 2776 .StoreAccumulatorInRegister(global_object) |
| 2779 .LoadLiteral(variable->name()) | 2777 .LoadLiteral(variable->name()) |
| 2780 .Delete(global_object, language_mode()); | 2778 .Delete(global_object, language_mode()); |
| 2781 break; | 2779 break; |
| 2782 } | 2780 } |
| 2783 case VariableLocation::PARAMETER: | 2781 case VariableLocation::PARAMETER: |
| 2784 case VariableLocation::LOCAL: | 2782 case VariableLocation::LOCAL: |
| 2785 case VariableLocation::CONTEXT: { | 2783 case VariableLocation::CONTEXT: { |
| 2786 // Deleting local var/let/const, context variables, and arguments | 2784 // Deleting local var/let/const, context variables, and arguments |
| 2787 // does not have any effect. | 2785 // does not have any effect. |
| 2788 if (variable->HasThisName(isolate(), | 2786 if (variable->is_this()) { |
| 2789 HandleDereferenceMode::kDisallowed)) { | |
| 2790 builder()->LoadTrue(); | 2787 builder()->LoadTrue(); |
| 2791 } else { | 2788 } else { |
| 2792 builder()->LoadFalse(); | 2789 builder()->LoadFalse(); |
| 2793 } | 2790 } |
| 2794 break; | 2791 break; |
| 2795 } | 2792 } |
| 2796 case VariableLocation::LOOKUP: { | 2793 case VariableLocation::LOOKUP: { |
| 2797 Register name_reg = register_allocator()->NewRegister(); | 2794 Register name_reg = register_allocator()->NewRegister(); |
| 2798 builder() | 2795 builder() |
| 2799 ->LoadLiteral(variable->name()) | 2796 ->LoadLiteral(variable->name()) |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3280 return execution_context()->scope()->language_mode(); | 3277 return execution_context()->scope()->language_mode(); |
| 3281 } | 3278 } |
| 3282 | 3279 |
| 3283 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3280 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3284 return TypeFeedbackVector::GetIndex(slot); | 3281 return TypeFeedbackVector::GetIndex(slot); |
| 3285 } | 3282 } |
| 3286 | 3283 |
| 3287 } // namespace interpreter | 3284 } // namespace interpreter |
| 3288 } // namespace internal | 3285 } // namespace internal |
| 3289 } // namespace v8 | 3286 } // namespace v8 |
| OLD | NEW |