Revision: 3517
Author: [email protected]
Date: Tue Dec 22 05:07:27 2009
Log: Revert r3514 and r3515.  The new cache is too large for some tests
that attempt to run with a small heap.  Additionally, it can
potentially keep a lot of string data alive and it is never flushed.
Can we make it grow dynamically if used so that we can still start the
VM with a small heap size?
Review URL: http://codereview.chromium.org/503081
http://code.google.com/p/v8/source/detail?r=3517

Modified:
  /branches/bleeding_edge/src/heap.cc
  /branches/bleeding_edge/src/heap.h
  /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc

=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Dec 22 03:35:05 2009
+++ /branches/bleeding_edge/src/heap.cc Tue Dec 22 05:07:27 2009
@@ -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);
=======================================
--- /branches/bleeding_edge/src/heap.h  Tue Dec 22 03:35:05 2009
+++ /branches/bleeding_edge/src/heap.h  Tue Dec 22 05:07:27 2009
@@ -821,7 +821,7 @@
    static void SetNumberStringCache(Object* number, String* str);

    // Entries in the cache.  Must be a power of 2.
-  static const int kNumberStringCacheSize = 16*KB;
+  static const int kNumberStringCacheSize = 64;

    // Adjusts the amount of registered external memory.
    // Returns the adjusted value.
=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc    Tue Dec 22  
04:39:56 2009
+++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc    Tue Dec 22  
05:07:27 2009
@@ -729,13 +729,13 @@
    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,13 @@
    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 +790,13 @@
    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);
  }


-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to