@ -1951,9 +1951,10 @@ MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes(
if ( ! JSObject : : cast ( pt ) - > HasDictionaryElements ( ) ) {
if ( ! JSObject : : cast ( pt ) - > HasDictionaryElements ( ) ) {
continue ;
continue ;
}
}
NumberDictionary * dictionary = JSObject : : cast ( pt ) - > element_dictionary ( ) ;
SeededNumberDictionary * dictionary =
JSObject : : cast ( pt ) - > element_dictionary ( ) ;
int entry = dictionary - > FindEntry ( index ) ;
int entry = dictionary - > FindEntry ( index ) ;
if ( entry ! = NumberDictionary : : kNotFound ) {
if ( entry ! = Seeded NumberDictionary: : kNotFound ) {
PropertyDetails details = dictionary - > DetailsAt ( entry ) ;
PropertyDetails details = dictionary - > DetailsAt ( entry ) ;
if ( details . type ( ) = = CALLBACKS ) {
if ( details . type ( ) = = CALLBACKS ) {
* found = true ;
* found = true ;
@ -2928,11 +2929,11 @@ MaybeObject* JSObject::NormalizeElements() {
int old_capacity = 0 ;
int old_capacity = 0 ;
int used_elements = 0 ;
int used_elements = 0 ;
GetElementsCapacityAndUsage ( & old_capacity , & used_elements ) ;
GetElementsCapacityAndUsage ( & old_capacity , & used_elements ) ;
NumberDictionary * dictionary = NULL ;
Seeded NumberDictionary* dictionary = NULL ;
{ Object * object ;
{ Object * object ;
MaybeObject * maybe = NumberDictionary : : Allocate ( used_elements ) ;
MaybeObject * maybe = Seeded NumberDictionary: : Allocate ( used_elements ) ;
if ( ! maybe - > ToObject ( & object ) ) return maybe ;
if ( ! maybe - > ToObject ( & object ) ) return maybe ;
dictionary = NumberDictionary : : cast ( object ) ;
dictionary = Seeded NumberDictionary: : cast ( object ) ;
}
}
// Copy the elements to the new backing store.
// Copy the elements to the new backing store.
@ -2962,7 +2963,7 @@ MaybeObject* JSObject::NormalizeElements() {
MaybeObject * maybe_result =
MaybeObject * maybe_result =
dictionary - > AddNumberEntry ( i , value , details ) ;
dictionary - > AddNumberEntry ( i , value , details ) ;
if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ;
if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ;
dictionary = NumberDictionary : : cast ( result ) ;
dictionary = Seeded NumberDictionary: : cast ( result ) ;
}
}
}
}
@ -3277,7 +3278,8 @@ bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
if ( ! element - > IsTheHole ( ) & & element = = object ) return true ;
if ( ! element - > IsTheHole ( ) & & element = = object ) return true ;
}
}
} else {
} else {
Object * key = NumberDictionary : : cast ( elements ) - > SlowReverseLookup ( object ) ;
Object * key =
SeededNumberDictionary : : cast ( elements ) - > SlowReverseLookup ( object ) ;
if ( ! key - > IsUndefined ( ) ) return true ;
if ( ! key - > IsUndefined ( ) ) return true ;
}
}
return false ;
return false ;
@ -3416,9 +3418,9 @@ MaybeObject* JSObject::PreventExtensions() {
}
}
// If there are fast elements we normalize.
// If there are fast elements we normalize.
NumberDictionary * dictionary = NULL ;
Seeded NumberDictionary* dictionary = NULL ;
{ MaybeObject * maybe = NormalizeElements ( ) ;
{ MaybeObject * maybe = NormalizeElements ( ) ;
if ( ! maybe - > To < NumberDictionary > ( & dictionary ) ) return maybe ;
if ( ! maybe - > To < Seeded NumberDictionary> ( & dictionary ) ) return maybe ;
}
}
ASSERT ( HasDictionaryElements ( ) | | HasDictionaryArgumentsElements ( ) ) ;
ASSERT ( HasDictionaryElements ( ) | | HasDictionaryArgumentsElements ( ) ) ;
// Make sure that we never go back to fast case.
// Make sure that we never go back to fast case.
@ -3581,11 +3583,11 @@ void JSObject::LookupCallback(String* name, LookupResult* result) {
// undefined if the element is read-only, or the getter/setter pair (fixed
// undefined if the element is read-only, or the getter/setter pair (fixed
// array) if there is an existing one, or the hole value if the element does
// array) if there is an existing one, or the hole value if the element does
// not exist or is a normal non-getter/setter data element.
// not exist or is a normal non-getter/setter data element.
static Object * FindGetterSetterInDictionary ( NumberDictionary * dictionary ,
static Object * FindGetterSetterInDictionary ( Seeded NumberDictionary* dictionary ,
uint32_t index ,
uint32_t index ,
Heap * heap ) {
Heap * heap ) {
int entry = dictionary - > FindEntry ( index ) ;
int entry = dictionary - > FindEntry ( index ) ;
if ( entry ! = NumberDictionary : : kNotFound ) {
if ( entry ! = Seeded NumberDictionary: : kNotFound ) {
Object * result = dictionary - > ValueAt ( entry ) ;
Object * result = dictionary - > ValueAt ( entry ) ;
PropertyDetails details = dictionary - > DetailsAt ( entry ) ;
PropertyDetails details = dictionary - > DetailsAt ( entry ) ;
if ( details . IsReadOnly ( ) ) return heap - > undefined_value ( ) ;
if ( details . IsReadOnly ( ) ) return heap - > undefined_value ( ) ;
@ -3647,7 +3649,8 @@ MaybeObject* JSObject::DefineGetterSetter(String* name,
if ( probe = = NULL | | probe - > IsTheHole ( ) ) {
if ( probe = = NULL | | probe - > IsTheHole ( ) ) {
FixedArray * arguments = FixedArray : : cast ( parameter_map - > get ( 1 ) ) ;
FixedArray * arguments = FixedArray : : cast ( parameter_map - > get ( 1 ) ) ;
if ( arguments - > IsDictionary ( ) ) {
if ( arguments - > IsDictionary ( ) ) {
NumberDictionary * dictionary = NumberDictionary : : cast ( arguments ) ;
SeededNumberDictionary * dictionary =
SeededNumberDictionary : : cast ( arguments ) ;
probe = FindGetterSetterInDictionary ( dictionary , index , heap ) ;
probe = FindGetterSetterInDictionary ( dictionary , index , heap ) ;
if ( ! probe - > IsTheHole ( ) ) return probe ;
if ( ! probe - > IsTheHole ( ) ) return probe ;
}
}
@ -3716,11 +3719,11 @@ MaybeObject* JSObject::SetElementCallback(uint32_t index,
PropertyDetails details = PropertyDetails ( attributes , CALLBACKS ) ;
PropertyDetails details = PropertyDetails ( attributes , CALLBACKS ) ;
// Normalize elements to make this operation simple.
// Normalize elements to make this operation simple.
NumberDictionary * dictionary = NULL ;
Seeded NumberDictionary* dictionary = NULL ;
{ Object * result ;
{ Object * result ;
MaybeObject * maybe = NormalizeElements ( ) ;
MaybeObject * maybe = NormalizeElements ( ) ;
if ( ! maybe - > ToObject ( & result ) ) return maybe ;
if ( ! maybe - > ToObject ( & result ) ) return maybe ;
dictionary = NumberDictionary : : cast ( result ) ;
dictionary = Seeded NumberDictionary: : cast ( result ) ;
}
}
ASSERT ( HasDictionaryElements ( ) | | HasDictionaryArgumentsElements ( ) ) ;
ASSERT ( HasDictionaryElements ( ) | | HasDictionaryArgumentsElements ( ) ) ;
@ -3728,7 +3731,7 @@ MaybeObject* JSObject::SetElementCallback(uint32_t index,
{ Object * result ;
{ Object * result ;
MaybeObject * maybe = dictionary - > Set ( index , structure , details ) ;
MaybeObject * maybe = dictionary - > Set ( index , structure , details ) ;
if ( ! maybe - > ToObject ( & result ) ) return maybe ;
if ( ! maybe - > ToObject ( & result ) ) return maybe ;
dictionary = NumberDictionary : : cast ( result ) ;
dictionary = Seeded NumberDictionary: : cast ( result ) ;
}
}
dictionary - > set_requires_slow_elements ( ) ;
dictionary - > set_requires_slow_elements ( ) ;
@ -3933,9 +3936,9 @@ Object* JSObject::LookupAccessor(String* name, bool is_getter) {
obj = JSObject : : cast ( obj ) - > GetPrototype ( ) ) {
obj = JSObject : : cast ( obj ) - > GetPrototype ( ) ) {
JSObject * js_object = JSObject : : cast ( obj ) ;
JSObject * js_object = JSObject : : cast ( obj ) ;
if ( js_object - > HasDictionaryElements ( ) ) {
if ( js_object - > HasDictionaryElements ( ) ) {
NumberDictionary * dictionary = js_object - > element_dictionary ( ) ;
Seeded NumberDictionary* dictionary = js_object - > element_dictionary ( ) ;
int entry = dictionary - > FindEntry ( index ) ;
int entry = dictionary - > FindEntry ( index ) ;
if ( entry ! = NumberDictionary : : kNotFound ) {
if ( entry ! = Seeded NumberDictionary: : kNotFound ) {
Object * element = dictionary - > ValueAt ( entry ) ;
Object * element = dictionary - > ValueAt ( entry ) ;
PropertyDetails details = dictionary - > DetailsAt ( entry ) ;
PropertyDetails details = dictionary - > DetailsAt ( entry ) ;
if ( details . type ( ) = = CALLBACKS ) {
if ( details . type ( ) = = CALLBACKS ) {
@ -6077,14 +6080,14 @@ uint32_t String::ComputeAndSetHash() {
if ( StringShape ( this ) . IsSequentialAscii ( ) ) {
if ( StringShape ( this ) . IsSequentialAscii ( ) ) {
field = HashSequentialString ( SeqAsciiString : : cast ( this ) - > GetChars ( ) ,
field = HashSequentialString ( SeqAsciiString : : cast ( this ) - > GetChars ( ) ,
len ,
len ,
GetHeap ( ) - > String HashSeed( ) ) ;
GetHeap ( ) - > HashSeed ( ) ) ;
} else if ( StringShape ( this ) . IsSequentialTwoByte ( ) ) {
} else if ( StringShape ( this ) . IsSequentialTwoByte ( ) ) {
field = HashSequentialString ( SeqTwoByteString : : cast ( this ) - > GetChars ( ) ,
field = HashSequentialString ( SeqTwoByteString : : cast ( this ) - > GetChars ( ) ,
len ,
len ,
GetHeap ( ) - > String HashSeed( ) ) ;
GetHeap ( ) - > HashSeed ( ) ) ;
} else {
} else {
StringInputBuffer buffer ( this ) ;
StringInputBuffer buffer ( this ) ;
field = ComputeHashField ( & buffer , len , GetHeap ( ) - > String HashSeed( ) ) ;
field = ComputeHashField ( & buffer , len , GetHeap ( ) - > HashSeed ( ) ) ;
}
}
// Store the hash code in the object.
// Store the hash code in the object.
@ -7276,7 +7279,7 @@ static void CopyFastElementsToFast(FixedArray* source,
}
}
static void CopySlowElementsToFast ( NumberDictionary * source ,
static void CopySlowElementsToFast ( Seeded NumberDictionary* source ,
FixedArray * destination ,
FixedArray * destination ,
WriteBarrierMode mode ) {
WriteBarrierMode mode ) {
for ( int i = 0 ; i < source - > Capacity ( ) ; + + i ) {
for ( int i = 0 ; i < source - > Capacity ( ) ; + + i ) {
@ -7324,7 +7327,7 @@ MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity,
case DICTIONARY_ELEMENTS : {
case DICTIONARY_ELEMENTS : {
AssertNoAllocation no_gc ;
AssertNoAllocation no_gc ;
WriteBarrierMode mode = new_elements - > GetWriteBarrierMode ( no_gc ) ;
WriteBarrierMode mode = new_elements - > GetWriteBarrierMode ( no_gc ) ;
CopySlowElementsToFast ( NumberDictionary : : cast ( elements ( ) ) ,
CopySlowElementsToFast ( Seeded NumberDictionary: : cast ( elements ( ) ) ,
new_elements ,
new_elements ,
mode ) ;
mode ) ;
set_map ( new_map ) ;
set_map ( new_map ) ;
@ -7339,7 +7342,7 @@ MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity,
FixedArray * parameter_map = FixedArray : : cast ( elements ( ) ) ;
FixedArray * parameter_map = FixedArray : : cast ( elements ( ) ) ;
FixedArray * arguments = FixedArray : : cast ( parameter_map - > get ( 1 ) ) ;
FixedArray * arguments = FixedArray : : cast ( parameter_map - > get ( 1 ) ) ;
if ( arguments - > IsDictionary ( ) ) {
if ( arguments - > IsDictionary ( ) ) {
CopySlowElementsToFast ( NumberDictionary : : cast ( arguments ) ,
CopySlowElementsToFast ( Seeded NumberDictionary: : cast ( arguments ) ,
new_elements ,
new_elements ,
mode ) ;
mode ) ;
} else {
} else {
@ -7426,7 +7429,7 @@ MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength(
break ;
break ;
}
}
case DICTIONARY_ELEMENTS : {
case DICTIONARY_ELEMENTS : {
elems - > Initialize ( NumberDictionary : : cast ( elements ( ) ) ) ;
elems - > Initialize ( Seeded NumberDictionary: : cast ( elements ( ) ) ) ;
break ;
break ;
}
}
default :
default :
@ -7861,7 +7864,7 @@ bool JSObject::HasElementPostInterceptor(JSReceiver* receiver, uint32_t index) {
}
}
case DICTIONARY_ELEMENTS : {
case DICTIONARY_ELEMENTS : {
if ( element_dictionary ( ) - > FindEntry ( index )
if ( element_dictionary ( ) - > FindEntry ( index )
! = NumberDictionary : : kNotFound ) {
! = Seeded NumberDictionary: : kNotFound ) {
return true ;
return true ;
}
}
break ;
break ;
@ -7993,7 +7996,7 @@ JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
}
}
case DICTIONARY_ELEMENTS : {
case DICTIONARY_ELEMENTS : {
if ( element_dictionary ( ) - > FindEntry ( index ) ! =
if ( element_dictionary ( ) - > FindEntry ( index ) ! =
NumberDictionary : : kNotFound ) {
Seeded NumberDictionary: : kNotFound ) {
return DICTIONARY_ELEMENT ;
return DICTIONARY_ELEMENT ;
}
}
break ;
break ;
@ -8010,8 +8013,9 @@ JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
// If not aliased, check the arguments.
// If not aliased, check the arguments.
FixedArray * arguments = FixedArray : : cast ( parameter_map - > get ( 1 ) ) ;
FixedArray * arguments = FixedArray : : cast ( parameter_map - > get ( 1 ) ) ;
if ( arguments - > IsDictionary ( ) ) {
if ( arguments - > IsDictionary ( ) ) {
NumberDictionary * dictionary = NumberDictionary : : cast ( arguments ) ;
SeededNumberDictionary * dictionary =
if ( dictionary - > FindEntry ( index ) ! = NumberDictionary : : kNotFound ) {
SeededNumberDictionary : : cast ( arguments ) ;
if ( dictionary - > FindEntry ( index ) ! = SeededNumberDictionary : : kNotFound ) {
return DICTIONARY_ELEMENT ;
return DICTIONARY_ELEMENT ;
}
}
} else {
} else {
@ -8040,8 +8044,8 @@ bool JSObject::HasElementInElements(FixedArray* elements,
return true ;
return true ;
}
}
} else {
} else {
if ( NumberDictionary : : cast ( elements ) - > FindEntry ( index ) ! =
if ( Seeded NumberDictionary: : cast ( elements ) - > FindEntry ( index ) ! =
NumberDictionary : : kNotFound ) {
Seeded NumberDictionary: : kNotFound ) {
return true ;
return true ;
}
}
}
}
@ -8107,7 +8111,7 @@ bool JSObject::HasElementWithReceiver(JSReceiver* receiver, uint32_t index) {
}
}
case DICTIONARY_ELEMENTS : {
case DICTIONARY_ELEMENTS : {
if ( element_dictionary ( ) - > FindEntry ( index )
if ( element_dictionary ( ) - > FindEntry ( index )
! = NumberDictionary : : kNotFound ) {
! = Seeded NumberDictionary: : kNotFound ) {
return true ;
return true ;
}
}
break ;
break ;
@ -8387,15 +8391,15 @@ MaybeObject* JSObject::SetDictionaryElement(uint32_t index,
FixedArray * elements = FixedArray : : cast ( this - > elements ( ) ) ;
FixedArray * elements = FixedArray : : cast ( this - > elements ( ) ) ;
bool is_arguments =
bool is_arguments =
( elements - > map ( ) = = heap - > non_strict_arguments_elements_map ( ) ) ;
( elements - > map ( ) = = heap - > non_strict_arguments_elements_map ( ) ) ;
NumberDictionary * dictionary = NULL ;
Seeded NumberDictionary* dictionary = NULL ;
if ( is_arguments ) {
if ( is_arguments ) {
dictionary = NumberDictionary : : cast ( elements - > get ( 1 ) ) ;
dictionary = Seeded NumberDictionary: : cast ( elements - > get ( 1 ) ) ;
} else {
} else {
dictionary = NumberDictionary : : cast ( elements ) ;
dictionary = Seeded NumberDictionary: : cast ( elements ) ;
}
}
int entry = dictionary - > FindEntry ( index ) ;
int entry = dictionary - > FindEntry ( index ) ;
if ( entry ! = NumberDictionary : : kNotFound ) {
if ( entry ! = Seeded NumberDictionary: : kNotFound ) {
Object * element = dictionary - > ValueAt ( entry ) ;
Object * element = dictionary - > ValueAt ( entry ) ;
PropertyDetails details = dictionary - > DetailsAt ( entry ) ;
PropertyDetails details = dictionary - > DetailsAt ( entry ) ;
if ( details . type ( ) = = CALLBACKS ) {
if ( details . type ( ) = = CALLBACKS ) {
@ -8440,13 +8444,13 @@ MaybeObject* JSObject::SetDictionaryElement(uint32_t index,
FixedArrayBase * new_dictionary ;
FixedArrayBase * new_dictionary ;
MaybeObject * maybe = dictionary - > AtNumberPut ( index , value ) ;
MaybeObject * maybe = dictionary - > AtNumberPut ( index , value ) ;
if ( ! maybe - > To < FixedArrayBase > ( & new_dictionary ) ) return maybe ;
if ( ! maybe - > To < FixedArrayBase > ( & new_dictionary ) ) return maybe ;
if ( dictionary ! = NumberDictionary : : cast ( new_dictionary ) ) {
if ( dictionary ! = Seeded NumberDictionary: : cast ( new_dictionary ) ) {
if ( is_arguments ) {
if ( is_arguments ) {
elements - > set ( 1 , new_dictionary ) ;
elements - > set ( 1 , new_dictionary ) ;
} else {
} else {
set_elements ( new_dictionary ) ;
set_elements ( new_dictionary ) ;
}
}
dictionary = NumberDictionary : : cast ( new_dictionary ) ;
dictionary = Seeded NumberDictionary: : cast ( new_dictionary ) ;
}
}
}
}
@ -8767,7 +8771,8 @@ void JSObject::GetElementsCapacityAndUsage(int* capacity, int* used) {
FixedArray : : cast ( FixedArray : : cast ( backing_store_base ) - > get ( 1 ) ) ;
FixedArray : : cast ( FixedArray : : cast ( backing_store_base ) - > get ( 1 ) ) ;
backing_store = FixedArray : : cast ( backing_store_base ) ;
backing_store = FixedArray : : cast ( backing_store_base ) ;
if ( backing_store - > IsDictionary ( ) ) {
if ( backing_store - > IsDictionary ( ) ) {
NumberDictionary * dictionary = NumberDictionary : : cast ( backing_store ) ;
SeededNumberDictionary * dictionary =
SeededNumberDictionary : : cast ( backing_store ) ;
* capacity = dictionary - > Capacity ( ) ;
* capacity = dictionary - > Capacity ( ) ;
* used = dictionary - > NumberOfElements ( ) ;
* used = dictionary - > NumberOfElements ( ) ;
break ;
break ;
@ -8781,8 +8786,8 @@ void JSObject::GetElementsCapacityAndUsage(int* capacity, int* used) {
}
}
break ;
break ;
case DICTIONARY_ELEMENTS : {
case DICTIONARY_ELEMENTS : {
NumberDictionary * dictionary =
Seeded NumberDictionary* dictionary =
NumberDictionary : : cast ( FixedArray : : cast ( elements ( ) ) ) ;
Seeded NumberDictionary: : cast ( FixedArray : : cast ( elements ( ) ) ) ;
* capacity = dictionary - > Capacity ( ) ;
* capacity = dictionary - > Capacity ( ) ;
* used = dictionary - > NumberOfElements ( ) ;
* used = dictionary - > NumberOfElements ( ) ;
break ;
break ;
@ -8827,8 +8832,8 @@ bool JSObject::ShouldConvertToSlowElements(int new_capacity) {
int old_capacity = 0 ;
int old_capacity = 0 ;
int used_elements = 0 ;
int used_elements = 0 ;
GetElementsCapacityAndUsage ( & old_capacity , & used_elements ) ;
GetElementsCapacityAndUsage ( & old_capacity , & used_elements ) ;
int dictionary_size = NumberDictionary : : ComputeCapacity ( used_elements ) *
int dictionary_size = Seeded NumberDictionary: : ComputeCapacity ( used_elements ) *
NumberDictionary : : kEntrySize ;
Seeded NumberDictionary: : kEntrySize ;
return 3 * dictionary_size < = new_capacity ;
return 3 * dictionary_size < = new_capacity ;
}
}
@ -8842,11 +8847,11 @@ bool JSObject::ShouldConvertToFastElements() {
if ( IsAccessCheckNeeded ( ) ) return false ;
if ( IsAccessCheckNeeded ( ) ) return false ;
FixedArray * elements = FixedArray : : cast ( this - > elements ( ) ) ;
FixedArray * elements = FixedArray : : cast ( this - > elements ( ) ) ;
NumberDictionary * dictionary = NULL ;
Seeded NumberDictionary* dictionary = NULL ;
if ( elements - > map ( ) = = GetHeap ( ) - > non_strict_arguments_elements_map ( ) ) {
if ( elements - > map ( ) = = GetHeap ( ) - > non_strict_arguments_elements_map ( ) ) {
dictionary = NumberDictionary : : cast ( elements - > get ( 1 ) ) ;
dictionary = Seeded NumberDictionary: : cast ( elements - > get ( 1 ) ) ;
} else {
} else {
dictionary = NumberDictionary : : cast ( elements ) ;
dictionary = Seeded NumberDictionary: : cast ( elements ) ;
}
}
// If an element has been added at a very high index in the elements
// If an element has been added at a very high index in the elements
// dictionary, we cannot go back to fast case.
// dictionary, we cannot go back to fast case.
@ -8861,7 +8866,7 @@ bool JSObject::ShouldConvertToFastElements() {
array_size = dictionary - > max_number_key ( ) ;
array_size = dictionary - > max_number_key ( ) ;
}
}
uint32_t dictionary_size = static_cast < uint32_t > ( dictionary - > Capacity ( ) ) *
uint32_t dictionary_size = static_cast < uint32_t > ( dictionary - > Capacity ( ) ) *
NumberDictionary : : kEntrySize ;
Seeded NumberDictionary: : kEntrySize ;
return 2 * dictionary_size > = array_size ;
return 2 * dictionary_size > = array_size ;
}
}
@ -8869,7 +8874,8 @@ bool JSObject::ShouldConvertToFastElements() {
bool JSObject : : CanConvertToFastDoubleElements ( ) {
bool JSObject : : CanConvertToFastDoubleElements ( ) {
if ( FLAG_unbox_double_arrays ) {
if ( FLAG_unbox_double_arrays ) {
ASSERT ( HasDictionaryElements ( ) ) ;
ASSERT ( HasDictionaryElements ( ) ) ;
NumberDictionary * dictionary = NumberDictionary : : cast ( elements ( ) ) ;
SeededNumberDictionary * dictionary =
SeededNumberDictionary : : cast ( elements ( ) ) ;
for ( int i = 0 ; i < dictionary - > Capacity ( ) ; i + + ) {
for ( int i = 0 ; i < dictionary - > Capacity ( ) ; i + + ) {
Object * key = dictionary - > KeyAt ( i ) ;
Object * key = dictionary - > KeyAt ( i ) ;
if ( key - > IsNumber ( ) ) {
if ( key - > IsNumber ( ) ) {
@ -9082,7 +9088,7 @@ bool JSObject::HasRealElementProperty(uint32_t index) {
}
}
case DICTIONARY_ELEMENTS : {
case DICTIONARY_ELEMENTS : {
return element_dictionary ( ) - > FindEntry ( index )
return element_dictionary ( ) - > FindEntry ( index )
! = NumberDictionary : : kNotFound ;
! = Seeded NumberDictionary: : kNotFound ;
}
}
case NON_STRICT_ARGUMENTS_ELEMENTS :
case NON_STRICT_ARGUMENTS_ELEMENTS :
UNIMPLEMENTED ( ) ;
UNIMPLEMENTED ( ) ;
@ -9350,7 +9356,7 @@ int JSObject::GetLocalElementKeys(FixedArray* storage,
if ( storage ! = NULL ) {
if ( storage ! = NULL ) {
element_dictionary ( ) - > CopyKeysTo ( storage ,
element_dictionary ( ) - > CopyKeysTo ( storage ,
filter ,
filter ,
NumberDictionary : : SORTED ) ;
Seeded NumberDictionary: : SORTED ) ;
}
}
counter + = element_dictionary ( ) - > NumberOfElementsFilterAttributes ( filter ) ;
counter + = element_dictionary ( ) - > NumberOfElementsFilterAttributes ( filter ) ;
break ;
break ;
@ -9362,9 +9368,11 @@ int JSObject::GetLocalElementKeys(FixedArray* storage,
if ( arguments - > IsDictionary ( ) ) {
if ( arguments - > IsDictionary ( ) ) {
// Copy the keys from arguments first, because Dictionary::CopyKeysTo
// Copy the keys from arguments first, because Dictionary::CopyKeysTo
// will insert in storage starting at index 0.
// will insert in storage starting at index 0.
NumberDictionary * dictionary = NumberDictionary : : cast ( arguments ) ;
SeededNumberDictionary * dictionary =
SeededNumberDictionary : : cast ( arguments ) ;
if ( storage ! = NULL ) {
if ( storage ! = NULL ) {
dictionary - > CopyKeysTo ( storage , filter , NumberDictionary : : UNSORTED ) ;
dictionary - > CopyKeysTo (
storage , filter , SeededNumberDictionary : : UNSORTED ) ;
}
}
counter + = dictionary - > NumberOfElementsFilterAttributes ( filter ) ;
counter + = dictionary - > NumberOfElementsFilterAttributes ( filter ) ;
for ( int i = 0 ; i < mapped_length ; + + i ) {
for ( int i = 0 ; i < mapped_length ; + + i ) {
@ -9671,7 +9679,7 @@ class SubStringAsciiSymbolKey : public HashTableKey {
uint32_t Hash ( ) {
uint32_t Hash ( ) {
ASSERT ( length_ > = 0 ) ;
ASSERT ( length_ > = 0 ) ;
ASSERT ( from_ + length_ < = string_ - > length ( ) ) ;
ASSERT ( from_ + length_ < = string_ - > length ( ) ) ;
StringHasher hasher ( length_ , string_ - > GetHeap ( ) - > String HashSeed( ) ) ;
StringHasher hasher ( length_ , string_ - > GetHeap ( ) - > HashSeed ( ) ) ;
// Very long strings have a trivial hash that doesn't inspect the
// Very long strings have a trivial hash that doesn't inspect the
// string contents.
// string contents.
@ -9880,7 +9888,7 @@ MaybeObject* HashTable<Shape, Key>::Rehash(HashTable* new_table, Key key) {
uint32_t from_index = EntryToIndex ( i ) ;
uint32_t from_index = EntryToIndex ( i ) ;
Object * k = get ( from_index ) ;
Object * k = get ( from_index ) ;
if ( IsKey ( k ) ) {
if ( IsKey ( k ) ) {
uint32_t hash = Shape : : HashForObject ( key , k ) ;
uint32_t hash = HashTable < Shape , Key > : : HashForObject ( key , k ) ;
uint32_t insertion_index =
uint32_t insertion_index =
EntryToIndex ( new_table - > FindInsertionEntry ( hash ) ) ;
EntryToIndex ( new_table - > FindInsertionEntry ( hash ) ) ;
for ( int j = 0 ; j < Shape : : kEntrySize ; j + + ) {
for ( int j = 0 ; j < Shape : : kEntrySize ; j + + ) {
@ -9976,38 +9984,46 @@ template class HashTable<ObjectHashTableShape, JSObject*>;
template class Dictionary < StringDictionaryShape , String * > ;
template class Dictionary < StringDictionaryShape , String * > ;
template class Dictionary < NumberDictionaryShape , uint32_t > ;
template class Dictionary < Seeded NumberDictionaryShape, uint32_t > ;
template MaybeObject * Dictionary < NumberDictionaryShape , uint32_t > : : Allocate (
template class Dictionary < UnseededNumberDictionaryShape , uint32_t > ;
int ) ;
template MaybeObject * Dictionary < SeededNumberDictionaryShape , uint32_t > : :
Allocate ( int at_least_space_for ) ;
template MaybeObject * Dictionary < UnseededNumberDictionaryShape , uint32_t > : :
Allocate ( int at_least_space_for ) ;
template MaybeObject * Dictionary < StringDictionaryShape , String * > : : Allocate (
template MaybeObject * Dictionary < StringDictionaryShape , String * > : : Allocate (
int ) ;
int ) ;
template MaybeObject * Dictionary < NumberDictionaryShape , uint32_t > : : AtPut (
template MaybeObject * Dictionary < Seeded NumberDictionaryShape, uint32_t > : : AtPut (
uint32_t , Object * ) ;
uint32_t , Object * ) ;
template Object * Dictionary < NumberDictionaryShape , uint32_t > : : SlowReverseLookup (
template MaybeObject * Dictionary < UnseededNumberDictionaryShape , uint32_t > : :
Object * ) ;
AtPut ( uint32_t , Object * ) ;
template Object * Dictionary < UnseededNumberDictionaryShape , uint32_t > : :
SlowReverseLookup ( Object * value ) ;
template Object * Dictionary < StringDictionaryShape , String * > : : SlowReverseLookup (
template Object * Dictionary < StringDictionaryShape , String * > : : SlowReverseLookup (
Object * ) ;
Object * ) ;
template void Dictionary < NumberDictionaryShape , uint32_t > : : CopyKeysTo (
template void Dictionary < Seeded NumberDictionaryShape, uint32_t > : : CopyKeysTo (
FixedArray * ,
FixedArray * ,
PropertyAttributes ,
PropertyAttributes ,
Dictionary < NumberDictionaryShape , uint32_t > : : SortMode ) ;
Dictionary < Seeded NumberDictionaryShape, uint32_t > : : SortMode ) ;
template Object * Dictionary < StringDictionaryShape , String * > : : DeleteProperty (
template Object * Dictionary < StringDictionaryShape , String * > : : DeleteProperty (
int , JSObject : : DeleteMode ) ;
int , JSObject : : DeleteMode ) ;
template Object * Dictionary < NumberDictionaryShape , uint32_t > : : DeleteProperty (
template Object * Dictionary < Seeded NumberDictionaryShape, uint32_t > : :
int , JSObject : : DeleteMode ) ;
DeleteProperty ( int , JSObject : : DeleteMode ) ;
template MaybeObject * Dictionary < StringDictionaryShape , String * > : : Shrink (
template MaybeObject * Dictionary < StringDictionaryShape , String * > : : Shrink (
String * ) ;
String * ) ;
template MaybeObject * Dictionary < NumberDictionaryShape , uint32_t > : : Shrink (
template MaybeObject * Dictionary < Seeded NumberDictionaryShape, uint32_t > : : Shrink (
uint32_t ) ;
uint32_t ) ;
template void Dictionary < StringDictionaryShape , String * > : : CopyKeysTo (
template void Dictionary < StringDictionaryShape , String * > : : CopyKeysTo (
@ -10026,32 +10042,41 @@ template MaybeObject*
Dictionary < StringDictionaryShape , String * > : : GenerateNewEnumerationIndices ( ) ;
Dictionary < StringDictionaryShape , String * > : : GenerateNewEnumerationIndices ( ) ;
template int
template int
Dictionary < NumberDictionaryShape , uint32_t > : : NumberOfElementsFilterAttributes (
Dictionary < SeededNumberDictionaryShape , uint32_t > : :
PropertyAttributes ) ;
NumberOfElementsFilterAttributes ( PropertyAttributes ) ;
template MaybeObject * Dictionary < SeededNumberDictionaryShape , uint32_t > : : Add (
uint32_t , Object * , PropertyDetails ) ;
template MaybeObject * Dictionary < NumberDictionaryShape , uint32_t > : : Add (
template MaybeObject * Dictionary < Unseeded NumberDictionaryShape, uint32_t > : : Add (
uint32_t , Object * , PropertyDetails ) ;
uint32_t , Object * , PropertyDetails ) ;
template MaybeObject * Dictionary < NumberDictionaryShape , uint32_t > : :
template MaybeObject * Dictionary < SeededNumberDictionaryShape , uint32_t > : :
EnsureCapacity ( int , uint32_t ) ;
template MaybeObject * Dictionary < UnseededNumberDictionaryShape , uint32_t > : :
EnsureCapacity ( int , uint32_t ) ;
EnsureCapacity ( int , uint32_t ) ;
template MaybeObject * Dictionary < StringDictionaryShape , String * > : :
template MaybeObject * Dictionary < StringDictionaryShape , String * > : :
EnsureCapacity ( int , String * ) ;
EnsureCapacity ( int , String * ) ;
template MaybeObject * Dictionary < NumberDictionaryShape , uint32_t > : : AddEntry (
template MaybeObject * Dictionary < SeededNumberDictionaryShape , uint32_t > : :
uint32_t , Object * , PropertyDetails , uint32_t ) ;
AddEntry ( uint32_t , Object * , PropertyDetails , uint32_t ) ;
template MaybeObject * Dictionary < UnseededNumberDictionaryShape , uint32_t > : :
AddEntry ( uint32_t , Object * , PropertyDetails , uint32_t ) ;
template MaybeObject * Dictionary < StringDictionaryShape , String * > : : AddEntry (
template MaybeObject * Dictionary < StringDictionaryShape , String * > : : AddEntry (
String * , Object * , PropertyDetails , uint32_t ) ;
String * , Object * , PropertyDetails , uint32_t ) ;
template
template
int Dictionary < NumberDictionaryShape , uint32_t > : : NumberOfEnumElements ( ) ;
int Dictionary < Seeded NumberDictionaryShape, uint32_t > : : NumberOfEnumElements ( ) ;
template
template
int Dictionary < StringDictionaryShape , String * > : : NumberOfEnumElements ( ) ;
int Dictionary < StringDictionaryShape , String * > : : NumberOfEnumElements ( ) ;
template
template
int HashTable < NumberDictionaryShape , uint32_t > : : FindEntry ( uint32_t ) ;
int HashTable < Seeded NumberDictionaryShape, uint32_t > : : FindEntry ( uint32_t ) ;
// Collates undefined and unexisting elements below limit from position
// Collates undefined and unexisting elements below limit from position
@ -10061,7 +10086,7 @@ MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) {
// Must stay in dictionary mode, either because of requires_slow_elements,
// Must stay in dictionary mode, either because of requires_slow_elements,
// or because we are not going to sort (and therefore compact) all of the
// or because we are not going to sort (and therefore compact) all of the
// elements.
// elements.
NumberDictionary * dict = element_dictionary ( ) ;
Seeded NumberDictionary* dict = element_dictionary ( ) ;
HeapNumber * result_double = NULL ;
HeapNumber * result_double = NULL ;
if ( limit > static_cast < uint32_t > ( Smi : : kMaxValue ) ) {
if ( limit > static_cast < uint32_t > ( Smi : : kMaxValue ) ) {
// Allocate space for result before we start mutating the object.
// Allocate space for result before we start mutating the object.
@ -10074,10 +10099,10 @@ MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) {
Object * obj ;
Object * obj ;
{ MaybeObject * maybe_obj =
{ MaybeObject * maybe_obj =
NumberDictionary : : Allocate ( dict - > NumberOfElements ( ) ) ;
Seeded NumberDictionary: : Allocate ( dict - > NumberOfElements ( ) ) ;
if ( ! maybe_obj - > ToObject ( & obj ) ) return maybe_obj ;
if ( ! maybe_obj - > ToObject ( & obj ) ) return maybe_obj ;
}
}
NumberDictionary * new_dict = NumberDictionary : : cast ( obj ) ;
Seeded NumberDictionary* new_dict = Seeded NumberDictionary: : cast ( obj ) ;
AssertNoAllocation no_alloc ;
AssertNoAllocation no_alloc ;
@ -10163,7 +10188,7 @@ MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) {
if ( HasDictionaryElements ( ) ) {
if ( HasDictionaryElements ( ) ) {
// Convert to fast elements containing only the existing properties.
// Convert to fast elements containing only the existing properties.
// Ordering is irrelevant, since we are going to sort anyway.
// Ordering is irrelevant, since we are going to sort anyway.
NumberDictionary * dict = element_dictionary ( ) ;
Seeded NumberDictionary* dict = element_dictionary ( ) ;
if ( IsJSArray ( ) | | dict - > requires_slow_elements ( ) | |
if ( IsJSArray ( ) | | dict - > requires_slow_elements ( ) | |
dict - > max_number_key ( ) > = limit ) {
dict - > max_number_key ( ) > = limit ) {
return PrepareSlowElementsForSort ( limit ) ;
return PrepareSlowElementsForSort ( limit ) ;
@ -10576,7 +10601,7 @@ bool SymbolTable::LookupSymbolIfExists(String* string, String** symbol) {
bool SymbolTable : : LookupTwoCharsSymbolIfExists ( uint32_t c1 ,
bool SymbolTable : : LookupTwoCharsSymbolIfExists ( uint32_t c1 ,
uint32_t c2 ,
uint32_t c2 ,
String * * symbol ) {
String * * symbol ) {
TwoCharHashTableKey key ( c1 , c2 , GetHeap ( ) - > String HashSeed( ) ) ;
TwoCharHashTableKey key ( c1 , c2 , GetHeap ( ) - > HashSeed ( ) ) ;
int entry = FindEntry ( & key ) ;
int entry = FindEntry ( & key ) ;
if ( entry = = kNotFound ) {
if ( entry = = kNotFound ) {
return false ;
return false ;
@ -10591,14 +10616,14 @@ bool SymbolTable::LookupTwoCharsSymbolIfExists(uint32_t c1,
MaybeObject * SymbolTable : : LookupSymbol ( Vector < const char > str ,
MaybeObject * SymbolTable : : LookupSymbol ( Vector < const char > str ,
Object * * s ) {
Object * * s ) {
Utf8SymbolKey key ( str , GetHeap ( ) - > String HashSeed( ) ) ;
Utf8SymbolKey key ( str , GetHeap ( ) - > HashSeed ( ) ) ;
return LookupKey ( & key , s ) ;
return LookupKey ( & key , s ) ;
}
}
MaybeObject * SymbolTable : : LookupAsciiSymbol ( Vector < const char > str ,
MaybeObject * SymbolTable : : LookupAsciiSymbol ( Vector < const char > str ,
Object * * s ) {
Object * * s ) {
AsciiSymbolKey key ( str , GetHeap ( ) - > String HashSeed( ) ) ;
AsciiSymbolKey key ( str , GetHeap ( ) - > HashSeed ( ) ) ;
return LookupKey ( & key , s ) ;
return LookupKey ( & key , s ) ;
}
}
@ -10607,14 +10632,14 @@ MaybeObject* SymbolTable::LookupSubStringAsciiSymbol(Handle<SeqAsciiString> str,
int from ,
int from ,
int length ,
int length ,
Object * * s ) {
Object * * s ) {
SubStringAsciiSymbolKey key ( str , from , length , GetHeap ( ) - > String HashSeed( ) ) ;
SubStringAsciiSymbolKey key ( str , from , length , GetHeap ( ) - > HashSeed ( ) ) ;
return LookupKey ( & key , s ) ;
return LookupKey ( & key , s ) ;
}
}
MaybeObject * SymbolTable : : LookupTwoByteSymbol ( Vector < const uc16 > str ,
MaybeObject * SymbolTable : : LookupTwoByteSymbol ( Vector < const uc16 > str ,
Object * * s ) {
Object * * s ) {
TwoByteSymbolKey key ( str , GetHeap ( ) - > String HashSeed( ) ) ;
TwoByteSymbolKey key ( str , GetHeap ( ) - > HashSeed ( ) ) ;
return LookupKey ( & key , s ) ;
return LookupKey ( & key , s ) ;
}
}
@ -10905,7 +10930,7 @@ MaybeObject* Dictionary<Shape, Key>::EnsureCapacity(int n, Key key) {
}
}
void NumberDictionary : : RemoveNumberEntries ( uint32_t from , uint32_t to ) {
void Seeded NumberDictionary: : RemoveNumberEntries ( uint32_t from , uint32_t to ) {
// Do nothing if the interval [from, to) is empty.
// Do nothing if the interval [from, to) is empty.
if ( from > = to ) return ;
if ( from > = to ) return ;
@ -10971,8 +10996,9 @@ MaybeObject* Dictionary<Shape, Key>::AtPut(Key key, Object* value) {
if ( ! maybe_k - > ToObject ( & k ) ) return maybe_k ;
if ( ! maybe_k - > ToObject ( & k ) ) return maybe_k ;
}
}
PropertyDetails details = PropertyDetails ( NONE , NORMAL ) ;
PropertyDetails details = PropertyDetails ( NONE , NORMAL ) ;
return Dictionary < Shape , Key > : : cast ( obj ) - >
AddEntry ( key , value , details , Shape : : Hash ( key ) ) ;
return Dictionary < Shape , Key > : : cast ( obj ) - > AddEntry ( key , value , details ,
Dictionary < Shape , Key > : : Hash ( key ) ) ;
}
}
@ -10987,8 +11013,9 @@ MaybeObject* Dictionary<Shape, Key>::Add(Key key,
{ MaybeObject * maybe_obj = EnsureCapacity ( 1 , key ) ;
{ MaybeObject * maybe_obj = EnsureCapacity ( 1 , key ) ;
if ( ! maybe_obj - > ToObject ( & obj ) ) return maybe_obj ;
if ( ! maybe_obj - > ToObject ( & obj ) ) return maybe_obj ;
}
}
return Dictionary < Shape , Key > : : cast ( obj ) - >
AddEntry ( key , value , details , Shape : : Hash ( key ) ) ;
return Dictionary < Shape , Key > : : cast ( obj ) - > AddEntry ( key , value , details ,
Dictionary < Shape , Key > : : Hash ( key ) ) ;
}
}
@ -11021,7 +11048,7 @@ MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key,
}
}
void NumberDictionary : : UpdateMaxNumberKey ( uint32_t key ) {
void Seeded NumberDictionary: : UpdateMaxNumberKey ( uint32_t key ) {
// If the dictionary requires slow elements an element has already
// If the dictionary requires slow elements an element has already
// been added at a high index.
// been added at a high index.
if ( requires_slow_elements ( ) ) return ;
if ( requires_slow_elements ( ) ) return ;
@ -11040,31 +11067,44 @@ void NumberDictionary::UpdateMaxNumberKey(uint32_t key) {
}
}
MaybeObject * NumberDictionary : : AddNumberEntry ( uint32_t key ,
MaybeObject * Seeded NumberDictionary: : AddNumberEntry ( uint32_t key ,
Object * value ,
Object * value ,
PropertyDetails details ) {
PropertyDetails details ) {
UpdateMaxNumberKey ( key ) ;
UpdateMaxNumberKey ( key ) ;
SLOW_ASSERT ( this - > FindEntry ( key ) = = kNotFound ) ;
SLOW_ASSERT ( this - > FindEntry ( key ) = = kNotFound ) ;
return Add ( key , value , details ) ;
return Add ( key , value , details ) ;
}
}
MaybeObject * NumberDictionary : : AtNumberPut ( uint32_t key , Object * value ) {
MaybeObject * UnseededNumberDictionary : : AddNumberEntry ( uint32_t key ,
Object * value ) {
SLOW_ASSERT ( this - > FindEntry ( key ) = = kNotFound ) ;
return Add ( key , value , PropertyDetails ( NONE , NORMAL ) ) ;
}
MaybeObject * SeededNumberDictionary : : AtNumberPut ( uint32_t key , Object * value ) {
UpdateMaxNumberKey ( key ) ;
UpdateMaxNumberKey ( key ) ;
return AtPut ( key , value ) ;
return AtPut ( key , value ) ;
}
}
MaybeObject * NumberDictionary : : Set ( uint32_t key ,
MaybeObject * UnseededNumberDictionary : : AtNumberPut ( uint32_t key ,
Object * value ,
Object * value ) {
PropertyDetails details ) {
return AtPut ( key , value ) ;
}
MaybeObject * SeededNumberDictionary : : Set ( uint32_t key ,
Object * value ,
PropertyDetails details ) {
int entry = FindEntry ( key ) ;
int entry = FindEntry ( key ) ;
if ( entry = = kNotFound ) return AddNumberEntry ( key , value , details ) ;
if ( entry = = kNotFound ) return AddNumberEntry ( key , value , details ) ;
// Preserve enumeration index.
// Preserve enumeration index.
details = PropertyDetails ( details . attributes ( ) ,
details = PropertyDetails ( details . attributes ( ) ,
details . type ( ) ,
details . type ( ) ,
DetailsAt ( entry ) . index ( ) ) ;
DetailsAt ( entry ) . index ( ) ) ;
MaybeObject * maybe_object_key = NumberDictionaryShape : : AsObject ( key ) ;
MaybeObject * maybe_object_key = Seeded NumberDictionaryShape: : AsObject ( key ) ;
Object * object_key ;
Object * object_key ;
if ( ! maybe_object_key - > ToObject ( & object_key ) ) return maybe_object_key ;
if ( ! maybe_object_key - > ToObject ( & object_key ) ) return maybe_object_key ;
SetEntry ( entry , object_key , value , details ) ;
SetEntry ( entry , object_key , value , details ) ;
@ -11072,6 +11112,18 @@ MaybeObject* NumberDictionary::Set(uint32_t key,
}
}
MaybeObject * UnseededNumberDictionary : : Set ( uint32_t key ,
Object * value ) {
int entry = FindEntry ( key ) ;
if ( entry = = kNotFound ) return AddNumberEntry ( key , value ) ;
MaybeObject * maybe_object_key = UnseededNumberDictionaryShape : : AsObject ( key ) ;
Object * object_key ;
if ( ! maybe_object_key - > ToObject ( & object_key ) ) return maybe_object_key ;
SetEntry ( entry , object_key , value ) ;
return this ;
}
template < typename Shape , typename Key >
template < typename Shape , typename Key >
int Dictionary < Shape , Key > : : NumberOfElementsFilterAttributes (
int Dictionary < Shape , Key > : : NumberOfElementsFilterAttributes (