Revision: 16334
Author: [email protected]
Date: Mon Aug 26 16:43:19 2013 UTC
Log: Fix replaying of captured objects during chunk building.
[email protected]
Review URL: https://codereview.chromium.org/22819011
http://code.google.com/p/v8/source/detail?r=16334
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/hydrogen-escape-analysis.cc
/branches/bleeding_edge/src/hydrogen-escape-analysis.h
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/mips/lithium-mips.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/test/mjsunit/compiler/escape-analysis.js
/branches/bleeding_edge/test/mjsunit/mjsunit.status
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Mon Aug 26 12:24:03 2013
UTC
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Mon Aug 26 16:43:19 2013
UTC
@@ -2435,6 +2435,9 @@
LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
+ HEnvironment* env = current_block_->last_environment();
+ instr->ReplayEnvironment(env);
+
// There are no real uses of a captured object.
return NULL;
}
=======================================
--- /branches/bleeding_edge/src/hydrogen-escape-analysis.cc Fri Aug 23
16:31:31 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-escape-analysis.cc Mon Aug 26
16:43:19 2013 UTC
@@ -65,7 +65,8 @@
HCapturedObject* HEscapeAnalysisPhase::NewState(HInstruction* previous) {
Zone* zone = graph()->zone();
- HCapturedObject* state = new(zone) HCapturedObject(number_of_values_,
zone);
+ HCapturedObject* state =
+ new(zone) HCapturedObject(number_of_values_, number_of_objects_,
zone);
state->InsertAfter(previous);
return state;
}
@@ -183,18 +184,9 @@
}
break;
}
+ case HValue::kArgumentsObject:
+ case HValue::kCapturedObject:
case HValue::kSimulate: {
- HSimulate* simulate = HSimulate::cast(instr);
- // TODO(mstarzinger): This doesn't track deltas for values on the
- // operand stack yet. Find a repro test case and fix this.
- for (int i = 0; i < simulate->OperandCount(); i++) {
- if (simulate->OperandAt(i) != allocate) continue;
- simulate->SetOperandAt(i, state);
- }
- break;
- }
- case HValue::kArgumentsObject:
- case HValue::kCapturedObject: {
for (int i = 0; i < instr->OperandCount(); i++) {
if (instr->OperandAt(i) != allocate) continue;
instr->SetOperandAt(i, state);
@@ -274,6 +266,7 @@
if (!allocate->size()->IsInteger32Constant()) continue;
int size_in_bytes = allocate->size()->GetInteger32Constant();
number_of_values_ = size_in_bytes / kPointerSize;
+ number_of_objects_++;
block_states_.Clear();
// Perform actual analysis steps.
=======================================
--- /branches/bleeding_edge/src/hydrogen-escape-analysis.h Wed Aug 7
11:24:14 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-escape-analysis.h Mon Aug 26
16:43:19 2013 UTC
@@ -40,6 +40,7 @@
explicit HEscapeAnalysisPhase(HGraph* graph)
: HPhase("H_Escape analysis", graph),
captured_(0, zone()),
+ number_of_objects_(0),
number_of_values_(0),
cumulative_values_(0),
block_states_(graph->blocks()->length(), zone()) { }
@@ -73,6 +74,9 @@
// List of allocations captured during collection phase.
ZoneList<HInstruction*> captured_;
+ // Number of captured objects on which scalar replacement was done.
+ int number_of_objects_;
+
// Number of scalar values tracked during scalar replacement phase.
int number_of_values_;
int cumulative_values_;
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Aug 22
14:22:55 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Mon Aug 26
16:43:19 2013 UTC
@@ -2287,6 +2287,23 @@
}
}
}
+
+
+// Replay captured objects by replacing all captured objects with the
+// same capture id in the current and all outer environments.
+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);
+ }
+ }
+ env = env->outer();
+ }
+}
void HEnterInlined::RegisterReturnTarget(HBasicBlock* return_target,
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Fri Aug 23 16:31:31
2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Mon Aug 26 16:43:19
2013 UTC
@@ -3208,8 +3208,8 @@
class HCapturedObject V8_FINAL : public HDematerializedObject {
public:
- HCapturedObject(int length, Zone* zone)
- : HDematerializedObject(length, zone) {
+ HCapturedObject(int length, int id, Zone* zone)
+ : HDematerializedObject(length, zone), capture_id_(id) {
set_representation(Representation::Tagged());
values_.AddBlock(NULL, length, zone); // Resize list.
}
@@ -3219,8 +3219,15 @@
// properties or elements backing store are not tracked here.
const ZoneList<HValue*>* values() const { return &values_; }
int length() const { return values_.length(); }
+ int capture_id() const { return capture_id_; }
+
+ // Replay effects of this instruction on the given environment.
+ void ReplayEnvironment(HEnvironment* env);
DECLARE_CONCRETE_INSTRUCTION(CapturedObject)
+
+ private:
+ int capture_id_;
};
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Wed Aug 21 08:28:59
2013 UTC
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Mon Aug 26 16:43:19
2013 UTC
@@ -2564,6 +2564,9 @@
LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
+ HEnvironment* env = current_block_->last_environment();
+ instr->ReplayEnvironment(env);
+
// There are no real uses of a captured object.
return NULL;
}
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.cc Wed Aug 21 08:28:59
2013 UTC
+++ /branches/bleeding_edge/src/mips/lithium-mips.cc Mon Aug 26 16:43:19
2013 UTC
@@ -2361,6 +2361,9 @@
LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
+ HEnvironment* env = current_block_->last_environment();
+ instr->ReplayEnvironment(env);
+
// There are no real uses of a captured object.
return NULL;
}
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Wed Aug 21 08:28:59 2013
UTC
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Mon Aug 26 16:43:19 2013
UTC
@@ -2374,6 +2374,9 @@
LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
+ HEnvironment* env = current_block_->last_environment();
+ instr->ReplayEnvironment(env);
+
// There are no real uses of a captured object.
return NULL;
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/compiler/escape-analysis.js Wed
Aug 7 11:24:14 2013 UTC
+++ /branches/bleeding_edge/test/mjsunit/compiler/escape-analysis.js Mon
Aug 26 16:43:19 2013 UTC
@@ -132,3 +132,44 @@
delete deopt.deopt;
func(); func();
})();
+
+
+// Test deoptimization with captured objects on operand stack.
+(function testDeoptOperand() {
+ var deopt = { deopt:false };
+ function constructor1() {
+ this.a = 1.0;
+ this.b = 2.3;
+ deopt.deopt;
+ assertEquals(1.0, this.a);
+ assertEquals(2.3, this.b);
+ this.b = 2.7;
+ this.c = 3.0;
+ this.d = 4.5;
+ }
+ function constructor2() {
+ this.e = 5.0;
+ this.f = new constructor1();
+ assertEquals(1.0, this.f.a);
+ assertEquals(2.7, this.f.b);
+ assertEquals(3.0, this.f.c);
+ assertEquals(4.5, this.f.d);
+ assertEquals(5.0, this.e);
+ this.e = 5.9;
+ this.g = 6.7;
+ }
+ function func() {
+ var o = new constructor2();
+ assertEquals(1.0, o.f.a);
+ assertEquals(2.7, o.f.b);
+ assertEquals(3.0, o.f.c);
+ assertEquals(4.5, o.f.d);
+ assertEquals(5.9, o.e);
+ assertEquals(6.7, o.g);
+ }
+ func(); func();
+ %OptimizeFunctionOnNextCall(func);
+ func(); func();
+ delete deopt.deopt;
+ func(); func();
+})();
=======================================
--- /branches/bleeding_edge/test/mjsunit/mjsunit.status Mon Aug 12 08:59:42
2013 UTC
+++ /branches/bleeding_edge/test/mjsunit/mjsunit.status Mon Aug 26 16:43:19
2013 UTC
@@ -251,8 +251,5 @@
readonly: SKIP
array-feedback: SKIP
-# TODO(mstarzinger): Enable once escape analysis is stabilized.
-compiler/escape-analysis: SKIP
-
# Deopt every n garbage collections collides with the deopt every n times
flag.
regress/regress-2653: SKIP
--
--
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.