OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5138 | 5138 |
5139 // In case the map did not own its own descriptors, a split is forced by | 5139 // In case the map did not own its own descriptors, a split is forced by |
5140 // copying the map; creating a new descriptor array cell. | 5140 // copying the map; creating a new descriptor array cell. |
5141 // Create a new free-floating map only if we are not allowed to store it. | 5141 // Create a new free-floating map only if we are not allowed to store it. |
5142 Map* new_map; | 5142 Map* new_map; |
5143 MaybeObject* maybe_new_map = Copy(); | 5143 MaybeObject* maybe_new_map = Copy(); |
5144 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 5144 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
5145 ASSERT(new_map->NumberOfOwnDescriptors() == NumberOfOwnDescriptors()); | 5145 ASSERT(new_map->NumberOfOwnDescriptors() == NumberOfOwnDescriptors()); |
5146 new_map->set_elements_kind(kind); | 5146 new_map->set_elements_kind(kind); |
5147 | 5147 |
5148 if (flag == INSERT_TRANSITION) { | 5148 if (flag == INSERT_TRANSITION && !HasElementsTransition()) { |
5149 // Map::Copy does not store the descriptor array in case it is empty, since | 5149 // Map::Copy does not store the descriptor array in case it is empty, since |
5150 // it does not insert a back pointer; implicitly indicating that its | 5150 // it does not insert a back pointer; implicitly indicating that its |
5151 // descriptor array is empty. Since in this case we do want to insert a back | 5151 // descriptor array is empty. Since in this case we do want to insert a back |
5152 // pointer, we have to manually set the empty descriptor array to force a | 5152 // pointer, we have to manually set the empty descriptor array to force a |
5153 // split. | 5153 // split. |
5154 if (!new_map->StoresOwnDescriptors()) { | 5154 if (!new_map->StoresOwnDescriptors()) { |
5155 ASSERT(new_map->NumberOfOwnDescriptors() == 0); | 5155 ASSERT(new_map->NumberOfOwnDescriptors() == 0); |
5156 MaybeObject* maybe_failure = | 5156 MaybeObject* maybe_failure = |
5157 new_map->SetDescriptors(GetHeap()->empty_descriptor_array()); | 5157 new_map->SetDescriptors(GetHeap()->empty_descriptor_array()); |
5158 if (maybe_failure->IsFailure()) return maybe_failure; | 5158 if (maybe_failure->IsFailure()) return maybe_failure; |
(...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7557 if (descriptors_owner_died) { | 7557 if (descriptors_owner_died) { |
7558 if (number_of_own_descriptors > 0) { | 7558 if (number_of_own_descriptors > 0) { |
7559 TrimDescriptorArray(heap, this, descriptors, number_of_own_descriptors); | 7559 TrimDescriptorArray(heap, this, descriptors, number_of_own_descriptors); |
7560 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); | 7560 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); |
7561 } else { | 7561 } else { |
7562 t->set_descriptors(heap->empty_descriptor_array()); | 7562 t->set_descriptors(heap->empty_descriptor_array()); |
7563 } | 7563 } |
7564 set_owns_descriptors(true); | 7564 set_owns_descriptors(true); |
7565 } | 7565 } |
7566 | 7566 |
7567 // If the final transition array does not contain any live transitions, remove | |
7568 // the transition array from the map. | |
7569 if (transition_index == 0 && | |
7570 !t->HasElementsTransition() && | |
7571 !t->HasPrototypeTransitions() && | |
7572 number_of_own_descriptors == 0) { | |
7573 ASSERT(owns_descriptors()); | |
7574 return ClearTransitions(heap); | |
7575 } | |
7576 | |
7577 int trim = t->number_of_transitions() - transition_index; | 7567 int trim = t->number_of_transitions() - transition_index; |
7578 if (trim > 0) { | 7568 if (trim > 0) { |
7579 RightTrimFixedArray<FROM_GC>(heap, t, t->IsSimpleTransition() | 7569 RightTrimFixedArray<FROM_GC>(heap, t, t->IsSimpleTransition() |
7580 ? trim : trim * TransitionArray::kTransitionSize); | 7570 ? trim : trim * TransitionArray::kTransitionSize); |
7581 } | 7571 } |
7582 } | 7572 } |
7583 | 7573 |
7584 | 7574 |
7585 int Map::Hash() { | 7575 int Map::Hash() { |
7586 // For performance reasons we only hash the 3 most variable fields of a map: | 7576 // For performance reasons we only hash the 3 most variable fields of a map: |
(...skipping 5963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13550 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13540 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13551 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13541 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13552 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13542 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13553 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13543 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13554 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13544 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13555 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13545 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13556 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13546 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13557 } | 13547 } |
13558 | 13548 |
13559 } } // namespace v8::internal | 13549 } } // namespace v8::internal |
OLD | NEW |