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

Unified Diff: src/array.js

Issue 279773002: Fix Array.prototype.push and Array.prototype.unshift for read-only length. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Extend test Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/builtins.cc » ('j') | src/builtins.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array.js
diff --git a/src/array.js b/src/array.js
index dcaf0f40080e84db790321726bd9c67244eca5be..6f649e1f39bfe7dd7e8f8b8508ede2e35ab4d632 100644
--- a/src/array.js
+++ b/src/array.js
@@ -603,7 +603,9 @@ function ObservedArrayUnshift() {
try {
BeginPerformSplice(this);
- SimpleMove(this, 0, 0, len, num_arguments);
+ if (len > 0) {
+ SimpleMove(this, 0, 0, len, num_arguments);
+ }
for (var i = 0; i < num_arguments; i++) {
this[i] = %_Arguments(i);
}
@@ -628,10 +630,12 @@ function ArrayUnshift(arg1) { // length == 1
var num_arguments = %_ArgumentsLength();
var is_sealed = ObjectIsSealed(array);
- if (IS_ARRAY(array) && !is_sealed) {
- SmartMove(array, 0, 0, len, num_arguments);
- } else {
- SimpleMove(array, 0, 0, len, num_arguments);
+ if (len > 0) {
+ if (IS_ARRAY(array) && !is_sealed) {
+ SmartMove(array, 0, 0, len, num_arguments);
+ } else {
+ SimpleMove(array, 0, 0, len, num_arguments);
+ }
}
for (var i = 0; i < num_arguments; i++) {
« no previous file with comments | « no previous file | src/builtins.cc » ('j') | src/builtins.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698