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

Side by Side Diff: src/objects.cc

Issue 660373: - Changed the growth policy for hash tables to reduce the wasted memory.... (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 | « no previous file | 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 6927 matching lines...) Expand 10 before | Expand all | Expand 10 after
6938 return kNotFound; 6938 return kNotFound;
6939 } 6939 }
6940 6940
6941 6941
6942 template<typename Shape, typename Key> 6942 template<typename Shape, typename Key>
6943 Object* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) { 6943 Object* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) {
6944 int capacity = Capacity(); 6944 int capacity = Capacity();
6945 int nof = NumberOfElements() + n; 6945 int nof = NumberOfElements() + n;
6946 int nod = NumberOfDeletedElements(); 6946 int nod = NumberOfDeletedElements();
6947 // Return if: 6947 // Return if:
6948 // 50% is still free after adding n elements and 6948 // 25% is still free after adding n elements and
6949 // at most 50% of the free elements are deleted elements. 6949 // at most 50% of the free elements are deleted elements.
6950 if ((nof + (nof >> 1) <= capacity) && 6950 if ((nof + (nof >> 2) <= capacity) &&
6951 (nod <= (capacity - nof) >> 1)) return this; 6951 (nod <= (capacity - nof) >> 1)) return this;
6952 6952
6953 Object* obj = Allocate(nof * 2); 6953 Object* obj = Allocate(nof * 2);
6954 if (obj->IsFailure()) return obj; 6954 if (obj->IsFailure()) return obj;
6955 6955
6956 AssertNoAllocation no_gc; 6956 AssertNoAllocation no_gc;
6957 HashTable* table = HashTable::cast(obj); 6957 HashTable* table = HashTable::cast(obj);
6958 WriteBarrierMode mode = table->GetWriteBarrierMode(no_gc); 6958 WriteBarrierMode mode = table->GetWriteBarrierMode(no_gc);
6959 6959
6960 // Copy prefix to new array. 6960 // Copy prefix to new array.
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
8362 if (break_point_objects()->IsUndefined()) return 0; 8362 if (break_point_objects()->IsUndefined()) return 0;
8363 // Single beak point. 8363 // Single beak point.
8364 if (!break_point_objects()->IsFixedArray()) return 1; 8364 if (!break_point_objects()->IsFixedArray()) return 1;
8365 // Multiple break points. 8365 // Multiple break points.
8366 return FixedArray::cast(break_point_objects())->length(); 8366 return FixedArray::cast(break_point_objects())->length();
8367 } 8367 }
8368 #endif 8368 #endif
8369 8369
8370 8370
8371 } } // namespace v8::internal 8371 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698