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 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2772 // and strict modes. | 2772 // and strict modes. |
2773 Property* property = expr->expression()->AsProperty(); | 2773 Property* property = expr->expression()->AsProperty(); |
2774 Register object = VisitForRegisterValue(property->obj()); | 2774 Register object = VisitForRegisterValue(property->obj()); |
2775 VisitForAccumulatorValue(property->key()); | 2775 VisitForAccumulatorValue(property->key()); |
2776 builder()->Delete(object, language_mode()); | 2776 builder()->Delete(object, language_mode()); |
2777 } else if (expr->expression()->IsVariableProxy()) { | 2777 } else if (expr->expression()->IsVariableProxy()) { |
2778 // Delete of an unqualified identifier is allowed in sloppy mode but is | 2778 // Delete of an unqualified identifier is allowed in sloppy mode but is |
2779 // not allowed in strict mode. Deleting 'this' is allowed in both modes. | 2779 // not allowed in strict mode. Deleting 'this' is allowed in both modes. |
2780 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 2780 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
2781 Variable* variable = proxy->var(); | 2781 Variable* variable = proxy->var(); |
2782 DCHECK( | 2782 DCHECK(is_sloppy(language_mode()) || variable->is_this()); |
2783 is_sloppy(language_mode()) || | |
2784 variable->HasThisName(isolate(), HandleDereferenceMode::kDisallowed)); | |
2785 switch (variable->location()) { | 2783 switch (variable->location()) { |
2786 case VariableLocation::GLOBAL: | 2784 case VariableLocation::GLOBAL: |
2787 case VariableLocation::UNALLOCATED: { | 2785 case VariableLocation::UNALLOCATED: { |
2788 // Global var, let, const or variables not explicitly declared. | 2786 // Global var, let, const or variables not explicitly declared. |
2789 Register native_context = register_allocator()->NewRegister(); | 2787 Register native_context = register_allocator()->NewRegister(); |
2790 Register global_object = register_allocator()->NewRegister(); | 2788 Register global_object = register_allocator()->NewRegister(); |
2791 builder() | 2789 builder() |
2792 ->LoadContextSlot(execution_context()->reg(), | 2790 ->LoadContextSlot(execution_context()->reg(), |
2793 Context::NATIVE_CONTEXT_INDEX) | 2791 Context::NATIVE_CONTEXT_INDEX) |
2794 .StoreAccumulatorInRegister(native_context) | 2792 .StoreAccumulatorInRegister(native_context) |
2795 .LoadContextSlot(native_context, Context::EXTENSION_INDEX) | 2793 .LoadContextSlot(native_context, Context::EXTENSION_INDEX) |
2796 .StoreAccumulatorInRegister(global_object) | 2794 .StoreAccumulatorInRegister(global_object) |
2797 .LoadLiteral(variable->name()) | 2795 .LoadLiteral(variable->name()) |
2798 .Delete(global_object, language_mode()); | 2796 .Delete(global_object, language_mode()); |
2799 break; | 2797 break; |
2800 } | 2798 } |
2801 case VariableLocation::PARAMETER: | 2799 case VariableLocation::PARAMETER: |
2802 case VariableLocation::LOCAL: | 2800 case VariableLocation::LOCAL: |
2803 case VariableLocation::CONTEXT: { | 2801 case VariableLocation::CONTEXT: { |
2804 // Deleting local var/let/const, context variables, and arguments | 2802 // Deleting local var/let/const, context variables, and arguments |
2805 // does not have any effect. | 2803 // does not have any effect. |
2806 if (variable->HasThisName(isolate(), | 2804 if (variable->is_this()) { |
2807 HandleDereferenceMode::kDisallowed)) { | |
2808 builder()->LoadTrue(); | 2805 builder()->LoadTrue(); |
2809 } else { | 2806 } else { |
2810 builder()->LoadFalse(); | 2807 builder()->LoadFalse(); |
2811 } | 2808 } |
2812 break; | 2809 break; |
2813 } | 2810 } |
2814 case VariableLocation::LOOKUP: { | 2811 case VariableLocation::LOOKUP: { |
2815 Register name_reg = register_allocator()->NewRegister(); | 2812 Register name_reg = register_allocator()->NewRegister(); |
2816 builder() | 2813 builder() |
2817 ->LoadLiteral(variable->name()) | 2814 ->LoadLiteral(variable->name()) |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3310 return execution_context()->scope()->language_mode(); | 3307 return execution_context()->scope()->language_mode(); |
3311 } | 3308 } |
3312 | 3309 |
3313 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3310 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3314 return TypeFeedbackVector::GetIndex(slot); | 3311 return TypeFeedbackVector::GetIndex(slot); |
3315 } | 3312 } |
3316 | 3313 |
3317 } // namespace interpreter | 3314 } // namespace interpreter |
3318 } // namespace internal | 3315 } // namespace internal |
3319 } // namespace v8 | 3316 } // namespace v8 |
OLD | NEW |