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

Side by Side Diff: test/mjsunit/smi-ops.js

Issue 151003: Add a compare stub on ARM. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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/html-comments.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 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 assertEquals(0, Xor100(100)); 189 assertEquals(0, Xor100(100));
190 assertEquals(7, Xor100Reversed(99)); 190 assertEquals(7, Xor100Reversed(99));
191 assertEquals(-1073741724, Xor100(SMI_MIN)); 191 assertEquals(-1073741724, Xor100(SMI_MIN));
192 assertEquals(-1073741724, Xor100Reversed(SMI_MIN)); 192 assertEquals(-1073741724, Xor100Reversed(SMI_MIN));
193 assertEquals(78, Xor100(OBJ_42)); 193 assertEquals(78, Xor100(OBJ_42));
194 assertEquals(78, Xor100Reversed(OBJ_42)); 194 assertEquals(78, Xor100Reversed(OBJ_42));
195 195
196 var x = 0x23; var y = 0x35; 196 var x = 0x23; var y = 0x35;
197 assertEquals(0x16, x ^ y); 197 assertEquals(0x16, x ^ y);
198 198
199
200 // Bitwise not.
201 var v = 0;
202 assertEquals(-1, ~v);
203 v = SMI_MIN;
204 assertEquals(0x3fffffff, ~v);
205 v = SMI_MAX;
206 assertEquals(-0x40000000, ~v);
207
208 // Overflowing ++ and --.
209 v = SMI_MAX;
210 v++;
211 assertEquals(0x40000000, v);
212 v = SMI_MIN;
213 v--;
214 assertEquals(-0x40000001, v);
215
216 // Not actually Smi operations.
217 // Check that relations on unary ops work.
218 var v = -1.2;
219 assertTrue(v == v);
220 assertTrue(v === v);
221 assertTrue(v <= v);
222 assertTrue(v >= v);
223 assertFalse(v < v);
224 assertFalse(v > v);
225 assertFalse(v != v);
226 assertFalse(v !== v);
227
228 // Right hand side of unary minus is overwritable.
229 v = 1.5
230 assertEquals(-2.25, -(v * v));
231
232 // Smi input to bitop gives non-smi result where the rhs is a float that
233 // can be overwritten.
234 var x1 = 0x10000000;
235 var x2 = 0x40000002;
236 var x3 = 0x40000000;
237 assertEquals(0x40000000, x1 << (x2 - x3));
238
239 // Smi input to bitop gives non-smi result where the rhs could be overwritten
240 // if it were a float, but it isn't.
241 x1 = 0x10000000
242 x2 = 4
243 x3 = 2
244 assertEquals(0x40000000, x1 << (x2 - x3));
245
246
199 // Test shift operators on non-smi inputs, giving smi and non-smi results. 247 // Test shift operators on non-smi inputs, giving smi and non-smi results.
200 function testShiftNonSmis() { 248 function testShiftNonSmis() {
201 var pos_non_smi = 2000000000; 249 var pos_non_smi = 2000000000;
202 var neg_non_smi = -pos_non_smi; 250 var neg_non_smi = -pos_non_smi;
203 var pos_smi = 1000000000; 251 var pos_smi = 1000000000;
204 var neg_smi = -pos_smi; 252 var neg_smi = -pos_smi;
205 253
206 // Begin block A 254 // Begin block A
207 assertEquals(pos_non_smi, (pos_non_smi) >> 0); 255 assertEquals(pos_non_smi, (pos_non_smi) >> 0);
208 assertEquals(pos_non_smi, (pos_non_smi) >>> 0); 256 assertEquals(pos_non_smi, (pos_non_smi) >>> 0);
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 } 633 }
586 634
587 testShiftNonSmis(); 635 testShiftNonSmis();
588 636
589 637
590 // Verify that we handle the (optimized) corner case of shifting by 638 // Verify that we handle the (optimized) corner case of shifting by
591 // zero even for non-smis. 639 // zero even for non-smis.
592 function shiftByZero(n) { return n << 0; } 640 function shiftByZero(n) { return n << 0; }
593 641
594 assertEquals(3, shiftByZero(3.1415)); 642 assertEquals(3, shiftByZero(3.1415));
OLDNEW
« no previous file with comments | « test/mjsunit/html-comments.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698