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

Unified Diff: src/builtins.cc

Issue 6062006: Add more bailouts for Array.slice over arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years 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/array-slice.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 0c76f6944f86684b31e360d5fe1d2f6d40ba8b78..a659c461c01e1bd68a4ef220962bbe027c02d07c 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -636,15 +636,20 @@ BUILTIN(ArraySlice) {
return CallJsBuiltin("ArraySlice", args);
}
elms = FixedArray::cast(JSObject::cast(receiver)->elements());
- len = elms->length();
-#ifdef DEBUG
- // Arguments object by construction should have no holes, check it.
- if (FLAG_enable_slow_asserts) {
- for (int i = 0; i < len; i++) {
- ASSERT(elms->get(i) != Heap::the_hole_value());
+ Object* len_obj = JSObject::cast(receiver)
+ ->InObjectPropertyAt(Heap::arguments_length_index);
+ if (!len_obj->IsSmi()) {
+ return CallJsBuiltin("ArraySlice", args);
+ }
+ len = Smi::cast(len_obj)->value();
+ if (len > elms->length()) {
+ return CallJsBuiltin("ArraySlice", args);
+ }
+ for (int i = 0; i < len; i++) {
+ if (elms->get(i) == Heap::the_hole_value()) {
+ return CallJsBuiltin("ArraySlice", args);
}
}
-#endif
}
ASSERT(len >= 0);
int n_arguments = args.length() - 1;
« no previous file with comments | « no previous file | test/mjsunit/array-slice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698