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

Side by Side Diff: bleeding_edge/src/objects.cc

Issue 506037: Improve performance of allocating closures for nested... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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
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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 map()->set_instance_descriptors(old_descriptors); 1344 map()->set_instance_descriptors(old_descriptors);
1345 new_map->set_instance_descriptors(DescriptorArray::cast(new_descriptors)); 1345 new_map->set_instance_descriptors(DescriptorArray::cast(new_descriptors));
1346 set_map(new_map); 1346 set_map(new_map);
1347 return FastPropertyAtPut(index, value); 1347 return FastPropertyAtPut(index, value);
1348 } 1348 }
1349 1349
1350 1350
1351 Object* JSObject::AddConstantFunctionProperty(String* name, 1351 Object* JSObject::AddConstantFunctionProperty(String* name,
1352 JSFunction* function, 1352 JSFunction* function,
1353 PropertyAttributes attributes) { 1353 PropertyAttributes attributes) {
1354 ASSERT(!Heap::InNewSpace(function));
1355
1354 // Allocate new instance descriptors with (name, function) added 1356 // Allocate new instance descriptors with (name, function) added
1355 ConstantFunctionDescriptor d(name, function, attributes); 1357 ConstantFunctionDescriptor d(name, function, attributes);
1356 Object* new_descriptors = 1358 Object* new_descriptors =
1357 map()->instance_descriptors()->CopyInsert(&d, REMOVE_TRANSITIONS); 1359 map()->instance_descriptors()->CopyInsert(&d, REMOVE_TRANSITIONS);
1358 if (new_descriptors->IsFailure()) return new_descriptors; 1360 if (new_descriptors->IsFailure()) return new_descriptors;
1359 1361
1360 // Allocate a new map for the object. 1362 // Allocate a new map for the object.
1361 Object* new_map = map()->CopyDropDescriptors(); 1363 Object* new_map = map()->CopyDropDescriptors();
1362 if (new_map->IsFailure()) return new_map; 1364 if (new_map->IsFailure()) return new_map;
1363 1365
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 1432
1431 1433
1432 Object* JSObject::AddProperty(String* name, 1434 Object* JSObject::AddProperty(String* name,
1433 Object* value, 1435 Object* value,
1434 PropertyAttributes attributes) { 1436 PropertyAttributes attributes) {
1435 ASSERT(!IsJSGlobalProxy()); 1437 ASSERT(!IsJSGlobalProxy());
1436 if (HasFastProperties()) { 1438 if (HasFastProperties()) {
1437 // Ensure the descriptor array does not get too big. 1439 // Ensure the descriptor array does not get too big.
1438 if (map()->instance_descriptors()->number_of_descriptors() < 1440 if (map()->instance_descriptors()->number_of_descriptors() <
1439 DescriptorArray::kMaxNumberOfDescriptors) { 1441 DescriptorArray::kMaxNumberOfDescriptors) {
1440 if (value->IsJSFunction()) { 1442 if (value->IsJSFunction() && !Heap::InNewSpace(value)) {
1441 return AddConstantFunctionProperty(name, 1443 return AddConstantFunctionProperty(name,
1442 JSFunction::cast(value), 1444 JSFunction::cast(value),
1443 attributes); 1445 attributes);
1444 } else { 1446 } else {
1445 return AddFastProperty(name, value, attributes); 1447 return AddFastProperty(name, value, attributes);
1446 } 1448 }
1447 } else { 1449 } else {
1448 // Normalize the object to prevent very large instance descriptors. 1450 // Normalize the object to prevent very large instance descriptors.
1449 // This eliminates unwanted N^2 allocation and lookup behavior. 1451 // This eliminates unwanted N^2 allocation and lookup behavior.
1450 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 1452 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 return true; 3249 return true;
3248 } 3250 }
3249 #endif 3251 #endif
3250 3252
3251 3253
3252 Object* DescriptorArray::Allocate(int number_of_descriptors) { 3254 Object* DescriptorArray::Allocate(int number_of_descriptors) {
3253 if (number_of_descriptors == 0) { 3255 if (number_of_descriptors == 0) {
3254 return Heap::empty_descriptor_array(); 3256 return Heap::empty_descriptor_array();
3255 } 3257 }
3256 // Allocate the array of keys. 3258 // Allocate the array of keys.
3257 Object* array = Heap::AllocateFixedArray(ToKeyIndex(number_of_descriptors)); 3259 Object* array =
3260 Heap::AllocateFixedArray(ToKeyIndex(number_of_descriptors));
3258 if (array->IsFailure()) return array; 3261 if (array->IsFailure()) return array;
3259 // Do not use DescriptorArray::cast on incomplete object. 3262 // Do not use DescriptorArray::cast on incomplete object.
3260 FixedArray* result = FixedArray::cast(array); 3263 FixedArray* result = FixedArray::cast(array);
3261 3264
3262 // Allocate the content array and set it in the descriptor array. 3265 // Allocate the content array and set it in the descriptor array.
3263 array = Heap::AllocateFixedArray(number_of_descriptors << 1); 3266 array = Heap::AllocateFixedArray(number_of_descriptors << 1);
3264 if (array->IsFailure()) return array; 3267 if (array->IsFailure()) return array;
3265 result->set(kContentArrayIndex, array); 3268 result->set(kContentArrayIndex, array);
3266 result->set(kEnumerationIndexIndex, 3269 result->set(kEnumerationIndexIndex,
3267 Smi::FromInt(PropertyDetails::kInitialIndex), 3270 Smi::FromInt(PropertyDetails::kInitialIndex),
(...skipping 4687 matching lines...) Expand 10 before | Expand all | Expand 10 after
7955 7958
7956 // Compute the length of the instance descriptor. 7959 // Compute the length of the instance descriptor.
7957 int capacity = Capacity(); 7960 int capacity = Capacity();
7958 for (int i = 0; i < capacity; i++) { 7961 for (int i = 0; i < capacity; i++) {
7959 Object* k = KeyAt(i); 7962 Object* k = KeyAt(i);
7960 if (IsKey(k)) { 7963 if (IsKey(k)) {
7961 Object* value = ValueAt(i); 7964 Object* value = ValueAt(i);
7962 PropertyType type = DetailsAt(i).type(); 7965 PropertyType type = DetailsAt(i).type();
7963 ASSERT(type != FIELD); 7966 ASSERT(type != FIELD);
7964 instance_descriptor_length++; 7967 instance_descriptor_length++;
7965 if (type == NORMAL && !value->IsJSFunction()) number_of_fields += 1; 7968 if (type == NORMAL &&
7969 (!value->IsJSFunction() || Heap::InNewSpace(value))) {
7970 number_of_fields += 1;
7971 }
7966 } 7972 }
7967 } 7973 }
7968 7974
7969 // Allocate the instance descriptor. 7975 // Allocate the instance descriptor.
7970 Object* descriptors_unchecked = 7976 Object* descriptors_unchecked =
7971 DescriptorArray::Allocate(instance_descriptor_length); 7977 DescriptorArray::Allocate(instance_descriptor_length);
7972 if (descriptors_unchecked->IsFailure()) return descriptors_unchecked; 7978 if (descriptors_unchecked->IsFailure()) return descriptors_unchecked;
7973 DescriptorArray* descriptors = DescriptorArray::cast(descriptors_unchecked); 7979 DescriptorArray* descriptors = DescriptorArray::cast(descriptors_unchecked);
7974 7980
7975 int inobject_props = obj->map()->inobject_properties(); 7981 int inobject_props = obj->map()->inobject_properties();
(...skipping 10 matching lines...) Expand all
7986 for (int i = 0; i < capacity; i++) { 7992 for (int i = 0; i < capacity; i++) {
7987 Object* k = KeyAt(i); 7993 Object* k = KeyAt(i);
7988 if (IsKey(k)) { 7994 if (IsKey(k)) {
7989 Object* value = ValueAt(i); 7995 Object* value = ValueAt(i);
7990 // Ensure the key is a symbol before writing into the instance descriptor. 7996 // Ensure the key is a symbol before writing into the instance descriptor.
7991 Object* key = Heap::LookupSymbol(String::cast(k)); 7997 Object* key = Heap::LookupSymbol(String::cast(k));
7992 if (key->IsFailure()) return key; 7998 if (key->IsFailure()) return key;
7993 PropertyDetails details = DetailsAt(i); 7999 PropertyDetails details = DetailsAt(i);
7994 PropertyType type = details.type(); 8000 PropertyType type = details.type();
7995 8001
7996 if (value->IsJSFunction()) { 8002 if (value->IsJSFunction() && !Heap::InNewSpace(value)) {
7997 ConstantFunctionDescriptor d(String::cast(key), 8003 ConstantFunctionDescriptor d(String::cast(key),
7998 JSFunction::cast(value), 8004 JSFunction::cast(value),
7999 details.attributes(), 8005 details.attributes(),
8000 details.index()); 8006 details.index());
8001 descriptors->Set(next_descriptor++, &d); 8007 descriptors->Set(next_descriptor++, &d);
8002 } else if (type == NORMAL) { 8008 } else if (type == NORMAL) {
8003 if (current_offset < inobject_props) { 8009 if (current_offset < inobject_props) {
8004 obj->InObjectPropertyAtPut(current_offset, 8010 obj->InObjectPropertyAtPut(current_offset,
8005 value, 8011 value,
8006 UPDATE_WRITE_BARRIER); 8012 UPDATE_WRITE_BARRIER);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
8288 if (break_point_objects()->IsUndefined()) return 0; 8294 if (break_point_objects()->IsUndefined()) return 0;
8289 // Single beak point. 8295 // Single beak point.
8290 if (!break_point_objects()->IsFixedArray()) return 1; 8296 if (!break_point_objects()->IsFixedArray()) return 1;
8291 // Multiple break points. 8297 // Multiple break points.
8292 return FixedArray::cast(break_point_objects())->length(); 8298 return FixedArray::cast(break_point_objects())->length();
8293 } 8299 }
8294 #endif 8300 #endif
8295 8301
8296 8302
8297 } } // namespace v8::internal 8303 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698