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

Unified Diff: test/mjsunit/compare-objects-fast.js

Issue 25009003: Inline some more compare operations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: add tests Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« src/hydrogen.cc ('K') | « test/mjsunit/compare-known-objects.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/compare-objects-fast.js
diff --git a/test/mjsunit/compare-known-objects-slow.js b/test/mjsunit/compare-objects-fast.js
similarity index 62%
copy from test/mjsunit/compare-known-objects-slow.js
copy to test/mjsunit/compare-objects-fast.js
index afa198fcb352ea7f186a285146a61fd1ab70d51b..e7cb25fb66664cff868ceb821fe67d0556535b6d 100644
--- a/test/mjsunit/compare-known-objects-slow.js
+++ b/test/mjsunit/compare-objects-fast.js
@@ -31,6 +31,14 @@
// objects in slow mode. These objects share the same map even though they
Hannes Payer (out of office) 2013/10/02 13:33:19 in fast mode?
// might have completely different properties.
+function lt(a, b) {
+ return a < b;
+}
+
+function gt(a, b) {
+ return a > b;
+}
+
function eq(a, b) {
return a == b;
}
@@ -39,31 +47,63 @@ function eq_strict(a, b) {
return a === b;
}
-function test(a, b) {
+function test(a, b, less, greater) {
// Check CompareIC for equality of known objects.
assertTrue(eq(a, a));
assertTrue(eq(b, b));
assertFalse(eq(a, b));
- // Check CompareIC for strict equality of known objects.
assertTrue(eq_strict(a, a));
assertTrue(eq_strict(b, b));
assertFalse(eq_strict(a, b));
+ assertEquals(lt(a, b), less);
+ assertEquals(gt(a, b), greater);
+ assertEquals(lt(b, a), greater);
+ assertEquals(gt(b, a), less);
}
-// Prepare two objects in slow mode that have the same map.
-var obj1 = %OptimizeObjectForAddingMultipleProperties({}, 1);
-var obj2 = %OptimizeObjectForAddingMultipleProperties({}, 1);
+var obj1 = {toString: function() {return "1";}};
+var obj2 = {toString: function() {return "2";}};
+
+var less = obj1 < obj2;
+var greater = obj1 > obj2;
-// Test original objects.
-assertTrue(%HaveSameMap(obj1, obj2));
-test(obj1, obj2);
+test(obj1, obj2, less, greater);
+test(obj1, obj2, less, greater);
+test(obj1, obj2, less, greater);
+%OptimizeFunctionOnNextCall(test);
+test(obj1, obj2, less, greater);
+test(obj1, obj2, less, greater);
-// Test after adding property to first object.
obj1.x = 1;
-assertTrue(%HaveSameMap(obj1, obj2));
-test(obj1, obj2);
+test(obj1, obj2, less, greater);
+
+obj2.y = 2;
+test(obj1, obj2, less, greater);
+
+var obj1 = {test: 3};
+var obj2 = {test2: 3};
+
+var less = obj1 < obj2;
+var greater = obj1 > obj2;
+
+test(obj1, obj2, less, greater);
+test(obj1, obj2, less, greater);
+test(obj1, obj2, less, greater);
+%OptimizeFunctionOnNextCall(test);
+test(obj1, obj2, less, greater);
+test(obj1, obj2, less, greater);
+
+obj1.toString = function() {return "1"};
+var less = obj1 < obj2;
+var greater = obj1 > obj2;
+test(obj1, obj2, less, greater);
+%OptimizeFunctionOnNextCall(test);
+test(obj1, obj2, less, greater);
+
+obj2.toString = function() {return "2"};
+var less = true;
+var greater = false;
-// Test after adding property to second object.
+test(obj1, obj2, less, greater);
obj2.y = 2;
-assertTrue(%HaveSameMap(obj1, obj2));
-test(obj1, obj2);
+test(obj1, obj2, less, greater);
« src/hydrogen.cc ('K') | « test/mjsunit/compare-known-objects.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698