OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 13095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13106 // External arrays are considered 100% used. | 13106 // External arrays are considered 100% used. |
13107 FixedArrayBase* external_array = FixedArrayBase::cast(elements()); | 13107 FixedArrayBase* external_array = FixedArrayBase::cast(elements()); |
13108 *capacity = external_array->length(); | 13108 *capacity = external_array->length(); |
13109 *used = external_array->length(); | 13109 *used = external_array->length(); |
13110 break; | 13110 break; |
13111 } | 13111 } |
13112 } | 13112 } |
13113 } | 13113 } |
13114 | 13114 |
13115 | 13115 |
| 13116 bool JSObject::WouldConvertToSlowElements(Handle<Object> key) { |
| 13117 uint32_t index; |
| 13118 if (HasFastElements() && key->ToArrayIndex(&index)) { |
| 13119 Handle<FixedArrayBase> backing_store(FixedArrayBase::cast(elements())); |
| 13120 uint32_t capacity = static_cast<uint32_t>(backing_store->length()); |
| 13121 if (index >= capacity) { |
| 13122 if ((index - capacity) >= kMaxGap) return true; |
| 13123 uint32_t new_capacity = NewElementsCapacity(index + 1); |
| 13124 return ShouldConvertToSlowElements(new_capacity); |
| 13125 } |
| 13126 } |
| 13127 return false; |
| 13128 } |
| 13129 |
| 13130 |
13116 bool JSObject::ShouldConvertToSlowElements(int new_capacity) { | 13131 bool JSObject::ShouldConvertToSlowElements(int new_capacity) { |
13117 STATIC_ASSERT(kMaxUncheckedOldFastElementsLength <= | 13132 STATIC_ASSERT(kMaxUncheckedOldFastElementsLength <= |
13118 kMaxUncheckedFastElementsLength); | 13133 kMaxUncheckedFastElementsLength); |
13119 if (new_capacity <= kMaxUncheckedOldFastElementsLength || | 13134 if (new_capacity <= kMaxUncheckedOldFastElementsLength || |
13120 (new_capacity <= kMaxUncheckedFastElementsLength && | 13135 (new_capacity <= kMaxUncheckedFastElementsLength && |
13121 GetHeap()->InNewSpace(this))) { | 13136 GetHeap()->InNewSpace(this))) { |
13122 return false; | 13137 return false; |
13123 } | 13138 } |
13124 // If the fast-case backing storage takes up roughly three times as | 13139 // If the fast-case backing storage takes up roughly three times as |
13125 // much space (in machine words) as a dictionary backing storage | 13140 // much space (in machine words) as a dictionary backing storage |
(...skipping 3363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16489 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16504 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16490 static const char* error_messages_[] = { | 16505 static const char* error_messages_[] = { |
16491 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16506 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16492 }; | 16507 }; |
16493 #undef ERROR_MESSAGES_TEXTS | 16508 #undef ERROR_MESSAGES_TEXTS |
16494 return error_messages_[reason]; | 16509 return error_messages_[reason]; |
16495 } | 16510 } |
16496 | 16511 |
16497 | 16512 |
16498 } } // namespace v8::internal | 16513 } } // namespace v8::internal |
OLD | NEW |