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

Side by Side Diff: src/objects.cc

Issue 7335002: Allow JSObject::PreventExtensions to work for arguments objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 } 3374 }
3375 3375
3376 if (IsJSGlobalProxy()) { 3376 if (IsJSGlobalProxy()) {
3377 Object* proto = GetPrototype(); 3377 Object* proto = GetPrototype();
3378 if (proto->IsNull()) return this; 3378 if (proto->IsNull()) return this;
3379 ASSERT(proto->IsJSGlobalObject()); 3379 ASSERT(proto->IsJSGlobalObject());
3380 return JSObject::cast(proto)->PreventExtensions(); 3380 return JSObject::cast(proto)->PreventExtensions();
3381 } 3381 }
3382 3382
3383 // If there are fast elements we normalize. 3383 // If there are fast elements we normalize.
3384 if (HasFastElements()) { 3384 NumberDictionary* dictionary = NULL;
3385 MaybeObject* result = NormalizeElements(); 3385 { MaybeObject* maybe = NormalizeElements();
3386 if (result->IsFailure()) return result; 3386 if (!maybe->To<NumberDictionary>(&dictionary)) return maybe;
3387 } 3387 }
3388 // TODO(kmillikin): Handle arguments object with dictionary elements. 3388 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements());
3389 ASSERT(HasDictionaryElements());
3390 // Make sure that we never go back to fast case. 3389 // Make sure that we never go back to fast case.
3391 element_dictionary()->set_requires_slow_elements(); 3390 dictionary->set_requires_slow_elements();
3392 3391
3393 // Do a map transition, other objects with this map may still 3392 // Do a map transition, other objects with this map may still
3394 // be extensible. 3393 // be extensible.
3395 Object* new_map; 3394 Map* new_map;
3396 { MaybeObject* maybe_new_map = map()->CopyDropTransitions(); 3395 { MaybeObject* maybe = map()->CopyDropTransitions();
3397 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; 3396 if (!maybe->To<Map>(&new_map)) return maybe;
3398 } 3397 }
3399 Map::cast(new_map)->set_is_extensible(false); 3398 new_map->set_is_extensible(false);
3400 set_map(Map::cast(new_map)); 3399 set_map(new_map);
3401 ASSERT(!map()->is_extensible()); 3400 ASSERT(!map()->is_extensible());
3402 return new_map; 3401 return new_map;
3403 } 3402 }
3404 3403
3405 3404
3406 // Tests for the fast common case for property enumeration: 3405 // Tests for the fast common case for property enumeration:
3407 // - This object and all prototypes has an enum cache (which means that it has 3406 // - This object and all prototypes has an enum cache (which means that it has
3408 // no interceptors and needs no access checks). 3407 // no interceptors and needs no access checks).
3409 // - This object has no elements. 3408 // - This object has no elements.
3410 // - No prototype has enumerable properties/elements. 3409 // - No prototype has enumerable properties/elements.
(...skipping 8281 matching lines...) Expand 10 before | Expand all | Expand 10 after
11692 if (break_point_objects()->IsUndefined()) return 0; 11691 if (break_point_objects()->IsUndefined()) return 0;
11693 // Single beak point. 11692 // Single beak point.
11694 if (!break_point_objects()->IsFixedArray()) return 1; 11693 if (!break_point_objects()->IsFixedArray()) return 1;
11695 // Multiple break points. 11694 // Multiple break points.
11696 return FixedArray::cast(break_point_objects())->length(); 11695 return FixedArray::cast(break_point_objects())->length();
11697 } 11696 }
11698 #endif 11697 #endif
11699 11698
11700 11699
11701 } } // namespace v8::internal 11700 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-88858.js » ('j') | test/mjsunit/regress/regress-88858.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698