OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8700 | 8700 |
8701 static void CompareScopeToData(Scope* scope, const PreParsedScopeData* data, | 8701 static void CompareScopeToData(Scope* scope, const PreParsedScopeData* data, |
8702 size_t& index) { | 8702 size_t& index) { |
8703 CHECK_EQ(data->backing_store_[index++], scope->scope_type()); | 8703 CHECK_EQ(data->backing_store_[index++], scope->scope_type()); |
8704 CHECK_EQ(data->backing_store_[index++], scope->start_position()); | 8704 CHECK_EQ(data->backing_store_[index++], scope->start_position()); |
8705 CHECK_EQ(data->backing_store_[index++], scope->end_position()); | 8705 CHECK_EQ(data->backing_store_[index++], scope->end_position()); |
8706 | 8706 |
8707 int inner_scope_count = 0; | 8707 int inner_scope_count = 0; |
8708 for (Scope* inner = scope->inner_scope(); inner != nullptr; | 8708 for (Scope* inner = scope->inner_scope(); inner != nullptr; |
8709 inner = inner->sibling()) { | 8709 inner = inner->sibling()) { |
8710 ++inner_scope_count; | 8710 if (!inner->is_hidden()) { |
| 8711 ++inner_scope_count; |
| 8712 } |
8711 } | 8713 } |
8712 CHECK_EQ(data->backing_store_[index++], inner_scope_count); | 8714 CHECK_EQ(data->backing_store_[index++], inner_scope_count); |
8713 | 8715 |
8714 int variable_count = 0; | 8716 int variable_count = 0; |
8715 for (Variable* local : scope->locals_) { | 8717 for (Variable* local : scope->locals_) { |
8716 if (local->mode() == VAR || local->mode() == LET || | 8718 if (local->mode() == VAR || local->mode() == LET || |
8717 local->mode() == CONST) { | 8719 local->mode() == CONST) { |
8718 ++variable_count; | 8720 ++variable_count; |
8719 } | 8721 } |
8720 } | 8722 } |
(...skipping 11 matching lines...) Expand all Loading... |
8732 CHECK_EQ(data->backing_store_[index++], local_name->raw_data()[i]); | 8734 CHECK_EQ(data->backing_store_[index++], local_name->raw_data()[i]); |
8733 } | 8735 } |
8734 #endif | 8736 #endif |
8735 CHECK_EQ(data->backing_store_[index++], local->location()); | 8737 CHECK_EQ(data->backing_store_[index++], local->location()); |
8736 CHECK_EQ(data->backing_store_[index++], local->maybe_assigned()); | 8738 CHECK_EQ(data->backing_store_[index++], local->maybe_assigned()); |
8737 } | 8739 } |
8738 } | 8740 } |
8739 | 8741 |
8740 for (Scope* inner = scope->inner_scope(); inner != nullptr; | 8742 for (Scope* inner = scope->inner_scope(); inner != nullptr; |
8741 inner = inner->sibling()) { | 8743 inner = inner->sibling()) { |
8742 CompareScopeToData(inner, data, index); | 8744 if (!inner->is_hidden()) { |
| 8745 CompareScopeToData(inner, data, index); |
| 8746 } |
8743 } | 8747 } |
8744 } | 8748 } |
8745 }; | 8749 }; |
8746 } // namespace internal | 8750 } // namespace internal |
8747 } // namespace v8 | 8751 } // namespace v8 |
8748 | 8752 |
8749 // Test that lazily parsed inner functions don't result in overly pessimistic | 8753 // Test that lazily parsed inner functions don't result in overly pessimistic |
8750 // context allocations. | 8754 // context allocations. |
8751 TEST(NoPessimisticContextAllocation) { | 8755 TEST(NoPessimisticContextAllocation) { |
8752 i::FLAG_lazy_inner_functions = true; | 8756 i::FLAG_lazy_inner_functions = true; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9093 {"", "let arguments; arguments = 5;"}, | 9097 {"", "let arguments; arguments = 5;"}, |
9094 {"", "if (true) { let arguments; }"}, | 9098 {"", "if (true) { let arguments; }"}, |
9095 {"", "if (true) { let arguments; arguments = 5; }"}, | 9099 {"", "if (true) { let arguments; arguments = 5; }"}, |
9096 {"", "let arguments; function f() { arguments; }"}, | 9100 {"", "let arguments; function f() { arguments; }"}, |
9097 {"", "let arguments; arguments = 5; function f() { arguments; }"}, | 9101 {"", "let arguments; arguments = 5; function f() { arguments; }"}, |
9098 {"", "let arguments; function f() { arguments = 5; }"}, | 9102 {"", "let arguments; function f() { arguments = 5; }"}, |
9099 | 9103 |
9100 {"", "const arguments = 5;"}, | 9104 {"", "const arguments = 5;"}, |
9101 {"", "if (true) { const arguments = 5; }"}, | 9105 {"", "if (true) { const arguments = 5; }"}, |
9102 {"", "const arguments = 5; function f() { arguments; }"}, | 9106 {"", "const arguments = 5; function f() { arguments; }"}, |
| 9107 |
| 9108 {"", "var [var1, var2] = [1, 2];"}, |
| 9109 {"", "var [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, |
| 9110 {"", "var [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, |
| 9111 {"", "var [var1, ...var2] = [1, 2, 3];"}, |
| 9112 |
| 9113 {"", "var {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, |
| 9114 {"", |
| 9115 "var {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, |
| 9116 {"", "var {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"}, |
| 9117 |
| 9118 {"", "let [var1, var2] = [1, 2];"}, |
| 9119 {"", "let [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, |
| 9120 {"", "let [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, |
| 9121 {"", "let [var1, ...var2] = [1, 2, 3];"}, |
| 9122 |
| 9123 {"", "let {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, |
| 9124 {"", |
| 9125 "let {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, |
| 9126 {"", "let {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"}, |
| 9127 |
| 9128 {"", "const [var1, var2] = [1, 2];"}, |
| 9129 {"", "const [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, |
| 9130 {"", "const [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, |
| 9131 {"", "const [var1, ...var2] = [1, 2, 3];"}, |
| 9132 |
| 9133 {"", "const {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, |
| 9134 {"", |
| 9135 "const {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, |
| 9136 {"", "const {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"}, |
9103 }; | 9137 }; |
9104 | 9138 |
9105 for (unsigned i = 0; i < arraysize(inners); ++i) { | 9139 for (unsigned i = 0; i < arraysize(inners); ++i) { |
9106 // First compile with the lazy inner function and extract the scope data. | 9140 // First compile with the lazy inner function and extract the scope data. |
9107 const char* inner_function = lazy_inner; | 9141 const char* inner_function = lazy_inner; |
9108 int inner_function_len = Utf8LengthHelper(inner_function) - 4; | 9142 int inner_function_len = Utf8LengthHelper(inner_function) - 4; |
9109 | 9143 |
9110 int params_len = Utf8LengthHelper(inners[i].params); | 9144 int params_len = Utf8LengthHelper(inners[i].params); |
9111 int source_len = Utf8LengthHelper(inners[i].source); | 9145 int source_len = Utf8LengthHelper(inners[i].source); |
9112 int len = | 9146 int len = |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9162 eager_info.literal()->scope()->inner_scope()->inner_scope(); | 9196 eager_info.literal()->scope()->inner_scope()->inner_scope(); |
9163 DCHECK_NOT_NULL(scope); | 9197 DCHECK_NOT_NULL(scope); |
9164 DCHECK_NULL(scope->sibling()); | 9198 DCHECK_NULL(scope->sibling()); |
9165 DCHECK(scope->is_function_scope()); | 9199 DCHECK(scope->is_function_scope()); |
9166 | 9200 |
9167 size_t index = 0; | 9201 size_t index = 0; |
9168 i::ScopeTestHelper::CompareScopeToData( | 9202 i::ScopeTestHelper::CompareScopeToData( |
9169 scope, lazy_info.preparsed_scope_data(), index); | 9203 scope, lazy_info.preparsed_scope_data(), index); |
9170 } | 9204 } |
9171 } | 9205 } |
OLD | NEW |