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

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

Issue 8677006: Recommit introducing short external strings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixing webkit failures. 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
« src/ia32/codegen-ia32.cc ('K') | « test/cctest/test-api.cc ('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 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 21 matching lines...) Expand all
32 function test() { 32 function test() {
33 var str = ""; 33 var str = "";
34 34
35 // Build an ascii cons string. 35 // Build an ascii cons string.
36 for (var i = 0; i < size; i++) { 36 for (var i = 0; i < size; i++) {
37 str += String.fromCharCode(i & 0x7f); 37 str += String.fromCharCode(i & 0x7f);
38 } 38 }
39 assertTrue(isAsciiString(str)); 39 assertTrue(isAsciiString(str));
40 40
41 var twoByteExternalWithAsciiData = 41 var twoByteExternalWithAsciiData =
42 "AAAAAAAA" + (function() { return "A"; })(); 42 "AA" + (function() { return "A"; })();
43 externalizeString(twoByteExternalWithAsciiData, true /* force two-byte */); 43 externalizeString(twoByteExternalWithAsciiData, true /* force two-byte */);
44 assertFalse(isAsciiString(twoByteExternalWithAsciiData)); 44 assertFalse(isAsciiString(twoByteExternalWithAsciiData));
45 45
46 var realTwoByteExternalString = 46 var realTwoByteExternalString =
47 "\u1234\u1234\u1234\u1234" + (function() { return "\u1234"; })(); 47 "\u1234\u1234\u1234\u1234" + (function() { return "\u1234"; })();
48 externalizeString(realTwoByteExternalString); 48 externalizeString(realTwoByteExternalString);
49 assertFalse(isAsciiString(realTwoByteExternalString)); 49 assertFalse(isAsciiString(realTwoByteExternalString));
50 50
51 assertTrue(isAsciiString(["a", twoByteExternalWithAsciiData].join(""))); 51 assertTrue(isAsciiString(["a", twoByteExternalWithAsciiData].join("")));
52 52
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 charat_str[2] = charat_str[0].slice(0, -1); 104 charat_str[2] = charat_str[0].slice(0, -1);
105 charat_str[3] = charat_str[1].slice(0, -1); 105 charat_str[3] = charat_str[1].slice(0, -1);
106 charat_str[4] = charat_str[0] + charat_str[0]; 106 charat_str[4] = charat_str[0] + charat_str[0];
107 107
108 for (var i = 0; i < 5; i++) { 108 for (var i = 0; i < 5; i++) {
109 assertEquals('B', charat_str[i].charAt(6*16 + 11)); 109 assertEquals('B', charat_str[i].charAt(6*16 + 11));
110 assertEquals('C', charat_str[i].charAt(6*16 + 12)); 110 assertEquals('C', charat_str[i].charAt(6*16 + 12));
111 assertEquals('A', charat_str[i].charAt(3*16 + 10)); 111 assertEquals('A', charat_str[i].charAt(3*16 + 10));
112 assertEquals('B', charat_str[i].charAt(3*16 + 11)); 112 assertEquals('B', charat_str[i].charAt(3*16 + 11));
113 } 113 }
114
115 charat_short = "012";
116 try { // String can only be externalized once
117 externalizeString(charat_short, true);
118 } catch (ex) { }
119 assertEquals("1", charat_short.charAt(1));
114 } 120 }
115 121
116 // Run the test many times to ensure IC-s don't break things. 122 // Run the test many times to ensure IC-s don't break things.
117 for (var i = 0; i < 10; i++) { 123 for (var i = 0; i < 10; i++) {
118 test(); 124 test();
119 } 125 }
120 126
121 // Clean up string to make Valgrind happy. 127 // Clean up string to make Valgrind happy.
122 gc(); 128 gc();
123 gc(); 129 gc();
OLDNEW
« src/ia32/codegen-ia32.cc ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698