Revision: 16969
Author: [email protected]
Date: Thu Sep 26 15:28:46 2013 UTC
Log: Fix replaying of HCapturedObject for nested objects.
[email protected]
TEST=mjsunit/compiler/property-refs,mjsunit/compiler/escape-analysis
Review URL: https://codereview.chromium.org/24561002
http://code.google.com/p/v8/source/detail?r=16969
Modified:
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/test/mjsunit/compiler/escape-analysis.js
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Wed Sep 25
15:10:48 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Sep 26
15:28:46 2013 UTC
@@ -2339,6 +2339,21 @@
}
}
}
+
+
+static void ReplayEnvironmentNested(const ZoneList<HValue*>* values,
+ HCapturedObject* other) {
+ for (int i = 0; i < values->length(); ++i) {
+ HValue* value = values->at(i);
+ if (value->IsCapturedObject()) {
+ if (HCapturedObject::cast(value)->capture_id() ==
other->capture_id()) {
+ values->at(i) = other;
+ } else {
+ ReplayEnvironmentNested(HCapturedObject::cast(value)->values(),
other);
+ }
+ }
+ }
+}
// Replay captured objects by replacing all captured objects with the
@@ -2346,13 +2361,7 @@
void HCapturedObject::ReplayEnvironment(HEnvironment* env) {
ASSERT(env != NULL);
while (env != NULL) {
- for (int i = 0; i < env->length(); ++i) {
- HValue* value = env->values()->at(i);
- if (value->IsCapturedObject() &&
- HCapturedObject::cast(value)->capture_id() ==
this->capture_id()) {
- env->SetValueAt(i, this);
- }
- }
+ ReplayEnvironmentNested(env->values(), this);
env = env->outer();
}
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/compiler/escape-analysis.js Mon
Sep 9 09:53:58 2013 UTC
+++ /branches/bleeding_edge/test/mjsunit/compiler/escape-analysis.js Thu
Sep 26 15:28:46 2013 UTC
@@ -271,3 +271,33 @@
%OptimizeFunctionOnNextCall(oob);
assertEquals(7, oob(cons2, true));
})();
+
+
+// Test non-shallow nested graph of captured objects.
+(function testDeep() {
+ var deopt = { deopt:false };
+ function constructor1() {
+ this.x = 23;
+ }
+ function constructor2(nested) {
+ this.a = 17;
+ this.b = nested;
+ this.c = 42;
+ }
+ function deep() {
+ var o1 = new constructor1();
+ var o2 = new constructor2(o1);
+ assertEquals(17, o2.a);
+ assertEquals(23, o2.b.x);
+ assertEquals(42, o2.c);
+ o1.x = 99;
+ deopt.deopt;
+ assertEquals(99, o1.x);
+ assertEquals(99, o2.b.x);
+ }
+ deep(); deep();
+ %OptimizeFunctionOnNextCall(deep);
+ deep(); deep();
+ delete deopt.deopt;
+ deep(); deep();
+})();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.