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

Side by Side Diff: src/builtins.cc

Issue 3277005: Follow Safari and Firefox in returning empty array from array splice... (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 | « src/array.js ('k') | test/mjsunit/array-splice.js » ('j') | 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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 return CallJsBuiltin("ArraySplice", args); 656 return CallJsBuiltin("ArraySplice", args);
657 } 657 }
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 // SpiderMonkey and JSC return undefined in the case where no 666 // Return empty array when no arguments are supplied.
667 // arguments are given instead of using the implicit undefined
668 // arguments. This does not follow ECMA-262, but we do the same for
669 // compatibility.
670 // TraceMonkey follows ECMA-262 though.
671 if (n_arguments == 0) { 667 if (n_arguments == 0) {
672 return Heap::undefined_value(); 668 // No handle scope needed since we return directly.
669 return *Factory::NewJSArray(0);
673 } 670 }
674 671
675 int relative_start = 0; 672 int relative_start = 0;
676 Object* arg1 = args[1]; 673 Object* arg1 = args[1];
677 if (arg1->IsSmi()) { 674 if (arg1->IsSmi()) {
678 relative_start = Smi::cast(arg1)->value(); 675 relative_start = Smi::cast(arg1)->value();
679 } else if (!arg1->IsUndefined()) { 676 } else if (!arg1->IsUndefined()) {
680 return CallJsBuiltin("ArraySplice", args); 677 return CallJsBuiltin("ArraySplice", args);
681 } 678 }
682 int actual_start = (relative_start < 0) ? Max(len + relative_start, 0) 679 int actual_start = (relative_start < 0) ? Max(len + relative_start, 0)
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 if (entry->contains(pc)) { 1532 if (entry->contains(pc)) {
1536 return names_[i]; 1533 return names_[i];
1537 } 1534 }
1538 } 1535 }
1539 } 1536 }
1540 return NULL; 1537 return NULL;
1541 } 1538 }
1542 1539
1543 1540
1544 } } // namespace v8::internal 1541 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/array.js ('k') | test/mjsunit/array-splice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698