Commit 248adeb1 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Revert 10502 (smaller number string cache) due to test failures.

Review URL: https://chromiumcodereview.appspot.com/9113060

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10504 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 67d72eab
...@@ -902,7 +902,8 @@ void Heap::MarkCompactPrologue() { ...@@ -902,7 +902,8 @@ void Heap::MarkCompactPrologue() {
CompletelyClearInstanceofCache(); CompletelyClearInstanceofCache();
FlushNumberStringCache(); // TODO(1605) select heuristic for flushing NumberString cache with
// FlushNumberStringCache
if (FLAG_cleanup_code_caches_at_gc) { if (FLAG_cleanup_code_caches_at_gc) {
polymorphic_code_cache()->set_cache(undefined_value()); polymorphic_code_cache()->set_cache(undefined_value());
} }
...@@ -2511,10 +2512,7 @@ bool Heap::CreateInitialObjects() { ...@@ -2511,10 +2512,7 @@ bool Heap::CreateInitialObjects() {
} }
set_intrinsic_function_names(StringDictionary::cast(obj)); set_intrinsic_function_names(StringDictionary::cast(obj));
{ MaybeObject* maybe_obj = AllocateInitialNumberStringCache(); if (InitializeNumberStringCache()->IsFailure()) return false;
if (!maybe_obj->ToObject(&obj)) return false;
}
set_number_string_cache(FixedArray::cast(obj));
// Allocate cache for single character ASCII strings. // Allocate cache for single character ASCII strings.
{ MaybeObject* maybe_obj = { MaybeObject* maybe_obj =
...@@ -2624,41 +2622,17 @@ void StringSplitCache::Clear(FixedArray* cache) { ...@@ -2624,41 +2622,17 @@ void StringSplitCache::Clear(FixedArray* cache) {
} }
MaybeObject* Heap::AllocateInitialNumberStringCache() { MaybeObject* Heap::InitializeNumberStringCache() {
MaybeObject* maybe_obj = // Compute the size of the number string cache based on the max heap size.
AllocateFixedArray(kInitialNumberStringCacheSize * 2, TENURED); // max_semispace_size_ == 512 KB => number_string_cache_size = 32.
return maybe_obj; // max_semispace_size_ == 8 MB => number_string_cache_size = 16KB.
}
int Heap::FullSizeNumberStringCacheLength() {
// Compute the size of the number string cache based on the max newspace size.
// The number string cache has a minimum size based on twice the initial cache
// size to ensure that it is bigger after being made 'full size'.
int number_string_cache_size = max_semispace_size_ / 512; int number_string_cache_size = max_semispace_size_ / 512;
number_string_cache_size = Max(kInitialNumberStringCacheSize * 2, number_string_cache_size = Max(32, Min(16*KB, number_string_cache_size));
Min(0x4000, number_string_cache_size)); Object* obj;
// There is a string and a number per entry so the length is twice the number
// of entries.
return number_string_cache_size * 2;
}
void Heap::AllocateFullSizeNumberStringCache() {
// The idea is to have a small number string cache in the snapshot to keep
// boot-time memory usage down. If we expand the number string cache already
// while creating the snapshot then that didn't work out.
ASSERT(!Serializer::enabled());
MaybeObject* maybe_obj = MaybeObject* maybe_obj =
AllocateFixedArray(FullSizeNumberStringCacheLength(), TENURED); AllocateFixedArray(number_string_cache_size * 2, TENURED);
Object* new_cache; if (maybe_obj->ToObject(&obj)) set_number_string_cache(FixedArray::cast(obj));
if (maybe_obj->ToObject(&new_cache)) { return maybe_obj;
// We don't bother to repopulate the cache with entries from the old cache.
// It will be repopulated soon enough with new strings.
set_number_string_cache(FixedArray::cast(new_cache));
}
// If allocation fails then we just return without doing anything. It is only
// a cache, so best effort is OK here.
} }
...@@ -2707,17 +2681,11 @@ void Heap::SetNumberStringCache(Object* number, String* string) { ...@@ -2707,17 +2681,11 @@ void Heap::SetNumberStringCache(Object* number, String* string) {
int mask = (number_string_cache()->length() >> 1) - 1; int mask = (number_string_cache()->length() >> 1) - 1;
if (number->IsSmi()) { if (number->IsSmi()) {
hash = smi_get_hash(Smi::cast(number)) & mask; hash = smi_get_hash(Smi::cast(number)) & mask;
number_string_cache()->set(hash * 2, Smi::cast(number));
} else { } else {
hash = double_get_hash(number->Number()) & mask; hash = double_get_hash(number->Number()) & mask;
number_string_cache()->set(hash * 2, number);
} }
if (number_string_cache()->get(hash * 2) != undefined_value() &&
number_string_cache()->length() != FullSizeNumberStringCacheLength()) {
// The first time we have a hash collision, we move to the full sized
// number string cache.
AllocateFullSizeNumberStringCache();
return;
}
number_string_cache()->set(hash * 2, number);
number_string_cache()->set(hash * 2 + 1, string); number_string_cache()->set(hash * 2 + 1, string);
} }
......
...@@ -1798,13 +1798,8 @@ class Heap { ...@@ -1798,13 +1798,8 @@ class Heap {
GCTracer* tracer_; GCTracer* tracer_;
// Allocates a small number to string cache. // Initializes the number to string cache based on the max semispace size.
MUST_USE_RESULT MaybeObject* AllocateInitialNumberStringCache(); MUST_USE_RESULT MaybeObject* InitializeNumberStringCache();
// Creates and installs the full-sized number string cache.
void AllocateFullSizeNumberStringCache();
// Get the length of the number to string cache based on the max semispace
// size.
int FullSizeNumberStringCacheLength();
// Flush the number to string cache. // Flush the number to string cache.
void FlushNumberStringCache(); void FlushNumberStringCache();
...@@ -1901,7 +1896,6 @@ class Heap { ...@@ -1901,7 +1896,6 @@ class Heap {
static const int kInitialSymbolTableSize = 2048; static const int kInitialSymbolTableSize = 2048;
static const int kInitialEvalCacheSize = 64; static const int kInitialEvalCacheSize = 64;
static const int kInitialNumberStringCacheSize = 256;
// Maximum GC pause. // Maximum GC pause.
int max_gc_pause_; int max_gc_pause_;
......
...@@ -540,7 +540,7 @@ TEST(BootUpMemoryUse) { ...@@ -540,7 +540,7 @@ TEST(BootUpMemoryUse) {
} }
} else { } else {
if (v8::internal::Snapshot::IsEnabled()) { if (v8::internal::Snapshot::IsEnabled()) {
CHECK_LE(booted_memory - initial_memory, 6500 * 1024); // 6356. CHECK_LE(booted_memory - initial_memory, 6500 * 1024); // 6365.
} else { } else {
CHECK_LE(booted_memory - initial_memory, 6654 * 1024); // 6424 CHECK_LE(booted_memory - initial_memory, 6654 * 1024); // 6424
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment