- Increased size of number string cache.
- Change the instruction order for inlined allocation. Review URL: http://codereview.chromium.org/501170 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3514 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
6ca5876419
commit
6742d62c30
25
src/heap.cc
25
src/heap.cc
@ -1577,6 +1577,7 @@ bool Heap::CreateInitialObjects() {
|
||||
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));
|
||||
@ -1610,25 +1611,29 @@ bool Heap::CreateInitialObjects() {
|
||||
}
|
||||
|
||||
|
||||
static inline int double_get_hash(double d) {
|
||||
static inline int NumberStringTruncateHash(int value) {
|
||||
return (((value >> 16) ^ value)) & (Heap::kNumberStringCacheSize - 1);
|
||||
}
|
||||
|
||||
|
||||
static inline int DoubleGetHash(double d) {
|
||||
DoubleRepresentation rep(d);
|
||||
return ((static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) &
|
||||
(Heap::kNumberStringCacheSize - 1));
|
||||
int value = (static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32));
|
||||
return NumberStringTruncateHash(value);
|
||||
}
|
||||
|
||||
|
||||
static inline int smi_get_hash(Smi* smi) {
|
||||
return (smi->value() & (Heap::kNumberStringCacheSize - 1));
|
||||
static inline int SmiGetHash(Smi* smi) {
|
||||
return NumberStringTruncateHash(smi->value());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Object* Heap::GetNumberStringCache(Object* number) {
|
||||
int hash;
|
||||
if (number->IsSmi()) {
|
||||
hash = smi_get_hash(Smi::cast(number));
|
||||
hash = SmiGetHash(Smi::cast(number));
|
||||
} else {
|
||||
hash = double_get_hash(number->Number());
|
||||
hash = DoubleGetHash(number->Number());
|
||||
}
|
||||
Object* key = number_string_cache()->get(hash * 2);
|
||||
if (key == number) {
|
||||
@ -1645,10 +1650,10 @@ Object* Heap::GetNumberStringCache(Object* number) {
|
||||
void Heap::SetNumberStringCache(Object* number, String* string) {
|
||||
int hash;
|
||||
if (number->IsSmi()) {
|
||||
hash = smi_get_hash(Smi::cast(number));
|
||||
hash = SmiGetHash(Smi::cast(number));
|
||||
number_string_cache()->set(hash * 2, number, SKIP_WRITE_BARRIER);
|
||||
} else {
|
||||
hash = double_get_hash(number->Number());
|
||||
hash = DoubleGetHash(number->Number());
|
||||
number_string_cache()->set(hash * 2, number);
|
||||
}
|
||||
number_string_cache()->set(hash * 2 + 1, string);
|
||||
|
@ -821,7 +821,7 @@ class Heap : public AllStatic {
|
||||
static void SetNumberStringCache(Object* number, String* str);
|
||||
|
||||
// Entries in the cache. Must be a power of 2.
|
||||
static const int kNumberStringCacheSize = 64;
|
||||
static const int kNumberStringCacheSize = 16*KB;
|
||||
|
||||
// Adjusts the amount of registered external memory.
|
||||
// Returns the adjusted value.
|
||||
|
@ -729,13 +729,13 @@ void MacroAssembler::AllocateInNewSpace(int object_size,
|
||||
cmp(result_end, Operand::StaticVariable(new_space_allocation_limit));
|
||||
j(above, gc_required, not_taken);
|
||||
|
||||
// Update allocation top.
|
||||
UpdateAllocationTopHelper(result_end, scratch);
|
||||
|
||||
// Tag result if requested.
|
||||
if ((flags & TAG_OBJECT) != 0) {
|
||||
or_(Operand(result), Immediate(kHeapObjectTag));
|
||||
}
|
||||
|
||||
// Update allocation top.
|
||||
UpdateAllocationTopHelper(result_end, scratch);
|
||||
}
|
||||
|
||||
|
||||
@ -759,13 +759,14 @@ void MacroAssembler::AllocateInNewSpace(int header_size,
|
||||
cmp(result_end, Operand::StaticVariable(new_space_allocation_limit));
|
||||
j(above, gc_required);
|
||||
|
||||
// Update allocation top.
|
||||
UpdateAllocationTopHelper(result_end, scratch);
|
||||
|
||||
// Tag result if requested.
|
||||
if ((flags & TAG_OBJECT) != 0) {
|
||||
or_(Operand(result), Immediate(kHeapObjectTag));
|
||||
}
|
||||
|
||||
// Update allocation top.
|
||||
UpdateAllocationTopHelper(result_end, scratch);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -790,13 +791,13 @@ void MacroAssembler::AllocateInNewSpace(Register object_size,
|
||||
cmp(result_end, Operand::StaticVariable(new_space_allocation_limit));
|
||||
j(above, gc_required, not_taken);
|
||||
|
||||
// Update allocation top.
|
||||
UpdateAllocationTopHelper(result_end, scratch);
|
||||
|
||||
// Tag result if requested.
|
||||
if ((flags & TAG_OBJECT) != 0) {
|
||||
or_(Operand(result), Immediate(kHeapObjectTag));
|
||||
}
|
||||
|
||||
// Update allocation top.
|
||||
UpdateAllocationTopHelper(result_end, scratch);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user