Author: [EMAIL PROTECTED]
Date: Sun Oct 26 13:50:05 2008
New Revision: 595
Removed:
changes/[EMAIL PROTECTED]/joehler/
Modified:
branches/bleeding_edge/src/factory.cc
branches/bleeding_edge/src/heap.cc
branches/bleeding_edge/src/ic-ia32.cc
branches/bleeding_edge/src/objects-inl.h
branches/bleeding_edge/src/objects.cc
branches/bleeding_edge/src/objects.h
branches/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: branches/bleeding_edge/src/factory.cc
==============================================================================
--- branches/bleeding_edge/src/factory.cc (original)
+++ branches/bleeding_edge/src/factory.cc Sun Oct 26 13:50:05 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: branches/bleeding_edge/src/heap.cc
==============================================================================
--- branches/bleeding_edge/src/heap.cc (original)
+++ branches/bleeding_edge/src/heap.cc Sun Oct 26 13:50:05 2008
@@ -1936,17 +1936,17 @@
}
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();
}
if (map == medium_sliced_ascii_string_map()) {
- return short_sliced_ascii_symbol_map();
+ return medium_sliced_ascii_symbol_map();
}
if (map == long_sliced_ascii_string_map()) {
- return short_sliced_ascii_symbol_map();
+ return long_sliced_ascii_symbol_map();
}
if (map == short_external_string_map()) return
short_external_string_map();
Modified: branches/bleeding_edge/src/ic-ia32.cc
==============================================================================
--- branches/bleeding_edge/src/ic-ia32.cc (original)
+++ branches/bleeding_edge/src/ic-ia32.cc Sun Oct 26 13:50:05 2008
@@ -206,6 +206,18 @@
}
+#ifdef DEBUG
+// For use in assert below.
+static int TenToThe(int exponent) {
+ ASSERT(exponent <= 9);
+ ASSERT(exponent >= 1);
+ int answer = 10;
+ for (int i = 1; i < exponent; i++) answer *= 10;
+ return answer;
+}
+#endif
+
+
void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- esp[0] : return address
@@ -262,6 +274,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(TenToThe(String::kMaxCachedArrayIndexLength) <
+ (1 << (String::kShortLengthShift - String::kHashShift)));
__ bind(&index_string);
const int kLengthFieldLimit =
(String::kMaxCachedArrayIndexLength + 1) <<
String::kShortLengthShift;
Modified: branches/bleeding_edge/src/objects-inl.h
==============================================================================
--- branches/bleeding_edge/src/objects-inl.h (original)
+++ branches/bleeding_edge/src/objects-inl.h Sun Oct 26 13:50:05 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: branches/bleeding_edge/src/objects.cc
==============================================================================
--- branches/bleeding_edge/src/objects.cc (original)
+++ branches/bleeding_edge/src/objects.cc Sun Oct 26 13:50:05 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: branches/bleeding_edge/src/objects.h
==============================================================================
--- branches/bleeding_edge/src/objects.h (original)
+++ branches/bleeding_edge/src/objects.h Sun Oct 26 13:50:05 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: branches/bleeding_edge/test/mjsunit/in.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/in.js (original)
+++ branches/bleeding_edge/test/mjsunit/in.js Sun Oct 26 13:50:05 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
-~----------~----~----~----~------~----~------~--~---