| 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 3397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3408 Object* value = FastPropertyAt(descs->GetFieldIndex(i)); | 3408 Object* value = FastPropertyAt(descs->GetFieldIndex(i)); |
| 3409 Object* result; | 3409 Object* result; |
| 3410 { MaybeObject* maybe_result = | 3410 { MaybeObject* maybe_result = |
| 3411 dictionary->Add(descs->GetKey(i), value, d); | 3411 dictionary->Add(descs->GetKey(i), value, d); |
| 3412 if (!maybe_result->ToObject(&result)) return maybe_result; | 3412 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 3413 } | 3413 } |
| 3414 dictionary = StringDictionary::cast(result); | 3414 dictionary = StringDictionary::cast(result); |
| 3415 break; | 3415 break; |
| 3416 } | 3416 } |
| 3417 case CALLBACKS: { | 3417 case CALLBACKS: { |
| 3418 PropertyDetails d = | 3418 if (!descs->IsProperty(i)) break; |
| 3419 PropertyDetails(details.attributes(), CALLBACKS, details.index()); | 3419 Descriptor desc; |
| 3420 Object* value = descs->GetCallbacksObject(i); | 3420 { MaybeObject* result = |
| 3421 descs->GetDescriptorWithoutTransitions(i, &desc); |
| 3422 if (result->IsFailure()) return result; |
| 3423 } |
| 3421 Object* result; | 3424 Object* result; |
| 3422 { MaybeObject* maybe_result = | 3425 { MaybeObject* maybe_result = |
| 3423 dictionary->Add(descs->GetKey(i), value, d); | 3426 dictionary->Add(desc.GetKey(), |
| 3427 desc.GetValue(), |
| 3428 desc.GetDetails()); |
| 3424 if (!maybe_result->ToObject(&result)) return maybe_result; | 3429 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 3425 } | 3430 } |
| 3426 dictionary = StringDictionary::cast(result); | 3431 dictionary = StringDictionary::cast(result); |
| 3427 break; | 3432 break; |
| 3428 } | 3433 } |
| 3429 case MAP_TRANSITION: | 3434 case MAP_TRANSITION: |
| 3430 case CONSTANT_TRANSITION: | 3435 case CONSTANT_TRANSITION: |
| 3431 case NULL_DESCRIPTOR: | 3436 case NULL_DESCRIPTOR: |
| 3432 case INTERCEPTOR: | 3437 case INTERCEPTOR: |
| 3433 case ELEMENTS_TRANSITION: | 3438 case ELEMENTS_TRANSITION: |
| (...skipping 2289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5723 FixedArray::cast(bridge_storage)-> | 5728 FixedArray::cast(bridge_storage)-> |
| 5724 set(kEnumCacheBridgeCacheIndex, new_cache); | 5729 set(kEnumCacheBridgeCacheIndex, new_cache); |
| 5725 NoWriteBarrierSet(FixedArray::cast(bridge_storage), | 5730 NoWriteBarrierSet(FixedArray::cast(bridge_storage), |
| 5726 kEnumCacheBridgeEnumIndex, | 5731 kEnumCacheBridgeEnumIndex, |
| 5727 get(kEnumerationIndexIndex)); | 5732 get(kEnumerationIndexIndex)); |
| 5728 set(kEnumerationIndexIndex, bridge_storage); | 5733 set(kEnumerationIndexIndex, bridge_storage); |
| 5729 } | 5734 } |
| 5730 } | 5735 } |
| 5731 | 5736 |
| 5732 | 5737 |
| 5738 MaybeObject* DescriptorArray::GetDescriptorWithoutTransitions( |
| 5739 int descriptor_number, |
| 5740 Descriptor* descriptor) { |
| 5741 PropertyDetails details(GetDetails(descriptor_number)); |
| 5742 Object* value = GetValue(descriptor_number); |
| 5743 if (details.type() == CALLBACKS && value->IsAccessorPair()) { |
| 5744 MaybeObject* maybe_copy = |
| 5745 AccessorPair::cast(value)->CopyWithoutTransitions(); |
| 5746 if (!maybe_copy->To(&value)) return maybe_copy; |
| 5747 } |
| 5748 descriptor->Init(GetKey(descriptor_number), value, details); |
| 5749 return Smi::FromInt(0); |
| 5750 } |
| 5751 |
| 5752 |
| 5733 static bool InsertionPointFound(String* key1, String* key2) { | 5753 static bool InsertionPointFound(String* key1, String* key2) { |
| 5734 return key1->Hash() > key2->Hash() || key1 == key2; | 5754 return key1->Hash() > key2->Hash() || key1 == key2; |
| 5735 } | 5755 } |
| 5736 | 5756 |
| 5737 | 5757 |
| 5738 MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor, | 5758 MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor, |
| 5739 TransitionFlag transition_flag) { | 5759 TransitionFlag transition_flag) { |
| 5740 // Transitions are only kept when inserting another transition. | 5760 // Transitions are only kept when inserting another transition. |
| 5741 // This precondition is not required by this function's implementation, but | 5761 // This precondition is not required by this function's implementation, but |
| 5742 // is currently required by the semantics of maps, so we check it. | 5762 // is currently required by the semantics of maps, so we check it. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5811 int insertion_index = -1; | 5831 int insertion_index = -1; |
| 5812 int from_index = 0; | 5832 int from_index = 0; |
| 5813 while (from_index < number_of_descriptors()) { | 5833 while (from_index < number_of_descriptors()) { |
| 5814 if (insertion_index < 0 && | 5834 if (insertion_index < 0 && |
| 5815 InsertionPointFound(GetKey(from_index), descriptor->GetKey())) { | 5835 InsertionPointFound(GetKey(from_index), descriptor->GetKey())) { |
| 5816 insertion_index = to_index++; | 5836 insertion_index = to_index++; |
| 5817 if (replacing) from_index++; | 5837 if (replacing) from_index++; |
| 5818 } else { | 5838 } else { |
| 5819 if (!(IsNullDescriptor(from_index) || | 5839 if (!(IsNullDescriptor(from_index) || |
| 5820 (remove_transitions && IsTransitionOnly(from_index)))) { | 5840 (remove_transitions && IsTransitionOnly(from_index)))) { |
| 5821 new_descriptors->CopyFrom(to_index++, this, from_index, witness); | 5841 Descriptor desc; |
| 5842 { MaybeObject* result = |
| 5843 GetDescriptorWithoutTransitions(from_index, &desc); |
| 5844 if (result->IsFailure()) return result; |
| 5845 } |
| 5846 new_descriptors->Set(to_index++, &desc, witness); |
| 5822 } | 5847 } |
| 5823 from_index++; | 5848 from_index++; |
| 5824 } | 5849 } |
| 5825 } | 5850 } |
| 5826 if (insertion_index < 0) insertion_index = to_index++; | 5851 if (insertion_index < 0) insertion_index = to_index++; |
| 5827 new_descriptors->Set(insertion_index, descriptor, witness); | 5852 new_descriptors->Set(insertion_index, descriptor, witness); |
| 5828 | 5853 |
| 5829 ASSERT(to_index == new_descriptors->number_of_descriptors()); | 5854 ASSERT(to_index == new_descriptors->number_of_descriptors()); |
| 5830 SLOW_ASSERT(new_descriptors->IsSortedNoDuplicates()); | 5855 SLOW_ASSERT(new_descriptors->IsSortedNoDuplicates()); |
| 5831 | 5856 |
| 5832 return new_descriptors; | 5857 return new_descriptors; |
| 5833 } | 5858 } |
| 5834 | 5859 |
| 5835 | 5860 |
| 5836 MaybeObject* DescriptorArray::RemoveTransitions() { | 5861 MaybeObject* DescriptorArray::RemoveTransitions() { |
| 5837 // Remove all transitions and null descriptors. Return a copy of the array | 5862 // Remove all transitions and null descriptors. Return a copy of the array |
| 5838 // with all transitions removed, or a Failure object if the new array could | 5863 // with all transitions removed, or a Failure object if the new array could |
| 5839 // not be allocated. | 5864 // not be allocated. |
| 5840 | 5865 |
| 5841 // Compute the size of the map transition entries to be removed. | 5866 // Allocate the new descriptor array. |
| 5842 int new_number_of_descriptors = 0; | 5867 int new_number_of_descriptors = 0; |
| 5843 for (int i = 0; i < number_of_descriptors(); i++) { | 5868 for (int i = 0; i < number_of_descriptors(); i++) { |
| 5844 if (IsProperty(i)) new_number_of_descriptors++; | 5869 if (IsProperty(i)) new_number_of_descriptors++; |
| 5845 } | 5870 } |
| 5846 | |
| 5847 // Allocate the new descriptor array. | |
| 5848 DescriptorArray* new_descriptors; | 5871 DescriptorArray* new_descriptors; |
| 5849 { MaybeObject* maybe_result = Allocate(new_number_of_descriptors); | 5872 { MaybeObject* maybe_result = Allocate(new_number_of_descriptors); |
| 5850 if (!maybe_result->To<DescriptorArray>(&new_descriptors)) { | 5873 if (!maybe_result->To(&new_descriptors)) return maybe_result; |
| 5851 return maybe_result; | |
| 5852 } | |
| 5853 } | 5874 } |
| 5854 | 5875 |
| 5876 // Copy the content. |
| 5855 DescriptorArray::WhitenessWitness witness(new_descriptors); | 5877 DescriptorArray::WhitenessWitness witness(new_descriptors); |
| 5856 | |
| 5857 // Copy the content. | |
| 5858 int next_descriptor = 0; | 5878 int next_descriptor = 0; |
| 5859 for (int i = 0; i < number_of_descriptors(); i++) { | 5879 for (int i = 0; i < number_of_descriptors(); i++) { |
| 5860 if (IsProperty(i)) { | 5880 if (IsProperty(i)) { |
| 5861 new_descriptors->CopyFrom(next_descriptor++, this, i, witness); | 5881 Descriptor desc; |
| 5882 { MaybeObject* result = GetDescriptorWithoutTransitions(i, &desc); |
| 5883 if (result->IsFailure()) return result; |
| 5884 } |
| 5885 new_descriptors->Set(next_descriptor++, &desc, witness); |
| 5862 } | 5886 } |
| 5863 } | 5887 } |
| 5864 ASSERT(next_descriptor == new_descriptors->number_of_descriptors()); | 5888 ASSERT(next_descriptor == new_descriptors->number_of_descriptors()); |
| 5865 | 5889 |
| 5866 return new_descriptors; | 5890 return new_descriptors; |
| 5867 } | 5891 } |
| 5868 | 5892 |
| 5869 | 5893 |
| 5870 void DescriptorArray::SortUnchecked(const WhitenessWitness& witness) { | 5894 void DescriptorArray::SortUnchecked(const WhitenessWitness& witness) { |
| 5871 // In-place heap sort. | 5895 // In-place heap sort. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5964 if ((entry->Hash() == hash) && | 5988 if ((entry->Hash() == hash) && |
| 5965 name->Equals(entry) && | 5989 name->Equals(entry) && |
| 5966 !is_null_descriptor(number)) { | 5990 !is_null_descriptor(number)) { |
| 5967 return number; | 5991 return number; |
| 5968 } | 5992 } |
| 5969 } | 5993 } |
| 5970 return kNotFound; | 5994 return kNotFound; |
| 5971 } | 5995 } |
| 5972 | 5996 |
| 5973 | 5997 |
| 5998 MaybeObject* AccessorPair::CopyWithoutTransitions() { |
| 5999 Heap* heap = GetHeap(); |
| 6000 AccessorPair* copy; |
| 6001 { MaybeObject* maybe_copy = heap->AllocateAccessorPair(); |
| 6002 if (!maybe_copy->To(©)) return maybe_copy; |
| 6003 } |
| 6004 copy->set_getter(getter()->IsMap() ? heap->the_hole_value() : getter()); |
| 6005 copy->set_setter(setter()->IsMap() ? heap->the_hole_value() : setter()); |
| 6006 return copy; |
| 6007 } |
| 6008 |
| 6009 |
| 5974 MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count, | 6010 MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count, |
| 5975 PretenureFlag pretenure) { | 6011 PretenureFlag pretenure) { |
| 5976 ASSERT(deopt_entry_count > 0); | 6012 ASSERT(deopt_entry_count > 0); |
| 5977 return HEAP->AllocateFixedArray(LengthFor(deopt_entry_count), | 6013 return HEAP->AllocateFixedArray(LengthFor(deopt_entry_count), |
| 5978 pretenure); | 6014 pretenure); |
| 5979 } | 6015 } |
| 5980 | 6016 |
| 5981 | 6017 |
| 5982 MaybeObject* DeoptimizationOutputData::Allocate(int number_of_deopt_points, | 6018 MaybeObject* DeoptimizationOutputData::Allocate(int number_of_deopt_points, |
| 5983 PretenureFlag pretenure) { | 6019 PretenureFlag pretenure) { |
| (...skipping 7047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13031 if (break_point_objects()->IsUndefined()) return 0; | 13067 if (break_point_objects()->IsUndefined()) return 0; |
| 13032 // Single break point. | 13068 // Single break point. |
| 13033 if (!break_point_objects()->IsFixedArray()) return 1; | 13069 if (!break_point_objects()->IsFixedArray()) return 1; |
| 13034 // Multiple break points. | 13070 // Multiple break points. |
| 13035 return FixedArray::cast(break_point_objects())->length(); | 13071 return FixedArray::cast(break_point_objects())->length(); |
| 13036 } | 13072 } |
| 13037 #endif // ENABLE_DEBUGGER_SUPPORT | 13073 #endif // ENABLE_DEBUGGER_SUPPORT |
| 13038 | 13074 |
| 13039 | 13075 |
| 13040 } } // namespace v8::internal | 13076 } } // namespace v8::internal |
| OLD | NEW |