@@ -2285,9 +2285,9 @@ bool HeapObject::NeedsRehashing() const {
22852285 case TRANSITION_ARRAY_TYPE:
22862286 return TransitionArray::cast (*this ).number_of_entries () > 1 ;
22872287 case ORDERED_HASH_MAP_TYPE:
2288- return OrderedHashMap::cast (* this ). NumberOfElements () > 0 ;
2288+ return false ; // We'll rehash from the JSMap referecing it
22892289 case ORDERED_HASH_SET_TYPE:
2290- return OrderedHashSet::cast (* this ). NumberOfElements () > 0 ;
2290+ return false ; // We'll rehash from the JSSap referecing it
22912291 case NAME_DICTIONARY_TYPE:
22922292 case GLOBAL_DICTIONARY_TYPE:
22932293 case NUMBER_DICTIONARY_TYPE:
@@ -2297,6 +2297,8 @@ bool HeapObject::NeedsRehashing() const {
22972297 case SMALL_ORDERED_HASH_MAP_TYPE:
22982298 case SMALL_ORDERED_HASH_SET_TYPE:
22992299 case SMALL_ORDERED_NAME_DICTIONARY_TYPE:
2300+ case JS_MAP_TYPE:
2301+ case JS_SET_TYPE:
23002302 return true ;
23012303 default :
23022304 return false ;
@@ -2306,8 +2308,12 @@ bool HeapObject::NeedsRehashing() const {
23062308bool HeapObject::CanBeRehashed () const {
23072309 DCHECK (NeedsRehashing ());
23082310 switch (map ().instance_type ()) {
2311+ case JS_MAP_TYPE:
2312+ case JS_SET_TYPE:
2313+ return true ;
23092314 case ORDERED_HASH_MAP_TYPE:
23102315 case ORDERED_HASH_SET_TYPE:
2316+ UNREACHABLE (); // We'll rehash from the JSMap or JSSet referecing them
23112317 case ORDERED_NAME_DICTIONARY_TYPE:
23122318 // TODO(yangguo): actually support rehashing OrderedHash{Map,Set}.
23132319 return false ;
@@ -2333,7 +2339,7 @@ bool HeapObject::CanBeRehashed() const {
23332339 return false ;
23342340}
23352341
2336- void HeapObject::RehashBasedOnMap (ReadOnlyRoots roots) {
2342+ void HeapObject::RehashBasedOnMap (Isolate* isolate, ReadOnlyRoots roots) {
23372343 switch (map ().instance_type ()) {
23382344 case HASH_TABLE_TYPE:
23392345 UNREACHABLE ();
@@ -2365,6 +2371,25 @@ void HeapObject::RehashBasedOnMap(ReadOnlyRoots roots) {
23652371 case SMALL_ORDERED_HASH_SET_TYPE:
23662372 DCHECK_EQ (0 , SmallOrderedHashSet::cast (*this ).NumberOfElements ());
23672373 break ;
2374+ case ORDERED_HASH_MAP_TYPE:
2375+ case ORDERED_HASH_SET_TYPE:
2376+ UNREACHABLE (); // We'll rehash from the JSMap or JSSet referecing them
2377+ case JS_MAP_TYPE: {
2378+ JSMap map = JSMap::cast (*this );
2379+ Handle<OrderedHashMap> table (OrderedHashMap::cast (map.table ()), isolate);
2380+ Handle<OrderedHashMap> new_table =
2381+ OrderedHashMap::Rehash (isolate, table).ToHandleChecked ();
2382+ map.set_table (*new_table);
2383+ break ;
2384+ }
2385+ case JS_SET_TYPE: {
2386+ JSSet set = JSSet::cast (*this );
2387+ Handle<OrderedHashSet> table (OrderedHashSet::cast (set.table ()), isolate);
2388+ Handle<OrderedHashSet> new_table =
2389+ OrderedHashSet::Rehash (isolate, table).ToHandleChecked ();
2390+ set.set_table (*new_table);
2391+ break ;
2392+ }
23682393 case SMALL_ORDERED_NAME_DICTIONARY_TYPE:
23692394 DCHECK_EQ (0 , SmallOrderedNameDictionary::cast (*this ).NumberOfElements ());
23702395 break ;
0 commit comments