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

Side by Side Diff: src/objects.cc

Issue 669057: - Fixed the compilation cache so Put works.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 9 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/compilation-cache.cc ('k') | no next file » | 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 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 ASSERT(!IsGlobalObject()); 2173 ASSERT(!IsGlobalObject());
2174 2174
2175 // Allocate new content. 2175 // Allocate new content.
2176 int property_count = map()->NumberOfDescribedProperties(); 2176 int property_count = map()->NumberOfDescribedProperties();
2177 if (expected_additional_properties > 0) { 2177 if (expected_additional_properties > 0) {
2178 property_count += expected_additional_properties; 2178 property_count += expected_additional_properties;
2179 } else { 2179 } else {
2180 property_count += 2; // Make space for two more properties. 2180 property_count += 2; // Make space for two more properties.
2181 } 2181 }
2182 Object* obj = 2182 Object* obj =
2183 StringDictionary::Allocate(property_count * 2); 2183 StringDictionary::Allocate(property_count);
2184 if (obj->IsFailure()) return obj; 2184 if (obj->IsFailure()) return obj;
2185 StringDictionary* dictionary = StringDictionary::cast(obj); 2185 StringDictionary* dictionary = StringDictionary::cast(obj);
2186 2186
2187 DescriptorArray* descs = map()->instance_descriptors(); 2187 DescriptorArray* descs = map()->instance_descriptors();
2188 for (int i = 0; i < descs->number_of_descriptors(); i++) { 2188 for (int i = 0; i < descs->number_of_descriptors(); i++) {
2189 PropertyDetails details = descs->GetDetails(i); 2189 PropertyDetails details = descs->GetDetails(i);
2190 switch (details.type()) { 2190 switch (details.type()) {
2191 case CONSTANT_FUNCTION: { 2191 case CONSTANT_FUNCTION: {
2192 PropertyDetails d = 2192 PropertyDetails d =
2193 PropertyDetails(details.attributes(), NORMAL, details.index()); 2193 PropertyDetails(details.attributes(), NORMAL, details.index());
(...skipping 4710 matching lines...) Expand 10 before | Expand all | Expand 10 after
6904 void HashTable<Shape, Key>::IterateElements(ObjectVisitor* v) { 6904 void HashTable<Shape, Key>::IterateElements(ObjectVisitor* v) {
6905 IteratePointers(v, 6905 IteratePointers(v,
6906 kElementsStartOffset, 6906 kElementsStartOffset,
6907 kHeaderSize + length() * kPointerSize); 6907 kHeaderSize + length() * kPointerSize);
6908 } 6908 }
6909 6909
6910 6910
6911 template<typename Shape, typename Key> 6911 template<typename Shape, typename Key>
6912 Object* HashTable<Shape, Key>::Allocate(int at_least_space_for, 6912 Object* HashTable<Shape, Key>::Allocate(int at_least_space_for,
6913 PretenureFlag pretenure) { 6913 PretenureFlag pretenure) {
6914 const int kMinCapacity = 32;
6914 int capacity = RoundUpToPowerOf2(at_least_space_for * 2); 6915 int capacity = RoundUpToPowerOf2(at_least_space_for * 2);
6915 if (capacity < 32) { 6916 if (capacity < kMinCapacity) {
6916 capacity = 32; // Guarantee min capacity. 6917 capacity = kMinCapacity; // Guarantee min capacity.
6917 } else if (capacity > HashTable::kMaxCapacity) { 6918 } else if (capacity > HashTable::kMaxCapacity) {
6918 return Failure::OutOfMemoryException(); 6919 return Failure::OutOfMemoryException();
6919 } 6920 }
6920 6921
6921 Object* obj = Heap::AllocateHashTable(EntryToIndex(capacity), pretenure); 6922 Object* obj = Heap::AllocateHashTable(EntryToIndex(capacity), pretenure);
6922 if (!obj->IsFailure()) { 6923 if (!obj->IsFailure()) {
6923 HashTable::cast(obj)->SetNumberOfElements(0); 6924 HashTable::cast(obj)->SetNumberOfElements(0);
6924 HashTable::cast(obj)->SetNumberOfDeletedElements(0); 6925 HashTable::cast(obj)->SetNumberOfDeletedElements(0);
6925 HashTable::cast(obj)->SetCapacity(capacity); 6926 HashTable::cast(obj)->SetCapacity(capacity);
6926 } 6927 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
7096 // elements. 7097 // elements.
7097 NumberDictionary* dict = element_dictionary(); 7098 NumberDictionary* dict = element_dictionary();
7098 HeapNumber* result_double = NULL; 7099 HeapNumber* result_double = NULL;
7099 if (limit > static_cast<uint32_t>(Smi::kMaxValue)) { 7100 if (limit > static_cast<uint32_t>(Smi::kMaxValue)) {
7100 // Allocate space for result before we start mutating the object. 7101 // Allocate space for result before we start mutating the object.
7101 Object* new_double = Heap::AllocateHeapNumber(0.0); 7102 Object* new_double = Heap::AllocateHeapNumber(0.0);
7102 if (new_double->IsFailure()) return new_double; 7103 if (new_double->IsFailure()) return new_double;
7103 result_double = HeapNumber::cast(new_double); 7104 result_double = HeapNumber::cast(new_double);
7104 } 7105 }
7105 7106
7106 int capacity = dict->Capacity(); 7107 Object* obj = NumberDictionary::Allocate(dict->NumberOfElements());
7107 Object* obj = NumberDictionary::Allocate(dict->Capacity());
7108 if (obj->IsFailure()) return obj; 7108 if (obj->IsFailure()) return obj;
7109 NumberDictionary* new_dict = NumberDictionary::cast(obj); 7109 NumberDictionary* new_dict = NumberDictionary::cast(obj);
7110 7110
7111 AssertNoAllocation no_alloc; 7111 AssertNoAllocation no_alloc;
7112 7112
7113 uint32_t pos = 0; 7113 uint32_t pos = 0;
7114 uint32_t undefs = 0; 7114 uint32_t undefs = 0;
7115 int capacity = dict->Capacity();
7115 for (int i = 0; i < capacity; i++) { 7116 for (int i = 0; i < capacity; i++) {
7116 Object* k = dict->KeyAt(i); 7117 Object* k = dict->KeyAt(i);
7117 if (dict->IsKey(k)) { 7118 if (dict->IsKey(k)) {
7118 ASSERT(k->IsNumber()); 7119 ASSERT(k->IsNumber());
7119 ASSERT(!k->IsSmi() || Smi::cast(k)->value() >= 0); 7120 ASSERT(!k->IsSmi() || Smi::cast(k)->value() >= 0);
7120 ASSERT(!k->IsHeapNumber() || HeapNumber::cast(k)->value() >= 0); 7121 ASSERT(!k->IsHeapNumber() || HeapNumber::cast(k)->value() >= 0);
7121 ASSERT(!k->IsHeapNumber() || HeapNumber::cast(k)->value() <= kMaxUInt32); 7122 ASSERT(!k->IsHeapNumber() || HeapNumber::cast(k)->value() <= kMaxUInt32);
7122 Object* value = dict->ValueAt(i); 7123 Object* value = dict->ValueAt(i);
7123 PropertyDetails details = dict->DetailsAt(i); 7124 PropertyDetails details = dict->DetailsAt(i);
7124 if (details.type() == CALLBACKS) { 7125 if (details.type() == CALLBACKS) {
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
8373 if (break_point_objects()->IsUndefined()) return 0; 8374 if (break_point_objects()->IsUndefined()) return 0;
8374 // Single beak point. 8375 // Single beak point.
8375 if (!break_point_objects()->IsFixedArray()) return 1; 8376 if (!break_point_objects()->IsFixedArray()) return 1;
8376 // Multiple break points. 8377 // Multiple break points.
8377 return FixedArray::cast(break_point_objects())->length(); 8378 return FixedArray::cast(break_point_objects())->length();
8378 } 8379 }
8379 #endif 8380 #endif
8380 8381
8381 8382
8382 } } // namespace v8::internal 8383 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compilation-cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698