OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 16862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16873 } | 16873 } |
16874 | 16874 |
16875 | 16875 |
16876 // Collects all defined (non-hole) and non-undefined (array) elements at | 16876 // Collects all defined (non-hole) and non-undefined (array) elements at |
16877 // the start of the elements array. | 16877 // the start of the elements array. |
16878 // If the object is in dictionary mode, it is converted to fast elements | 16878 // If the object is in dictionary mode, it is converted to fast elements |
16879 // mode. | 16879 // mode. |
16880 Handle<Object> JSObject::PrepareElementsForSort(Handle<JSObject> object, | 16880 Handle<Object> JSObject::PrepareElementsForSort(Handle<JSObject> object, |
16881 uint32_t limit) { | 16881 uint32_t limit) { |
16882 Isolate* isolate = object->GetIsolate(); | 16882 Isolate* isolate = object->GetIsolate(); |
16883 if (object->HasSloppyArgumentsElements()) { | 16883 if (object->HasSloppyArgumentsElements() || !object->map()->is_extensible()) { |
16884 return handle(Smi::FromInt(-1), isolate); | 16884 return handle(Smi::FromInt(-1), isolate); |
16885 } | 16885 } |
16886 | 16886 |
16887 if (object->HasStringWrapperElements()) { | 16887 if (object->HasStringWrapperElements()) { |
16888 int len = String::cast(Handle<JSValue>::cast(object)->value())->length(); | 16888 int len = String::cast(Handle<JSValue>::cast(object)->value())->length(); |
16889 return handle(Smi::FromInt(len), isolate); | 16889 return handle(Smi::FromInt(len), isolate); |
16890 } | 16890 } |
16891 | 16891 |
16892 if (object->HasDictionaryElements()) { | 16892 if (object->HasDictionaryElements()) { |
16893 // Convert to fast elements containing only the existing properties. | 16893 // Convert to fast elements containing only the existing properties. |
(...skipping 3131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20025 // depend on this. | 20025 // depend on this. |
20026 return DICTIONARY_ELEMENTS; | 20026 return DICTIONARY_ELEMENTS; |
20027 } | 20027 } |
20028 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20028 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20029 return kind; | 20029 return kind; |
20030 } | 20030 } |
20031 } | 20031 } |
20032 | 20032 |
20033 } // namespace internal | 20033 } // namespace internal |
20034 } // namespace v8 | 20034 } // namespace v8 |
OLD | NEW |