Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: src/ast/scopes.cc

Issue 2398023002: [wasm] asm.js - Parse and convert asm.js to wasm a function at a time. (Closed)
Patch Set: drop leftover Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/compiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ||
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_);
marja 2016/11/26 15:46:36 Why is the outer scope not already_resolved_ in yo
bradn 2016/11/27 01:14:02 So I'm calling this on a scope for an asm function
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();
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_ =
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
marja 2016/11/26 15:46:36 Removing this check seems wrong - why would your C
bradn 2016/11/27 01:14:02 So this is happening because I'm passing in an Ast
marja 2016/11/28 11:47:21 Yeah, the AstValueFactory needs to be the same, if
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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 1641
1642 Variable* invalidated = var; 1642 Variable* invalidated = var;
1643 var = NonLocal(proxy->raw_name(), DYNAMIC_LOCAL); 1643 var = NonLocal(proxy->raw_name(), DYNAMIC_LOCAL);
1644 var->set_local_if_not_shadowed(invalidated); 1644 var->set_local_if_not_shadowed(invalidated);
1645 } 1645 }
1646 1646
1647 return var; 1647 return var;
1648 } 1648 }
1649 1649
1650 void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) { 1650 void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) {
1651 DCHECK(info->script_scope()->is_script_scope()); 1651 // DCHECK(info->script_scope()->is_script_scope());
marja 2016/11/26 15:46:36 What's the failure here? is script_scope() null or
bradn 2016/11/27 01:14:02 scope_type_ = v8::internal::ScopeType::FUNCTION_SC
marja 2016/11/28 11:47:21 Ok, we need to think how to make the scope analysi
1652 DCHECK(!proxy->is_resolved()); 1652 DCHECK(!proxy->is_resolved());
1653 Variable* var = LookupRecursive(proxy, nullptr); 1653 Variable* var = LookupRecursive(proxy, nullptr);
1654 ResolveTo(info, proxy, var); 1654 ResolveTo(info, proxy, var);
1655 } 1655 }
1656 1656
1657 namespace { 1657 namespace {
1658 1658
1659 bool AccessNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) { 1659 bool AccessNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) {
1660 if (!var->binding_needs_init()) { 1660 if (!var->binding_needs_init()) {
1661 return false; 1661 return false;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
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
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
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698