Author: [EMAIL PROTECTED]
Date: Fri Oct 24 05:08:53 2008
New Revision: 589

Added:
    changes/[EMAIL PROTECTED]/joehler/
    changes/[EMAIL PROTECTED]/joehler/bleeding_edge/
       - copied from r588, /branches/bleeding_edge/
Modified:
    changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/factory.cc
    changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/heap.cc
    changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/ic-ia32.cc
    changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects-inl.h
    changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects.cc
    changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects.h
    changes/[EMAIL PROTECTED]/joehler/bleeding_edge/test/mjsunit/in.js

Log:
You can't use BinarySearch on an unsorted array and other
sillinesses found while trying to get rid of medium-sized strings.


Modified: changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/factory.cc
==============================================================================
--- /branches/bleeding_edge/src/factory.cc      (original)
+++ changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/factory.cc      Fri  
Oct 24 05:08:53 2008
@@ -524,7 +524,7 @@
      Handle<String> key =
          SymbolFromString(Handle<String>(String::cast(entry->name())));
      // Check if a descriptor with this name already exists before writing.
-    if (result->BinarySearch(*key, 0, descriptor_count - 1) ==
+    if (result->LinearSearch(*key, descriptor_count) ==
          DescriptorArray::kNotFound) {
        CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
        w.Write(&desc);

Modified: changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/heap.cc
==============================================================================
--- /branches/bleeding_edge/src/heap.cc (original)
+++ changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/heap.cc Fri Oct  
24 05:08:53 2008
@@ -1936,8 +1936,8 @@
    }

    if (map == short_sliced_string_map()) return short_sliced_symbol_map();
-  if (map == medium_sliced_string_map()) return short_sliced_symbol_map();
-  if (map == long_sliced_string_map()) return short_sliced_symbol_map();
+  if (map == medium_sliced_string_map()) return medium_sliced_symbol_map();
+  if (map == long_sliced_string_map()) return long_sliced_symbol_map();

    if (map == short_sliced_ascii_string_map()) {
      return short_sliced_ascii_symbol_map();

Modified: changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/ic-ia32.cc
==============================================================================
--- /branches/bleeding_edge/src/ic-ia32.cc      (original)
+++ changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/ic-ia32.cc      Fri  
Oct 24 05:08:53 2008
@@ -262,6 +262,11 @@
    __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1);
    __ ret(0);
    // Array index string: If short enough use cache in length/hash field  
(ebx).
+  // We assert that there are enough bits in an int32_t after the hash  
shift
+  // bits have been subtracted to allow space for the length and the cached
+  // array index.
+  ASSERT(String::kMaxCachedArrayIndexLength <
+             (1 << (32 - String::kShortLengthShift - String::kHashShift)));
    __ bind(&index_string);
    const int kLengthFieldLimit =
        (String::kMaxCachedArrayIndexLength + 1) <<  
String::kShortLengthShift;

Modified:  
changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects-inl.h
==============================================================================
--- /branches/bleeding_edge/src/objects-inl.h   (original)
+++ changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects-inl.h    
Fri Oct 24 05:08:53 2008
@@ -1130,10 +1130,7 @@
    // Fast case: do linear search for small arrays.
    const int kMaxElementsForLinearSearch = 8;
    if (name->IsSymbol() && nof < kMaxElementsForLinearSearch) {
-    for (int number = 0; number < nof; number++) {
-      if (name == GetKey(number)) return number;
-    }
-    return kNotFound;
+    return LinearSearch(name, nof);
    }

    // Slow case: perform binary search.

Modified: changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects.cc
==============================================================================
--- /branches/bleeding_edge/src/objects.cc      (original)
+++ changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects.cc      Fri  
Oct 24 05:08:53 2008
@@ -2877,6 +2877,14 @@
  }


+int DescriptorArray::LinearSearch(String* name, int len) {
+  for (int number = 0; number < len; number++) {
+    if (name->Equals(GetKey(number))) return number;
+  }
+  return kNotFound;
+}
+
+
  #ifdef DEBUG
  bool DescriptorArray::IsEqualTo(DescriptorArray* other) {
    if (IsEmpty()) return other->IsEmpty();

Modified: changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects.h
==============================================================================
--- /branches/bleeding_edge/src/objects.h       (original)
+++ changes/[EMAIL PROTECTED]/joehler/bleeding_edge/src/objects.h       Fri  
Oct 24 05:08:53 2008
@@ -1629,6 +1629,10 @@
    // with low=0 and high=2.
    int BinarySearch(String* name, int low, int high);

+  // Perform a linear search in the instance descriptors represented
+  // by this fixed array.  len is the number of descriptor indeces that are
+  // valid.  Does not require the descriptors to be sorted.
+  int LinearSearch(String* name, int len);

    // Allocates a DescriptorArray, but returns the singleton
    // empty descriptor array object if number_of_descriptors is 0.

Modified:  
changes/[EMAIL PROTECTED]/joehler/bleeding_edge/test/mjsunit/in.js
==============================================================================
--- /branches/bleeding_edge/test/mjsunit/in.js  (original)
+++ changes/[EMAIL PROTECTED]/joehler/bleeding_edge/test/mjsunit/in.js   
Fri Oct 24 05:08:53 2008
@@ -81,18 +81,12 @@
  assertFalse(Infinity in a);
  assertFalse(-Infinity in a);

-/*****
- * NOTE: Two of the tests below are disabled due to a bug in V8.
- * Fast case (non-dictionary) sparse arrays do not work as advertised.
- *
- */
-
  var a = [];
  a[1] = 2;
-//assertFalse(0 in a);
+assertFalse(0 in a);
  assertTrue(1 in a);
  assertFalse(2 in a);
-//assertFalse('0' in a);
+assertFalse('0' in a);
  assertTrue('1' in a);
  assertFalse('2' in a);
  assertTrue('toString' in a, "toString");

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

Reply via email to