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

Side by Side Diff: src/scopes.cc

Issue 6374006: Revert "Make 'with' mark only variables occurring in the body as used." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/debug-evaluate-locals.js » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 Variable* invalidated_local = NULL; 719 Variable* invalidated_local = NULL;
720 Variable* var = LookupRecursive(proxy->name(), false, &invalidated_local); 720 Variable* var = LookupRecursive(proxy->name(), false, &invalidated_local);
721 721
722 if (proxy->inside_with()) { 722 if (proxy->inside_with()) {
723 // If we are inside a local 'with' statement, all bets are off 723 // If we are inside a local 'with' statement, all bets are off
724 // and we cannot resolve the proxy to a local variable even if 724 // and we cannot resolve the proxy to a local variable even if
725 // we found an outer matching variable. 725 // we found an outer matching variable.
726 // Note that we must do a lookup anyway, because if we find one, 726 // Note that we must do a lookup anyway, because if we find one,
727 // we must mark that variable as potentially accessed from this 727 // we must mark that variable as potentially accessed from this
728 // inner scope (the property may not be in the 'with' object). 728 // inner scope (the property may not be in the 'with' object).
729 if (var != NULL) var->set_is_used(true);
730 var = NonLocal(proxy->name(), Variable::DYNAMIC); 729 var = NonLocal(proxy->name(), Variable::DYNAMIC);
731 730
732 } else { 731 } else {
733 // We are not inside a local 'with' statement. 732 // We are not inside a local 'with' statement.
734 733
735 if (var == NULL) { 734 if (var == NULL) {
736 // We did not find the variable. We have a global variable 735 // We did not find the variable. We have a global variable
737 // if we are in the global scope (we know already that we 736 // if we are in the global scope (we know already that we
738 // are outside a 'with' statement) or if there is no way 737 // are outside a 'with' statement) or if there is no way
739 // that the variable might be introduced dynamically (through 738 // that the variable might be introduced dynamically (through
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 return scope_calls_eval_ || inner_scope_calls_eval_; 826 return scope_calls_eval_ || inner_scope_calls_eval_;
828 } 827 }
829 828
830 829
831 bool Scope::MustAllocate(Variable* var) { 830 bool Scope::MustAllocate(Variable* var) {
832 // Give var a read/write use if there is a chance it might be accessed 831 // Give var a read/write use if there is a chance it might be accessed
833 // via an eval() call. This is only possible if the variable has a 832 // via an eval() call. This is only possible if the variable has a
834 // visible name. 833 // visible name.
835 if ((var->is_this() || var->name()->length() > 0) && 834 if ((var->is_this() || var->name()->length() > 0) &&
836 (var->is_accessed_from_inner_scope() || 835 (var->is_accessed_from_inner_scope() ||
837 scope_calls_eval_ || 836 scope_calls_eval_ || inner_scope_calls_eval_ ||
838 inner_scope_calls_eval_)) { 837 scope_contains_with_)) {
839 var->set_is_used(true); 838 var->set_is_used(true);
840 } 839 }
841 // Global variables do not need to be allocated. 840 // Global variables do not need to be allocated.
842 return !var->is_global() && var->is_used(); 841 return !var->is_global() && var->is_used();
843 } 842 }
844 843
845 844
846 bool Scope::MustAllocateInContext(Variable* var) { 845 bool Scope::MustAllocateInContext(Variable* var) {
847 // If var is accessed from an inner scope, or if there is a 846 // If var is accessed from an inner scope, or if there is a
848 // possibility that it might be accessed from the current or an inner 847 // possibility that it might be accessed from the current or an inner
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 1055 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
1057 !must_have_local_context) { 1056 !must_have_local_context) {
1058 num_heap_slots_ = 0; 1057 num_heap_slots_ = 0;
1059 } 1058 }
1060 1059
1061 // Allocation done. 1060 // Allocation done.
1062 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1061 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1063 } 1062 }
1064 1063
1065 } } // namespace v8::internal 1064 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/debug-evaluate-locals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698