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

Unified Diff: src/heap.cc

Issue 503081: Revert r3514 and r3515. The new cache is too large for some tests... (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap.h ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 3516)
+++ src/heap.cc (working copy)
@@ -1577,7 +1577,6 @@
CreateFixedStubs();
// Allocate the number->string conversion cache
- ASSERT(IsPowerOf2(kNumberStringCacheSize));
obj = AllocateFixedArray(kNumberStringCacheSize * 2);
if (obj->IsFailure()) return false;
set_number_string_cache(FixedArray::cast(obj));
@@ -1611,29 +1610,25 @@
}
-static inline int NumberStringTruncateHash(int value) {
- return (((value >> 16) ^ value)) & (Heap::kNumberStringCacheSize - 1);
-}
-
-
-static inline int DoubleGetHash(double d) {
+static inline int double_get_hash(double d) {
DoubleRepresentation rep(d);
- int value = (static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32));
- return NumberStringTruncateHash(value);
+ return ((static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) &
+ (Heap::kNumberStringCacheSize - 1));
}
-static inline int SmiGetHash(Smi* smi) {
- return NumberStringTruncateHash(smi->value());
+static inline int smi_get_hash(Smi* smi) {
+ return (smi->value() & (Heap::kNumberStringCacheSize - 1));
}
+
Object* Heap::GetNumberStringCache(Object* number) {
int hash;
if (number->IsSmi()) {
- hash = SmiGetHash(Smi::cast(number));
+ hash = smi_get_hash(Smi::cast(number));
} else {
- hash = DoubleGetHash(number->Number());
+ hash = double_get_hash(number->Number());
}
Object* key = number_string_cache()->get(hash * 2);
if (key == number) {
@@ -1650,10 +1645,10 @@
void Heap::SetNumberStringCache(Object* number, String* string) {
int hash;
if (number->IsSmi()) {
- hash = SmiGetHash(Smi::cast(number));
+ hash = smi_get_hash(Smi::cast(number));
number_string_cache()->set(hash * 2, number, SKIP_WRITE_BARRIER);
} else {
- hash = DoubleGetHash(number->Number());
+ hash = double_get_hash(number->Number());
number_string_cache()->set(hash * 2, number);
}
number_string_cache()->set(hash * 2 + 1, string);
« no previous file with comments | « src/heap.h ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698