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

Side by Side Diff: src/runtime.cc

Issue 460070: Fix issue 540 by handling the case that a declaration is in the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-540.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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // Functions are not read-only. 712 // Functions are not read-only.
713 ASSERT(mode != READ_ONLY || initial_value->IsTheHole()); 713 ASSERT(mode != READ_ONLY || initial_value->IsTheHole());
714 const char* type = ((attributes & READ_ONLY) != 0) ? "const" : "var"; 714 const char* type = ((attributes & READ_ONLY) != 0) ? "const" : "var";
715 return ThrowRedeclarationError(type, name); 715 return ThrowRedeclarationError(type, name);
716 } 716 }
717 717
718 // Initialize it if necessary. 718 // Initialize it if necessary.
719 if (*initial_value != NULL) { 719 if (*initial_value != NULL) {
720 if (index >= 0) { 720 if (index >= 0) {
721 // The variable or constant context slot should always be in 721 // The variable or constant context slot should always be in
722 // the function context; not in any outer context nor in the 722 // the function context or the arguments object.
723 // arguments object. 723 if (holder->IsContext()) {
724 ASSERT(holder.is_identical_to(context)); 724 ASSERT(holder.is_identical_to(context));
725 if (((attributes & READ_ONLY) == 0) || 725 if (((attributes & READ_ONLY) == 0) ||
726 context->get(index)->IsTheHole()) { 726 context->get(index)->IsTheHole()) {
727 context->set(index, *initial_value); 727 context->set(index, *initial_value);
728 }
729 } else {
730 Handle<JSObject>::cast(holder)->SetElement(index, *initial_value);
728 } 731 }
729 } else { 732 } else {
730 // Slow case: The property is not in the FixedArray part of the context. 733 // Slow case: The property is not in the FixedArray part of the context.
731 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); 734 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder);
732 SetProperty(context_ext, name, initial_value, mode); 735 SetProperty(context_ext, name, initial_value, mode);
733 } 736 }
734 } 737 }
735 738
736 } else { 739 } else {
737 // The property is not in the function context. It needs to be 740 // The property is not in the function context. It needs to be
(...skipping 7221 matching lines...) Expand 10 before | Expand all | Expand 10 after
7959 } else { 7962 } else {
7960 // Handle last resort GC and make sure to allow future allocations 7963 // Handle last resort GC and make sure to allow future allocations
7961 // to grow the heap without causing GCs (if possible). 7964 // to grow the heap without causing GCs (if possible).
7962 Counters::gc_last_resort_from_js.Increment(); 7965 Counters::gc_last_resort_from_js.Increment();
7963 Heap::CollectAllGarbage(false); 7966 Heap::CollectAllGarbage(false);
7964 } 7967 }
7965 } 7968 }
7966 7969
7967 7970
7968 } } // namespace v8::internal 7971 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-540.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698