Reviewers: danno, Jakob,
Description:
Distinguish two DCE phases
Non-live Constants are safe to remove in the last dce phase.
BUG=2881
Please review this at https://codereview.chromium.org/23811011/
SVN Base: git://github.com/v8/v8.git@master
Affected files (+19, -4 lines):
src/hydrogen-dce.cc
src/hydrogen.h
src/hydrogen.cc
Index: src/hydrogen-dce.cc
diff --git a/src/hydrogen-dce.cc b/src/hydrogen-dce.cc
index
0e7253d5a4869d44ee137129bd4c037eb8774dfd..c2408ed5cdf1d7b5ef809eb3b8a2484173dec6c9
100644
--- a/src/hydrogen-dce.cc
+++ b/src/hydrogen-dce.cc
@@ -94,9 +94,11 @@ void HDeadCodeEliminationPhase::RemoveDeadInstructions()
{
HInstruction* instr = it.Current();
if (!instr->CheckFlag(HValue::kIsLive)) {
// Instruction has not been marked live; assume it is dead and
remove.
- // TODO(titzer): we don't remove constants because some special
ones
- // might be used by later phases and are assumed to be in the graph
- if (!instr->IsConstant()) instr->DeleteAndReplaceWith(NULL);
+ // Constans are only removed in the last dce because some special
ones
+ // might be used by later phases and are assumed to be in the
graph.
+ if (!instr->IsConstant() || graph()->is_last_dce()) {
+ instr->DeleteAndReplaceWith(NULL);
+ }
} else {
// Clear the liveness flag to leave the graph clean for the next
DCE.
instr->ClearFlag(HValue::kIsLive);
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
23c373fa0b461e7a911ec9ac90a9575ea7f36feb..bdc71758b0869cd0e1ad8dba3aa9f6e82e938588
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -2111,6 +2111,7 @@ HGraph::HGraph(CompilationInfo* info)
use_optimistic_licm_(false),
has_soft_deoptimize_(false),
depends_on_empty_array_proto_elements_(false),
+ last_dce_(false),
type_change_checksum_(0),
maximum_environment_size_(0),
no_side_effects_scope_count_(0) {
@@ -3013,7 +3014,10 @@ bool HGraph::Optimize(BailoutReason* bailout_reason)
{
Run<HBoundsCheckHoistingPhase>();
}
if (FLAG_array_index_dehoisting) Run<HDehoistIndexComputationsPhase>();
- if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>();
+ if (FLAG_dead_code_elimination) {
+ MarkLastDCE();
+ Run<HDeadCodeEliminationPhase>();
+ }
RestoreActualValues();
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index
c1dafa8b5a7a73171c3c6c693f60210656ccac27..ec9be61f9a6571e492c9c75f32534c7b148cfd0b
100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -435,6 +435,14 @@ class HGraph V8_FINAL : public ZoneObject {
return depends_on_empty_array_proto_elements_;
}
+ void MarkLastDCE() {
+ last_dce_ = true;
+ }
+
+ bool is_last_dce() const {
+ return last_dce_;
+ }
+
bool has_uint32_instructions() {
ASSERT(uint32_instructions_ == NULL |
| !uint32_instructions_->is_empty());
return uint32_instructions_ != NULL;
@@ -497,6 +505,7 @@ class HGraph V8_FINAL : public ZoneObject {
bool use_optimistic_licm_;
bool has_soft_deoptimize_;
bool depends_on_empty_array_proto_elements_;
+ bool last_dce_;
int type_change_checksum_;
int maximum_environment_size_;
int no_side_effects_scope_count_;
--
--
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.