Use hydrogen accessor in a few more places to save space in the lithium IR.

Review URL: http://codereview.chromium.org/6207007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6288 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3a7c6964
...@@ -945,22 +945,21 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { ...@@ -945,22 +945,21 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
Token::Value op = compare->token(); Token::Value op = compare->token();
HValue* left = compare->left(); HValue* left = compare->left();
HValue* right = compare->right(); HValue* right = compare->right();
if (left->representation().IsInteger32()) { Representation r = compare->GetInputRepresentation();
if (r.IsInteger32()) {
ASSERT(left->representation().IsInteger32());
ASSERT(right->representation().IsInteger32()); ASSERT(right->representation().IsInteger32());
return new LCmpIDAndBranch(op, return new LCmpIDAndBranch(UseRegisterAtStart(left),
UseRegisterAtStart(left),
UseOrConstantAtStart(right), UseOrConstantAtStart(right),
first_id, first_id,
second_id, second_id);
false); } else if (r.IsDouble()) {
} else if (left->representation().IsDouble()) { ASSERT(left->representation().IsDouble());
ASSERT(right->representation().IsDouble()); ASSERT(right->representation().IsDouble());
return new LCmpIDAndBranch(op, return new LCmpIDAndBranch(UseRegisterAtStart(left),
UseRegisterAtStart(left),
UseRegisterAtStart(right), UseRegisterAtStart(right),
first_id, first_id,
second_id, second_id);
true);
} else { } else {
ASSERT(left->representation().IsTagged()); ASSERT(left->representation().IsTagged());
ASSERT(right->representation().IsTagged()); ASSERT(right->representation().IsTagged());
...@@ -998,7 +997,6 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { ...@@ -998,7 +997,6 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
ASSERT(compare->value()->representation().IsTagged()); ASSERT(compare->value()->representation().IsTagged());
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), return new LIsNullAndBranch(UseRegisterAtStart(compare->value()),
compare->is_strict(),
first_id, first_id,
second_id); second_id);
} else if (v->IsIsObject()) { } else if (v->IsIsObject()) {
...@@ -1350,17 +1348,22 @@ LInstruction* LChunkBuilder::DoPower(HPower* instr) { ...@@ -1350,17 +1348,22 @@ LInstruction* LChunkBuilder::DoPower(HPower* instr) {
LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { LInstruction* LChunkBuilder::DoCompare(HCompare* instr) {
Token::Value op = instr->token(); Token::Value op = instr->token();
if (instr->left()->representation().IsInteger32()) { Representation r = instr->GetInputRepresentation();
if (r.IsInteger32()) {
ASSERT(instr->left()->representation().IsInteger32());
ASSERT(instr->right()->representation().IsInteger32()); ASSERT(instr->right()->representation().IsInteger32());
LOperand* left = UseRegisterAtStart(instr->left()); LOperand* left = UseRegisterAtStart(instr->left());
LOperand* right = UseOrConstantAtStart(instr->right()); LOperand* right = UseOrConstantAtStart(instr->right());
return DefineAsRegister(new LCmpID(op, left, right, false)); return DefineAsRegister(new LCmpID(left, right));
} else if (instr->left()->representation().IsDouble()) { } else if (r.IsDouble()) {
ASSERT(instr->left()->representation().IsDouble());
ASSERT(instr->right()->representation().IsDouble()); ASSERT(instr->right()->representation().IsDouble());
LOperand* left = UseRegisterAtStart(instr->left()); LOperand* left = UseRegisterAtStart(instr->left());
LOperand* right = UseRegisterAtStart(instr->right()); LOperand* right = UseRegisterAtStart(instr->right());
return DefineAsRegister(new LCmpID(op, left, right, true)); return DefineAsRegister(new LCmpID(left, right));
} else { } else {
ASSERT(instr->left()->representation().IsTagged());
ASSERT(instr->right()->representation().IsTagged());
bool reversed = (op == Token::GT || op == Token::LTE); bool reversed = (op == Token::GT || op == Token::LTE);
LOperand* left = UseFixed(instr->left(), reversed ? r0 : r1); LOperand* left = UseFixed(instr->left(), reversed ? r0 : r1);
LOperand* right = UseFixed(instr->right(), reversed ? r1 : r0); LOperand* right = UseFixed(instr->right(), reversed ? r1 : r0);
...@@ -1383,8 +1386,7 @@ LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) { ...@@ -1383,8 +1386,7 @@ LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) {
ASSERT(instr->value()->representation().IsTagged()); ASSERT(instr->value()->representation().IsTagged());
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
return DefineAsRegister(new LIsNull(value, return DefineAsRegister(new LIsNull(value));
instr->is_strict()));
} }
......
...@@ -583,29 +583,26 @@ class LMulI: public LBinaryOperation { ...@@ -583,29 +583,26 @@ class LMulI: public LBinaryOperation {
class LCmpID: public LBinaryOperation { class LCmpID: public LBinaryOperation {
public: public:
LCmpID(Token::Value op, LOperand* left, LOperand* right, bool is_double) LCmpID(LOperand* left, LOperand* right)
: LBinaryOperation(left, right), op_(op), is_double_(is_double) { } : LBinaryOperation(left, right) { }
Token::Value op() const { return op_; } Token::Value op() const { return hydrogen()->token(); }
bool is_double() const { return is_double_; } bool is_double() const {
return hydrogen()->GetInputRepresentation().IsDouble();
}
DECLARE_CONCRETE_INSTRUCTION(CmpID, "cmp-id") DECLARE_CONCRETE_INSTRUCTION(CmpID, "cmp-id")
DECLARE_HYDROGEN_ACCESSOR(Compare)
private:
Token::Value op_;
bool is_double_;
}; };
class LCmpIDAndBranch: public LCmpID { class LCmpIDAndBranch: public LCmpID {
public: public:
LCmpIDAndBranch(Token::Value op, LCmpIDAndBranch(LOperand* left,
LOperand* left,
LOperand* right, LOperand* right,
int true_block_id, int true_block_id,
int false_block_id, int false_block_id)
bool is_double) : LCmpID(left, right),
: LCmpID(op, left, right, is_double),
true_block_id_(true_block_id), true_block_id_(true_block_id),
false_block_id_(false_block_id) { } false_block_id_(false_block_id) { }
...@@ -668,25 +665,21 @@ class LCmpJSObjectEqAndBranch: public LCmpJSObjectEq { ...@@ -668,25 +665,21 @@ class LCmpJSObjectEqAndBranch: public LCmpJSObjectEq {
class LIsNull: public LUnaryOperation { class LIsNull: public LUnaryOperation {
public: public:
LIsNull(LOperand* value, bool is_strict) explicit LIsNull(LOperand* value) : LUnaryOperation(value) {}
: LUnaryOperation(value), is_strict_(is_strict) {}
DECLARE_CONCRETE_INSTRUCTION(IsNull, "is-null") DECLARE_CONCRETE_INSTRUCTION(IsNull, "is-null")
DECLARE_HYDROGEN_ACCESSOR(IsNull);
bool is_strict() const { return is_strict_; } bool is_strict() const { return hydrogen()->is_strict(); }
private:
bool is_strict_;
}; };
class LIsNullAndBranch: public LIsNull { class LIsNullAndBranch: public LIsNull {
public: public:
LIsNullAndBranch(LOperand* value, LIsNullAndBranch(LOperand* value,
bool is_strict,
int true_block_id, int true_block_id,
int false_block_id) int false_block_id)
: LIsNull(value, is_strict), : LIsNull(value),
true_block_id_(true_block_id), true_block_id_(true_block_id),
false_block_id_(false_block_id) { } false_block_id_(false_block_id) { }
......
...@@ -957,22 +957,23 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { ...@@ -957,22 +957,23 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
Token::Value op = compare->token(); Token::Value op = compare->token();
HValue* left = compare->left(); HValue* left = compare->left();
HValue* right = compare->right(); HValue* right = compare->right();
if (left->representation().IsInteger32()) { Representation r = compare->GetInputRepresentation();
if (r.IsInteger32()) {
ASSERT(left->representation().IsInteger32());
ASSERT(right->representation().IsInteger32()); ASSERT(right->representation().IsInteger32());
return new LCmpIDAndBranch(op,
UseRegisterAtStart(left), return new LCmpIDAndBranch(UseRegisterAtStart(left),
UseOrConstantAtStart(right), UseOrConstantAtStart(right),
first_id, first_id,
second_id, second_id);
false); } else if (r.IsDouble()) {
} else if (left->representation().IsDouble()) { ASSERT(left->representation().IsDouble());
ASSERT(right->representation().IsDouble()); ASSERT(right->representation().IsDouble());
return new LCmpIDAndBranch(op,
UseRegisterAtStart(left), return new LCmpIDAndBranch(UseRegisterAtStart(left),
UseRegisterAtStart(right), UseRegisterAtStart(right),
first_id, first_id,
second_id, second_id);
true);
} else { } else {
ASSERT(left->representation().IsTagged()); ASSERT(left->representation().IsTagged());
ASSERT(right->representation().IsTagged()); ASSERT(right->representation().IsTagged());
...@@ -1013,7 +1014,6 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { ...@@ -1013,7 +1014,6 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
// We only need a temp register for non-strict compare. // We only need a temp register for non-strict compare.
LOperand* temp = compare->is_strict() ? NULL : TempRegister(); LOperand* temp = compare->is_strict() ? NULL : TempRegister();
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), return new LIsNullAndBranch(UseRegisterAtStart(compare->value()),
compare->is_strict(),
temp, temp,
first_id, first_id,
second_id); second_id);
...@@ -1379,17 +1379,22 @@ LInstruction* LChunkBuilder::DoPower(HPower* instr) { ...@@ -1379,17 +1379,22 @@ LInstruction* LChunkBuilder::DoPower(HPower* instr) {
LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { LInstruction* LChunkBuilder::DoCompare(HCompare* instr) {
Token::Value op = instr->token(); Token::Value op = instr->token();
if (instr->left()->representation().IsInteger32()) { Representation r = instr->GetInputRepresentation();
if (r.IsInteger32()) {
ASSERT(instr->left()->representation().IsInteger32());
ASSERT(instr->right()->representation().IsInteger32()); ASSERT(instr->right()->representation().IsInteger32());
LOperand* left = UseRegisterAtStart(instr->left()); LOperand* left = UseRegisterAtStart(instr->left());
LOperand* right = UseOrConstantAtStart(instr->right()); LOperand* right = UseOrConstantAtStart(instr->right());
return DefineAsRegister(new LCmpID(op, left, right, false)); return DefineAsRegister(new LCmpID(left, right));
} else if (instr->left()->representation().IsDouble()) { } else if (r.IsDouble()) {
ASSERT(instr->left()->representation().IsDouble());
ASSERT(instr->right()->representation().IsDouble()); ASSERT(instr->right()->representation().IsDouble());
LOperand* left = UseRegisterAtStart(instr->left()); LOperand* left = UseRegisterAtStart(instr->left());
LOperand* right = UseRegisterAtStart(instr->right()); LOperand* right = UseRegisterAtStart(instr->right());
return DefineAsRegister(new LCmpID(op, left, right, true)); return DefineAsRegister(new LCmpID(left, right));
} else { } else {
ASSERT(instr->left()->representation().IsTagged());
ASSERT(instr->right()->representation().IsTagged());
bool reversed = (op == Token::GT || op == Token::LTE); bool reversed = (op == Token::GT || op == Token::LTE);
LOperand* left = UseFixed(instr->left(), reversed ? eax : edx); LOperand* left = UseFixed(instr->left(), reversed ? eax : edx);
LOperand* right = UseFixed(instr->right(), reversed ? edx : eax); LOperand* right = UseFixed(instr->right(), reversed ? edx : eax);
...@@ -1412,8 +1417,7 @@ LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) { ...@@ -1412,8 +1417,7 @@ LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) {
ASSERT(instr->value()->representation().IsTagged()); ASSERT(instr->value()->representation().IsTagged());
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
return DefineAsRegister(new LIsNull(value, return DefineAsRegister(new LIsNull(value));
instr->is_strict()));
} }
......
...@@ -633,29 +633,26 @@ class LMulI: public LBinaryOperation<1> { ...@@ -633,29 +633,26 @@ class LMulI: public LBinaryOperation<1> {
class LCmpID: public LBinaryOperation<1> { class LCmpID: public LBinaryOperation<1> {
public: public:
LCmpID(Token::Value op, LOperand* left, LOperand* right, bool is_double) LCmpID(LOperand* left, LOperand* right)
: LBinaryOperation<1>(left, right), op_(op), is_double_(is_double) { } : LBinaryOperation<1>(left, right) { }
Token::Value op() const { return op_; } Token::Value op() const { return hydrogen()->token(); }
bool is_double() const { return is_double_; } bool is_double() const {
return hydrogen()->GetInputRepresentation().IsDouble();
}
DECLARE_CONCRETE_INSTRUCTION(CmpID, "cmp-id") DECLARE_CONCRETE_INSTRUCTION(CmpID, "cmp-id")
DECLARE_HYDROGEN_ACCESSOR(Compare)
private:
Token::Value op_;
bool is_double_;
}; };
class LCmpIDAndBranch: public LCmpID { class LCmpIDAndBranch: public LCmpID {
public: public:
LCmpIDAndBranch(Token::Value op, LCmpIDAndBranch(LOperand* left,
LOperand* left,
LOperand* right, LOperand* right,
int true_block_id, int true_block_id,
int false_block_id, int false_block_id)
bool is_double) : LCmpID(left, right),
: LCmpID(op, left, right, is_double),
true_block_id_(true_block_id), true_block_id_(true_block_id),
false_block_id_(false_block_id) { } false_block_id_(false_block_id) { }
...@@ -718,26 +715,22 @@ class LCmpJSObjectEqAndBranch: public LCmpJSObjectEq { ...@@ -718,26 +715,22 @@ class LCmpJSObjectEqAndBranch: public LCmpJSObjectEq {
class LIsNull: public LUnaryOperation<1> { class LIsNull: public LUnaryOperation<1> {
public: public:
LIsNull(LOperand* value, bool is_strict) explicit LIsNull(LOperand* value) : LUnaryOperation<1>(value) { }
: LUnaryOperation<1>(value), is_strict_(is_strict) {}
DECLARE_CONCRETE_INSTRUCTION(IsNull, "is-null") DECLARE_CONCRETE_INSTRUCTION(IsNull, "is-null")
DECLARE_HYDROGEN_ACCESSOR(IsNull)
bool is_strict() const { return is_strict_; } bool is_strict() const { return hydrogen()->is_strict(); }
private:
bool is_strict_;
}; };
class LIsNullAndBranch: public LIsNull { class LIsNullAndBranch: public LIsNull {
public: public:
LIsNullAndBranch(LOperand* value, LIsNullAndBranch(LOperand* value,
bool is_strict,
LOperand* temp, LOperand* temp,
int true_block_id, int true_block_id,
int false_block_id) int false_block_id)
: LIsNull(value, is_strict), : LIsNull(value),
temp_(temp), temp_(temp),
true_block_id_(true_block_id), true_block_id_(true_block_id),
false_block_id_(false_block_id) { } false_block_id_(false_block_id) { }
......
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