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

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

Issue 1708523002: [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;
214 return %StringBuilderConcat(elements, elements_length, ''); 212 return %StringBuilderConcat(elements, elements_length, '');
215 } 213 }
216 // Non-empty separator case. 214 // Non-empty separator case.
217 // If the first element is a number then use the heuristic that the 215 // If the first element is a number then use the heuristic that the
218 // remaining elements are also likely to be numbers. 216 // remaining elements are also likely to be numbers.
219 if (!IS_NUMBER(array[0])) { 217 if (!IS_NUMBER(array[0])) {
220 for (var i = 0; i < length; i++) { 218 for (var i = 0; i < length; i++) {
221 var e = array[i]; 219 var e = array[i];
222 if (!IS_STRING(e)) e = convert(e); 220 if (!IS_STRING(e)) e = convert(e);
223 elements[i] = e; 221 elements[i] = e;
224 } 222 }
225 } else { 223 } else {
226 for (var i = 0; i < length; i++) { 224 for (var i = 0; i < length; i++) {
227 var e = array[i]; 225 var e = array[i];
228 if (IS_NUMBER(e)) { 226 if (IS_NUMBER(e)) {
229 e = %_NumberToString(e); 227 e = %_NumberToString(e);
230 } else if (!IS_STRING(e)) { 228 } else if (!IS_STRING(e)) {
231 e = convert(e); 229 e = convert(e);
232 } 230 }
233 elements[i] = e; 231 elements[i] = e;
234 } 232 }
235 } 233 }
236 var result = %_FastOneByteArrayJoin(elements, separator);
237 if (!IS_UNDEFINED(result)) return result;
238
239 return %StringBuilderJoin(elements, length, separator); 234 return %StringBuilderJoin(elements, length, separator);
240 } finally { 235 } finally {
241 // Make sure to remove the last element of the visited array no 236 // Make sure to remove the last element of the visited array no
242 // matter what happens. 237 // matter what happens.
243 if (is_array) visited_arrays.length = visited_arrays.length - 1; 238 if (is_array) visited_arrays.length = visited_arrays.length - 1;
244 } 239 }
245 } 240 }
246 241
247 242
248 function ConvertToString(x) { 243 function ConvertToString(x) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 435 }
441 436
442 437
443 function InnerArrayJoin(separator, array, length) { 438 function InnerArrayJoin(separator, array, length) {
444 if (IS_UNDEFINED(separator)) { 439 if (IS_UNDEFINED(separator)) {
445 separator = ','; 440 separator = ',';
446 } else { 441 } else {
447 separator = TO_STRING(separator); 442 separator = TO_STRING(separator);
448 } 443 }
449 444
450 var result = %_FastOneByteArrayJoin(array, separator);
451 if (!IS_UNDEFINED(result)) return result;
452
453 // Fast case for one-element arrays. 445 // Fast case for one-element arrays.
454 if (length === 1) { 446 if (length === 1) {
455 var e = array[0]; 447 var e = array[0];
456 if (IS_NULL_OR_UNDEFINED(e)) return ''; 448 if (IS_NULL_OR_UNDEFINED(e)) return '';
457 return TO_STRING(e); 449 return TO_STRING(e);
458 } 450 }
459 451
460 return Join(array, length, separator, ConvertToString); 452 return Join(array, length, separator, ConvertToString);
461 } 453 }
462 454
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 %InstallToContext([ 1951 %InstallToContext([
1960 "array_pop", ArrayPop, 1952 "array_pop", ArrayPop,
1961 "array_push", ArrayPush, 1953 "array_push", ArrayPush,
1962 "array_shift", ArrayShift, 1954 "array_shift", ArrayShift,
1963 "array_splice", ArraySplice, 1955 "array_splice", ArraySplice,
1964 "array_slice", ArraySlice, 1956 "array_slice", ArraySlice,
1965 "array_unshift", ArrayUnshift, 1957 "array_unshift", ArrayUnshift,
1966 ]); 1958 ]);
1967 1959
1968 }); 1960 });
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