| OLD | NEW | 
|      1 // Copyright 2013 the V8 project authors. All rights reserved. |      1 // Copyright 2013 the V8 project authors. All rights reserved. | 
|      2 // Redistribution and use in source and binary forms, with or without |      2 // Redistribution and use in source and binary forms, with or without | 
|      3 // modification, are permitted provided that the following conditions are |      3 // modification, are permitted provided that the following conditions are | 
|      4 // met: |      4 // met: | 
|      5 // |      5 // | 
|      6 //     * Redistributions of source code must retain the above copyright |      6 //     * Redistributions of source code must retain the above copyright | 
|      7 //       notice, this list of conditions and the following disclaimer. |      7 //       notice, this list of conditions and the following disclaimer. | 
|      8 //     * Redistributions in binary form must reproduce the above |      8 //     * Redistributions in binary form must reproduce the above | 
|      9 //       copyright notice, this list of conditions and the following |      9 //       copyright notice, this list of conditions and the following | 
|     10 //       disclaimer in the documentation and/or other materials provided |     10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   2453     return CopyGeneralizeAllRepresentations(); |   2453     return CopyGeneralizeAllRepresentations(); | 
|   2454   } |   2454   } | 
|   2455  |   2455  | 
|   2456   int verbatim = root_map->NumberOfOwnDescriptors(); |   2456   int verbatim = root_map->NumberOfOwnDescriptors(); | 
|   2457  |   2457  | 
|   2458   Map* updated = root_map->FindUpdatedMap( |   2458   Map* updated = root_map->FindUpdatedMap( | 
|   2459       verbatim, descriptors, old_descriptors); |   2459       verbatim, descriptors, old_descriptors); | 
|   2460   // Check the state of the root map. |   2460   // Check the state of the root map. | 
|   2461   DescriptorArray* updated_descriptors = updated->instance_descriptors(); |   2461   DescriptorArray* updated_descriptors = updated->instance_descriptors(); | 
|   2462  |   2462  | 
 |   2463   int valid = updated->NumberOfOwnDescriptors(); | 
 |   2464   if (updated_descriptors->IsMoreGeneralThan( | 
 |   2465           verbatim, valid, descriptors, old_descriptors)) { | 
 |   2466     Representation updated_representation = | 
 |   2467         updated_descriptors->GetDetails(modify_index).representation(); | 
 |   2468     if (new_representation.fits_into(updated_representation)) return updated; | 
 |   2469   } | 
 |   2470  | 
|   2463   DescriptorArray* new_descriptors; |   2471   DescriptorArray* new_descriptors; | 
|   2464   MaybeObject* maybe_descriptors = updated_descriptors->Merge( |   2472   MaybeObject* maybe_descriptors = updated_descriptors->Merge( | 
|   2465       verbatim, |   2473       verbatim, valid, descriptors, old_descriptors); | 
|   2466       updated->NumberOfOwnDescriptors(), |  | 
|   2467       descriptors, |  | 
|   2468       old_descriptors); |  | 
|   2469   if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; |   2474   if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; | 
|   2470  |   2475  | 
|   2471   old_reprepresentation = |   2476   old_reprepresentation = | 
|   2472       new_descriptors->GetDetails(modify_index).representation(); |   2477       new_descriptors->GetDetails(modify_index).representation(); | 
|   2473   new_representation = new_representation.generalize(old_reprepresentation); |   2478   new_representation = new_representation.generalize(old_reprepresentation); | 
|   2474   new_descriptors->SetRepresentation(modify_index, new_representation); |   2479   new_descriptors->SetRepresentation(modify_index, new_representation); | 
|   2475  |   2480  | 
|   2476   Map* split_map = root_map->FindLastMatchMap( |   2481   Map* split_map = root_map->FindLastMatchMap( | 
|   2477       verbatim, descriptors, new_descriptors); |   2482       verbatim, descriptors, new_descriptors); | 
|   2478  |   2483  | 
|   2479   int split_descriptors = split_map->NumberOfOwnDescriptors(); |   2484   int split_descriptors = split_map->NumberOfOwnDescriptors(); | 
|   2480   // Check whether |split_map| matches what we were looking for. If so, return |   2485   // This is shadowed by |updated_descriptors| being more general than | 
|   2481   // it. |   2486   // |old_descriptors|. | 
|   2482   if (descriptors == split_descriptors) return split_map; |   2487   ASSERT(descriptors != split_descriptors); | 
|   2483  |   2488  | 
|   2484   int descriptor = split_descriptors; |   2489   int descriptor = split_descriptors; | 
|   2485   split_map->DeprecateTarget( |   2490   split_map->DeprecateTarget( | 
|   2486       old_descriptors->GetKey(descriptor), new_descriptors); |   2491       old_descriptors->GetKey(descriptor), new_descriptors); | 
|   2487  |   2492  | 
|   2488   Map* new_map = split_map; |   2493   Map* new_map = split_map; | 
|   2489   // Add missing transitions. |   2494   // Add missing transitions. | 
|   2490   for (; descriptor < descriptors; descriptor++) { |   2495   for (; descriptor < descriptors; descriptor++) { | 
|   2491     MaybeObject* maybe_map = new_map->CopyInstallDescriptors( |   2496     MaybeObject* maybe_map = new_map->CopyInstallDescriptors( | 
|   2492         descriptor, new_descriptors); |   2497         descriptor, new_descriptors); | 
| (...skipping 4760 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   7253                                DescriptorArray* src, |   7258                                DescriptorArray* src, | 
|   7254                                int src_index, |   7259                                int src_index, | 
|   7255                                const WhitenessWitness& witness) { |   7260                                const WhitenessWitness& witness) { | 
|   7256   Object* value = src->GetValue(src_index); |   7261   Object* value = src->GetValue(src_index); | 
|   7257   PropertyDetails details = src->GetDetails(src_index); |   7262   PropertyDetails details = src->GetDetails(src_index); | 
|   7258   Descriptor desc(src->GetKey(src_index), value, details); |   7263   Descriptor desc(src->GetKey(src_index), value, details); | 
|   7259   Set(dst_index, &desc, witness); |   7264   Set(dst_index, &desc, witness); | 
|   7260 } |   7265 } | 
|   7261  |   7266  | 
|   7262  |   7267  | 
|   7263 // Generalize the |other| descriptor array by merging it with the (at least |   7268 // Generalize the |other| descriptor array by merging it into the (at least | 
|   7264 // partly) updated |this| descriptor array. |   7269 // partly) updated |this| descriptor array. | 
|   7265 // The method merges two descriptor array in three parts. Both descriptor arrays |   7270 // The method merges two descriptor array in three parts. Both descriptor arrays | 
|   7266 // are identical up to |verbatim|. They also overlap in keys up to |valid|. |   7271 // are identical up to |verbatim|. They also overlap in keys up to |valid|. | 
|   7267 // Between |verbatim| and |valid|, the resulting descriptor type as well as the |   7272 // Between |verbatim| and |valid|, the resulting descriptor type as well as the | 
|   7268 // representation are generalized from both |this| and |other|. Beyond |valid|, |   7273 // representation are generalized from both |this| and |other|. Beyond |valid|, | 
|   7269 // the descriptors are copied verbatim from |other| up to |new_size|. |   7274 // the descriptors are copied verbatim from |other| up to |new_size|. | 
|   7270 // In case of incompatible types, the type and representation of |other| is |   7275 // In case of incompatible types, the type and representation of |other| is | 
|   7271 // used. |   7276 // used. | 
|   7272 MaybeObject* DescriptorArray::Merge(int verbatim, |   7277 MaybeObject* DescriptorArray::Merge(int verbatim, | 
|   7273                                     int valid, |   7278                                     int valid, | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   7336     } else { |   7341     } else { | 
|   7337       result->CopyFrom(descriptor, other, descriptor, witness); |   7342       result->CopyFrom(descriptor, other, descriptor, witness); | 
|   7338     } |   7343     } | 
|   7339   } |   7344   } | 
|   7340  |   7345  | 
|   7341   result->Sort(); |   7346   result->Sort(); | 
|   7342   return result; |   7347   return result; | 
|   7343 } |   7348 } | 
|   7344  |   7349  | 
|   7345  |   7350  | 
 |   7351 // Checks whether a merge of |other| into |this| would return a copy of |this|. | 
 |   7352 bool DescriptorArray::IsMoreGeneralThan(int verbatim, | 
 |   7353                                         int valid, | 
 |   7354                                         int new_size, | 
 |   7355                                         DescriptorArray* other) { | 
 |   7356   ASSERT(verbatim <= valid); | 
 |   7357   ASSERT(valid <= new_size); | 
 |   7358   if (valid != new_size) return false; | 
 |   7359  | 
 |   7360   for (int descriptor = verbatim; descriptor < valid; descriptor++) { | 
 |   7361     PropertyDetails details = GetDetails(descriptor); | 
 |   7362     PropertyDetails other_details = other->GetDetails(descriptor); | 
 |   7363     if (details.type() != other_details.type()) { | 
 |   7364       if (details.type() != FIELD || | 
 |   7365           other_details.type() != CONSTANT_FUNCTION) { | 
 |   7366         return false; | 
 |   7367       } | 
 |   7368     } else if (details.type() == CONSTANT_FUNCTION) { | 
 |   7369       if (GetValue(descriptor) != other->GetValue(descriptor)) { | 
 |   7370         return false; | 
 |   7371       } | 
 |   7372     } else if (!other_details.representation().fits_into( | 
 |   7373                    details.representation())) { | 
 |   7374       return false; | 
 |   7375     } | 
 |   7376   } | 
 |   7377  | 
 |   7378   return true; | 
 |   7379 } | 
 |   7380  | 
 |   7381  | 
|   7346 // We need the whiteness witness since sort will reshuffle the entries in the |   7382 // We need the whiteness witness since sort will reshuffle the entries in the | 
|   7347 // descriptor array. If the descriptor array were to be black, the shuffling |   7383 // descriptor array. If the descriptor array were to be black, the shuffling | 
|   7348 // would move a slot that was already recorded as pointing into an evacuation |   7384 // would move a slot that was already recorded as pointing into an evacuation | 
|   7349 // candidate. This would result in missing updates upon evacuation. |   7385 // candidate. This would result in missing updates upon evacuation. | 
|   7350 void DescriptorArray::Sort() { |   7386 void DescriptorArray::Sort() { | 
|   7351   // In-place heap sort. |   7387   // In-place heap sort. | 
|   7352   int len = number_of_descriptors(); |   7388   int len = number_of_descriptors(); | 
|   7353   // Reset sorting since the descriptor array might contain invalid pointers. |   7389   // Reset sorting since the descriptor array might contain invalid pointers. | 
|   7354   for (int i = 0; i < len; ++i) SetSortedKey(i, i); |   7390   for (int i = 0; i < len; ++i) SetSortedKey(i, i); | 
|   7355   // Bottom-up max-heap construction. |   7391   // Bottom-up max-heap construction. | 
| (...skipping 7734 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  15090   set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |  15126   set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 
|  15091   set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |  15127   set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 
|  15092   set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |  15128   set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 
|  15093   set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |  15129   set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 
|  15094   set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |  15130   set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 
|  15095   set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |  15131   set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 
|  15096   set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |  15132   set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 
|  15097 } |  15133 } | 
|  15098  |  15134  | 
|  15099 } }  // namespace v8::internal |  15135 } }  // namespace v8::internal | 
| OLD | NEW |