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

Side by Side Diff: src/objects.cc

Issue 9389005: DescriptorArray::CopyFrom should always drop transitions for CALLBACKS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Improved comments. 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 | « src/objects.h ('k') | src/objects-inl.h » ('j') | 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 5717 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) { 5733 static bool InsertionPointFound(String* key1, String* key2) {
5734 return key1->Hash() > key2->Hash() || key1 == key2; 5734 return key1->Hash() > key2->Hash() || key1 == key2;
5735 } 5735 }
5736 5736
5737 5737
5738 void DescriptorArray::CopyFrom(Handle<DescriptorArray> dst,
5739 int dst_index,
5740 Handle<DescriptorArray> src,
5741 int src_index,
5742 const WhitenessWitness& witness) {
5743 CALL_HEAP_FUNCTION_VOID(dst->GetIsolate(),
5744 dst->CopyFrom(dst_index, *src, src_index, witness));
5745 }
5746
5747
5748 MaybeObject* DescriptorArray::CopyFrom(int dst_index,
5749 DescriptorArray* src,
5750 int src_index,
5751 const WhitenessWitness& witness) {
5752 Object* value = src->GetValue(src_index);
5753 PropertyDetails details(src->GetDetails(src_index));
5754 if (details.type() == CALLBACKS && value->IsAccessorPair()) {
5755 MaybeObject* maybe_copy =
5756 AccessorPair::cast(value)->CopyWithoutTransitions();
5757 if (!maybe_copy->To(&value)) return maybe_copy;
5758 }
5759 Descriptor desc(src->GetKey(src_index), value, details);
5760 Set(dst_index, &desc, witness);
5761 return this;
5762 }
5763
5764
5738 MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor, 5765 MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor,
5739 TransitionFlag transition_flag) { 5766 TransitionFlag transition_flag) {
5740 // Transitions are only kept when inserting another transition. 5767 // Transitions are only kept when inserting another transition.
5741 // This precondition is not required by this function's implementation, but 5768 // This precondition is not required by this function's implementation, but
5742 // is currently required by the semantics of maps, so we check it. 5769 // is currently required by the semantics of maps, so we check it.
5743 // Conversely, we filter after replacing, so replacing a transition and 5770 // Conversely, we filter after replacing, so replacing a transition and
5744 // removing all other transitions is not supported. 5771 // removing all other transitions is not supported.
5745 bool remove_transitions = transition_flag == REMOVE_TRANSITIONS; 5772 bool remove_transitions = transition_flag == REMOVE_TRANSITIONS;
5746 ASSERT(remove_transitions == !descriptor->ContainsTransition()); 5773 ASSERT(remove_transitions == !descriptor->ContainsTransition());
5747 ASSERT(descriptor->GetDetails().type() != NULL_DESCRIPTOR); 5774 ASSERT(descriptor->GetDetails().type() != NULL_DESCRIPTOR);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
5811 int insertion_index = -1; 5838 int insertion_index = -1;
5812 int from_index = 0; 5839 int from_index = 0;
5813 while (from_index < number_of_descriptors()) { 5840 while (from_index < number_of_descriptors()) {
5814 if (insertion_index < 0 && 5841 if (insertion_index < 0 &&
5815 InsertionPointFound(GetKey(from_index), descriptor->GetKey())) { 5842 InsertionPointFound(GetKey(from_index), descriptor->GetKey())) {
5816 insertion_index = to_index++; 5843 insertion_index = to_index++;
5817 if (replacing) from_index++; 5844 if (replacing) from_index++;
5818 } else { 5845 } else {
5819 if (!(IsNullDescriptor(from_index) || 5846 if (!(IsNullDescriptor(from_index) ||
5820 (remove_transitions && IsTransitionOnly(from_index)))) { 5847 (remove_transitions && IsTransitionOnly(from_index)))) {
5821 new_descriptors->CopyFrom(to_index++, this, from_index, witness); 5848 MaybeObject* copy_result =
5849 new_descriptors->CopyFrom(to_index++, this, from_index, witness);
5850 if (copy_result->IsFailure()) return copy_result;
5822 } 5851 }
5823 from_index++; 5852 from_index++;
5824 } 5853 }
5825 } 5854 }
5826 if (insertion_index < 0) insertion_index = to_index++; 5855 if (insertion_index < 0) insertion_index = to_index++;
5827 new_descriptors->Set(insertion_index, descriptor, witness); 5856 new_descriptors->Set(insertion_index, descriptor, witness);
5828 5857
5829 ASSERT(to_index == new_descriptors->number_of_descriptors()); 5858 ASSERT(to_index == new_descriptors->number_of_descriptors());
5830 SLOW_ASSERT(new_descriptors->IsSortedNoDuplicates()); 5859 SLOW_ASSERT(new_descriptors->IsSortedNoDuplicates());
5831 5860
(...skipping 19 matching lines...) Expand all
5851 return maybe_result; 5880 return maybe_result;
5852 } 5881 }
5853 } 5882 }
5854 5883
5855 DescriptorArray::WhitenessWitness witness(new_descriptors); 5884 DescriptorArray::WhitenessWitness witness(new_descriptors);
5856 5885
5857 // Copy the content. 5886 // Copy the content.
5858 int next_descriptor = 0; 5887 int next_descriptor = 0;
5859 for (int i = 0; i < number_of_descriptors(); i++) { 5888 for (int i = 0; i < number_of_descriptors(); i++) {
5860 if (IsProperty(i)) { 5889 if (IsProperty(i)) {
5861 new_descriptors->CopyFrom(next_descriptor++, this, i, witness); 5890 MaybeObject* copy_result =
5891 new_descriptors->CopyFrom(next_descriptor++, this, i, witness);
5892 if (copy_result->IsFailure()) return copy_result;
5862 } 5893 }
5863 } 5894 }
5864 ASSERT(next_descriptor == new_descriptors->number_of_descriptors()); 5895 ASSERT(next_descriptor == new_descriptors->number_of_descriptors());
5865 5896
5866 return new_descriptors; 5897 return new_descriptors;
5867 } 5898 }
5868 5899
5869 5900
5870 void DescriptorArray::SortUnchecked(const WhitenessWitness& witness) { 5901 void DescriptorArray::SortUnchecked(const WhitenessWitness& witness) {
5871 // In-place heap sort. 5902 // In-place heap sort.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5964 if ((entry->Hash() == hash) && 5995 if ((entry->Hash() == hash) &&
5965 name->Equals(entry) && 5996 name->Equals(entry) &&
5966 !is_null_descriptor(number)) { 5997 !is_null_descriptor(number)) {
5967 return number; 5998 return number;
5968 } 5999 }
5969 } 6000 }
5970 return kNotFound; 6001 return kNotFound;
5971 } 6002 }
5972 6003
5973 6004
6005 MaybeObject* AccessorPair::CopyWithoutTransitions() {
6006 Heap* heap = GetHeap();
6007 AccessorPair* copy;
6008 { MaybeObject* maybe_copy = heap->AllocateAccessorPair();
6009 if (!maybe_copy->To(&copy)) return maybe_copy;
6010 }
6011 copy->set_getter(getter()->IsMap() ? heap->the_hole_value() : getter());
6012 copy->set_setter(setter()->IsMap() ? heap->the_hole_value() : setter());
6013 return copy;
6014 }
6015
6016
5974 MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count, 6017 MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count,
5975 PretenureFlag pretenure) { 6018 PretenureFlag pretenure) {
5976 ASSERT(deopt_entry_count > 0); 6019 ASSERT(deopt_entry_count > 0);
5977 return HEAP->AllocateFixedArray(LengthFor(deopt_entry_count), 6020 return HEAP->AllocateFixedArray(LengthFor(deopt_entry_count),
5978 pretenure); 6021 pretenure);
5979 } 6022 }
5980 6023
5981 6024
5982 MaybeObject* DeoptimizationOutputData::Allocate(int number_of_deopt_points, 6025 MaybeObject* DeoptimizationOutputData::Allocate(int number_of_deopt_points,
5983 PretenureFlag pretenure) { 6026 PretenureFlag pretenure) {
(...skipping 7047 matching lines...) Expand 10 before | Expand all | Expand 10 after
13031 if (break_point_objects()->IsUndefined()) return 0; 13074 if (break_point_objects()->IsUndefined()) return 0;
13032 // Single break point. 13075 // Single break point.
13033 if (!break_point_objects()->IsFixedArray()) return 1; 13076 if (!break_point_objects()->IsFixedArray()) return 1;
13034 // Multiple break points. 13077 // Multiple break points.
13035 return FixedArray::cast(break_point_objects())->length(); 13078 return FixedArray::cast(break_point_objects())->length();
13036 } 13079 }
13037 #endif // ENABLE_DEBUGGER_SUPPORT 13080 #endif // ENABLE_DEBUGGER_SUPPORT
13038 13081
13039 13082
13040 } } // namespace v8::internal 13083 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698