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/objects.cc

Issue 8951013: Remove bogus writability check in DefineGetterSetter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 9 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 | 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 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 4239 matching lines...) Expand 10 before | Expand all | Expand 10 after
4250 current != heap->null_value() && current->IsJSObject(); 4250 current != heap->null_value() && current->IsJSObject();
4251 current = JSObject::cast(current)->GetPrototype()) { 4251 current = JSObject::cast(current)->GetPrototype()) {
4252 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); 4252 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result);
4253 if (result->IsProperty() && result->type() == CALLBACKS) return; 4253 if (result->IsProperty() && result->type() == CALLBACKS) return;
4254 } 4254 }
4255 result->NotFound(); 4255 result->NotFound();
4256 } 4256 }
4257 4257
4258 4258
4259 // Search for a getter or setter in an elements dictionary and update its 4259 // Search for a getter or setter in an elements dictionary and update its
4260 // attributes. Returns either undefined if the element is read-only, or the 4260 // attributes. Returns either undefined if the element is non-deletable, or
4261 // getter/setter pair (fixed array) if there is an existing one, or the hole 4261 // the getter/setter pair (fixed array) if there is an existing one, or the
4262 // value if the element does not exist or is a normal non-getter/setter data 4262 // hole value if the element does not exist or is a normal non-getter/setter
4263 // element. 4263 // data element.
4264 static Object* UpdateGetterSetterInDictionary(NumberDictionary* dictionary, 4264 static Object* UpdateGetterSetterInDictionary(NumberDictionary* dictionary,
4265 uint32_t index, 4265 uint32_t index,
4266 PropertyAttributes attributes, 4266 PropertyAttributes attributes,
4267 Heap* heap) { 4267 Heap* heap) {
4268 int entry = dictionary->FindEntry(index); 4268 int entry = dictionary->FindEntry(index);
4269 if (entry != NumberDictionary::kNotFound) { 4269 if (entry != NumberDictionary::kNotFound) {
4270 Object* result = dictionary->ValueAt(entry); 4270 Object* result = dictionary->ValueAt(entry);
4271 PropertyDetails details = dictionary->DetailsAt(entry); 4271 PropertyDetails details = dictionary->DetailsAt(entry);
4272 if (details.IsReadOnly()) return heap->undefined_value(); 4272 // TODO(mstarzinger): We should check for details.IsDontDelete() here once
4273 // we only call into the runtime once to set both getter and setter.
4273 if (details.type() == CALLBACKS && result->IsFixedArray()) { 4274 if (details.type() == CALLBACKS && result->IsFixedArray()) {
4274 if (details.attributes() != attributes) { 4275 if (details.attributes() != attributes) {
4275 dictionary->DetailsAtPut(entry, 4276 dictionary->DetailsAtPut(entry,
4276 PropertyDetails(attributes, CALLBACKS, index)); 4277 PropertyDetails(attributes, CALLBACKS, index));
4277 } 4278 }
4278 return result; 4279 return result;
4279 } 4280 }
4280 } 4281 }
4281 return heap->the_hole_value(); 4282 return heap->the_hole_value();
4282 } 4283 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4346 } 4347 }
4347 } 4348 }
4348 break; 4349 break;
4349 } 4350 }
4350 } 4351 }
4351 } else { 4352 } else {
4352 // Lookup the name. 4353 // Lookup the name.
4353 LookupResult result(heap->isolate()); 4354 LookupResult result(heap->isolate());
4354 LocalLookup(name, &result); 4355 LocalLookup(name, &result);
4355 if (result.IsProperty()) { 4356 if (result.IsProperty()) {
4356 if (result.IsReadOnly()) return heap->undefined_value(); 4357 // TODO(mstarzinger): We should check for result.IsDontDelete() here once
4358 // we only call into the runtime once to set both getter and setter.
4357 if (result.type() == CALLBACKS) { 4359 if (result.type() == CALLBACKS) {
4358 Object* obj = result.GetCallbackObject(); 4360 Object* obj = result.GetCallbackObject();
4359 // Need to preserve old getters/setters. 4361 // Need to preserve old getters/setters.
4360 if (obj->IsFixedArray()) { 4362 if (obj->IsFixedArray()) {
4361 // Use set to update attributes. 4363 // Use set to update attributes.
4362 return SetPropertyCallback(name, obj, attributes); 4364 return SetPropertyCallback(name, obj, attributes);
4363 } 4365 }
4364 } 4366 }
4365 } 4367 }
4366 } 4368 }
(...skipping 8185 matching lines...) Expand 10 before | Expand all | Expand 10 after
12552 if (break_point_objects()->IsUndefined()) return 0; 12554 if (break_point_objects()->IsUndefined()) return 0;
12553 // Single break point. 12555 // Single break point.
12554 if (!break_point_objects()->IsFixedArray()) return 1; 12556 if (!break_point_objects()->IsFixedArray()) return 1;
12555 // Multiple break points. 12557 // Multiple break points.
12556 return FixedArray::cast(break_point_objects())->length(); 12558 return FixedArray::cast(break_point_objects())->length();
12557 } 12559 }
12558 #endif // ENABLE_DEBUGGER_SUPPORT 12560 #endif // ENABLE_DEBUGGER_SUPPORT
12559 12561
12560 12562
12561 } } // namespace v8::internal 12563 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698