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

Unified Diff: src/builtins.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 | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 5eefd27fbbd8a4ade93285de1b8797da58ccb73f..aed6030b6d4441e40e0a4a08853a5eb5e6e3d9ee 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -420,6 +420,10 @@ BUILTIN(ArrayPop) {
int len = Smi::cast(array->length())->value();
if (len == 0) return isolate->heap()->undefined_value();
+ if (JSArray::HasReadOnlyLength(array)) {
+ return CallJsBuiltin(isolate, "ArrayPop", args);
+ }
+
ElementsAccessor* accessor = array->GetElementsAccessor();
int new_length = len - 1;
Handle<Object> element =
@@ -451,6 +455,10 @@ BUILTIN(ArrayShift) {
int len = Smi::cast(array->length())->value();
if (len == 0) return heap->undefined_value();
+ if (JSArray::HasReadOnlyLength(array)) {
+ return CallJsBuiltin(isolate, "ArrayShift", args);
+ }
+
// Get first element
ElementsAccessor* accessor = array->GetElementsAccessor();
Handle<Object> first =
@@ -756,6 +764,11 @@ BUILTIN(ArraySplice) {
return CallJsBuiltin(isolate, "ArraySplice", args);
}
+ if (new_length != len && JSArray::HasReadOnlyLength(array)) {
+ AllowHeapAllocation allow_allocation;
+ return CallJsBuiltin(isolate, "ArraySplice", args);
+ }
+
if (new_length == 0) {
Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(
elms_obj, elements_kind, actual_delete_count);
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698