Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: src/objects.cc

Issue 2664173002: Throw when a holey property is set in Array.sort (Closed)
Patch Set: Not allow adding propertes in non-extensible array Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | test/mjsunit/array-sort.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « AUTHORS ('k') | test/mjsunit/array-sort.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698