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

Side by Side Diff: src/js/array.js

Issue 1709693002: Revert of [fullcodegen] Remove the hacky %_FastOneByteArrayJoin intrinsic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/runtime/runtime.h » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils, extrasUtils) { 5 (function(global, utils, extrasUtils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 // We pull the empty separator check outside the loop for speed! 203 // We pull the empty separator check outside the loop for speed!
204 if (separator.length == 0) { 204 if (separator.length == 0) {
205 var elements_length = 0; 205 var elements_length = 0;
206 for (var i = 0; i < length; i++) { 206 for (var i = 0; i < length; i++) {
207 var e = array[i]; 207 var e = array[i];
208 if (!IS_STRING(e)) e = convert(e); 208 if (!IS_STRING(e)) e = convert(e);
209 elements[elements_length++] = e; 209 elements[elements_length++] = e;
210 } 210 }
211 elements.length = elements_length; 211 elements.length = elements_length;
212 var result = %_FastOneByteArrayJoin(elements, '');
213 if (!IS_UNDEFINED(result)) return result;
212 return %StringBuilderConcat(elements, elements_length, ''); 214 return %StringBuilderConcat(elements, elements_length, '');
213 } 215 }
214 // Non-empty separator case. 216 // Non-empty separator case.
215 // If the first element is a number then use the heuristic that the 217 // If the first element is a number then use the heuristic that the
216 // remaining elements are also likely to be numbers. 218 // remaining elements are also likely to be numbers.
217 if (!IS_NUMBER(array[0])) { 219 if (!IS_NUMBER(array[0])) {
218 for (var i = 0; i < length; i++) { 220 for (var i = 0; i < length; i++) {
219 var e = array[i]; 221 var e = array[i];
220 if (!IS_STRING(e)) e = convert(e); 222 if (!IS_STRING(e)) e = convert(e);
221 elements[i] = e; 223 elements[i] = e;
222 } 224 }
223 } else { 225 } else {
224 for (var i = 0; i < length; i++) { 226 for (var i = 0; i < length; i++) {
225 var e = array[i]; 227 var e = array[i];
226 if (IS_NUMBER(e)) { 228 if (IS_NUMBER(e)) {
227 e = %_NumberToString(e); 229 e = %_NumberToString(e);
228 } else if (!IS_STRING(e)) { 230 } else if (!IS_STRING(e)) {
229 e = convert(e); 231 e = convert(e);
230 } 232 }
231 elements[i] = e; 233 elements[i] = e;
232 } 234 }
233 } 235 }
236 var result = %_FastOneByteArrayJoin(elements, separator);
237 if (!IS_UNDEFINED(result)) return result;
238
234 return %StringBuilderJoin(elements, length, separator); 239 return %StringBuilderJoin(elements, length, separator);
235 } finally { 240 } finally {
236 // Make sure to remove the last element of the visited array no 241 // Make sure to remove the last element of the visited array no
237 // matter what happens. 242 // matter what happens.
238 if (is_array) visited_arrays.length = visited_arrays.length - 1; 243 if (is_array) visited_arrays.length = visited_arrays.length - 1;
239 } 244 }
240 } 245 }
241 246
242 247
243 function ConvertToString(x) { 248 function ConvertToString(x) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 440 }
436 441
437 442
438 function InnerArrayJoin(separator, array, length) { 443 function InnerArrayJoin(separator, array, length) {
439 if (IS_UNDEFINED(separator)) { 444 if (IS_UNDEFINED(separator)) {
440 separator = ','; 445 separator = ',';
441 } else { 446 } else {
442 separator = TO_STRING(separator); 447 separator = TO_STRING(separator);
443 } 448 }
444 449
450 var result = %_FastOneByteArrayJoin(array, separator);
451 if (!IS_UNDEFINED(result)) return result;
452
445 // Fast case for one-element arrays. 453 // Fast case for one-element arrays.
446 if (length === 1) { 454 if (length === 1) {
447 var e = array[0]; 455 var e = array[0];
448 if (IS_NULL_OR_UNDEFINED(e)) return ''; 456 if (IS_NULL_OR_UNDEFINED(e)) return '';
449 return TO_STRING(e); 457 return TO_STRING(e);
450 } 458 }
451 459
452 return Join(array, length, separator, ConvertToString); 460 return Join(array, length, separator, ConvertToString);
453 } 461 }
454 462
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 %InstallToContext([ 1959 %InstallToContext([
1952 "array_pop", ArrayPop, 1960 "array_pop", ArrayPop,
1953 "array_push", ArrayPush, 1961 "array_push", ArrayPush,
1954 "array_shift", ArrayShift, 1962 "array_shift", ArrayShift,
1955 "array_splice", ArraySplice, 1963 "array_splice", ArraySplice,
1956 "array_slice", ArraySlice, 1964 "array_slice", ArraySlice,
1957 "array_unshift", ArrayUnshift, 1965 "array_unshift", ArrayUnshift,
1958 ]); 1966 ]);
1959 1967
1960 }); 1968 });
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698