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

Side by Side Diff: src/objects.cc

Issue 726773002: Throw as per spec when modifying an Array with builtin methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added a TODO Created 6 years, 1 month 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 | « src/objects.h ('k') | test/mjsunit/array-methods-read-only-length.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 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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 13079 matching lines...) Expand 10 before | Expand all | Expand 10 after
13090 bool JSArray::IsReadOnlyLengthDescriptor(Handle<Map> jsarray_map) { 13090 bool JSArray::IsReadOnlyLengthDescriptor(Handle<Map> jsarray_map) {
13091 Isolate* isolate = jsarray_map->GetIsolate(); 13091 Isolate* isolate = jsarray_map->GetIsolate();
13092 DCHECK(!jsarray_map->is_dictionary_map()); 13092 DCHECK(!jsarray_map->is_dictionary_map());
13093 LookupResult lookup(isolate); 13093 LookupResult lookup(isolate);
13094 Handle<Name> length_string = isolate->factory()->length_string(); 13094 Handle<Name> length_string = isolate->factory()->length_string();
13095 jsarray_map->LookupDescriptor(NULL, *length_string, &lookup); 13095 jsarray_map->LookupDescriptor(NULL, *length_string, &lookup);
13096 return lookup.IsReadOnly(); 13096 return lookup.IsReadOnly();
13097 } 13097 }
13098 13098
13099 13099
13100 bool JSArray::HasReadOnlyLength(Handle<JSArray> array) {
13101 LookupIterator it(array, array->GetIsolate()->factory()->length_string(),
13102 LookupIterator::OWN_SKIP_INTERCEPTOR);
13103 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state());
13104 CHECK(it.IsFound());
13105 CHECK_EQ(LookupIterator::ACCESSOR, it.state());
13106 return it.IsReadOnly();
13107 }
13108
13109
13100 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, 13110 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array,
13101 uint32_t index) { 13111 uint32_t index) {
13102 uint32_t length = 0; 13112 uint32_t length = 0;
13103 CHECK(array->length()->ToArrayIndex(&length)); 13113 CHECK(array->length()->ToArrayIndex(&length));
13104 if (length <= index) { 13114 if (length <= index) return HasReadOnlyLength(array);
13105 LookupIterator it(array, array->GetIsolate()->factory()->length_string(),
13106 LookupIterator::OWN_SKIP_INTERCEPTOR);
13107 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state());
13108 CHECK(it.IsFound());
13109 CHECK_EQ(LookupIterator::ACCESSOR, it.state());
13110 return it.IsReadOnly();
13111 }
13112 return false; 13115 return false;
13113 } 13116 }
13114 13117
13115 13118
13116 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { 13119 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) {
13117 Isolate* isolate = array->GetIsolate(); 13120 Isolate* isolate = array->GetIsolate();
13118 Handle<Name> length = isolate->factory()->length_string(); 13121 Handle<Name> length = isolate->factory()->length_string();
13119 Handle<Object> args[2] = { length, array }; 13122 Handle<Object> args[2] = { length, array };
13120 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", 13123 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property",
13121 HandleVector(args, arraysize(args))), 13124 HandleVector(args, arraysize(args))),
(...skipping 3667 matching lines...) Expand 10 before | Expand all | Expand 10 after
16789 Handle<DependentCode> codes = 16792 Handle<DependentCode> codes =
16790 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16793 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16791 DependentCode::kPropertyCellChangedGroup, 16794 DependentCode::kPropertyCellChangedGroup,
16792 info->object_wrapper()); 16795 info->object_wrapper());
16793 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16796 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16794 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16797 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16795 cell, info->zone()); 16798 cell, info->zone());
16796 } 16799 }
16797 16800
16798 } } // namespace v8::internal 16801 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/array-methods-read-only-length.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698