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

Unified Diff: test/mjsunit/compiler/escape-analysis.js

Issue 93803003: Fixed Lithium environment generation bug for captured objects (created (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Move common code from LChunkBuilder into a (new) base class Created 7 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 side-by-side diff with in-line comments
Download patch
« src/lithium.cc ('K') | « src/x64/lithium-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/compiler/escape-analysis.js
diff --git a/test/mjsunit/compiler/escape-analysis.js b/test/mjsunit/compiler/escape-analysis.js
index dccc476925788ab0057d698f670cf0bbf33299f0..b12e7bfca0af1016dfa03cdebbb2924983f5f54f 100644
--- a/test/mjsunit/compiler/escape-analysis.js
+++ b/test/mjsunit/compiler/escape-analysis.js
@@ -303,6 +303,101 @@
})();
+// Test non-shallow nested graph of captured objects with duplicates
+(function testDeepDuplicate() {
+ function constructor1() {
+ this.x = 23;
+ }
+ function constructor2(nested) {
+ this.a = 17;
+ this.b = nested;
+ this.c = 42;
+ }
+ function deep(shouldDeopt) {
+ var o1 = new constructor1();
+ var o2 = new constructor2(o1);
+ var o3 = new constructor2(o1);
+ assertEquals(17, o2.a);
+ assertEquals(23, o2.b.x);
+ assertEquals(42, o2.c);
+ o3.c = 54;
+ o1.x = 99;
+ if (shouldDeopt) %DeoptimizeFunction(deep);
+ assertEquals(99, o1.x);
+ assertEquals(99, o2.b.x);
+ assertEquals(99, o3.b.x);
+ assertEquals(54, o3.c);
+ assertEquals(17, o3.a);
+ assertEquals(42, o2.c);
+ assertEquals(17, o2.a);
+ o3.b.x = 1;
+ assertEquals(1, o1.x);
+ }
+ deep(false); deep(false);
+ %OptimizeFunctionOnNextCall(deep);
+ deep(false); deep(false);
+ deep(true); deep(true);
+})();
+
+
+// Test non-shallow nested graph of captured objects with inline
+(function testDeepInline() {
+ function h() {
+ return { y : 3 };
+ }
+
+ function g(x) {
+ var u = { x : h() };
+ %DeoptimizeFunction(f);
+ return u;
+ }
+
+ function f() {
+ var l = { dummy : { } };
+ var r = g(l);
+ assertEquals(3, r.x.y);
+ }
+
+ f(); f(); f();
+ %OptimizeFunctionOnNextCall(f);
+ f();
+})();
+
+
+// Test two nested objects
+(function testTwoNestedObjects() {
+ function f() {
+ var l = { x : { y : 111 } };
+ var l2 = { x : { y : 111 } };
+ %DeoptimizeFunction(f);
+ assertEquals(111, l.x.y);
+ assertEquals(111, l2.x.y);
+ }
+
+ f(); f(); f();
+ %OptimizeFunctionOnNextCall(f);
+ f();
+})();
+
+
+// Test a nested object and a duplicate
+(function testTwoObjectsWithDuplicate() {
+ function f() {
+ var l = { x : { y : 111 } };
+ var dummy = { d : 0 };
+ var l2 = l.x;
+ %DeoptimizeFunction(f);
+ assertEquals(111, l.x.y);
+ assertEquals(111, l2.y);
+ assertEquals(0, dummy.d);
+ }
+
+ f(); f(); f();
+ %OptimizeFunctionOnNextCall(f);
+ f();
+})();
+
+
// Test materialization of a field that requires a Smi value.
(function testSmiField() {
var deopt = { deopt:false };
« src/lithium.cc ('K') | « src/x64/lithium-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698