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

Side by Side Diff: src/objects.cc

Issue 6800014: Bug 1309 non-extensible objects have immutable __Proto__ (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Git Created 9 years, 8 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/messages.js ('k') | src/runtime.cc » ('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 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 6848 matching lines...) Expand 10 before | Expand all | Expand 10 after
6859 } 6859 }
6860 6860
6861 6861
6862 MaybeObject* JSObject::SetPrototype(Object* value, 6862 MaybeObject* JSObject::SetPrototype(Object* value,
6863 bool skip_hidden_prototypes) { 6863 bool skip_hidden_prototypes) {
6864 Heap* heap = GetHeap(); 6864 Heap* heap = GetHeap();
6865 // Silently ignore the change if value is not a JSObject or null. 6865 // Silently ignore the change if value is not a JSObject or null.
6866 // SpiderMonkey behaves this way. 6866 // SpiderMonkey behaves this way.
6867 if (!value->IsJSObject() && !value->IsNull()) return value; 6867 if (!value->IsJSObject() && !value->IsNull()) return value;
6868 6868
6869 // From 8.6.2 Object Internal Methods
6870 // ...
6871 // In addition, if [[Extensible]] is false the value of the [[Class]] and
6872 // [[Prototype]] internal properties of the object may not be modified.
6873 // ...
6874 // Implementation specific extensions that modify [[Class]], [[Prototype]]
6875 // or [[Extensible]] must not violate the invariants defined in the preceding
6876 // paragraph.
6877 if (!this->map()->is_extensible()) {
6878 HandleScope scope;
6879 Handle<Object> handle(this, heap->isolate());
6880 return heap->isolate()->Throw(
6881 *FACTORY->NewTypeError("non_extensible_proto",
6882 HandleVector<Object>(&handle, 1)));
6883 }
6884
6869 // Before we can set the prototype we need to be sure 6885 // Before we can set the prototype we need to be sure
6870 // prototype cycles are prevented. 6886 // prototype cycles are prevented.
6871 // It is sufficient to validate that the receiver is not in the new prototype 6887 // It is sufficient to validate that the receiver is not in the new prototype
6872 // chain. 6888 // chain.
6873 for (Object* pt = value; pt != heap->null_value(); pt = pt->GetPrototype()) { 6889 for (Object* pt = value; pt != heap->null_value(); pt = pt->GetPrototype()) {
6874 if (JSObject::cast(pt) == this) { 6890 if (JSObject::cast(pt) == this) {
6875 // Cycle detected. 6891 // Cycle detected.
6876 HandleScope scope; 6892 HandleScope scope;
6877 return heap->isolate()->Throw( 6893 return heap->isolate()->Throw(
6878 *FACTORY->NewError("cyclic_proto", HandleVector<Object>(NULL, 0))); 6894 *FACTORY->NewError("cyclic_proto", HandleVector<Object>(NULL, 0)));
(...skipping 3408 matching lines...) Expand 10 before | Expand all | Expand 10 after
10287 if (break_point_objects()->IsUndefined()) return 0; 10303 if (break_point_objects()->IsUndefined()) return 0;
10288 // Single beak point. 10304 // Single beak point.
10289 if (!break_point_objects()->IsFixedArray()) return 1; 10305 if (!break_point_objects()->IsFixedArray()) return 1;
10290 // Multiple break points. 10306 // Multiple break points.
10291 return FixedArray::cast(break_point_objects())->length(); 10307 return FixedArray::cast(break_point_objects())->length();
10292 } 10308 }
10293 #endif 10309 #endif
10294 10310
10295 10311
10296 } } // namespace v8::internal 10312 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698