Revision: 19094
Author: [email protected]
Date: Wed Feb 5 09:30:53 2014 UTC
Log: Optimize redundant HCompareMap instructions with known successors.
[email protected]
Review URL: https://codereview.chromium.org/150663005
http://code.google.com/p/v8/source/detail?r=19094
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/hydrogen-check-elimination.cc
/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/src/arm/lithium-arm.cc Fri Jan 31 16:52:17 2014
UTC
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Wed Feb 5 09:30:53 2014
UTC
@@ -942,6 +942,9 @@
LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
+ LInstruction* goto_instr = CheckElideControlInstruction(instr);
+ if (goto_instr != NULL) return goto_instr;
+
ASSERT(instr->value()->representation().IsTagged());
LOperand* value = UseRegisterAtStart(instr->value());
LOperand* temp = TempRegister();
=======================================
--- /branches/bleeding_edge/src/hydrogen-check-elimination.cc Tue Jan 28
17:49:13 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen-check-elimination.cc Wed Feb 5
09:30:53 2014 UTC
@@ -341,11 +341,15 @@
if (maps == NULL) return;
if (maps->Contains(instr->map())) {
if (maps->size() == 1) {
- // TODO(titzer): replace with goto true branch
+ TRACE(("Marking redundant CompareMap #%d at B%d as true\n",
+ instr->id(), instr->block()->block_id()));
+ instr->set_known_successor_index(0);
INC_STAT(compares_true_);
}
} else {
- // TODO(titzer): replace with goto false branch
+ TRACE(("Marking redundant CompareMap #%d at B%d as false\n",
+ instr->id(), instr->block()->block_id()));
+ instr->set_known_successor_index(1);
INC_STAT(compares_false_);
}
}
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Feb 4
22:23:26 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Wed Feb 5
09:30:53 2014 UTC
@@ -1117,6 +1117,11 @@
value()->PrintNameTo(stream);
stream->Add(" (%p)", *map().handle());
HControlInstruction::PrintDataTo(stream);
+ if (known_successor_index() == 0) {
+ stream->Add(" [true]");
+ } else if (known_successor_index() == 1) {
+ stream->Add(" [false]");
+ }
}
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Tue Feb 4 10:48:49
2014 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Wed Feb 5 09:30:53
2014 UTC
@@ -1529,7 +1529,22 @@
DECLARE_INSTRUCTION_FACTORY_P4(HCompareMap, HValue*, Handle<Map>,
HBasicBlock*, HBasicBlock*);
+ virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE {
+ if (known_successor_index() != kNoKnownSuccessorIndex) {
+ *block = SuccessorAt(known_successor_index());
+ return true;
+ }
+ *block = NULL;
+ return false;
+ }
+
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
+
+ static const int kNoKnownSuccessorIndex = -1;
+ int known_successor_index() const { return known_successor_index_; }
+ void set_known_successor_index(int known_successor_index) {
+ known_successor_index_ = known_successor_index;
+ }
Unique<Map> map() const { return map_; }
@@ -1548,10 +1563,11 @@
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target),
- map_(Unique<Map>(map)) {
+ known_successor_index_(kNoKnownSuccessorIndex),
map_(Unique<Map>(map)) {
ASSERT(!map.is_null());
}
+ int known_successor_index_;
Unique<Map> map_;
};
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Fri Jan 31 16:52:17
2014 UTC
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Wed Feb 5 09:30:53
2014 UTC
@@ -1027,6 +1027,9 @@
LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
+ LInstruction* goto_instr = CheckElideControlInstruction(instr);
+ if (goto_instr != NULL) return goto_instr;
+
ASSERT(instr->value()->representation().IsTagged());
LOperand* value = UseRegisterAtStart(instr->value());
return new(zone()) LCmpMapAndBranch(value);
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.cc Sat Feb 1 02:23:46
2014 UTC
+++ /branches/bleeding_edge/src/mips/lithium-mips.cc Wed Feb 5 09:30:53
2014 UTC
@@ -945,6 +945,9 @@
LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
+ LInstruction* goto_instr = CheckElideControlInstruction(instr);
+ if (goto_instr != NULL) return goto_instr;
+
ASSERT(instr->value()->representation().IsTagged());
LOperand* value = UseRegisterAtStart(instr->value());
LOperand* temp = TempRegister();
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Fri Jan 31 16:52:17 2014
UTC
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Wed Feb 5 09:30:53 2014
UTC
@@ -952,6 +952,9 @@
LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
+ LInstruction* goto_instr = CheckElideControlInstruction(instr);
+ if (goto_instr != NULL) return goto_instr;
+
ASSERT(instr->value()->representation().IsTagged());
LOperand* value = UseRegisterAtStart(instr->value());
return new(zone()) LCmpMapAndBranch(value);
--
--
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.