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

Side by Side Diff: src/array.js

Issue 6606006: [Isolates] Merge 6500:6700 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 var length2 = (length << 1) - 1; 164 var length2 = (length << 1) - 1;
165 var j = length2; 165 var j = length2;
166 var i = length; 166 var i = length;
167 elements[--j] = elements[--i]; 167 elements[--j] = elements[--i];
168 while (i > 0) { 168 while (i > 0) {
169 elements[--j] = separator; 169 elements[--j] = separator;
170 elements[--j] = elements[--i]; 170 elements[--j] = elements[--i];
171 } 171 }
172 return %StringBuilderConcat(elements, length2, ''); 172 return %StringBuilderConcat(elements, length2, '');
173 } finally { 173 } finally {
174 // Make sure to pop the visited array no matter what happens. 174 // Make sure to remove the last element of the visited array no
175 if (is_array) visited_arrays.pop(); 175 // matter what happens.
176 if (is_array) visited_arrays.length = visited_arrays.length - 1;
176 } 177 }
177 } 178 }
178 179
179 180
180 function ConvertToString(x) { 181 function ConvertToString(x) {
181 // Assumes x is a non-string. 182 // Assumes x is a non-string.
182 if (IS_NUMBER(x)) return %_NumberToString(x); 183 if (IS_NUMBER(x)) return %_NumberToString(x);
183 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; 184 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
184 return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x)); 185 return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x));
185 } 186 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 var start_i = TO_INTEGER(start); 597 var start_i = TO_INTEGER(start);
597 598
598 if (start_i < 0) { 599 if (start_i < 0) {
599 start_i += len; 600 start_i += len;
600 if (start_i < 0) start_i = 0; 601 if (start_i < 0) start_i = 0;
601 } else { 602 } else {
602 if (start_i > len) start_i = len; 603 if (start_i > len) start_i = len;
603 } 604 }
604 605
605 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is 606 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is
606 // given differently from when an undefined delete count is given. 607 // given as a request to delete all the elements from the start.
608 // And it differs from the case of undefined delete count.
607 // This does not follow ECMA-262, but we do the same for 609 // This does not follow ECMA-262, but we do the same for
608 // compatibility. 610 // compatibility.
609 var del_count = 0; 611 var del_count = 0;
610 if (num_arguments > 1) { 612 if (num_arguments == 1) {
613 del_count = len - start_i;
614 } else {
611 del_count = TO_INTEGER(delete_count); 615 del_count = TO_INTEGER(delete_count);
612 if (del_count < 0) del_count = 0; 616 if (del_count < 0) del_count = 0;
613 if (del_count > len - start_i) del_count = len - start_i; 617 if (del_count > len - start_i) del_count = len - start_i;
614 } else {
615 del_count = len - start_i;
616 } 618 }
617 619
618 var deleted_elements = []; 620 var deleted_elements = [];
619 deleted_elements.length = del_count; 621 deleted_elements.length = del_count;
620 622
621 // Number of elements to add. 623 // Number of elements to add.
622 var num_additional_args = 0; 624 var num_additional_args = 0;
623 if (num_arguments > 2) { 625 if (num_arguments > 2) {
624 num_additional_args = num_arguments - 2; 626 num_additional_args = num_arguments - 2;
625 } 627 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 1011
1010 1012
1011 function ArrayIndexOf(element, index) { 1013 function ArrayIndexOf(element, index) {
1012 var length = TO_UINT32(this.length); 1014 var length = TO_UINT32(this.length);
1013 if (length == 0) return -1; 1015 if (length == 0) return -1;
1014 if (IS_UNDEFINED(index)) { 1016 if (IS_UNDEFINED(index)) {
1015 index = 0; 1017 index = 0;
1016 } else { 1018 } else {
1017 index = TO_INTEGER(index); 1019 index = TO_INTEGER(index);
1018 // If index is negative, index from the end of the array. 1020 // If index is negative, index from the end of the array.
1019 if (index < 0) index = length + index; 1021 if (index < 0) {
1020 // If index is still negative, search the entire array. 1022 index = length + index;
1021 if (index < 0) index = 0; 1023 // If index is still negative, search the entire array.
1024 if (index < 0) index = 0;
1025 }
1022 } 1026 }
1023 var min = index; 1027 var min = index;
1024 var max = length; 1028 var max = length;
1025 if (UseSparseVariant(this, length, true)) { 1029 if (UseSparseVariant(this, length, true)) {
1026 var intervals = %GetArrayKeys(this, length); 1030 var intervals = %GetArrayKeys(this, length);
1027 if (intervals.length == 2 && intervals[0] < 0) { 1031 if (intervals.length == 2 && intervals[0] < 0) {
1028 // A single interval. 1032 // A single interval.
1029 var intervalMin = -(intervals[0] + 1); 1033 var intervalMin = -(intervals[0] + 1);
1030 var intervalMax = intervalMin + intervals[1]; 1034 var intervalMax = intervalMin + intervals[1];
1031 min = MAX(min, intervalMin); 1035 min = MAX(min, intervalMin);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), 1231 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1),
1228 "reduce", getFunction("reduce", ArrayReduce, 1), 1232 "reduce", getFunction("reduce", ArrayReduce, 1),
1229 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) 1233 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1)
1230 )); 1234 ));
1231 1235
1232 %FinishArrayPrototypeSetup($Array.prototype); 1236 %FinishArrayPrototypeSetup($Array.prototype);
1233 } 1237 }
1234 1238
1235 1239
1236 SetupArray(); 1240 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