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 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 Object** zap = reinterpret_cast<Object**>(new_end); | 2114 Object** zap = reinterpret_cast<Object**>(new_end); |
2115 for (int i = 1; i < to_trim; i++) { | 2115 for (int i = 1; i < to_trim; i++) { |
2116 *zap++ = Smi::FromInt(0); | 2116 *zap++ = Smi::FromInt(0); |
2117 } | 2117 } |
2118 } | 2118 } |
2119 | 2119 |
2120 template<RightTrimMode trim_mode> | 2120 template<RightTrimMode trim_mode> |
2121 static void RightTrimFixedArray(Heap* heap, FixedArray* elms, int to_trim) { | 2121 static void RightTrimFixedArray(Heap* heap, FixedArray* elms, int to_trim) { |
2122 ASSERT(elms->map() != HEAP->fixed_cow_array_map()); | 2122 ASSERT(elms->map() != HEAP->fixed_cow_array_map()); |
2123 // For now this trick is only applied to fixed arrays in new and paged space. | 2123 // For now this trick is only applied to fixed arrays in new and paged space. |
2124 // In large object space the object's start must coincide with chunk | |
2125 // and thus the trick is just not applicable. | |
2126 ASSERT(!HEAP->lo_space()->Contains(elms)); | 2124 ASSERT(!HEAP->lo_space()->Contains(elms)); |
2127 | 2125 |
2128 const int len = elms->length(); | 2126 const int len = elms->length(); |
2129 | 2127 |
2130 ASSERT(to_trim < len); | 2128 ASSERT(to_trim < len); |
2131 | 2129 |
2132 Address new_end = elms->address() + FixedArray::SizeFor(len - to_trim); | 2130 Address new_end = elms->address() + FixedArray::SizeFor(len - to_trim); |
2133 | 2131 |
2134 if (trim_mode == FROM_GC) { | 2132 if (trim_mode == FROM_GC) { |
2135 #ifdef DEBUG | 2133 #ifdef DEBUG |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 } | 2209 } |
2212 | 2210 |
2213 int new_number_of_descriptors = map->NumberOfSetDescriptors(); | 2211 int new_number_of_descriptors = map->NumberOfSetDescriptors(); |
2214 // Reinstall the original descriptor array if no new elements were added. | 2212 // Reinstall the original descriptor array if no new elements were added. |
2215 if (new_number_of_descriptors == descriptor_count) { | 2213 if (new_number_of_descriptors == descriptor_count) { |
2216 map->set_instance_descriptors(*array); | 2214 map->set_instance_descriptors(*array); |
2217 return; | 2215 return; |
2218 } | 2216 } |
2219 | 2217 |
2220 // If duplicates were detected, trim the descriptor array to the right size. | 2218 // If duplicates were detected, trim the descriptor array to the right size. |
2221 int new_array_size = DescriptorArray::SizeFor(new_number_of_descriptors); | 2219 int new_array_size = DescriptorArray::LengthFor(new_number_of_descriptors); |
2222 if (new_array_size < result->length()) { | 2220 if (new_array_size < result->length()) { |
2223 RightTrimFixedArray<FROM_MUTATOR>( | 2221 RightTrimFixedArray<FROM_MUTATOR>( |
2224 isolate->heap(), *result, result->length() - new_array_size); | 2222 isolate->heap(), *result, result->length() - new_array_size); |
2225 } | 2223 } |
2226 } | 2224 } |
2227 | 2225 |
2228 | 2226 |
2229 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) { | 2227 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) { |
2230 ASSERT(!map.is_null()); | 2228 ASSERT(!map.is_null()); |
2231 for (int i = 0; i < maps->length(); ++i) { | 2229 for (int i = 0; i < maps->length(); ++i) { |
(...skipping 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4877 | 4875 |
4878 if (last_added == kNoneAdded) { | 4876 if (last_added == kNoneAdded) { |
4879 ASSERT(descriptors->IsEmpty()); | 4877 ASSERT(descriptors->IsEmpty()); |
4880 } else { | 4878 } else { |
4881 ASSERT(descriptors->GetDetails(last_added).index() == | 4879 ASSERT(descriptors->GetDetails(last_added).index() == |
4882 descriptors->number_of_descriptors()); | 4880 descriptors->number_of_descriptors()); |
4883 result->set_instance_descriptors(descriptors); | 4881 result->set_instance_descriptors(descriptors); |
4884 result->SetLastAdded(last_added); | 4882 result->SetLastAdded(last_added); |
4885 } | 4883 } |
4886 | 4884 |
4887 if (flag == INSERT_TRANSITION) { | 4885 if (flag == INSERT_TRANSITION && CanHaveMoreTransitions()) { |
4888 TransitionArray* transitions; | 4886 TransitionArray* transitions; |
4889 MaybeObject* maybe_transitions = AddTransition(name, result); | 4887 MaybeObject* maybe_transitions = AddTransition(name, result); |
4890 if (!maybe_transitions->To(&transitions)) return maybe_transitions; | 4888 if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
4891 | 4889 |
4892 MaybeObject* maybe_set = set_transitions(transitions); | 4890 MaybeObject* maybe_set = set_transitions(transitions); |
4893 if (maybe_set->IsFailure()) return maybe_set; | 4891 if (maybe_set->IsFailure()) return maybe_set; |
4894 | 4892 |
4895 result->SetBackPointer(this); | 4893 result->SetBackPointer(this); |
4896 } | 4894 } |
4897 | 4895 |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5837 MaybeObject* DescriptorArray::Allocate(int number_of_descriptors, | 5835 MaybeObject* DescriptorArray::Allocate(int number_of_descriptors, |
5838 SharedMode shared_mode) { | 5836 SharedMode shared_mode) { |
5839 Heap* heap = Isolate::Current()->heap(); | 5837 Heap* heap = Isolate::Current()->heap(); |
5840 // Do not use DescriptorArray::cast on incomplete object. | 5838 // Do not use DescriptorArray::cast on incomplete object. |
5841 FixedArray* result; | 5839 FixedArray* result; |
5842 if (number_of_descriptors == 0 && shared_mode == MAY_BE_SHARED) { | 5840 if (number_of_descriptors == 0 && shared_mode == MAY_BE_SHARED) { |
5843 return heap->empty_descriptor_array(); | 5841 return heap->empty_descriptor_array(); |
5844 } | 5842 } |
5845 // Allocate the array of keys. | 5843 // Allocate the array of keys. |
5846 MaybeObject* maybe_array = | 5844 MaybeObject* maybe_array = |
5847 heap->AllocateFixedArray(SizeFor(number_of_descriptors)); | 5845 heap->AllocateFixedArray(LengthFor(number_of_descriptors)); |
5848 if (!maybe_array->To(&result)) return maybe_array; | 5846 if (!maybe_array->To(&result)) return maybe_array; |
5849 | 5847 |
5850 result->set(kEnumCacheIndex, Smi::FromInt(0)); | 5848 result->set(kEnumCacheIndex, Smi::FromInt(0)); |
5851 result->set(kTransitionsIndex, Smi::FromInt(0)); | 5849 result->set(kTransitionsIndex, Smi::FromInt(0)); |
5852 return result; | 5850 return result; |
5853 } | 5851 } |
5854 | 5852 |
5855 | 5853 |
5856 void DescriptorArray::SetEnumCache(FixedArray* bridge_storage, | 5854 void DescriptorArray::SetEnumCache(FixedArray* bridge_storage, |
5857 FixedArray* new_cache, | 5855 FixedArray* new_cache, |
(...skipping 7276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13134 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13132 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13135 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13133 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13136 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13134 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13137 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13135 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13138 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13136 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13139 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13137 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13140 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13138 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13141 } | 13139 } |
13142 | 13140 |
13143 } } // namespace v8::internal | 13141 } } // namespace v8::internal |
OLD | NEW |