Commit 704d737d authored by bmeurer's avatar bmeurer Committed by Commit bot

[builtins] Don't enforce I+TF for ArraySort helpers.

The current Array.prototype.sort implementation is pretty sensitive to
compiler changes, i.e. switching to I+TF completely, so refactor it a
bit so that it can stay with FCG+CS for now.

Middle-term the Array builtins need to be refactored to TurboFan
builtins anyways.

BUG=chromium:670691,v8:5666
R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2553523002
Cr-Commit-Position: refs/heads/master@{#41471}
parent a67126cb
...@@ -723,7 +723,7 @@ function InnerArraySort(array, length, comparefn) { ...@@ -723,7 +723,7 @@ function InnerArraySort(array, length, comparefn) {
else return x < y ? -1 : 1; else return x < y ? -1 : 1;
}; };
} }
var InsertionSort = function InsertionSort(a, from, to) { function InsertionSort(a, from, to) {
for (var i = from + 1; i < to; i++) { for (var i = from + 1; i < to; i++) {
var element = a[i]; var element = a[i];
for (var j = i - 1; j >= from; j--) { for (var j = i - 1; j >= from; j--) {
...@@ -739,7 +739,7 @@ function InnerArraySort(array, length, comparefn) { ...@@ -739,7 +739,7 @@ function InnerArraySort(array, length, comparefn) {
} }
}; };
var GetThirdIndex = function(a, from, to) { function GetThirdIndex(a, from, to) {
var t_array = new InternalArray(); var t_array = new InternalArray();
// Use both 'from' and 'to' to determine the pivot candidates. // Use both 'from' and 'to' to determine the pivot candidates.
var increment = 200 + ((to - from) & 15); var increment = 200 + ((to - from) & 15);
...@@ -757,7 +757,7 @@ function InnerArraySort(array, length, comparefn) { ...@@ -757,7 +757,7 @@ function InnerArraySort(array, length, comparefn) {
return third_index; return third_index;
} }
var QuickSort = function QuickSort(a, from, to) { function QuickSort(a, from, to) {
var third_index = 0; var third_index = 0;
while (true) { while (true) {
// Insertion sort is faster for short arrays. // Insertion sort is faster for short arrays.
...@@ -846,7 +846,7 @@ function InnerArraySort(array, length, comparefn) { ...@@ -846,7 +846,7 @@ function InnerArraySort(array, length, comparefn) {
// Copy elements in the range 0..length from obj's prototype chain // Copy elements in the range 0..length from obj's prototype chain
// to obj itself, if obj has holes. Return one more than the maximal index // to obj itself, if obj has holes. Return one more than the maximal index
// of a prototype property. // of a prototype property.
var CopyFromPrototype = function CopyFromPrototype(obj, length) { function CopyFromPrototype(obj, length) {
var max = 0; var max = 0;
for (var proto = %object_get_prototype_of(obj); proto; for (var proto = %object_get_prototype_of(obj); proto;
proto = %object_get_prototype_of(proto)) { proto = %object_get_prototype_of(proto)) {
...@@ -876,7 +876,7 @@ function InnerArraySort(array, length, comparefn) { ...@@ -876,7 +876,7 @@ function InnerArraySort(array, length, comparefn) {
// Set a value of "undefined" on all indices in the range from..to // Set a value of "undefined" on all indices in the range from..to
// where a prototype of obj has an element. I.e., shadow all prototype // where a prototype of obj has an element. I.e., shadow all prototype
// elements in that range. // elements in that range.
var ShadowPrototypeElements = function(obj, from, to) { function ShadowPrototypeElements(obj, from, to) {
for (var proto = %object_get_prototype_of(obj); proto; for (var proto = %object_get_prototype_of(obj); proto;
proto = %object_get_prototype_of(proto)) { proto = %object_get_prototype_of(proto)) {
var indices = IS_PROXY(proto) ? to : %GetArrayKeys(proto, to); var indices = IS_PROXY(proto) ? to : %GetArrayKeys(proto, to);
...@@ -899,7 +899,7 @@ function InnerArraySort(array, length, comparefn) { ...@@ -899,7 +899,7 @@ function InnerArraySort(array, length, comparefn) {
} }
}; };
var SafeRemoveArrayHoles = function SafeRemoveArrayHoles(obj) { function SafeRemoveArrayHoles(obj) {
// Copy defined elements from the end to fill in all holes and undefineds // Copy defined elements from the end to fill in all holes and undefineds
// in the beginning of the array. Write undefineds and holes at the end // in the beginning of the array. Write undefineds and holes at the end
// after loop is finished. // after loop is finished.
...@@ -1528,7 +1528,7 @@ utils.InstallFunctions(GlobalArray, DONT_ENUM, [ ...@@ -1528,7 +1528,7 @@ utils.InstallFunctions(GlobalArray, DONT_ENUM, [
var specialFunctions = %SpecialArrayFunctions(); var specialFunctions = %SpecialArrayFunctions();
var getFunction = function(name, jsBuiltin, len) { function getFunction(name, jsBuiltin, len) {
var f = jsBuiltin; var f = jsBuiltin;
if (specialFunctions.hasOwnProperty(name)) { if (specialFunctions.hasOwnProperty(name)) {
f = specialFunctions[name]; f = specialFunctions[name];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment