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

Side by Side Diff: src/builtins.cc

Issue 3216014: Simplify Array.splice by simply returning the result of AllocateEmptyJSArray.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 FixedArray* elms = FixedArray::cast(elms_obj); 658 FixedArray* elms = FixedArray::cast(elms_obj);
659 JSArray* array = JSArray::cast(receiver); 659 JSArray* array = JSArray::cast(receiver);
660 ASSERT(array->HasFastElements()); 660 ASSERT(array->HasFastElements());
661 661
662 int len = Smi::cast(array->length())->value(); 662 int len = Smi::cast(array->length())->value();
663 663
664 int n_arguments = args.length() - 1; 664 int n_arguments = args.length() - 1;
665 665
666 // Return empty array when no arguments are supplied. 666 // Return empty array when no arguments are supplied.
667 if (n_arguments == 0) { 667 if (n_arguments == 0) {
668 Object* result = AllocateEmptyJSArray(); 668 return AllocateEmptyJSArray();
669 if (result->IsFailure()) return result;
670 return JSArray::cast(result);
671 } 669 }
672 670
673 int relative_start = 0; 671 int relative_start = 0;
674 Object* arg1 = args[1]; 672 Object* arg1 = args[1];
675 if (arg1->IsSmi()) { 673 if (arg1->IsSmi()) {
676 relative_start = Smi::cast(arg1)->value(); 674 relative_start = Smi::cast(arg1)->value();
677 } else if (!arg1->IsUndefined()) { 675 } else if (!arg1->IsUndefined()) {
678 return CallJsBuiltin("ArraySplice", args); 676 return CallJsBuiltin("ArraySplice", args);
679 } 677 }
680 int actual_start = (relative_start < 0) ? Max(len + relative_start, 0) 678 int actual_start = (relative_start < 0) ? Max(len + relative_start, 0)
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 if (entry->contains(pc)) { 1531 if (entry->contains(pc)) {
1534 return names_[i]; 1532 return names_[i];
1535 } 1533 }
1536 } 1534 }
1537 } 1535 }
1538 return NULL; 1536 return NULL;
1539 } 1537 }
1540 1538
1541 1539
1542 } } // namespace v8::internal 1540 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698