OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 11702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11713 Handle<JSFunction>(isolate->observers_end_perform_splice()), | 11713 Handle<JSFunction>(isolate->observers_end_perform_splice()), |
11714 isolate->factory()->undefined_value(), | 11714 isolate->factory()->undefined_value(), |
11715 ARRAY_SIZE(args), | 11715 ARRAY_SIZE(args), |
11716 args).Assert(); | 11716 args).Assert(); |
11717 } | 11717 } |
11718 | 11718 |
11719 | 11719 |
11720 MaybeHandle<Object> JSArray::SetElementsLength( | 11720 MaybeHandle<Object> JSArray::SetElementsLength( |
11721 Handle<JSArray> array, | 11721 Handle<JSArray> array, |
11722 Handle<Object> new_length_handle) { | 11722 Handle<Object> new_length_handle) { |
| 11723 if (array->HasFastElements()) { |
| 11724 // If the new array won't fit in a some non-trivial fraction of the max old |
| 11725 // space size, then force it to go dictionary mode. |
| 11726 int max_fast_array_size = static_cast<int>( |
| 11727 (array->GetHeap()->MaxOldGenerationSize() / kDoubleSize) / 4); |
| 11728 if (new_length_handle->IsNumber() && |
| 11729 NumberToInt32(*new_length_handle) >= max_fast_array_size) { |
| 11730 NormalizeElements(array); |
| 11731 } |
| 11732 } |
| 11733 |
11723 // We should never end in here with a pixel or external array. | 11734 // We should never end in here with a pixel or external array. |
11724 ASSERT(array->AllowsSetElementsLength()); | 11735 ASSERT(array->AllowsSetElementsLength()); |
11725 if (!array->map()->is_observed()) { | 11736 if (!array->map()->is_observed()) { |
11726 return array->GetElementsAccessor()->SetLength(array, new_length_handle); | 11737 return array->GetElementsAccessor()->SetLength(array, new_length_handle); |
11727 } | 11738 } |
11728 | 11739 |
11729 Isolate* isolate = array->GetIsolate(); | 11740 Isolate* isolate = array->GetIsolate(); |
11730 List<uint32_t> indices; | 11741 List<uint32_t> indices; |
11731 List<Handle<Object> > old_values; | 11742 List<Handle<Object> > old_values; |
11732 Handle<Object> old_length_handle(array->length(), isolate); | 11743 Handle<Object> old_length_handle(array->length(), isolate); |
(...skipping 5209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16942 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16953 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16943 static const char* error_messages_[] = { | 16954 static const char* error_messages_[] = { |
16944 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16955 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16945 }; | 16956 }; |
16946 #undef ERROR_MESSAGES_TEXTS | 16957 #undef ERROR_MESSAGES_TEXTS |
16947 return error_messages_[reason]; | 16958 return error_messages_[reason]; |
16948 } | 16959 } |
16949 | 16960 |
16950 | 16961 |
16951 } } // namespace v8::internal | 16962 } } // namespace v8::internal |
OLD | NEW |