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

Side by Side Diff: src/scopes.cc

Issue 19569003: Do not materialize context-allocated values for debug-evaluate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: improved test Created 7 years, 5 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 | « src/runtime.cc ('k') | test/mjsunit/debug-evaluate-closure.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 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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 var->AllocateTo(Variable::LOOKUP, -1); 963 var->AllocateTo(Variable::LOOKUP, -1);
964 } 964 }
965 return var; 965 return var;
966 } 966 }
967 967
968 968
969 Variable* Scope::LookupRecursive(Handle<String> name, 969 Variable* Scope::LookupRecursive(Handle<String> name,
970 BindingKind* binding_kind, 970 BindingKind* binding_kind,
971 AstNodeFactory<AstNullVisitor>* factory) { 971 AstNodeFactory<AstNullVisitor>* factory) {
972 ASSERT(binding_kind != NULL); 972 ASSERT(binding_kind != NULL);
973 if (already_resolved() && is_with_scope()) {
974 // Short-cut: if the scope is deserialized from a scope info, variable
975 // allocation is already fixed. We can simply return with dynamic lookup.
976 *binding_kind = DYNAMIC_LOOKUP;
977 return NULL;
978 }
979
973 // Try to find the variable in this scope. 980 // Try to find the variable in this scope.
974 Variable* var = LocalLookup(name); 981 Variable* var = LocalLookup(name);
975 982
976 // We found a variable and we are done. (Even if there is an 'eval' in 983 // We found a variable and we are done. (Even if there is an 'eval' in
977 // this scope which introduces the same variable again, the resulting 984 // this scope which introduces the same variable again, the resulting
978 // variable remains the same.) 985 // variable remains the same.)
979 if (var != NULL) { 986 if (var != NULL) {
980 *binding_kind = BOUND; 987 *binding_kind = BOUND;
981 return var; 988 return var;
982 } 989 }
983 990
984 // We did not find a variable locally. Check against the function variable, 991 // We did not find a variable locally. Check against the function variable,
985 // if any. We can do this for all scopes, since the function variable is 992 // if any. We can do this for all scopes, since the function variable is
986 // only present - if at all - for function scopes. 993 // only present - if at all - for function scopes.
987 *binding_kind = UNBOUND; 994 *binding_kind = UNBOUND;
988 var = LookupFunctionVar(name, factory); 995 var = LookupFunctionVar(name, factory);
989 if (var != NULL) { 996 if (var != NULL) {
990 *binding_kind = BOUND; 997 *binding_kind = BOUND;
991 } else if (outer_scope_ != NULL) { 998 } else if (outer_scope_ != NULL) {
992 var = outer_scope_->LookupRecursive(name, binding_kind, factory); 999 var = outer_scope_->LookupRecursive(name, binding_kind, factory);
993 if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) { 1000 if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) {
994 var->ForceContextAllocation(); 1001 var->ForceContextAllocation();
995 } 1002 }
996 } else { 1003 } else {
997 ASSERT(is_global_scope()); 1004 ASSERT(is_global_scope());
998 } 1005 }
999 1006
1000 if (is_with_scope()) { 1007 if (is_with_scope()) {
1008 ASSERT(!already_resolved());
1001 // The current scope is a with scope, so the variable binding can not be 1009 // The current scope is a with scope, so the variable binding can not be
1002 // statically resolved. However, note that it was necessary to do a lookup 1010 // statically resolved. However, note that it was necessary to do a lookup
1003 // in the outer scope anyway, because if a binding exists in an outer scope, 1011 // in the outer scope anyway, because if a binding exists in an outer scope,
1004 // the associated variable has to be marked as potentially being accessed 1012 // the associated variable has to be marked as potentially being accessed
1005 // from inside of an inner with scope (the property may not be in the 'with' 1013 // from inside of an inner with scope (the property may not be in the 'with'
1006 // object). 1014 // object).
1007 *binding_kind = DYNAMIC_LOOKUP; 1015 *binding_kind = DYNAMIC_LOOKUP;
1008 return NULL; 1016 return NULL;
1009 } else if (calls_non_strict_eval()) { 1017 } else if (calls_non_strict_eval()) {
1010 // A variable binding may have been found in an outer scope, but the current 1018 // A variable binding may have been found in an outer scope, but the current
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 } 1401 }
1394 1402
1395 1403
1396 int Scope::ContextLocalCount() const { 1404 int Scope::ContextLocalCount() const {
1397 if (num_heap_slots() == 0) return 0; 1405 if (num_heap_slots() == 0) return 0;
1398 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1406 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1399 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1407 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1400 } 1408 }
1401 1409
1402 } } // namespace v8::internal 1410 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/debug-evaluate-closure.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698