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

Side by Side Diff: src/runtime.cc

Issue 6673042: Do not set value on host objects in Object.defineProperty (fixes issue 1250).... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')
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 3744 matching lines...) Expand 10 before | Expand all | Expand 10 after
3755 // Make sure that we never go back to fast case. 3755 // Make sure that we never go back to fast case.
3756 dictionary->set_requires_slow_elements(); 3756 dictionary->set_requires_slow_elements();
3757 PropertyDetails details = PropertyDetails(attr, NORMAL); 3757 PropertyDetails details = PropertyDetails(attr, NORMAL);
3758 NumberDictionarySet(dictionary, index, obj_value, details); 3758 NumberDictionarySet(dictionary, index, obj_value, details);
3759 return *obj_value; 3759 return *obj_value;
3760 } 3760 }
3761 3761
3762 LookupResult result; 3762 LookupResult result;
3763 js_object->LookupRealNamedProperty(*name, &result); 3763 js_object->LookupRealNamedProperty(*name, &result);
3764 3764
3765 // To be compatible with safari we do not change the value on API objects
3766 // in defineProperty. Firefox disagrees here, and actually changes the value.
3767 if (result.IsProperty() &&
3768 (result.type() == CALLBACKS) &&
3769 result.GetCallbackObject()->IsAccessorInfo()) {
3770 return Heap::undefined_value();
3771 }
3772
3765 // Take special care when attributes are different and there is already 3773 // Take special care when attributes are different and there is already
3766 // a property. For simplicity we normalize the property which enables us 3774 // a property. For simplicity we normalize the property which enables us
3767 // to not worry about changing the instance_descriptor and creating a new 3775 // to not worry about changing the instance_descriptor and creating a new
3768 // map. The current version of SetObjectProperty does not handle attributes 3776 // map. The current version of SetObjectProperty does not handle attributes
3769 // correctly in the case where a property is a field and is reset with 3777 // correctly in the case where a property is a field and is reset with
3770 // new attributes. 3778 // new attributes.
3771 if (result.IsProperty() && 3779 if (result.IsProperty() &&
3772 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { 3780 (attr != result.GetAttributes() || result.type() == CALLBACKS)) {
3773 // New attributes - normalize to avoid writing to instance descriptor 3781 // New attributes - normalize to avoid writing to instance descriptor
3774 if (js_object->IsJSGlobalProxy()) { 3782 if (js_object->IsJSGlobalProxy()) {
(...skipping 7853 matching lines...) Expand 10 before | Expand all | Expand 10 after
11628 } else { 11636 } else {
11629 // Handle last resort GC and make sure to allow future allocations 11637 // Handle last resort GC and make sure to allow future allocations
11630 // to grow the heap without causing GCs (if possible). 11638 // to grow the heap without causing GCs (if possible).
11631 Counters::gc_last_resort_from_js.Increment(); 11639 Counters::gc_last_resort_from_js.Increment();
11632 Heap::CollectAllGarbage(false); 11640 Heap::CollectAllGarbage(false);
11633 } 11641 }
11634 } 11642 }
11635 11643
11636 11644
11637 } } // namespace v8::internal 11645 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698