Optimize numeric comparison with known successors.

R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/246133005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20880 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
bmeurer@chromium.org 2014-04-22 10:49:28 +00:00
parent eeb1d7020e
commit 376bff2411
8 changed files with 30 additions and 6 deletions

View File

@ -1676,6 +1676,8 @@ LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
HCompareNumericAndBranch* instr) {
LInstruction* goto_instr = CheckElideControlInstruction(instr);
if (goto_instr != NULL) return goto_instr;
Representation r = instr->representation();
if (r.IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(r));

View File

@ -1251,8 +1251,9 @@ LInstruction* LChunkBuilder::DoClassOfTestAndBranch(
LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
HCompareNumericAndBranch* instr) {
LInstruction* goto_instr = CheckElideControlInstruction(instr);
if (goto_instr != NULL) return goto_instr;
Representation r = instr->representation();
if (r.IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(r));
ASSERT(instr->right()->representation().Equals(r));

View File

@ -3303,6 +3303,21 @@ void HCompareHoleAndBranch::InferRepresentation(
}
bool HCompareNumericAndBranch::KnownSuccessorBlock(HBasicBlock** block) {
if (left() == right() &&
left()->representation().IsSmiOrInteger32()) {
*block = (token() == Token::EQ ||
token() == Token::EQ_STRICT ||
token() == Token::LTE ||
token() == Token::GTE)
? FirstSuccessor() : SecondSuccessor();
return true;
}
*block = NULL;
return false;
}
bool HCompareMinusZeroAndBranch::KnownSuccessorBlock(HBasicBlock** block) {
if (FLAG_fold_constants && value()->IsConstant()) {
HConstant* constant = HConstant::cast(value());

View File

@ -4218,6 +4218,9 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
virtual Representation observed_input_representation(int index) V8_OVERRIDE {
return observed_input_representation_[index];
}
virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE;
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
void SetOperandPositions(Zone* zone,

View File

@ -1314,11 +1314,8 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(
HValue* max_gap = Add<HConstant>(static_cast<int32_t>(JSObject::kMaxGap));
HValue* max_capacity = AddUncasted<HAdd>(current_capacity, max_gap);
IfBuilder key_checker(this);
key_checker.If<HCompareNumericAndBranch>(key, max_capacity, Token::LT);
key_checker.Then();
key_checker.ElseDeopt("Key out of capacity range");
key_checker.End();
Add<HBoundsCheck>(key, max_capacity);
HValue* new_capacity = BuildNewElementsCapacity(key);
HValue* new_elements = BuildGrowElementsCapacity(object, elements,

View File

@ -1677,6 +1677,8 @@ LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
HCompareNumericAndBranch* instr) {
LInstruction* goto_instr = CheckElideControlInstruction(instr);
if (goto_instr != NULL) return goto_instr;
Representation r = instr->representation();
if (r.IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(r));

View File

@ -1626,6 +1626,8 @@ LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
HCompareNumericAndBranch* instr) {
LInstruction* goto_instr = CheckElideControlInstruction(instr);
if (goto_instr != NULL) return goto_instr;
Representation r = instr->representation();
if (r.IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(r));

View File

@ -1621,6 +1621,8 @@ LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
HCompareNumericAndBranch* instr) {
LInstruction* goto_instr = CheckElideControlInstruction(instr);
if (goto_instr != NULL) return goto_instr;
Representation r = instr->representation();
if (r.IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(r));