| 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/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
| 10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
| (...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1736 | 1736 |
| 1737 // The same parameter may occur multiple times in the parameters_ list. | 1737 // The same parameter may occur multiple times in the parameters_ list. |
| 1738 // If it does, and if it is not copied into the context object, it must | 1738 // If it does, and if it is not copied into the context object, it must |
| 1739 // receive the highest parameter index for that parameter; thus iteration | 1739 // receive the highest parameter index for that parameter; thus iteration |
| 1740 // order is relevant! | 1740 // order is relevant! |
| 1741 for (int i = num_parameters() - 1; i >= 0; --i) { | 1741 for (int i = num_parameters() - 1; i >= 0; --i) { |
| 1742 Variable* var = params_[i]; | 1742 Variable* var = params_[i]; |
| 1743 DCHECK(!has_rest_ || var != rest_parameter()); | 1743 DCHECK(!has_rest_ || var != rest_parameter()); |
| 1744 DCHECK_EQ(this, var->scope()); | 1744 DCHECK_EQ(this, var->scope()); |
| 1745 if (uses_sloppy_arguments) { | 1745 if (uses_sloppy_arguments) { |
| 1746 var->set_is_used(); |
| 1746 var->ForceContextAllocation(); | 1747 var->ForceContextAllocation(); |
| 1747 } | 1748 } |
| 1748 AllocateParameter(var, i); | 1749 AllocateParameter(var, i); |
| 1749 } | 1750 } |
| 1750 } | 1751 } |
| 1751 | 1752 |
| 1752 void DeclarationScope::AllocateParameter(Variable* var, int index) { | 1753 void DeclarationScope::AllocateParameter(Variable* var, int index) { |
| 1753 if (MustAllocate(var)) { | 1754 if (MustAllocate(var)) { |
| 1754 if (MustAllocateInContext(var)) { | 1755 if (MustAllocateInContext(var)) { |
| 1755 DCHECK(var->IsUnallocated() || var->IsContextSlot()); | 1756 DCHECK(var->IsUnallocated() || var->IsContextSlot()); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1903 Variable* function = | 1904 Variable* function = |
| 1904 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1905 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
| 1905 bool is_function_var_in_context = | 1906 bool is_function_var_in_context = |
| 1906 function != nullptr && function->IsContextSlot(); | 1907 function != nullptr && function->IsContextSlot(); |
| 1907 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1908 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 1908 (is_function_var_in_context ? 1 : 0); | 1909 (is_function_var_in_context ? 1 : 0); |
| 1909 } | 1910 } |
| 1910 | 1911 |
| 1911 } // namespace internal | 1912 } // namespace internal |
| 1912 } // namespace v8 | 1913 } // namespace v8 |
| OLD | NEW |