Chromium Code Reviews| 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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 | 539 |
| 540 if (scope->is_eval_scope() && is_sloppy(scope->language_mode())) { | 540 if (scope->is_eval_scope() && is_sloppy(scope->language_mode())) { |
| 541 AstNodeFactory factory(info->ast_value_factory()); | 541 AstNodeFactory factory(info->ast_value_factory()); |
| 542 scope->HoistSloppyBlockFunctions(&factory); | 542 scope->HoistSloppyBlockFunctions(&factory); |
| 543 } | 543 } |
| 544 | 544 |
| 545 // We are compiling one of three cases: | 545 // We are compiling one of three cases: |
| 546 // 1) top-level code, | 546 // 1) top-level code, |
| 547 // 2) a function/eval/module on the top-level | 547 // 2) a function/eval/module on the top-level |
| 548 // 3) a function/eval in a scope that was already resolved. | 548 // 3) a function/eval in a scope that was already resolved. |
| 549 DCHECK(scope->scope_type() == SCRIPT_SCOPE || | 549 // DCHECK(scope->scope_type() == SCRIPT_SCOPE || |
|
titzer
2016/11/28 10:40:11
Can you explain why this DCHECK is no longer neede
marja
2016/11/28 11:10:17
I think these commented-out-DCHECKs are stuff that
bradn
2016/11/29 06:30:35
Done.
bradn
2016/11/29 06:30:35
Added back with new case and comment.
| |
| 550 scope->outer_scope()->scope_type() == SCRIPT_SCOPE || | 550 // scope->outer_scope()->scope_type() == SCRIPT_SCOPE || |
| 551 scope->outer_scope()->already_resolved_); | 551 // scope->outer_scope()->already_resolved_); |
| 552 | 552 |
| 553 // The outer scope is never lazy. | 553 // The outer scope is never lazy. |
| 554 scope->set_should_eager_compile(); | 554 scope->set_should_eager_compile(); |
|
titzer
2016/11/28 10:40:11
Fishy. I don't think we want to set eager compile
bradn
2016/11/29 06:30:35
I think this ends up being moot in the asm case, a
| |
| 555 | 555 |
| 556 scope->AllocateVariables(info, mode); | 556 scope->AllocateVariables(info, mode); |
| 557 | 557 |
| 558 // Ensuring that the outer script scope has a scope info avoids having | 558 // Ensuring that the outer script scope has a scope info avoids having |
| 559 // special case for native contexts vs other contexts. | 559 // special case for native contexts vs other contexts. |
| 560 if (info->script_scope()->scope_info_.is_null()) { | 560 if (info->script_scope()->scope_info_.is_null()) { |
| 561 info->script_scope()->scope_info_ = | 561 info->script_scope()->scope_info_ = |
| 562 handle(ScopeInfo::Empty(info->isolate())); | 562 handle(ScopeInfo::Empty(info->isolate())); |
| 563 } | 563 } |
| 564 | 564 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 999 return var; | 999 return var; |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, | 1002 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, |
| 1003 const AstRawString* name, | 1003 const AstRawString* name, |
| 1004 int start_position, VariableKind kind) { | 1004 int start_position, VariableKind kind) { |
| 1005 // Note that we must not share the unresolved variables with | 1005 // Note that we must not share the unresolved variables with |
| 1006 // the same name because they may be removed selectively via | 1006 // the same name because they may be removed selectively via |
| 1007 // RemoveUnresolved(). | 1007 // RemoveUnresolved(). |
| 1008 DCHECK(!already_resolved_); | 1008 DCHECK(!already_resolved_); |
| 1009 DCHECK_EQ(factory->zone(), zone()); | 1009 // DCHECK_EQ(factory->zone(), zone()); |
|
titzer
2016/11/28 10:40:11
delete
marja
2016/11/28 11:47:21
No, don't delete :)
bradn
2016/11/29 06:30:35
Keeping with additional clause.
| |
| 1010 VariableProxy* proxy = factory->NewVariableProxy(name, kind, start_position); | 1010 VariableProxy* proxy = factory->NewVariableProxy(name, kind, start_position); |
| 1011 proxy->set_next_unresolved(unresolved_); | 1011 proxy->set_next_unresolved(unresolved_); |
| 1012 unresolved_ = proxy; | 1012 unresolved_ = proxy; |
| 1013 return proxy; | 1013 return proxy; |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 void Scope::AddUnresolved(VariableProxy* proxy) { | 1016 void Scope::AddUnresolved(VariableProxy* proxy) { |
| 1017 DCHECK(!already_resolved_); | 1017 DCHECK(!already_resolved_); |
| 1018 DCHECK(!proxy->is_resolved()); | 1018 DCHECK(!proxy->is_resolved()); |
| 1019 proxy->set_next_unresolved(unresolved_); | 1019 proxy->set_next_unresolved(unresolved_); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1729 } | 1729 } |
| 1730 #endif | 1730 #endif |
| 1731 | 1731 |
| 1732 DCHECK_NOT_NULL(var); | 1732 DCHECK_NOT_NULL(var); |
| 1733 if (proxy->is_assigned()) var->set_maybe_assigned(); | 1733 if (proxy->is_assigned()) var->set_maybe_assigned(); |
| 1734 if (AccessNeedsHoleCheck(var, proxy, this)) proxy->set_needs_hole_check(); | 1734 if (AccessNeedsHoleCheck(var, proxy, this)) proxy->set_needs_hole_check(); |
| 1735 proxy->BindTo(var); | 1735 proxy->BindTo(var); |
| 1736 } | 1736 } |
| 1737 | 1737 |
| 1738 void Scope::ResolveVariablesRecursively(ParseInfo* info) { | 1738 void Scope::ResolveVariablesRecursively(ParseInfo* info) { |
| 1739 DCHECK(info->script_scope()->is_script_scope()); | 1739 // DCHECK(info->script_scope()->is_script_scope()); |
|
titzer
2016/11/28 10:40:11
delete
marja
2016/11/28 11:47:21
Ditto, don't delete; but I think this needs to be
bradn
2016/11/29 06:30:35
Kept instead.
bradn
2016/11/29 06:30:35
doing this above.
Actually this one can be kept as
| |
| 1740 // Lazy parsed declaration scopes are already partially analyzed. If there are | 1740 // Lazy parsed declaration scopes are already partially analyzed. If there are |
| 1741 // unresolved references remaining, they just need to be resolved in outer | 1741 // unresolved references remaining, they just need to be resolved in outer |
| 1742 // scopes. | 1742 // scopes. |
| 1743 if (is_declaration_scope() && AsDeclarationScope()->is_lazily_parsed()) { | 1743 if (is_declaration_scope() && AsDeclarationScope()->is_lazily_parsed()) { |
| 1744 DCHECK(variables_.occupancy() == 0); | 1744 DCHECK(variables_.occupancy() == 0); |
| 1745 for (VariableProxy* proxy = unresolved_; proxy != nullptr; | 1745 for (VariableProxy* proxy = unresolved_; proxy != nullptr; |
| 1746 proxy = proxy->next_unresolved()) { | 1746 proxy = proxy->next_unresolved()) { |
| 1747 Variable* var = outer_scope()->LookupRecursive(proxy, nullptr); | 1747 Variable* var = outer_scope()->LookupRecursive(proxy, nullptr); |
| 1748 if (!var->is_dynamic()) { | 1748 if (!var->is_dynamic()) { |
| 1749 var->set_is_used(); | 1749 var->set_is_used(); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2071 Variable* function = | 2071 Variable* function = |
| 2072 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2072 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
| 2073 bool is_function_var_in_context = | 2073 bool is_function_var_in_context = |
| 2074 function != nullptr && function->IsContextSlot(); | 2074 function != nullptr && function->IsContextSlot(); |
| 2075 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2075 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 2076 (is_function_var_in_context ? 1 : 0); | 2076 (is_function_var_in_context ? 1 : 0); |
| 2077 } | 2077 } |
| 2078 | 2078 |
| 2079 } // namespace internal | 2079 } // namespace internal |
| 2080 } // namespace v8 | 2080 } // namespace v8 |
| OLD | NEW |