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

Side by Side Diff: src/scopes.cc

Issue 366027: Fix case where we treat an unaliased call to eval as an aliased call... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month 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/regress/regress-496.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // Declare a new non-local. 533 // Declare a new non-local.
534 var = map->Declare(NULL, name, mode, true, Variable::NORMAL); 534 var = map->Declare(NULL, name, mode, true, Variable::NORMAL);
535 // Allocate it by giving it a dynamic lookup. 535 // Allocate it by giving it a dynamic lookup.
536 var->rewrite_ = new Slot(var, Slot::LOOKUP, -1); 536 var->rewrite_ = new Slot(var, Slot::LOOKUP, -1);
537 } 537 }
538 return var; 538 return var;
539 } 539 }
540 540
541 541
542 // Lookup a variable starting with this scope. The result is either 542 // Lookup a variable starting with this scope. The result is either
543 // the statically resolved (local!) variable belonging to an outer scope, 543 // the statically resolved (local!) variable belonging to an outer scope,
Kevin Millikin (Chromium) 2009/11/05 11:12:47 Could you delete "(local!)" from this comment?
544 // or NULL. It may be NULL because a) we couldn't find a variable, or b) 544 // or NULL. It may be NULL because a) we couldn't find a variable, or b)
545 // because the variable is just a guess (and may be shadowed by another 545 // because the variable is just a guess (and may be shadowed by another
546 // variable that is introduced dynamically via an 'eval' call or a 'with' 546 // variable that is introduced dynamically via an 'eval' call or a 'with'
547 // statement). 547 // statement).
548 Variable* Scope::LookupRecursive(Handle<String> name, 548 Variable* Scope::LookupRecursive(Handle<String> name,
549 bool inner_lookup, 549 bool inner_lookup,
550 Variable** invalidated_local) { 550 Variable** invalidated_local) {
551 // If we find a variable, but the current scope calls 'eval', the found 551 // If we find a variable, but the current scope calls 'eval', the found
552 // variable may not be the correct one (the 'eval' may introduce a 552 // variable may not be the correct one (the 'eval' may introduce a
553 // property with the same name). In that case, remember that the variable 553 // property with the same name). In that case, remember that the variable
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 if (var == NULL) 591 if (var == NULL)
592 return NULL; 592 return NULL;
593 } 593 }
594 594
595 ASSERT(var != NULL); 595 ASSERT(var != NULL);
596 596
597 // If this is a lookup from an inner scope, mark the variable. 597 // If this is a lookup from an inner scope, mark the variable.
598 if (inner_lookup) 598 if (inner_lookup)
599 var->is_accessed_from_inner_scope_ = true; 599 var->is_accessed_from_inner_scope_ = true;
600 600
601 // If the variable we have found is just a guess, invalidate the result. 601 // If the variable we have found is just a guess, invalidate the
602 // result. If the found variable is local, record that fact so we
603 // can generate fast code to get it if it is not shadowed by eval.
602 if (guess) { 604 if (guess) {
603 *invalidated_local = var; 605 if (!var->is_global()) *invalidated_local = var;
604 var = NULL; 606 var = NULL;
605 } 607 }
606 608
607 return var; 609 return var;
608 } 610 }
609 611
610 612
611 void Scope::ResolveVariable(Scope* global_scope, 613 void Scope::ResolveVariable(Scope* global_scope,
612 Handle<Context> context, 614 Handle<Context> context,
613 VariableProxy* proxy) { 615 VariableProxy* proxy) {
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 955 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
954 !must_have_local_context) { 956 !must_have_local_context) {
955 num_heap_slots_ = 0; 957 num_heap_slots_ = 0;
956 } 958 }
957 959
958 // Allocation done. 960 // Allocation done.
959 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 961 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
960 } 962 }
961 963
962 } } // namespace v8::internal 964 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-496.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698