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 11701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11712 Handle<JSFunction>(isolate->observers_end_perform_splice()), | 11712 Handle<JSFunction>(isolate->observers_end_perform_splice()), |
11713 isolate->factory()->undefined_value(), | 11713 isolate->factory()->undefined_value(), |
11714 ARRAY_SIZE(args), | 11714 ARRAY_SIZE(args), |
11715 args).Assert(); | 11715 args).Assert(); |
11716 } | 11716 } |
11717 | 11717 |
11718 | 11718 |
11719 MaybeHandle<Object> JSArray::SetElementsLength( | 11719 MaybeHandle<Object> JSArray::SetElementsLength( |
11720 Handle<JSArray> array, | 11720 Handle<JSArray> array, |
11721 Handle<Object> new_length_handle) { | 11721 Handle<Object> new_length_handle) { |
| 11722 if (array->HasFastElements()) { |
| 11723 // If the new array won't fit in a some non-trivial fraction of the max old |
| 11724 // space size, then force it to go dictionary mode. |
| 11725 int max_fast_array_size = static_cast<int>( |
| 11726 (array->GetHeap()->MaxOldGenerationSize() / kDoubleSize) / 4); |
| 11727 if (new_length_handle->IsNumber() && |
| 11728 NumberToInt32(*new_length_handle) >= max_fast_array_size) { |
| 11729 NormalizeElements(array); |
| 11730 } |
| 11731 } |
| 11732 |
11722 // We should never end in here with a pixel or external array. | 11733 // We should never end in here with a pixel or external array. |
11723 ASSERT(array->AllowsSetElementsLength()); | 11734 ASSERT(array->AllowsSetElementsLength()); |
11724 if (!array->map()->is_observed()) { | 11735 if (!array->map()->is_observed()) { |
11725 return array->GetElementsAccessor()->SetLength(array, new_length_handle); | 11736 return array->GetElementsAccessor()->SetLength(array, new_length_handle); |
11726 } | 11737 } |
11727 | 11738 |
11728 Isolate* isolate = array->GetIsolate(); | 11739 Isolate* isolate = array->GetIsolate(); |
11729 List<uint32_t> indices; | 11740 List<uint32_t> indices; |
11730 List<Handle<Object> > old_values; | 11741 List<Handle<Object> > old_values; |
11731 Handle<Object> old_length_handle(array->length(), isolate); | 11742 Handle<Object> old_length_handle(array->length(), isolate); |
(...skipping 5209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16941 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16952 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16942 static const char* error_messages_[] = { | 16953 static const char* error_messages_[] = { |
16943 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16954 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16944 }; | 16955 }; |
16945 #undef ERROR_MESSAGES_TEXTS | 16956 #undef ERROR_MESSAGES_TEXTS |
16946 return error_messages_[reason]; | 16957 return error_messages_[reason]; |
16947 } | 16958 } |
16948 | 16959 |
16949 | 16960 |
16950 } } // namespace v8::internal | 16961 } } // namespace v8::internal |
OLD | NEW |