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

Side by Side Diff: test/mjsunit/compare-objects.js

Issue 145773008: A64: Synchronize with r17104. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/compare-known-objects.js ('k') | test/mjsunit/debug-step-4-in-frame.js » ('j') | 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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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: --allow-natives-syntax 28 // Flags: --allow-natives-syntax
29 29
30 // Test CompareIC stubs for normal and strict equality comparison of known 30 // Test CompareIC stubs for normal and strict equality comparison of known
31 // objects in slow mode. These objects share the same map even though they 31 // objects in hydrogen.
32 // might have completely different properties. 32
33 function lt(a, b) {
34 return a < b;
35 }
36
37 function gt(a, b) {
38 return a > b;
39 }
33 40
34 function eq(a, b) { 41 function eq(a, b) {
35 return a == b; 42 return a == b;
36 } 43 }
37 44
38 function eq_strict(a, b) { 45 function eq_strict(a, b) {
39 return a === b; 46 return a === b;
40 } 47 }
41 48
42 function test(a, b) { 49 function test(a, b, less, greater) {
43 // Check CompareIC for equality of known objects. 50 // Check CompareIC for equality of known objects.
44 assertTrue(eq(a, a)); 51 assertTrue(eq(a, a));
45 assertTrue(eq(b, b)); 52 assertTrue(eq(b, b));
46 assertFalse(eq(a, b)); 53 assertFalse(eq(a, b));
47 // Check CompareIC for strict equality of known objects.
48 assertTrue(eq_strict(a, a)); 54 assertTrue(eq_strict(a, a));
49 assertTrue(eq_strict(b, b)); 55 assertTrue(eq_strict(b, b));
50 assertFalse(eq_strict(a, b)); 56 assertFalse(eq_strict(a, b));
57 assertEquals(lt(a, b), less);
58 assertEquals(gt(a, b), greater);
59 assertEquals(lt(b, a), greater);
60 assertEquals(gt(b, a), less);
51 } 61 }
52 62
53 // Prepare two objects in slow mode that have the same map. 63 var obj1 = {toString: function() {return "1";}};
54 var obj1 = %OptimizeObjectForAddingMultipleProperties({}, 1); 64 var obj2 = {toString: function() {return "2";}};
55 var obj2 = %OptimizeObjectForAddingMultipleProperties({}, 1);
56 65
57 // Test original objects. 66 var less = obj1 < obj2;
58 assertTrue(%HaveSameMap(obj1, obj2)); 67 var greater = obj1 > obj2;
59 test(obj1, obj2);
60 68
61 // Test after adding property to first object. 69 test(obj1, obj2, less, greater);
70 test(obj1, obj2, less, greater);
71 test(obj1, obj2, less, greater);
72 %OptimizeFunctionOnNextCall(test);
73 test(obj1, obj2, less, greater);
74 test(obj1, obj2, less, greater);
75
62 obj1.x = 1; 76 obj1.x = 1;
63 assertTrue(%HaveSameMap(obj1, obj2)); 77 test(obj1, obj2, less, greater);
64 test(obj1, obj2);
65 78
66 // Test after adding property to second object.
67 obj2.y = 2; 79 obj2.y = 2;
68 assertTrue(%HaveSameMap(obj1, obj2)); 80 test(obj1, obj2, less, greater);
69 test(obj1, obj2); 81
82 var obj1 = {test: 3};
83 var obj2 = {test2: 3};
84
85 var less = obj1 < obj2;
86 var greater = obj1 > obj2;
87
88 test(obj1, obj2, less, greater);
89 test(obj1, obj2, less, greater);
90 test(obj1, obj2, less, greater);
91 %OptimizeFunctionOnNextCall(test);
92 test(obj1, obj2, less, greater);
93 test(obj1, obj2, less, greater);
94
95 obj1.toString = function() {return "1"};
96 var less = obj1 < obj2;
97 var greater = obj1 > obj2;
98 test(obj1, obj2, less, greater);
99 %OptimizeFunctionOnNextCall(test);
100 test(obj1, obj2, less, greater);
101
102 obj2.toString = function() {return "2"};
103 var less = true;
104 var greater = false;
105
106 test(obj1, obj2, less, greater);
107 obj2.y = 2;
108 test(obj1, obj2, less, greater);
OLDNEW
« no previous file with comments | « test/mjsunit/compare-known-objects.js ('k') | test/mjsunit/debug-step-4-in-frame.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698