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

Side by Side Diff: src/array.js

Issue 6614010: [Isolates] Merge 6700:7030 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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/virtual-frame-arm.cc ('k') | src/assembler.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (IS_NUMBER(e)) elements[i] = %_NumberToString(e); 154 if (IS_NUMBER(e)) elements[i] = %_NumberToString(e);
155 else { 155 else {
156 if (!IS_STRING(e)) e = convert(e); 156 if (!IS_STRING(e)) e = convert(e);
157 elements[i] = e; 157 elements[i] = e;
158 } 158 }
159 } 159 }
160 } 160 }
161 var result = %_FastAsciiArrayJoin(elements, separator); 161 var result = %_FastAsciiArrayJoin(elements, separator);
162 if (!IS_UNDEFINED(result)) return result; 162 if (!IS_UNDEFINED(result)) return result;
163 163
164 var length2 = (length << 1) - 1; 164 return %StringBuilderJoin(elements, length, separator);
165 var j = length2;
166 var i = length;
167 elements[--j] = elements[--i];
168 while (i > 0) {
169 elements[--j] = separator;
170 elements[--j] = elements[--i];
171 }
172 return %StringBuilderConcat(elements, length2, '');
173 } finally { 165 } finally {
174 // Make sure to remove the last element of the visited array no 166 // Make sure to remove the last element of the visited array no
175 // matter what happens. 167 // matter what happens.
176 if (is_array) visited_arrays.length = visited_arrays.length - 1; 168 if (is_array) visited_arrays.length = visited_arrays.length - 1;
177 } 169 }
178 } 170 }
179 171
180 172
181 function ConvertToString(x) { 173 function ConvertToString(x) {
182 // Assumes x is a non-string. 174 // Assumes x is a non-string.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 var m = %_ArgumentsLength(); 411 var m = %_ArgumentsLength();
420 for (var i = 0; i < m; i++) { 412 for (var i = 0; i < m; i++) {
421 this[i+n] = %_Arguments(i); 413 this[i+n] = %_Arguments(i);
422 } 414 }
423 this.length = n + m; 415 this.length = n + m;
424 return this.length; 416 return this.length;
425 } 417 }
426 418
427 419
428 function ArrayConcat(arg1) { // length == 1 420 function ArrayConcat(arg1) { // length == 1
429 // TODO: can we just use arguments?
430 var arg_count = %_ArgumentsLength(); 421 var arg_count = %_ArgumentsLength();
431 var arrays = new $Array(1 + arg_count); 422 var arrays = new $Array(1 + arg_count);
432 arrays[0] = this; 423 arrays[0] = this;
433 for (var i = 0; i < arg_count; i++) { 424 for (var i = 0; i < arg_count; i++) {
434 arrays[i + 1] = %_Arguments(i); 425 arrays[i + 1] = %_Arguments(i);
435 } 426 }
436 427
437 return %ArrayConcat(arrays); 428 return %ArrayConcat(arrays);
438 } 429 }
439 430
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 index = TO_INTEGER(index); 1010 index = TO_INTEGER(index);
1020 // If index is negative, index from the end of the array. 1011 // If index is negative, index from the end of the array.
1021 if (index < 0) { 1012 if (index < 0) {
1022 index = length + index; 1013 index = length + index;
1023 // If index is still negative, search the entire array. 1014 // If index is still negative, search the entire array.
1024 if (index < 0) index = 0; 1015 if (index < 0) index = 0;
1025 } 1016 }
1026 } 1017 }
1027 var min = index; 1018 var min = index;
1028 var max = length; 1019 var max = length;
1029 if (UseSparseVariant(this, length, true)) { 1020 if (UseSparseVariant(this, length, IS_ARRAY(this))) {
1030 var intervals = %GetArrayKeys(this, length); 1021 var intervals = %GetArrayKeys(this, length);
1031 if (intervals.length == 2 && intervals[0] < 0) { 1022 if (intervals.length == 2 && intervals[0] < 0) {
1032 // A single interval. 1023 // A single interval.
1033 var intervalMin = -(intervals[0] + 1); 1024 var intervalMin = -(intervals[0] + 1);
1034 var intervalMax = intervalMin + intervals[1]; 1025 var intervalMax = intervalMin + intervals[1];
1035 min = MAX(min, intervalMin); 1026 if (min < intervalMin) min = intervalMin;
1036 max = intervalMax; // Capped by length already. 1027 max = intervalMax; // Capped by length already.
1037 // Fall through to loop below. 1028 // Fall through to loop below.
1038 } else { 1029 } else {
1039 if (intervals.length == 0) return -1; 1030 if (intervals.length == 0) return -1;
1040 // Get all the keys in sorted order. 1031 // Get all the keys in sorted order.
1041 var sortedKeys = GetSortedArrayKeys(this, intervals); 1032 var sortedKeys = GetSortedArrayKeys(this, intervals);
1042 var n = sortedKeys.length; 1033 var n = sortedKeys.length;
1043 var i = 0; 1034 var i = 0;
1044 while (i < n && sortedKeys[i] < index) i++; 1035 while (i < n && sortedKeys[i] < index) i++;
1045 while (i < n) { 1036 while (i < n) {
(...skipping 29 matching lines...) Expand all
1075 } else { 1066 } else {
1076 index = TO_INTEGER(index); 1067 index = TO_INTEGER(index);
1077 // If index is negative, index from end of the array. 1068 // If index is negative, index from end of the array.
1078 if (index < 0) index += length; 1069 if (index < 0) index += length;
1079 // If index is still negative, do not search the array. 1070 // If index is still negative, do not search the array.
1080 if (index < 0) return -1; 1071 if (index < 0) return -1;
1081 else if (index >= length) index = length - 1; 1072 else if (index >= length) index = length - 1;
1082 } 1073 }
1083 var min = 0; 1074 var min = 0;
1084 var max = index; 1075 var max = index;
1085 if (UseSparseVariant(this, length, true)) { 1076 if (UseSparseVariant(this, length, IS_ARRAY(this))) {
1086 var intervals = %GetArrayKeys(this, index + 1); 1077 var intervals = %GetArrayKeys(this, index + 1);
1087 if (intervals.length == 2 && intervals[0] < 0) { 1078 if (intervals.length == 2 && intervals[0] < 0) {
1088 // A single interval. 1079 // A single interval.
1089 var intervalMin = -(intervals[0] + 1); 1080 var intervalMin = -(intervals[0] + 1);
1090 var intervalMax = intervalMin + intervals[1]; 1081 var intervalMax = intervalMin + intervals[1];
1091 min = MAX(min, intervalMin); 1082 if (min < intervalMin) min = intervalMin;
1092 max = intervalMax; // Capped by index already. 1083 max = intervalMax; // Capped by index already.
1093 // Fall through to loop below. 1084 // Fall through to loop below.
1094 } else { 1085 } else {
1095 if (intervals.length == 0) return -1; 1086 if (intervals.length == 0) return -1;
1096 // Get all the keys in sorted order. 1087 // Get all the keys in sorted order.
1097 var sortedKeys = GetSortedArrayKeys(this, intervals); 1088 var sortedKeys = GetSortedArrayKeys(this, intervals);
1098 var i = sortedKeys.length - 1; 1089 var i = sortedKeys.length - 1;
1099 while (i >= 0) { 1090 while (i >= 0) {
1100 var key = sortedKeys[i]; 1091 var key = sortedKeys[i];
1101 if (!IS_UNDEFINED(key) && this[key] === element) return key; 1092 if (!IS_UNDEFINED(key) && this[key] === element) return key;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), 1222 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1),
1232 "reduce", getFunction("reduce", ArrayReduce, 1), 1223 "reduce", getFunction("reduce", ArrayReduce, 1),
1233 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) 1224 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1)
1234 )); 1225 ));
1235 1226
1236 %FinishArrayPrototypeSetup($Array.prototype); 1227 %FinishArrayPrototypeSetup($Array.prototype);
1237 } 1228 }
1238 1229
1239 1230
1240 SetupArray(); 1231 SetupArray();
OLDNEW
« no previous file with comments | « src/arm/virtual-frame-arm.cc ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698