Commit 557e9b9d authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Fix IfBuilder to use instruction factories. Add missing instruction factories.

This also makes the instruction constructors private and fixes
all uses of the public constructors to use the factory methods
instead.

R=svenpanne@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16808 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent bf192205
......@@ -1351,14 +1351,12 @@ class HUnaryControlInstruction : public HTemplateControlInstruction<2, 1> {
class HBranch V8_FINAL : public HUnaryControlInstruction {
public:
HBranch(HValue* value,
ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(),
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target),
expected_input_types_(expected_input_types) {
SetFlag(kAllowUndefinedAsNaN);
}
DECLARE_INSTRUCTION_FACTORY_P1(HBranch, HValue*);
DECLARE_INSTRUCTION_FACTORY_P2(HBranch, HValue*,
ToBooleanStub::Types);
DECLARE_INSTRUCTION_FACTORY_P4(HBranch, HValue*,
ToBooleanStub::Types,
HBasicBlock*, HBasicBlock*);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::None();
......@@ -1372,20 +1370,24 @@ class HBranch V8_FINAL : public HUnaryControlInstruction {
DECLARE_CONCRETE_INSTRUCTION(Branch)
private:
HBranch(HValue* value,
ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(),
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target),
expected_input_types_(expected_input_types) {
SetFlag(kAllowUndefinedAsNaN);
}
ToBooleanStub::Types expected_input_types_;
};
class HCompareMap V8_FINAL : public HUnaryControlInstruction {
public:
HCompareMap(HValue* value,
Handle<Map> map,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target),
map_(map) {
ASSERT(!map.is_null());
}
DECLARE_INSTRUCTION_FACTORY_P2(HCompareMap, HValue*, Handle<Map>);
DECLARE_INSTRUCTION_FACTORY_P4(HCompareMap, HValue*, Handle<Map>,
HBasicBlock*, HBasicBlock*);
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
......@@ -1401,6 +1403,14 @@ class HCompareMap V8_FINAL : public HUnaryControlInstruction {
virtual int RedefinedOperandIndex() { return 0; }
private:
HCompareMap(HValue* value,
Handle<Map> map,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target), map_(map) {
ASSERT(!map.is_null());
}
Handle<Map> map_;
};
......@@ -4033,13 +4043,11 @@ class HCompareGeneric V8_FINAL : public HBinaryOperation {
class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
public:
HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token)
: token_(token) {
SetFlag(kFlexibleRepresentation);
ASSERT(Token::IsCompareOp(token));
SetOperandAt(0, left);
SetOperandAt(1, right);
}
DECLARE_INSTRUCTION_FACTORY_P3(HCompareNumericAndBranch,
HValue*, HValue*, Token::Value);
DECLARE_INSTRUCTION_FACTORY_P5(HCompareNumericAndBranch,
HValue*, HValue*, Token::Value,
HBasicBlock*, HBasicBlock*);
HValue* left() { return OperandAt(0); }
HValue* right() { return OperandAt(1); }
......@@ -4065,6 +4073,20 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch)
private:
HCompareNumericAndBranch(HValue* left,
HValue* right,
Token::Value token,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: token_(token) {
SetFlag(kFlexibleRepresentation);
ASSERT(Token::IsCompareOp(token));
SetOperandAt(0, left);
SetOperandAt(1, right);
SetSuccessorAt(0, true_target);
SetSuccessorAt(1, false_target);
}
Representation observed_input_representation_[2];
Token::Value token_;
};
......@@ -4072,16 +4094,6 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
class HCompareHoleAndBranch V8_FINAL : public HUnaryControlInstruction {
public:
// TODO(danno): make this private when the IfBuilder properly constructs
// control flow instructions.
HCompareHoleAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {
SetFlag(kFlexibleRepresentation);
SetFlag(kAllowUndefinedAsNaN);
}
DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*);
DECLARE_INSTRUCTION_FACTORY_P3(HCompareHoleAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
......@@ -4094,20 +4106,23 @@ class HCompareHoleAndBranch V8_FINAL : public HUnaryControlInstruction {
}
DECLARE_CONCRETE_INSTRUCTION(CompareHoleAndBranch)
private:
HCompareHoleAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {
SetFlag(kFlexibleRepresentation);
SetFlag(kAllowUndefinedAsNaN);
}
};
class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
public:
// TODO(danno): make this private when the IfBuilder properly constructs
// control flow instructions.
HCompareObjectEqAndBranch(HValue* left,
HValue* right) {
SetOperandAt(0, left);
SetOperandAt(1, right);
}
DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*);
DECLARE_INSTRUCTION_FACTORY_P4(HCompareObjectEqAndBranch, HValue*, HValue*,
HBasicBlock*, HBasicBlock*);
HValue* left() { return OperandAt(0); }
HValue* right() { return OperandAt(1); }
......@@ -4123,38 +4138,65 @@ class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
}
DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch)
private:
HCompareObjectEqAndBranch(HValue* left,
HValue* right,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL) {
SetOperandAt(0, left);
SetOperandAt(1, right);
SetSuccessorAt(0, true_target);
SetSuccessorAt(1, false_target);
}
};
class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction {
public:
explicit HIsObjectAndBranch(HValue* value)
: HUnaryControlInstruction(value, NULL, NULL) { }
DECLARE_INSTRUCTION_FACTORY_P1(HIsObjectAndBranch, HValue*);
DECLARE_INSTRUCTION_FACTORY_P3(HIsObjectAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
}
DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch)
private:
HIsObjectAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {}
};
class HIsStringAndBranch V8_FINAL : public HUnaryControlInstruction {
public:
explicit HIsStringAndBranch(HValue* value)
: HUnaryControlInstruction(value, NULL, NULL) { }
DECLARE_INSTRUCTION_FACTORY_P1(HIsStringAndBranch, HValue*);
DECLARE_INSTRUCTION_FACTORY_P3(HIsStringAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
}
DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch)
private:
HIsStringAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {}
};
class HIsSmiAndBranch V8_FINAL : public HUnaryControlInstruction {
public:
explicit HIsSmiAndBranch(HValue* value)
: HUnaryControlInstruction(value, NULL, NULL) { }
DECLARE_INSTRUCTION_FACTORY_P1(HIsSmiAndBranch, HValue*);
DECLARE_INSTRUCTION_FACTORY_P3(HIsSmiAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch)
......@@ -4164,19 +4206,32 @@ class HIsSmiAndBranch V8_FINAL : public HUnaryControlInstruction {
protected:
virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
private:
HIsSmiAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {}
};
class HIsUndetectableAndBranch V8_FINAL : public HUnaryControlInstruction {
public:
explicit HIsUndetectableAndBranch(HValue* value)
: HUnaryControlInstruction(value, NULL, NULL) { }
DECLARE_INSTRUCTION_FACTORY_P1(HIsUndetectableAndBranch, HValue*);
DECLARE_INSTRUCTION_FACTORY_P3(HIsUndetectableAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
}
DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch)
private:
HIsUndetectableAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {}
};
......
......@@ -63,8 +63,8 @@ HBasicBlock* HOsrBuilder::BuildPossibleOsrLoopEntry(
HBasicBlock* non_osr_entry = graph->CreateBasicBlock();
osr_entry_ = graph->CreateBasicBlock();
HValue* true_value = graph->GetConstantTrue();
HBranch* test = new(zone) HBranch(true_value, ToBooleanStub::Types(),
non_osr_entry, osr_entry_);
HBranch* test = builder_->New<HBranch>(true_value, ToBooleanStub::Types(),
non_osr_entry, osr_entry_);
builder_->current_block()->Finish(test);
HBasicBlock* loop_predecessor = graph->CreateBasicBlock();
......
This diff is collapsed.
......@@ -1285,29 +1285,29 @@ class HGraphBuilder {
}
template<class Condition>
HInstruction* If(HValue *p) {
HControlInstruction* compare = new(zone()) Condition(p);
Condition* If(HValue *p) {
Condition* compare = builder()->New<Condition>(p);
AddCompare(compare);
return compare;
}
template<class Condition, class P2>
HInstruction* If(HValue* p1, P2 p2) {
HControlInstruction* compare = new(zone()) Condition(p1, p2);
Condition* If(HValue* p1, P2 p2) {
Condition* compare = builder()->New<Condition>(p1, p2);
AddCompare(compare);
return compare;
}
template<class Condition, class P2, class P3>
HInstruction* If(HValue* p1, P2 p2, P3 p3) {
HControlInstruction* compare = new(zone()) Condition(p1, p2, p3);
Condition* If(HValue* p1, P2 p2, P3 p3) {
Condition* compare = builder()->New<Condition>(p1, p2, p3);
AddCompare(compare);
return compare;
}
template<class Condition, class P2>
HInstruction* IfNot(HValue* p1, P2 p2) {
HControlInstruction* compare = new(zone()) Condition(p1, p2);
Condition* IfNot(HValue* p1, P2 p2) {
Condition* compare = builder()->New<Condition>(p1, p2);
AddCompare(compare);
HBasicBlock* block0 = compare->SuccessorAt(0);
HBasicBlock* block1 = compare->SuccessorAt(1);
......@@ -1317,8 +1317,8 @@ class HGraphBuilder {
}
template<class Condition, class P2, class P3>
HInstruction* IfNot(HValue* p1, P2 p2, P3 p3) {
HControlInstruction* compare = new(zone()) Condition(p1, p2, p3);
Condition* IfNot(HValue* p1, P2 p2, P3 p3) {
Condition* compare = builder()->New<Condition>(p1, p2, p3);
AddCompare(compare);
HBasicBlock* block0 = compare->SuccessorAt(0);
HBasicBlock* block1 = compare->SuccessorAt(1);
......@@ -1328,37 +1328,37 @@ class HGraphBuilder {
}
template<class Condition>
HInstruction* OrIf(HValue *p) {
Condition* OrIf(HValue *p) {
Or();
return If<Condition>(p);
}
template<class Condition, class P2>
HInstruction* OrIf(HValue* p1, P2 p2) {
Condition* OrIf(HValue* p1, P2 p2) {
Or();
return If<Condition>(p1, p2);
}
template<class Condition, class P2, class P3>
HInstruction* OrIf(HValue* p1, P2 p2, P3 p3) {
Condition* OrIf(HValue* p1, P2 p2, P3 p3) {
Or();
return If<Condition>(p1, p2, p3);
}
template<class Condition>
HInstruction* AndIf(HValue *p) {
Condition* AndIf(HValue *p) {
And();
return If<Condition>(p);
}
template<class Condition, class P2>
HInstruction* AndIf(HValue* p1, P2 p2) {
Condition* AndIf(HValue* p1, P2 p2) {
And();
return If<Condition>(p1, p2);
}
template<class Condition, class P2, class P3>
HInstruction* AndIf(HValue* p1, P2 p2, P3 p3) {
Condition* AndIf(HValue* p1, P2 p2, P3 p3) {
And();
return If<Condition>(p1, p2, p3);
}
......@@ -1383,7 +1383,7 @@ class HGraphBuilder {
private:
void AddCompare(HControlInstruction* compare);
Zone* zone() { return builder_->zone(); }
HGraphBuilder* builder() const { return builder_; }
HGraphBuilder* builder_;
int position_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment