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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 7212 matching lines...) Expand 10 before | Expand all | Expand 10 after
7223 7223
7224 if (result <= static_cast<uint32_t>(Smi::kMaxValue)) { 7224 if (result <= static_cast<uint32_t>(Smi::kMaxValue)) {
7225 return Smi::FromInt(static_cast<int>(result)); 7225 return Smi::FromInt(static_cast<int>(result));
7226 } 7226 }
7227 ASSERT_NE(NULL, result_double); 7227 ASSERT_NE(NULL, result_double);
7228 result_double->set_value(static_cast<double>(result)); 7228 result_double->set_value(static_cast<double>(result));
7229 return result_double; 7229 return result_double;
7230 } 7230 }
7231 7231
7232 7232
7233 static bool CallbacksObjectHasSetter(Object* callbacks) {
7234 if (!callbacks->IsFixedArray()) {
7235 ASSERT(callbacks->IsAccessorInfo() || callbacks->IsProxy());
7236 return true;
7237 } else {
7238 Object* setter = (FixedArray::cast(callbacks))->get(kSetterIndex);
7239 if (setter->IsJSFunction()) {
7240 return true;
7241 }
7242 }
7243
7244 return false;
7245 }
7246
7247
7248 bool JSObject::HasSetter() {
7249 for (Object* obj = this;
7250 obj != Heap::null_value();
7251 obj = JSObject::cast(obj)->GetPrototype()) {
7252 JSObject* js_object = JSObject::cast(obj);
7253 if (js_object->HasFastProperties()) {
7254 DescriptorArray* descs = js_object->map()->instance_descriptors();
7255 for (int i = 0; i < descs->number_of_descriptors(); i++) {
7256 PropertyDetails details = descs->GetDetails(i);
7257 if (details.type() == CALLBACKS) {
7258 Object* callbacks = descs->GetCallbacksObject(i);
7259 if (CallbacksObjectHasSetter(callbacks)) {
7260 return true;
7261 }
7262 }
7263 }
7264 } else {
7265 StringDictionary* dict = js_object->property_dictionary();
7266 int capacity = dict->Capacity();
7267 for (int i = 0; i < capacity; i++) {
7268 Object* k = dict->KeyAt(i);
7269 if (dict->IsKey(k)) {
7270 PropertyType type = dict->DetailsAt(i).type();
7271 ASSERT(type != FIELD);
7272 if (type == CALLBACKS) {
7273 Object* callbacks = dict->ValueAt(i);
7274 if (CallbacksObjectHasSetter(callbacks)) {
7275 return true;
7276 }
7277 }
7278 }
7279 }
7280 }
7281 }
7282
7283 return false;
7284 }
7285
7286
7287
7233 Object* PixelArray::SetValue(uint32_t index, Object* value) { 7288 Object* PixelArray::SetValue(uint32_t index, Object* value) {
7234 uint8_t clamped_value = 0; 7289 uint8_t clamped_value = 0;
7235 if (index < static_cast<uint32_t>(length())) { 7290 if (index < static_cast<uint32_t>(length())) {
7236 if (value->IsSmi()) { 7291 if (value->IsSmi()) {
7237 int int_value = Smi::cast(value)->value(); 7292 int int_value = Smi::cast(value)->value();
7238 if (int_value < 0) { 7293 if (int_value < 0) {
7239 clamped_value = 0; 7294 clamped_value = 0;
7240 } else if (int_value > 255) { 7295 } else if (int_value > 255) {
7241 clamped_value = 255; 7296 clamped_value = 255;
7242 } else { 7297 } else {
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
8342 if (break_point_objects()->IsUndefined()) return 0; 8397 if (break_point_objects()->IsUndefined()) return 0;
8343 // Single beak point. 8398 // Single beak point.
8344 if (!break_point_objects()->IsFixedArray()) return 1; 8399 if (!break_point_objects()->IsFixedArray()) return 1;
8345 // Multiple break points. 8400 // Multiple break points.
8346 return FixedArray::cast(break_point_objects())->length(); 8401 return FixedArray::cast(break_point_objects())->length();
8347 } 8402 }
8348 #endif 8403 #endif
8349 8404
8350 8405
8351 } } // namespace v8::internal 8406 } } // namespace v8::internal
OLDNEW
« 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