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

Side by Side Diff: src/array.js

Issue 10392150: Remove %_SwapElements. This inlined runtime contained an optimization that was dangerous in the pr… (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/hydrogen.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 var high_start = to - 1; // Lower bound of elements greater than pivot. 820 var high_start = to - 1; // Lower bound of elements greater than pivot.
821 a[middle_index] = a[low_end]; 821 a[middle_index] = a[low_end];
822 a[low_end] = pivot; 822 a[low_end] = pivot;
823 823
824 // From low_end to i are elements equal to pivot. 824 // From low_end to i are elements equal to pivot.
825 // From i to high_start are elements that haven't been compared yet. 825 // From i to high_start are elements that haven't been compared yet.
826 partition: for (var i = low_end + 1; i < high_start; i++) { 826 partition: for (var i = low_end + 1; i < high_start; i++) {
827 var element = a[i]; 827 var element = a[i];
828 var order = %_CallFunction(receiver, element, pivot, comparefn); 828 var order = %_CallFunction(receiver, element, pivot, comparefn);
829 if (order < 0) { 829 if (order < 0) {
830 %_SwapElements(a, i, low_end); 830 a[i] = a[low_end];
831 a[low_end] = element;
831 low_end++; 832 low_end++;
832 } else if (order > 0) { 833 } else if (order > 0) {
833 do { 834 do {
834 high_start--; 835 high_start--;
835 if (high_start == i) break partition; 836 if (high_start == i) break partition;
836 var top_elem = a[high_start]; 837 var top_elem = a[high_start];
837 order = %_CallFunction(receiver, top_elem, pivot, comparefn); 838 order = %_CallFunction(receiver, top_elem, pivot, comparefn);
838 } while (order > 0); 839 } while (order > 0);
839 %_SwapElements(a, i, high_start); 840 a[i] = a[high_start];
841 a[high_start] = element;
840 if (order < 0) { 842 if (order < 0) {
841 %_SwapElements(a, i, low_end); 843 element = a[i];
844 a[i] = a[low_end];
845 a[low_end] = element;
842 low_end++; 846 low_end++;
843 } 847 }
844 } 848 }
845 } 849 }
846 QuickSort(a, from, low_end); 850 QuickSort(a, from, low_end);
847 QuickSort(a, high_start, to); 851 QuickSort(a, high_start, to);
848 }; 852 };
849 853
850 // Copy elements in the range 0..length from obj's prototype chain 854 // Copy elements in the range 0..length from obj's prototype chain
851 // to obj itself, if obj has holes. Return one more than the maximal index 855 // to obj itself, if obj has holes. Return one more than the maximal index
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 // exposed to user code. 1524 // exposed to user code.
1521 // Adding only the functions that are actually used. 1525 // Adding only the functions that are actually used.
1522 SetUpLockedPrototype(InternalArray, $Array(), $Array( 1526 SetUpLockedPrototype(InternalArray, $Array(), $Array(
1523 "join", getFunction("join", ArrayJoin), 1527 "join", getFunction("join", ArrayJoin),
1524 "pop", getFunction("pop", ArrayPop), 1528 "pop", getFunction("pop", ArrayPop),
1525 "push", getFunction("push", ArrayPush) 1529 "push", getFunction("push", ArrayPush)
1526 )); 1530 ));
1527 } 1531 }
1528 1532
1529 SetUpArray(); 1533 SetUpArray();
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698