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

Side by Side Diff: test/mjsunit/string-slices.js

Issue 8889012: Avoid bailing out to runtime for short substrings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 for ( var i = 0; i < 1000; i++) { 153 for ( var i = 0; i < 1000; i++) {
154 f(flat, cons, slice, i); 154 f(flat, cons, slice, i);
155 } 155 }
156 flat = "abcdefghijkl1\u20232345"; 156 flat = "abcdefghijkl1\u20232345";
157 cons = flat + flat.toUpperCase(); 157 cons = flat + flat.toUpperCase();
158 slice = "abcdefghijklmn1\u20232345".slice(1, -1); 158 slice = "abcdefghijklmn1\u20232345".slice(1, -1);
159 for ( var i = 0; i < 1000; i++) { 159 for ( var i = 0; i < 1000; i++) {
160 f(flat, cons, slice, i); 160 f(flat, cons, slice, i);
161 } 161 }
162 162
163 // Short substrings.
164 flat = "abcdefghijkl12345";
165 cons = flat + flat.toUpperCase();
166 /x/.exec(cons); // Flatten cons
167 slice = "abcdefghijklmn12345".slice(1, -1);
168 assertEquals("cdefg", flat.substr(2, 5));
169 assertEquals("cdefg", cons.substr(2, 5));
170 assertEquals("cdefg", slice.substr(1, 5));
171
172 flat = "abc\u1234defghijkl12345";
173 cons = flat + flat.toUpperCase();
174 /x/.exec(cons); // Flatten cons
175 slice = "abc\u1234defghijklmn12345".slice(1, -1);
176 assertEquals("c\u1234def", flat.substr(2, 5));
177 assertEquals("c\u1234def", cons.substr(2, 5));
178 assertEquals("c\u1234def", slice.substr(1, 5));
179
163 // Concatenate substrings. 180 // Concatenate substrings.
164 var ascii = 'abcdefghijklmnop'; 181 var ascii = 'abcdefghijklmnop';
165 var utf = '\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB'; 182 var utf = '\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB';
166 assertEquals("klmno", ascii.substring(10,15) + ascii.substring(16)); 183 assertEquals("klmno", ascii.substring(10,15) + ascii.substring(16));
167 assertEquals("\u03B4\u03B7", utf.substring(3,4) + utf.substring(6,7)); 184 assertEquals("\u03B4\u03B7", utf.substring(3,4) + utf.substring(6,7));
168 assertEquals("klp", ascii.substring(10,12) + ascii.substring(15,16)); 185 assertEquals("klp", ascii.substring(10,12) + ascii.substring(15,16));
169 assertEquals("\u03B1\u03B4\u03B5", utf.substring(0,1) + utf.substring(5,3)); 186 assertEquals("\u03B1\u03B4\u03B5", utf.substring(0,1) + utf.substring(5,3));
170 assertEquals("", ascii.substring(16) + utf.substring(16)); 187 assertEquals("", ascii.substring(16) + utf.substring(16));
171 assertEquals("bcdef\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9", 188 assertEquals("bcdef\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9",
172 ascii.substring(1,6) + utf.substring(3,9)); 189 ascii.substring(1,6) + utf.substring(3,9));
(...skipping 26 matching lines...) Expand all
199 assertEquals(b.charAt(4), c.charAt(4)); 216 assertEquals(b.charAt(4), c.charAt(4));
200 assertTrue(/3456789qwe/.test(c)); 217 assertTrue(/3456789qwe/.test(c));
201 assertEquals(4, c.indexOf("678")); 218 assertEquals(4, c.indexOf("678"));
202 assertEquals("2345", c.split("6")[0]); 219 assertEquals("2345", c.split("6")[0]);
203 } 220 }
204 } 221 }
205 222
206 test_crankshaft(); 223 test_crankshaft();
207 %OptimizeFunctionOnNextCall(test_crankshaft); 224 %OptimizeFunctionOnNextCall(test_crankshaft);
208 test_crankshaft(); 225 test_crankshaft();
OLDNEW
« src/ia32/code-stubs-ia32.cc ('K') | « test/mjsunit/string-external-cached.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698