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

Side by Side Diff: src/string.js

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/spaces.cc ('k') | src/stub-cache.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return %StringBuilderConcat(parts, len + 1, ""); 96 return %StringBuilderConcat(parts, len + 1, "");
97 } 97 }
98 98
99 // Match ES3 and Safari 99 // Match ES3 and Safari
100 %FunctionSetLength(StringConcat, 1); 100 %FunctionSetLength(StringConcat, 1);
101 101
102 102
103 // ECMA-262 section 15.5.4.7 103 // ECMA-262 section 15.5.4.7
104 function StringIndexOf(pattern /* position */) { // length == 1 104 function StringIndexOf(pattern /* position */) { // length == 1
105 var subject = TO_STRING_INLINE(this); 105 var subject = TO_STRING_INLINE(this);
106 var pattern = TO_STRING_INLINE(pattern); 106 pattern = TO_STRING_INLINE(pattern);
107 var subject_len = subject.length;
108 var pattern_len = pattern.length;
109 var index = 0; 107 var index = 0;
110 if (%_ArgumentsLength() > 1) { 108 if (%_ArgumentsLength() > 1) {
111 var arg1 = %_Arguments(1); // position 109 index = %_Arguments(1); // position
112 index = TO_INTEGER(arg1); 110 index = TO_INTEGER(index);
111 if (index < 0) index = 0;
112 if (index > subject.length) index = subject.length;
113 } 113 }
114 if (index < 0) index = 0;
115 if (index > subject_len) index = subject_len;
116 if (pattern_len + index > subject_len) return -1;
117 return %StringIndexOf(subject, pattern, index); 114 return %StringIndexOf(subject, pattern, index);
118 } 115 }
119 116
120 117
121 // ECMA-262 section 15.5.4.8 118 // ECMA-262 section 15.5.4.8
122 function StringLastIndexOf(pat /* position */) { // length == 1 119 function StringLastIndexOf(pat /* position */) { // length == 1
123 var sub = TO_STRING_INLINE(this); 120 var sub = TO_STRING_INLINE(this);
124 var subLength = sub.length; 121 var subLength = sub.length;
125 var pat = TO_STRING_INLINE(pat); 122 var pat = TO_STRING_INLINE(pat);
126 var patLength = pat.length; 123 var patLength = pat.length;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 match_start = (elem >> 11) + (elem & 0x7ff); 395 match_start = (elem >> 11) + (elem & 0x7ff);
399 } else { 396 } else {
400 match_start = res[++i] - elem; 397 match_start = res[++i] - elem;
401 } 398 }
402 } else { 399 } else {
403 override[0] = elem; 400 override[0] = elem;
404 override[1] = match_start; 401 override[1] = match_start;
405 lastMatchInfoOverride = override; 402 lastMatchInfoOverride = override;
406 var func_result = 403 var func_result =
407 %_CallFunction(receiver, elem, match_start, subject, replace); 404 %_CallFunction(receiver, elem, match_start, subject, replace);
408 func_result = TO_STRING_INLINE(func_result); 405 res[i] = TO_STRING_INLINE(func_result);
409 res[i] = func_result;
410 match_start += elem.length; 406 match_start += elem.length;
411 } 407 }
412 i++; 408 i++;
413 } 409 }
414 } else { 410 } else {
415 while (i < len) { 411 while (i < len) {
416 var elem = res[i]; 412 var elem = res[i];
417 if (!%_IsSmi(elem)) { 413 if (!%_IsSmi(elem)) {
418 // elem must be an Array. 414 // elem must be an Array.
419 // Use the apply argument as backing for global RegExp properties. 415 // Use the apply argument as backing for global RegExp properties.
420 lastMatchInfoOverride = elem; 416 lastMatchInfoOverride = elem;
421 var func_result = replace.apply(null, elem); 417 var func_result = replace.apply(null, elem);
422 func_result = TO_STRING_INLINE(func_result); 418 res[i] = TO_STRING_INLINE(func_result);
423 res[i] = func_result;
424 } 419 }
425 i++; 420 i++;
426 } 421 }
427 } 422 }
428 var resultBuilder = new ReplaceResultBuilder(subject, res); 423 var resultBuilder = new ReplaceResultBuilder(subject, res);
429 var result = resultBuilder.generate(); 424 var result = resultBuilder.generate();
430 resultArray.length = 0; 425 resultArray.length = 0;
431 reusableReplaceArray = resultArray; 426 reusableReplaceArray = resultArray;
432 return result; 427 return result;
433 } 428 }
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 "italics", StringItalics, 906 "italics", StringItalics,
912 "small", StringSmall, 907 "small", StringSmall,
913 "strike", StringStrike, 908 "strike", StringStrike,
914 "sub", StringSub, 909 "sub", StringSub,
915 "sup", StringSup 910 "sup", StringSup
916 )); 911 ));
917 } 912 }
918 913
919 914
920 SetupString(); 915 SetupString();
OLDNEW
« no previous file with comments | « src/spaces.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698