Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/objects.cc

Issue 9371013: Cleaned up DescriptorArray::CopyInsert a bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Cleaned up DescriptorArray::CopyInsert a bit. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5712 matching lines...) Expand 10 before | Expand all | Expand 10 after
5723 FixedArray::cast(bridge_storage)-> 5723 FixedArray::cast(bridge_storage)->
5724 set(kEnumCacheBridgeCacheIndex, new_cache); 5724 set(kEnumCacheBridgeCacheIndex, new_cache);
5725 NoWriteBarrierSet(FixedArray::cast(bridge_storage), 5725 NoWriteBarrierSet(FixedArray::cast(bridge_storage),
5726 kEnumCacheBridgeEnumIndex, 5726 kEnumCacheBridgeEnumIndex,
5727 get(kEnumerationIndexIndex)); 5727 get(kEnumerationIndexIndex));
5728 set(kEnumerationIndexIndex, bridge_storage); 5728 set(kEnumerationIndexIndex, bridge_storage);
5729 } 5729 }
5730 } 5730 }
5731 5731
5732 5732
5733 static bool InsertionPointFound(String* key1, String* key2) {
5734 return key1->Hash() > key2->Hash() || key1 == key2;
5735 }
5736
5737
5733 MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor, 5738 MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor,
5734 TransitionFlag transition_flag) { 5739 TransitionFlag transition_flag) {
5735 // Transitions are only kept when inserting another transition. 5740 // Transitions are only kept when inserting another transition.
5736 // This precondition is not required by this function's implementation, but 5741 // This precondition is not required by this function's implementation, but
5737 // is currently required by the semantics of maps, so we check it. 5742 // is currently required by the semantics of maps, so we check it.
5738 // Conversely, we filter after replacing, so replacing a transition and 5743 // Conversely, we filter after replacing, so replacing a transition and
5739 // removing all other transitions is not supported. 5744 // removing all other transitions is not supported.
5740 bool remove_transitions = transition_flag == REMOVE_TRANSITIONS; 5745 bool remove_transitions = transition_flag == REMOVE_TRANSITIONS;
5741 ASSERT(remove_transitions == !descriptor->ContainsTransition()); 5746 ASSERT(remove_transitions == !descriptor->ContainsTransition());
5742 ASSERT(descriptor->GetDetails().type() != NULL_DESCRIPTOR); 5747 ASSERT(descriptor->GetDetails().type() != NULL_DESCRIPTOR);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5795 PropertyDetails(GetDetails(index)).index()); 5800 PropertyDetails(GetDetails(index)).index());
5796 } else { 5801 } else {
5797 descriptor->SetEnumerationIndex(enumeration_index); 5802 descriptor->SetEnumerationIndex(enumeration_index);
5798 ++enumeration_index; 5803 ++enumeration_index;
5799 } 5804 }
5800 } 5805 }
5801 new_descriptors->SetNextEnumerationIndex(enumeration_index); 5806 new_descriptors->SetNextEnumerationIndex(enumeration_index);
5802 5807
5803 // Copy the descriptors, filtering out transitions and null descriptors, 5808 // Copy the descriptors, filtering out transitions and null descriptors,
5804 // and inserting or replacing a descriptor. 5809 // and inserting or replacing a descriptor.
5805 uint32_t descriptor_hash = descriptor->GetKey()->Hash(); 5810 int to_index = 0;
5811 int insertion_index = -1;
5806 int from_index = 0; 5812 int from_index = 0;
5807 int to_index = 0; 5813 while (from_index < number_of_descriptors()) {
5808 5814 if (insertion_index < 0 &&
5809 for (; from_index < number_of_descriptors(); from_index++) { 5815 InsertionPointFound(GetKey(from_index), descriptor->GetKey())) {
5810 String* key = GetKey(from_index); 5816 insertion_index = to_index++;
5811 if (key->Hash() > descriptor_hash || key == descriptor->GetKey()) { 5817 if (replacing) from_index++;
5812 break; 5818 } else {
5819 if (!(IsNullDescriptor(from_index) ||
5820 (remove_transitions && IsTransitionOnly(from_index)))) {
5821 new_descriptors->CopyFrom(to_index++, this, from_index, witness);
5822 }
5823 from_index++;
5813 } 5824 }
5814 if (IsNullDescriptor(from_index)) continue;
5815 if (remove_transitions && IsTransitionOnly(from_index)) continue;
5816 new_descriptors->CopyFrom(to_index++, this, from_index, witness);
5817 } 5825 }
5818 5826 if (insertion_index < 0) insertion_index = to_index++;
5819 new_descriptors->Set(to_index++, descriptor, witness); 5827 new_descriptors->Set(insertion_index, descriptor, witness);
5820 if (replacing) from_index++;
5821
5822 for (; from_index < number_of_descriptors(); from_index++) {
5823 if (IsNullDescriptor(from_index)) continue;
5824 if (remove_transitions && IsTransitionOnly(from_index)) continue;
5825 new_descriptors->CopyFrom(to_index++, this, from_index, witness);
5826 }
5827 5828
5828 ASSERT(to_index == new_descriptors->number_of_descriptors()); 5829 ASSERT(to_index == new_descriptors->number_of_descriptors());
5829 SLOW_ASSERT(new_descriptors->IsSortedNoDuplicates()); 5830 SLOW_ASSERT(new_descriptors->IsSortedNoDuplicates());
5830 5831
5831 return new_descriptors; 5832 return new_descriptors;
5832 } 5833 }
5833 5834
5834 5835
5835 MaybeObject* DescriptorArray::RemoveTransitions() { 5836 MaybeObject* DescriptorArray::RemoveTransitions() {
5836 // Remove all transitions and null descriptors. Return a copy of the array 5837 // Remove all transitions and null descriptors. Return a copy of the array
(...skipping 7196 matching lines...) Expand 10 before | Expand all | Expand 10 after
13033 if (break_point_objects()->IsUndefined()) return 0; 13034 if (break_point_objects()->IsUndefined()) return 0;
13034 // Single break point. 13035 // Single break point.
13035 if (!break_point_objects()->IsFixedArray()) return 1; 13036 if (!break_point_objects()->IsFixedArray()) return 1;
13036 // Multiple break points. 13037 // Multiple break points.
13037 return FixedArray::cast(break_point_objects())->length(); 13038 return FixedArray::cast(break_point_objects())->length();
13038 } 13039 }
13039 #endif // ENABLE_DEBUGGER_SUPPORT 13040 #endif // ENABLE_DEBUGGER_SUPPORT
13040 13041
13041 13042
13042 } } // namespace v8::internal 13043 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698