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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index d48a30d8abc922dc4966c3d5e5413d7207f27f1c..27f5e3640cdf63d1dbbcbe9f7d3d4695ad09c325 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -13097,18 +13097,21 @@ bool JSArray::IsReadOnlyLengthDescriptor(Handle<Map> jsarray_map) {
}
+bool JSArray::HasReadOnlyLength(Handle<JSArray> array) {
+ LookupIterator it(array, array->GetIsolate()->factory()->length_string(),
+ LookupIterator::OWN_SKIP_INTERCEPTOR);
+ CHECK_NE(LookupIterator::ACCESS_CHECK, it.state());
+ CHECK(it.IsFound());
+ CHECK_EQ(LookupIterator::ACCESSOR, it.state());
+ return it.IsReadOnly();
+}
+
+
bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array,
uint32_t index) {
uint32_t length = 0;
CHECK(array->length()->ToArrayIndex(&length));
- if (length <= index) {
- LookupIterator it(array, array->GetIsolate()->factory()->length_string(),
- LookupIterator::OWN_SKIP_INTERCEPTOR);
- CHECK_NE(LookupIterator::ACCESS_CHECK, it.state());
- CHECK(it.IsFound());
- CHECK_EQ(LookupIterator::ACCESSOR, it.state());
- return it.IsReadOnly();
- }
+ if (length <= index) return HasReadOnlyLength(array);
return false;
}
« 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