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

Side by Side Diff: test/mjsunit/string-external-cached.js

Issue 8931025: Handle external strings in generated code when concatenating short strings. (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
« no previous file with comments | « src/ia32/code-stubs-ia32.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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 assertEquals(["B", "B"], re.exec(ascii_slice)); 79 assertEquals(["B", "B"], re.exec(ascii_slice));
80 assertEquals(["TAB", "TAB"], rere.exec(ascii_cons)); 80 assertEquals(["TAB", "TAB"], rere.exec(ascii_cons));
81 assertEquals(["A", "A"], re.exec(twobyte)); 81 assertEquals(["A", "A"], re.exec(twobyte));
82 assertEquals(["B", "B"], re.exec(twobyte_slice)); 82 assertEquals(["B", "B"], re.exec(twobyte_slice));
83 assertEquals(["T_AB", "T_AB"], rere.exec(twobyte_cons)); 83 assertEquals(["T_AB", "T_AB"], rere.exec(twobyte_cons));
84 assertEquals("DEFG", ascii_slice.substr(2, 4)); 84 assertEquals("DEFG", ascii_slice.substr(2, 4));
85 assertEquals("DEFG", twobyte_slice.substr(2, 4)); 85 assertEquals("DEFG", twobyte_slice.substr(2, 4));
86 assertEquals("DEFG", ascii_cons.substr(3, 4)); 86 assertEquals("DEFG", ascii_cons.substr(3, 4));
87 assertEquals("DEFG", twobyte_cons.substr(4, 4)); 87 assertEquals("DEFG", twobyte_cons.substr(4, 4));
88 } 88 }
89
90 // Test adding external strings
91 var short_ascii = "E=";
92 var long_ascii = "MCsquared";
93 var short_twobyte = "E\u1234";
94 var long_twobyte = "MCsquare\u1234";
95 try { // String can only be externalized once
96 externalizeString(short_ascii, false);
97 externalizeString(long_ascii, false);
98 externalizeString(short_twobyte, true);
99 externalizeString(long_twobyte, true);
100 assertTrue(isAsciiString(short_asii) && isAsciiString(long_ascii));
101 assertFalse(isAsciiString(short_twobyte) || isAsciiString(long_twobyte));
102 } catch (ex) { }
103 assertEquals("E=MCsquared", short_ascii + long_ascii);
104 assertTrue(isAsciiString(short_ascii + long_ascii));
105 assertEquals("MCsquaredE=", long_ascii + short_ascii);
106 assertEquals("E\u1234MCsquare\u1234", short_twobyte + long_twobyte);
107 assertFalse(isAsciiString(short_twobyte + long_twobyte));
108 assertEquals("E=MCsquared", "E=" + long_ascii);
109 assertEquals("E\u1234MCsquared", short_twobyte + "MCsquared");
110 assertEquals("E\u1234MCsquared", short_twobyte + long_ascii);
111 assertFalse(isAsciiString(short_twobyte + long_ascii));
89 } 112 }
90 113
91 // Run the test many times to ensure IC-s don't break things. 114 // Run the test many times to ensure IC-s don't break things.
92 for (var i = 0; i < 10; i++) { 115 for (var i = 0; i < 10; i++) {
93 test(); 116 test();
94 } 117 }
95 118
96 // Clean up string to make Valgrind happy. 119 // Clean up string to make Valgrind happy.
97 gc(); 120 gc();
98 gc(); 121 gc();
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698