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

Unified Diff: src/builtins.cc

Issue 8430036: Fix Array.{splice,slice} to set proper ElementsKind of result (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | test/mjsunit/elements-kind.js » ('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 e758b9a41587141e380ec2ddf446a78c8f989e80..f252911d9fc5418d736674f20b2ba660bd25aa3b 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -772,6 +772,13 @@ BUILTIN(ArraySlice) {
// Set the length.
result_array->set_length(Smi::FromInt(result_len));
+
+ // Set the ElementsKind.
+ ElementsKind elements_kind = JSObject::cast(receiver)->GetElementsKind();
+ if (result_array->GetElementsKind() != elements_kind) {
+ MaybeObject* maybe = result_array->TransitionElementsKind(elements_kind);
+ if (maybe->IsFailure()) return maybe;
+ }
return result_array;
}
@@ -865,6 +872,13 @@ BUILTIN(ArraySplice) {
// Set the length.
result_array->set_length(Smi::FromInt(actual_delete_count));
+
+ // Set the ElementsKind.
+ ElementsKind elements_kind = array->GetElementsKind();
+ if (result_array->GetElementsKind() != elements_kind) {
+ MaybeObject* maybe = result_array->TransitionElementsKind(elements_kind);
+ if (maybe->IsFailure()) return maybe;
+ }
}
int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0;
« no previous file with comments | « no previous file | test/mjsunit/elements-kind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698