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

Side by Side Diff: src/objects.cc

Issue 10694155: Renamed ConvertDescriptorToFieldAndMapTransition to ConvertTransitionToMapTransition, and let it re… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 if (old_index != -1) { 1772 if (old_index != -1) {
1773 // All calls to ReplaceSlowProperty have had all transitions removed. 1773 // All calls to ReplaceSlowProperty have had all transitions removed.
1774 new_enumeration_index = dictionary->DetailsAt(old_index).index(); 1774 new_enumeration_index = dictionary->DetailsAt(old_index).index();
1775 } 1775 }
1776 1776
1777 PropertyDetails new_details(attributes, NORMAL, new_enumeration_index); 1777 PropertyDetails new_details(attributes, NORMAL, new_enumeration_index);
1778 return SetNormalizedProperty(name, value, new_details); 1778 return SetNormalizedProperty(name, value, new_details);
1779 } 1779 }
1780 1780
1781 1781
1782 MaybeObject* JSObject::ConvertDescriptorToFieldAndMapTransition( 1782 MaybeObject* JSObject::ConvertTransitionToMapTransition(
1783 int transition_index,
1783 String* name, 1784 String* name,
1784 Object* new_value, 1785 Object* new_value,
1785 PropertyAttributes attributes) { 1786 PropertyAttributes attributes) {
1786 Map* old_map = map(); 1787 Map* old_map = map();
1787 FixedArray* old_properties = properties();
1788 Object* result; 1788 Object* result;
1789 1789
1790 MaybeObject* maybe_result = 1790 MaybeObject* maybe_result =
1791 ConvertDescriptorToField(name, new_value, attributes); 1791 ConvertDescriptorToField(name, new_value, attributes);
1792 if (!maybe_result->To(&result)) return maybe_result; 1792 if (!maybe_result->To(&result)) return maybe_result;
1793 1793
1794 if (!HasFastProperties()) return result; 1794 if (!HasFastProperties()) return result;
1795 1795
1796 // This method should only be used to convert existing transitions. Objects 1796 // This method should only be used to convert existing transitions. Objects
1797 // with the map of "new Object()" cannot have transitions in the first place. 1797 // with the map of "new Object()" cannot have transitions in the first place.
1798 ASSERT(map() != GetIsolate()->empty_object_map()); 1798 ASSERT(map() != GetIsolate()->empty_object_map());
1799 1799
1800 TransitionArray* new_transitions; 1800 // TODO(verwaest): From here on we lose existing map transitions, causing
1801 MaybeObject* maybe_new_transitions = old_map->AddTransition(name, map()); 1801 // invalid back pointers. This will change once we can store multiple
1802 if (!maybe_new_transitions->To(&new_transitions)) { 1802 // transitions with the same key.
1803 // Undo changes and return failure. 1803 old_map->SetTransition(transition_index, map());
1804 set_map(old_map);
1805 set_properties(old_properties);
1806 return maybe_new_transitions;
1807 }
1808
1809 MaybeObject* transition_added = old_map->set_transitions(new_transitions);
1810 if (transition_added->IsFailure()) {
1811 // Undo changes and return failure.
1812 set_map(old_map);
1813 set_properties(old_properties);
1814 return transition_added;
1815 }
1816
1817 map()->SetBackPointer(old_map); 1804 map()->SetBackPointer(old_map);
1818 return result; 1805 return result;
1819 } 1806 }
1820 1807
1821 1808
1822 MaybeObject* JSObject::ConvertDescriptorToField(String* name, 1809 MaybeObject* JSObject::ConvertDescriptorToField(String* name,
1823 Object* new_value, 1810 Object* new_value,
1824 PropertyAttributes attributes) { 1811 PropertyAttributes attributes) {
1825 if (map()->unused_property_fields() == 0 && 1812 if (map()->unused_property_fields() == 0 &&
1826 TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) { 1813 TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) {
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 // Is transition to CONSTANT_FUNCTION. 2894 // Is transition to CONSTANT_FUNCTION.
2908 Object* constant_function = descriptors->GetValue(descriptor); 2895 Object* constant_function = descriptors->GetValue(descriptor);
2909 // If the same constant function is being added we can simply 2896 // If the same constant function is being added we can simply
2910 // transition to the target map. 2897 // transition to the target map.
2911 if (constant_function == *value) { 2898 if (constant_function == *value) {
2912 self->set_map(transition_map); 2899 self->set_map(transition_map);
2913 return constant_function; 2900 return constant_function;
2914 } 2901 }
2915 // Otherwise, replace with a map transition to a new map with a FIELD, 2902 // Otherwise, replace with a map transition to a new map with a FIELD,
2916 // even if the value is a constant function. 2903 // even if the value is a constant function.
2917 return self->ConvertDescriptorToFieldAndMapTransition(*name, 2904 return ConvertTransitionToMapTransition(
2918 *value, 2905 result->GetTransitionIndex(), *name, *value, attributes);
2919 attributes);
2920 } 2906 }
2921 case HANDLER: 2907 case HANDLER:
2922 case NONEXISTENT: 2908 case NONEXISTENT:
2923 UNREACHABLE(); 2909 UNREACHABLE();
2924 return *value; 2910 return *value;
2925 } 2911 }
2926 UNREACHABLE(); // keep the compiler happy 2912 UNREACHABLE(); // keep the compiler happy
2927 return *value; 2913 return *value;
2928 } 2914 }
2929 2915
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 return AddFastPropertyUsingMap(transition_map, 3009 return AddFastPropertyUsingMap(transition_map,
3024 name, 3010 name,
3025 value, 3011 value,
3026 field_index); 3012 field_index);
3027 } 3013 }
3028 return ConvertDescriptorToField(name, value, attributes); 3014 return ConvertDescriptorToField(name, value, attributes);
3029 } 3015 }
3030 3016
3031 // Was transition to CONSTANT_FUNCTION. Replace with a map transition to a 3017 // Was transition to CONSTANT_FUNCTION. Replace with a map transition to a
3032 // new map with a FIELD, even if the value is a function. 3018 // new map with a FIELD, even if the value is a function.
3033 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes); 3019 return ConvertTransitionToMapTransition(
3020 result.GetTransitionIndex(), name, value, attributes);
3034 } 3021 }
3035 case HANDLER: 3022 case HANDLER:
3036 case NONEXISTENT: 3023 case NONEXISTENT:
3037 UNREACHABLE(); 3024 UNREACHABLE();
3038 } 3025 }
3039 UNREACHABLE(); // keep the compiler happy 3026 UNREACHABLE(); // keep the compiler happy
3040 return value; 3027 return value;
3041 } 3028 }
3042 3029
3043 3030
(...skipping 10223 matching lines...) Expand 10 before | Expand all | Expand 10 after
13267 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13254 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13268 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13255 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13269 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13256 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13270 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13257 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13271 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13258 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13272 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13259 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13273 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13260 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13274 } 13261 }
13275 13262
13276 } } // namespace v8::internal 13263 } } // 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