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

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

Issue 1582041: Reapply: Inline fast cases in string keyed load IC. (Closed)
Patch Set: . Created 10 years, 8 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
« src/ia32/ic-ia32.cc ('K') | « src/ia32/ic-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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 17 matching lines...) Expand all
28 /** 28 /**
29 * @fileoverview Test indexing on strings with []. 29 * @fileoverview Test indexing on strings with [].
30 */ 30 */
31 31
32 var foo = "Foo"; 32 var foo = "Foo";
33 assertEquals("Foo", foo); 33 assertEquals("Foo", foo);
34 assertEquals("F", foo[0]); 34 assertEquals("F", foo[0]);
35 assertEquals("o", foo[1]); 35 assertEquals("o", foo[1]);
36 assertEquals("o", foo[2]); 36 assertEquals("o", foo[2]);
37 37
38 // Test string keyed load IC.
39 for (var i = 0; i < 10; i++) {
40 assertEquals("F", foo[0]);
41 assertEquals("o", foo[1]);
42 assertEquals("o", foo[2]);
43 assertEquals("F", (foo[0] + "BarBazQuuxFooBarQuux")[0]);
44 }
45
38 assertEquals("F", foo["0" + ""], "string index"); 46 assertEquals("F", foo["0" + ""], "string index");
39 assertEquals("o", foo["1"], "string index"); 47 assertEquals("o", foo["1"], "string index");
40 assertEquals("o", foo["2"], "string index"); 48 assertEquals("o", foo["2"], "string index");
41 49
42 assertEquals("undefined", typeof(foo[3]), "out of range"); 50 assertEquals("undefined", typeof(foo[3]), "out of range");
43 // SpiderMonkey 1.5 fails this next one. So does FF 2.0.6. 51 // SpiderMonkey 1.5 fails this next one. So does FF 2.0.6.
44 assertEquals("undefined", typeof(foo[-1]), "known failure in SpiderMonkey 1.5"); 52 assertEquals("undefined", typeof(foo[-1]), "known failure in SpiderMonkey 1.5");
45 assertEquals("undefined", typeof(foo[-2]), "negative index"); 53 assertEquals("undefined", typeof(foo[-2]), "negative index");
46 54
47 foo[0] = "f"; 55 foo[0] = "f";
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 var foo = ['a12', ['a', 2, 'c'], 'a31', 42]; 179 var foo = ['a12', ['a', 2, 'c'], 'a31', 42];
172 var results = [1, 2, 3, NaN]; 180 var results = [1, 2, 3, NaN];
173 for (var i = 0; i < 200; ++i) { 181 for (var i = 0; i < 200; ++i) {
174 var index = Math.floor(i / 50); 182 var index = Math.floor(i / 50);
175 var receiver = foo[index]; 183 var receiver = foo[index];
176 var expected = results[index]; 184 var expected = results[index];
177 var actual = +(receiver[1]); 185 var actual = +(receiver[1]);
178 assertEquals(expected, actual); 186 assertEquals(expected, actual);
179 } 187 }
180 188
181 var keys = [0, '1', 2, 3.0]; 189 var keys = [0, '1', 2, 3.0, -1, 10];
182 var str = 'abcd', arr = ['a', 'b', 'c', 'd']; 190 var str = 'abcd', arr = ['a', 'b', 'c', 'd', undefined, undefined];
183 for (var i = 0; i < 200; ++i) { 191 for (var i = 0; i < 300; ++i) {
184 var index = Math.floor(i / 50); 192 var index = Math.floor(i / 50);
185 var key = keys[index]; 193 var key = keys[index];
186 var expected = arr[index]; 194 var expected = arr[index];
187 var actual = str[key]; 195 var actual = str[key];
188 assertEquals(expected, actual); 196 assertEquals(expected, actual);
189 } 197 }
OLDNEW
« src/ia32/ic-ia32.cc ('K') | « src/ia32/ic-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698