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

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

Issue 561133005: Change the order of arguments of the (One|Two)ByteSeqStringSetChar intrinsic. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | « test/mjsunit/regress/string-set-char-deopt.js ('k') | no next file » | 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 // 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --expose-gc --allow-natives-syntax 28 // Flags: --expose-gc --allow-natives-syntax
29 29
30 function test() { 30 function test() {
31 var s1 = %NewString(26, true); 31 var s1 = %NewString(26, true);
32 for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, 65); 32 for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(i, 65, s1);
33 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s1); 33 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s1);
34 %_OneByteSeqStringSetChar(s1, 25, 66); 34 %_OneByteSeqStringSetChar(25, 66, s1);
35 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s1); 35 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s1);
36 for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, i+65); 36 for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(i, i+65, s1);
37 assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s1); 37 assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s1);
38 s1 = %TruncateString(s1, 13); 38 s1 = %TruncateString(s1, 13);
39 assertEquals("ABCDEFGHIJKLM", s1); 39 assertEquals("ABCDEFGHIJKLM", s1);
40 40
41 var s2 = %NewString(26, false); 41 var s2 = %NewString(26, false);
42 for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, 65); 42 for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, 65, s2);
43 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s2); 43 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s2);
44 %_TwoByteSeqStringSetChar(s2, 25, 66); 44 %_TwoByteSeqStringSetChar(25, 66, s2);
45 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s2); 45 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s2);
46 for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, i+65); 46 for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, i+65, s2);
47 assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s2); 47 assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s2);
48 s2 = %TruncateString(s2, 13); 48 s2 = %TruncateString(s2, 13);
49 assertEquals("ABCDEFGHIJKLM", s2); 49 assertEquals("ABCDEFGHIJKLM", s2);
50 50
51 var s3 = %NewString(26, false); 51 var s3 = %NewString(26, false);
52 for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s3, i, i+1000); 52 for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, i+1000, s3);
53 for (i = 0; i < 26; i++) assertEquals(s3[i], String.fromCharCode(i+1000)); 53 for (i = 0; i < 26; i++) assertEquals(s3[i], String.fromCharCode(i+1000));
54 54
55 var a = []; 55 var a = [];
56 for (var i = 0; i < 1000; i++) { 56 for (var i = 0; i < 1000; i++) {
57 var s = %NewString(10000, i % 2 == 1); 57 var s = %NewString(10000, i % 2 == 1);
58 a.push(s); 58 a.push(s);
59 } 59 }
60 60
61 gc(); 61 gc();
62 62
63 for (var i = 0; i < 1000; i++) { 63 for (var i = 0; i < 1000; i++) {
64 assertEquals(10000, a[i].length); 64 assertEquals(10000, a[i].length);
65 a[i] = %TruncateString(a[i], 5000); 65 a[i] = %TruncateString(a[i], 5000);
66 } 66 }
67 67
68 gc(); 68 gc();
69 69
70 for (var i = 0; i < 1000; i++) { 70 for (var i = 0; i < 1000; i++) {
71 assertEquals(5000, a[i].length); 71 assertEquals(5000, a[i].length);
72 } 72 }
73 } 73 }
74 74
75 75
76 test(); 76 test();
77 test(); 77 test();
78 %OptimizeFunctionOnNextCall(test); 78 %OptimizeFunctionOnNextCall(test);
79 test(); 79 test();
OLDNEW
« no previous file with comments | « test/mjsunit/regress/string-set-char-deopt.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698