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

Unified Diff: src/objects.cc

Issue 606062: Fix construction of simple objects with setters on prototype... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 3877)
+++ src/objects.cc (working copy)
@@ -7230,6 +7230,61 @@
}
+static bool CallbacksObjectHasSetter(Object* callbacks) {
+ if (!callbacks->IsFixedArray()) {
+ ASSERT(callbacks->IsAccessorInfo() || callbacks->IsProxy());
+ return true;
+ } else {
+ Object* setter = (FixedArray::cast(callbacks))->get(kSetterIndex);
+ if (setter->IsJSFunction()) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+bool JSObject::HasSetter() {
+ for (Object* obj = this;
+ obj != Heap::null_value();
+ obj = JSObject::cast(obj)->GetPrototype()) {
+ JSObject* js_object = JSObject::cast(obj);
+ if (js_object->HasFastProperties()) {
+ DescriptorArray* descs = js_object->map()->instance_descriptors();
+ for (int i = 0; i < descs->number_of_descriptors(); i++) {
+ PropertyDetails details = descs->GetDetails(i);
+ if (details.type() == CALLBACKS) {
+ Object* callbacks = descs->GetCallbacksObject(i);
+ if (CallbacksObjectHasSetter(callbacks)) {
+ return true;
+ }
+ }
+ }
+ } else {
+ StringDictionary* dict = js_object->property_dictionary();
+ int capacity = dict->Capacity();
+ for (int i = 0; i < capacity; i++) {
+ Object* k = dict->KeyAt(i);
+ if (dict->IsKey(k)) {
+ PropertyType type = dict->DetailsAt(i).type();
+ ASSERT(type != FIELD);
+ if (type == CALLBACKS) {
+ Object* callbacks = dict->ValueAt(i);
+ if (CallbacksObjectHasSetter(callbacks)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+
+
Object* PixelArray::SetValue(uint32_t index, Object* value) {
uint8_t clamped_value = 0;
if (index < static_cast<uint32_t>(length())) {
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698