Revision: 6352
Author: [email protected]
Date: Mon Jan 17 05:51:59 2011
Log: Merge changes to LTemplateInstruction to X64 (Issue 1048).
Implement ConstantD and ConstantI.
BUG=1048
Review URL: http://codereview.chromium.org/6262005
http://code.google.com/p/v8/source/detail?r=6352
Modified:
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.h
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Mon Jan 17
00:11:03 2011
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Mon Jan 17
05:51:59 2011
@@ -996,7 +996,8 @@
SetFlag(kUseGVN);
if (handle_->IsNumber()) {
double n = handle_->Number();
- has_int32_value_ = static_cast<double>(static_cast<int32_t>(n)) == n;
+ double roundtrip_value = static_cast<double>(static_cast<int32_t>(n));
+ has_int32_value_ = BitCast<int64_t>(roundtrip_value) ==
BitCast<int64_t>(n);
if (has_int32_value_) int32_value_ = static_cast<int32_t>(n);
double_value_ = n;
has_double_value_ = true;
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Mon Jan 17
05:11:39 2011
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Mon Jan 17
05:51:59 2011
@@ -825,12 +825,31 @@
void LCodeGen::DoConstantI(LConstantI* instr) {
- Abort("Unimplemented: %s", "DoConstantI");
+ ASSERT(instr->result()->IsRegister());
+ __ movl(ToRegister(instr->result()), Immediate(instr->value()));
}
void LCodeGen::DoConstantD(LConstantD* instr) {
- Abort("Unimplemented: %s", "DoConstantI");
+ ASSERT(instr->result()->IsDoubleRegister());
+ XMMRegister res = ToDoubleRegister(instr->result());
+ double v = instr->value();
+ // Use xor to produce +0.0 in a fast and compact way, but avoid to
+ // do so if the constant is -0.0.
+ if (BitCast<uint64_t, double>(v) == 0) {
+ __ xorpd(res, res);
+ } else {
+ Register tmp = ToRegister(instr->TempAt(0));
+ int32_t v_int32 = static_cast<int32_t>(v);
+ if (static_cast<double>(v_int32) == v) {
+ __ movl(tmp, Immediate(v_int32));
+ __ cvtlsi2sd(res, tmp);
+ } else {
+ uint64_t int_val = BitCast<uint64_t, double>(v);
+ __ Set(tmp, int_val);
+ __ movd(res, tmp);
+ }
+ }
}
@@ -1030,27 +1049,6 @@
void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
Abort("Unimplemented: %s", "DoIsSmiAndBranch");
}
-
-
-InstanceType LHasInstanceType::TestType() {
- InstanceType from = hydrogen()->from();
- InstanceType to = hydrogen()->to();
- if (from == FIRST_TYPE) return to;
- ASSERT(from == to || to == LAST_TYPE);
- return from;
-}
-
-
-
-Condition LHasInstanceType::BranchCondition() {
- InstanceType from = hydrogen()->from();
- InstanceType to = hydrogen()->to();
- if (from == to) return equal;
- if (to == LAST_TYPE) return above_equal;
- if (from == FIRST_TYPE) return below_equal;
- UNREACHABLE();
- return equal;
-}
void LCodeGen::DoHasInstanceType(LHasInstanceType* instr) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Mon Jan 17 04:54:52 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Mon Jan 17 05:51:59 2011
@@ -90,18 +90,22 @@
template<int R, int I, int T>
void LTemplateInstruction<R, I, T>::PrintDataTo(StringStream* stream) {
- for (int i = 0; i < I; i++) {
- stream->Add(i == 0 ? "= " : " ");
- inputs_.at(i)->PrintTo(stream);
- }
+ stream->Add("= ");
+ inputs_.PrintOperandsTo(stream);
}
template<int R, int I, int T>
void LTemplateInstruction<R, I, T>::PrintOutputOperandTo(StringStream*
stream) {
- if (this->HasResult()) {
- this->result()->PrintTo(stream);
- stream->Add(" ");
+ results_.PrintOperandsTo(stream);
+}
+
+
+template<typename T, int N>
+void OperandContainer<T, N>::PrintOperandsTo(StringStream* stream) {
+ for (int i = 0; i < N; i++) {
+ if (i > 0) stream->Add(" ");
+ elems_[i]->PrintTo(stream);
}
}
@@ -172,22 +176,22 @@
void LBranch::PrintDataTo(StringStream* stream) {
stream->Add("B%d | B%d on ", true_block_id(), false_block_id());
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
}
void LCmpIDAndBranch::PrintDataTo(StringStream* stream) {
stream->Add("if ");
- left()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(" %s ", Token::String(op()));
- right()->PrintTo(stream);
+ InputAt(1)->PrintTo(stream);
stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
}
void LIsNullAndBranch::PrintDataTo(StringStream* stream) {
stream->Add("if ");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(is_strict() ? " === null" : " == null");
stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
}
@@ -195,35 +199,35 @@
void LIsObjectAndBranch::PrintDataTo(StringStream* stream) {
stream->Add("if is_object(");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
}
void LIsSmiAndBranch::PrintDataTo(StringStream* stream) {
stream->Add("if is_smi(");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
}
void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) {
stream->Add("if has_instance_type(");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
}
void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) {
stream->Add("if has_cached_array_index(");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
}
void LClassOfTestAndBranch::PrintDataTo(StringStream* stream) {
stream->Add("if class_of_test(");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(", \"%o\") then B%d else B%d",
*hydrogen()->class_name(),
true_block_id(),
@@ -232,14 +236,14 @@
void LTypeofIs::PrintDataTo(StringStream* stream) {
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(" == \"%s\"", *hydrogen()->type_literal()->ToCString());
}
void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
stream->Add("if typeof ");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(" == \"%s\" then B%d else B%d",
*hydrogen()->type_literal()->ToCString(),
true_block_id(), false_block_id());
@@ -253,7 +257,7 @@
void LUnaryMathOperation::PrintDataTo(StringStream* stream) {
stream->Add("/%s ", hydrogen()->OpName());
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
}
@@ -263,7 +267,7 @@
void LCallKeyed::PrintDataTo(StringStream* stream) {
- stream->Add("[rcx] #%d / ", arity());
+ stream->Add("[ecx] #%d / ", arity());
}
@@ -286,14 +290,14 @@
void LCallNew::PrintDataTo(StringStream* stream) {
stream->Add("= ");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(" #%d / ", arity());
}
void LClassOfTest::PrintDataTo(StringStream* stream) {
stream->Add("= class_of_test(");
- input()->PrintTo(stream);
+ InputAt(0)->PrintTo(stream);
stream->Add(", \"%o\")", *hydrogen()->class_name());
}
@@ -832,8 +836,17 @@
if (FLAG_stress_environments && !instr->HasEnvironment()) {
instr = AssignEnvironment(instr);
}
- if (current->IsBranch()) {
- instr->set_hydrogen_value(HBranch::cast(current)->value());
+ if (current->IsBranch() && !instr->IsGoto()) {
+ // TODO(fschneider): Handle branch instructions uniformly like
+ // other instructions. This requires us to generate the right
+ // branch instruction already at the HIR level.
+ ASSERT(instr->IsControl());
+ HBranch* branch = HBranch::cast(current);
+ instr->set_hydrogen_value(branch->value());
+ HBasicBlock* first = branch->FirstSuccessor();
+ HBasicBlock* second = branch->SecondSuccessor();
+ ASSERT(first != NULL && second != NULL);
+ instr->SetBranchTargets(first->block_id(), second->block_id());
} else {
instr->set_hydrogen_value(current);
}
@@ -1217,7 +1230,8 @@
return DefineAsRegister(new LConstantI(value));
} else if (r.IsDouble()) {
double value = instr->DoubleValue();
- return DefineAsRegister(new LConstantD(value));
+ LOperand* temp = TempRegister();
+ return DefineAsRegister(new LConstantD(value, temp));
} else if (r.IsTagged()) {
return DefineAsRegister(new LConstantT(instr->handle()));
} else {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h Mon Jan 17 04:54:52 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.h Mon Jan 17 05:51:59 2011
@@ -43,10 +43,22 @@
// Type hierarchy:
//
// LInstruction
-// LAccessArgumentsAt
-// LArgumentsElements
-// LArgumentsLength
-// LBinaryOperation
+// LTemplateInstruction
+// LControlInstruction
+// LBranch
+// LClassOfTestAndBranch
+// LCmpJSObjectEqAndBranch
+// LCmpIDAndBranch
+// LHasCachedArrayIndexAndBranch
+// LHasInstanceTypeAndBranch
+// LInstanceOfAndBranch
+// LIsNullAndBranch
+// LIsObjectAndBranch
+// LIsSmiAndBranch
+// LTypeofIsAndBranch
+// LAccessArgumentsAt
+// LArgumentsElements
+// LArgumentsLength
// LAddI
// LApplyArguments
// LArithmeticD
@@ -54,13 +66,10 @@
// LBitI
// LBoundsCheck
// LCmpID
-// LCmpIDAndBranch
// LCmpJSObjectEq
-// LCmpJSObjectEqAndBranch
// LCmpT
// LDivI
// LInstanceOf
-// LInstanceOfAndBranch
// LInstanceOfKnownGlobal
// LLoadKeyedFastElement
// LLoadKeyedGeneric
@@ -69,67 +78,59 @@
// LPower
// LShiftI
// LSubI
-// LCallConstantFunction
-// LCallFunction
-// LCallGlobal
-// LCallKeyed
-// LCallKnownGlobal
-// LCallNamed
-// LCallRuntime
-// LCallStub
-// LCheckPrototypeMaps
-// LConstant
-// LConstantD
-// LConstantI
-// LConstantT
-// LDeoptimize
-// LFunctionLiteral
-// LGap
-// LLabel
-// LGlobalObject
-// LGlobalReceiver
-// LGoto
-// LLazyBailout
-// LLoadContextSlot
-// LLoadGlobal
-// LMaterializedLiteral
+// LCallConstantFunction
+// LCallFunction
+// LCallGlobal
+// LCallKeyed
+// LCallKnownGlobal
+// LCallNamed
+// LCallRuntime
+// LCallStub
+// LConstant
+// LConstantD
+// LConstantI
+// LConstantT
+// LDeoptimize
+// LFunctionLiteral
+// LGap
+// LLabel
+// LGlobalObject
+// LGlobalReceiver
+// LGoto
+// LLazyBailout
+// LLoadGlobal
+// LCheckPrototypeMaps
+// LLoadContextSlot
// LArrayLiteral
// LObjectLiteral
// LRegExpLiteral
-// LOsrEntry
-// LParameter
-// LRegExpConstructResult
-// LStackCheck
-// LStoreKeyed
-// LStoreKeyedFastElement
-// LStoreKeyedGeneric
-// LStoreNamed
-// LStoreNamedField
-// LStoreNamedGeneric
-// LUnaryOperation
+// LOsrEntry
+// LParameter
+// LRegExpConstructResult
+// LStackCheck
+// LStoreKeyed
+// LStoreKeyedFastElement
+// LStoreKeyedGeneric
+// LStoreNamed
+// LStoreNamedField
+// LStoreNamedGeneric
// LBitNotI
-// LBranch
// LCallNew
// LCheckFunction
+// LCheckPrototypeMaps
// LCheckInstanceType
// LCheckMap
// LCheckSmi
// LClassOfTest
-// LClassOfTestAndBranch
// LDeleteProperty
// LDoubleToI
// LFixedArrayLength
// LHasCachedArrayIndex
-// LHasCachedArrayIndexAndBranch
// LHasInstanceType
-// LHasInstanceTypeAndBranch
// LInteger32ToDouble
// LIsNull
-// LIsNullAndBranch
// LIsObject
-// LIsObjectAndBranch
// LIsSmi
-// LIsSmiAndBranch
// LJSArrayLength
// LLoadNamedField
// LLoadNamedGeneric
@@ -144,19 +145,16 @@
// LThrow
// LTypeof
// LTypeofIs
-// LTypeofIsAndBranch
// LUnaryMathOperation
// LValueOf
-// LUnknownOSRValue
+// LUnknownOSRValue
#define LITHIUM_ALL_INSTRUCTION_LIST(V) \
- V(BinaryOperation) \
+ V(ControlInstruction) \
V(Constant) \
V(Call) \
- V(MaterializedLiteral) \
V(StoreKeyed) \
V(StoreNamed) \
- V(UnaryOperation) \
LITHIUM_CONCRETE_INSTRUCTION_LIST(V)
@@ -302,7 +300,9 @@
#define DECLARE_DO(type) virtual bool Is##type() const { return false; }
LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO)
#undef DECLARE_DO
+
virtual bool IsControl() const { return false; }
+ virtual void SetBranchTargets(int true_block_id, int false_block_id) { }
void set_environment(LEnvironment* env) { environment_.set(env); }
LEnvironment* environment() const { return environment_.get(); }
@@ -341,9 +341,13 @@
OperandContainer() {
for (int i = 0; i < N; i++) elems_[i] = NULL;
}
- int length() const { return N; }
- T at(int i) const { return elems_[i]; }
- void set_at(int i, T value) { elems_[i] = value; }
+ int length() { return N; }
+ T& operator[](int i) {
+ ASSERT(i < length());
+ return elems_[i];
+ }
+ void PrintOperandsTo(StringStream* stream);
+
private:
T elems_[N];
};
@@ -352,38 +356,31 @@
template<typename T>
class OperandContainer<T, 0> {
public:
- int length() const { return 0; }
- T at(int i) const {
- UNREACHABLE();
- return NULL;
- }
- void set_at(int i, T value) {
- UNREACHABLE();
- }
+ int length() { return 0; }
+ void PrintOperandsTo(StringStream* stream) { }
};
-template<int R, int I, int T>
+template<int R, int I, int T = 0>
class LTemplateInstruction: public LInstruction {
public:
// Allow 0 or 1 output operands.
STATIC_ASSERT(R == 0 || R == 1);
virtual bool HasResult() const { return R != 0; }
- void set_result(LOperand* operand) { outputs_.set_at(0, operand); }
- LOperand* result() const { return outputs_.at(0); }
-
- int InputCount() const { return inputs_.length(); }
- LOperand* InputAt(int i) const { return inputs_.at(i); }
- void SetInputAt(int i, LOperand* operand) { inputs_.set_at(i, operand); }
-
- int TempCount() const { return temps_.length(); }
- LOperand* TempAt(int i) const { return temps_.at(i); }
+ void set_result(LOperand* operand) { results_[0] = operand; }
+ LOperand* result() { return results_[0]; }
+
+ int InputCount() { return I; }
+ LOperand* InputAt(int i) { return inputs_[i]; }
+
+ int TempCount() { return T; }
+ LOperand* TempAt(int i) { return temps_[i]; }
virtual void PrintDataTo(StringStream* stream);
virtual void PrintOutputOperandTo(StringStream* stream);
- private:
- OperandContainer<LOperand*, R> outputs_;
+ protected:
+ OperandContainer<LOperand*, R> results_;
OperandContainer<LOperand*, I> inputs_;
OperandContainer<LOperand*, T> temps_;
};
@@ -515,31 +512,22 @@
};
-template<int R>
-class LUnaryOperation: public LTemplateInstruction<R, 1, 0> {
+template<int I, int T = 0>
+class LControlInstruction: public LTemplateInstruction<0, I, T> {
public:
- explicit LUnaryOperation<R>(LOperand* input) {
- this->SetInputAt(0, input);
- }
-
- LOperand* input() const { return this->InputAt(0); }
-
- DECLARE_INSTRUCTION(UnaryOperation)
-};
-
-
-template<int R>
-class LBinaryOperation: public LTemplateInstruction<R, 2, 0> {
- public:
- LBinaryOperation(LOperand* left, LOperand* right) {
- this->SetInputAt(0, left);
- this->SetInputAt(1, right);
+ DECLARE_INSTRUCTION(ControlInstruction)
+ virtual bool IsControl() const { return true; }
+
+ int true_block_id() const { return true_block_id_; }
+ int false_block_id() const { return false_block_id_; }
+ void SetBranchTargets(int true_block_id, int false_block_id) {
+ true_block_id_ = true_block_id;
+ false_block_id_ = false_block_id;
}
- DECLARE_INSTRUCTION(BinaryOperation)
-
- LOperand* left() const { return this->InputAt(0); }
- LOperand* right() const { return this->InputAt(1); }
+ private:
+ int true_block_id_;
+ int false_block_id_;
};
@@ -549,43 +537,44 @@
LOperand* receiver,
LOperand* length,
LOperand* elements) {
- this->SetInputAt(0, function);
- this->SetInputAt(1, receiver);
- this->SetInputAt(2, length);
- this->SetInputAt(3, elements);
+ inputs_[0] = function;
+ inputs_[1] = receiver;
+ inputs_[2] = length;
+ inputs_[3] = elements;
}
DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
- LOperand* function() const { return InputAt(0); }
- LOperand* receiver() const { return InputAt(1); }
- LOperand* length() const { return InputAt(2); }
- LOperand* elements() const { return InputAt(3); }
+ LOperand* function() { return inputs_[0]; }
+ LOperand* receiver() { return inputs_[1]; }
+ LOperand* length() { return inputs_[2]; }
+ LOperand* elements() { return inputs_[3]; }
};
class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
public:
LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand*
index) {
- this->SetInputAt(0, arguments);
- this->SetInputAt(1, length);
- this->SetInputAt(2, index);
+ inputs_[0] = arguments;
+ inputs_[1] = length;
+ inputs_[2] = index;
}
DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
- LOperand* arguments() const { return this->InputAt(0); }
- LOperand* length() const { return this->InputAt(1); }
- LOperand* index() const { return this->InputAt(2); }
+ LOperand* arguments() { return inputs_[0]; }
+ LOperand* length() { return inputs_[1]; }
+ LOperand* index() { return inputs_[2]; }
virtual void PrintDataTo(StringStream* stream);
};
-class LArgumentsLength: public LUnaryOperation<1> {
+class LArgumentsLength: public LTemplateInstruction<1, 1> {
public:
- explicit LArgumentsLength(LOperand* elements)
- : LUnaryOperation<1>(elements) {}
+ explicit LArgumentsLength(LOperand* elements) {
+ inputs_[0] = elements;
+ }
DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
};
@@ -599,82 +588,86 @@
};
-class LModI: public LBinaryOperation<1> {
+class LModI: public LTemplateInstruction<1, 2, 1> {
public:
- LModI(LOperand* left, LOperand* right) : LBinaryOperation<1>(left,
right) { }
+ LModI(LOperand* left, LOperand* right, LOperand* temp) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ temps_[0] = temp;
+ }
DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
DECLARE_HYDROGEN_ACCESSOR(Mod)
};
-class LDivI: public LBinaryOperation<1> {
+class LDivI: public LTemplateInstruction<1, 2, 1> {
public:
- LDivI(LOperand* left, LOperand* right)
- : LBinaryOperation<1>(left, right) { }
+ LDivI(LOperand* left, LOperand* right, LOperand* temp) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ temps_[0] = temp;
+ }
DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
DECLARE_HYDROGEN_ACCESSOR(Div)
};
-class LMulI: public LBinaryOperation<1> {
+class LMulI: public LTemplateInstruction<1, 2, 1> {
public:
- LMulI(LOperand* left, LOperand* right, LOperand* temp)
- : LBinaryOperation<1>(left, right), temp_(temp) { }
+ LMulI(LOperand* left, LOperand* right, LOperand* temp) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ temps_[0] = temp;
+ }
DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
DECLARE_HYDROGEN_ACCESSOR(Mul)
-
- LOperand* temp() const { return temp_; }
-
- private:
- LOperand* temp_;
};
-class LCmpID: public LBinaryOperation<1> {
+class LCmpID: public LTemplateInstruction<1, 2> {
public:
- LCmpID(LOperand* left, LOperand* right)
- : LBinaryOperation<1>(left, right) { }
+ LCmpID(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
+
+ DECLARE_CONCRETE_INSTRUCTION(CmpID, "cmp-id")
+ DECLARE_HYDROGEN_ACCESSOR(Compare)
Token::Value op() const { return hydrogen()->token(); }
bool is_double() const {
return hydrogen()->GetInputRepresentation().IsDouble();
}
-
- DECLARE_CONCRETE_INSTRUCTION(CmpID, "cmp-id")
- DECLARE_HYDROGEN_ACCESSOR(Compare)
};
-class LCmpIDAndBranch: public LCmpID {
+class LCmpIDAndBranch: public LControlInstruction<2> {
public:
- LCmpIDAndBranch(LOperand* left,
- LOperand* right,
- int true_block_id,
- int false_block_id)
- : LCmpID(left, right),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ LCmpIDAndBranch(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
- virtual void PrintDataTo(StringStream* stream);
- virtual bool IsControl() const { return true; }
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- private:
- int true_block_id_;
- int false_block_id_;
+ DECLARE_HYDROGEN_ACCESSOR(Compare)
+
+ Token::Value op() const { return hydrogen()->token(); }
+ bool is_double() const {
+ return hydrogen()->GetInputRepresentation().IsDouble();
+ }
+
+ virtual void PrintDataTo(StringStream* stream);
};
-class LUnaryMathOperation: public LUnaryOperation<1> {
+class LUnaryMathOperation: public LTemplateInstruction<1, 1> {
public:
- explicit LUnaryMathOperation(LOperand* value)
- : LUnaryOperation<1>(value) { }
+ explicit LUnaryMathOperation(LOperand* value) {
+ inputs_[0] = value;
+ }
DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
@@ -684,40 +677,34 @@
};
-class LCmpJSObjectEq: public LBinaryOperation<1> {
+class LCmpJSObjectEq: public LTemplateInstruction<1, 2> {
public:
- LCmpJSObjectEq(LOperand* left, LOperand* right)
- : LBinaryOperation<1>(left, right) {}
+ LCmpJSObjectEq(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
DECLARE_CONCRETE_INSTRUCTION(CmpJSObjectEq, "cmp-jsobject-eq")
};
-class LCmpJSObjectEqAndBranch: public LCmpJSObjectEq {
+class LCmpJSObjectEqAndBranch: public LControlInstruction<2> {
public:
- LCmpJSObjectEqAndBranch(LOperand* left,
- LOperand* right,
- int true_block_id,
- int false_block_id)
- : LCmpJSObjectEq(left, right),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ LCmpJSObjectEqAndBranch(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
DECLARE_CONCRETE_INSTRUCTION(CmpJSObjectEqAndBranch,
"cmp-jsobject-eq-and-branch")
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- private:
- int true_block_id_;
- int false_block_id_;
};
-class LIsNull: public LUnaryOperation<1> {
+class LIsNull: public LTemplateInstruction<1, 1> {
public:
- explicit LIsNull(LOperand* value) : LUnaryOperation<1>(value) { }
+ explicit LIsNull(LOperand* value) {
+ inputs_[0] = value;
+ }
DECLARE_CONCRETE_INSTRUCTION(IsNull, "is-null")
DECLARE_HYDROGEN_ACCESSOR(IsNull)
@@ -726,227 +713,155 @@
};
-class LIsNullAndBranch: public LIsNull {
+class LIsNullAndBranch: public LControlInstruction<1, 1> {
public:
- LIsNullAndBranch(LOperand* value,
- LOperand* temp,
- int true_block_id,
- int false_block_id)
- : LIsNull(value),
- temp_(temp),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ LIsNullAndBranch(LOperand* value, LOperand* temp) {
+ inputs_[0] = value;
+ temps_[0] = temp;
+ }
DECLARE_CONCRETE_INSTRUCTION(IsNullAndBranch, "is-null-and-branch")
- virtual void PrintDataTo(StringStream* stream);
- virtual bool IsControl() const { return true; }
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- LOperand* temp() const { return temp_; }
-
- private:
- LOperand* temp_;
- int true_block_id_;
- int false_block_id_;
+ DECLARE_HYDROGEN_ACCESSOR(IsNull)
+
+ bool is_strict() const { return hydrogen()->is_strict(); }
+
+ virtual void PrintDataTo(StringStream* stream);
};
-class LIsObject: public LUnaryOperation<1> {
+class LIsObject: public LTemplateInstruction<1, 1, 1> {
public:
- LIsObject(LOperand* value, LOperand* temp)
- : LUnaryOperation<1>(value), temp_(temp) {}
+ LIsObject(LOperand* value, LOperand* temp) {
+ inputs_[0] = value;
+ temps_[0] = temp;
+ }
DECLARE_CONCRETE_INSTRUCTION(IsObject, "is-object")
-
- LOperand* temp() const { return temp_; }
-
- private:
- LOperand* temp_;
};
-class LIsObjectAndBranch: public LIsObject {
+class LIsObjectAndBranch: public LControlInstruction<1, 2> {
public:
- LIsObjectAndBranch(LOperand* value,
- LOperand* temp,
- LOperand* temp2,
- int true_block_id,
- int false_block_id)
- : LIsObject(value, temp),
- temp2_(temp2),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ LIsObjectAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
+ inputs_[0] = value;
+ temps_[0] = temp;
+ temps_[1] = temp2;
+ }
DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
- virtual void PrintDataTo(StringStream* stream);
- virtual bool IsControl() const { return true; }
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- LOperand* temp2() const { return temp2_; }
-
- private:
- LOperand* temp2_;
- int true_block_id_;
- int false_block_id_;
+
+ virtual void PrintDataTo(StringStream* stream);
};
-class LIsSmi: public LUnaryOperation<1> {
+class LIsSmi: public LTemplateInstruction<1, 1> {
public:
- explicit LIsSmi(LOperand* value) : LUnaryOperation<1>(value) {}
+ explicit LIsSmi(LOperand* value) {
+ inputs_[0] = value;
+ }
DECLARE_CONCRETE_INSTRUCTION(IsSmi, "is-smi")
DECLARE_HYDROGEN_ACCESSOR(IsSmi)
};
-class LIsSmiAndBranch: public LIsSmi {
+class LIsSmiAndBranch: public LControlInstruction<1> {
public:
- LIsSmiAndBranch(LOperand* value,
- int true_block_id,
- int false_block_id)
- : LIsSmi(value),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ explicit LIsSmiAndBranch(LOperand* value) {
+ inputs_[0] = value;
+ }
DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
- virtual void PrintDataTo(StringStream* stream);
- virtual bool IsControl() const { return true; }
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- private:
- int true_block_id_;
- int false_block_id_;
+
+ virtual void PrintDataTo(StringStream* stream);
};
-class LHasInstanceType: public LUnaryOperation<1> {
+class LHasInstanceType: public LTemplateInstruction<1, 1> {
public:
- explicit LHasInstanceType(LOperand* value)
- : LUnaryOperation<1>(value) { }
+ explicit LHasInstanceType(LOperand* value) {
+ inputs_[0] = value;
+ }
DECLARE_CONCRETE_INSTRUCTION(HasInstanceType, "has-instance-type")
DECLARE_HYDROGEN_ACCESSOR(HasInstanceType)
-
- InstanceType TestType(); // The type to test against when generating
code.
- Condition BranchCondition(); // The branch condition for 'true'.
};
-class LHasInstanceTypeAndBranch: public LHasInstanceType {
+class LHasInstanceTypeAndBranch: public LControlInstruction<1, 1> {
public:
- LHasInstanceTypeAndBranch(LOperand* value,
- LOperand* temporary,
- int true_block_id,
- int false_block_id)
- : LHasInstanceType(value),
- temp_(temporary),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
+ inputs_[0] = value;
+ temps_[0] = temp;
+ }
DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
"has-instance-type-and-branch")
- virtual void PrintDataTo(StringStream* stream);
- virtual bool IsControl() const { return true; }
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- LOperand* temp() { return temp_; }
-
- private:
- LOperand* temp_;
- int true_block_id_;
- int false_block_id_;
+ DECLARE_HYDROGEN_ACCESSOR(HasInstanceType)
+
+ virtual void PrintDataTo(StringStream* stream);
};
-class LHasCachedArrayIndex: public LUnaryOperation<1> {
+class LHasCachedArrayIndex: public LTemplateInstruction<1, 1> {
public:
- explicit LHasCachedArrayIndex(LOperand* value) :
LUnaryOperation<1>(value) {}
+ explicit LHasCachedArrayIndex(LOperand* value) {
+ inputs_[0] = value;
+ }
DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has-cached-array-index")
DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndex)
};
-class LHasCachedArrayIndexAndBranch: public LHasCachedArrayIndex {
+class LHasCachedArrayIndexAndBranch: public LControlInstruction<1> {
public:
- LHasCachedArrayIndexAndBranch(LOperand* value,
- int true_block_id,
- int false_block_id)
- : LHasCachedArrayIndex(value),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
+ inputs_[0] = value;
+ }
DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
"has-cached-array-index-and-branch")
virtual void PrintDataTo(StringStream* stream);
- virtual bool IsControl() const { return true; }
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- private:
- int true_block_id_;
- int false_block_id_;
};
-class LClassOfTest: public LUnaryOperation<1> {
+class LClassOfTest: public LTemplateInstruction<1, 1, 1> {
public:
- LClassOfTest(LOperand* value, LOperand* temp)
- : LUnaryOperation<1>(value), temporary_(temp) {}
+ LClassOfTest(LOperand* value, LOperand* temp) {
+ inputs_[0] = value;
+ temps_[0] = temp;
+ }
DECLARE_CONCRETE_INSTRUCTION(ClassOfTest, "class-of-test")
DECLARE_HYDROGEN_ACCESSOR(ClassOfTest)
virtual void PrintDataTo(StringStream* stream);
-
- LOperand* temporary() { return temporary_; }
-
- private:
- LOperand* temporary_;
};
-class LClassOfTestAndBranch: public LClassOfTest {
+class LClassOfTestAndBranch: public LControlInstruction<1, 2> {
public:
- LClassOfTestAndBranch(LOperand* value,
- LOperand* temporary,
- LOperand* temporary2,
- int true_block_id,
- int false_block_id)
- : LClassOfTest(value, temporary),
- temporary2_(temporary2),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
+ inputs_[0] = value;
+ temps_[0] = temp;
+ temps_[1] = temp2;
+ }
DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
"class-of-test-and-branch")
- virtual void PrintDataTo(StringStream* stream);
- virtual bool IsControl() const { return true; }
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
- LOperand* temporary2() { return temporary2_; }
-
- private:
- LOperand* temporary2_;
- int true_block_id_;
- int false_block_id_;
+ DECLARE_HYDROGEN_ACCESSOR(ClassOfTest)
+
+ virtual void PrintDataTo(StringStream* stream);
};
-class LCmpT: public LBinaryOperation<1> {
+class LCmpT: public LTemplateInstruction<1, 2> {
public:
- LCmpT(LOperand* left, LOperand* right) : LBinaryOperation<1>(left,
right) {}
+ LCmpT(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
DECLARE_HYDROGEN_ACCESSOR(Compare)
@@ -955,90 +870,78 @@
};
-class LCmpTAndBranch: public LCmpT {
+class LCmpTAndBranch: public LControlInstruction<2> {
public:
- LCmpTAndBranch(LOperand* left,
- LOperand* right,
- int true_block_id,
- int false_block_id)
- : LCmpT(left, right),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ LCmpTAndBranch(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
DECLARE_CONCRETE_INSTRUCTION(CmpTAndBranch, "cmp-t-and-branch")
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- private:
- int true_block_id_;
- int false_block_id_;
+ DECLARE_HYDROGEN_ACCESSOR(Compare)
+
+ Token::Value op() const { return hydrogen()->token(); }
};
-class LInstanceOf: public LBinaryOperation<1> {
+class LInstanceOf: public LTemplateInstruction<1, 2> {
public:
- LInstanceOf(LOperand* left, LOperand* right)
- : LBinaryOperation<1>(left, right) { }
+ LInstanceOf(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
};
-class LInstanceOfAndBranch: public LInstanceOf {
+class LInstanceOfAndBranch: public LControlInstruction<2> {
public:
- LInstanceOfAndBranch(LOperand* left,
- LOperand* right,
- int true_block_id,
- int false_block_id)
- : LInstanceOf(left, right),
- true_block_id_(true_block_id),
- false_block_id_(false_block_id) { }
+ LInstanceOfAndBranch(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
DECLARE_CONCRETE_INSTRUCTION(InstanceOfAndBranch, "instance-of-and-branch")
-
- int true_block_id() const { return true_block_id_; }
- int false_block_id() const { return false_block_id_; }
-
- private:
- int true_block_id_;
- int false_block_id_;
};
-class LInstanceOfKnownGlobal: public LUnaryOperation<1> {
+class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
public:
- LInstanceOfKnownGlobal(LOperand* left, LOperand* temp)
- : LUnaryOperation<1>(left), temp_(temp) { }
+ LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
+ inputs_[0] = value;
+ temps_[0] = temp;
+ }
DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
"instance-of-known-global")
DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
Handle<JSFunction> function() const { return hydrogen()->function(); }
- LOperand* temp() const { return temp_; }
-
- private:
- LOperand* temp_;
};
-class LBoundsCheck: public LBinaryOperation<0> {
+class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
public:
- LBoundsCheck(LOperand* index, LOperand* length)
- : LBinaryOperation<0>(index, length) { }
-
- LOperand* index() const { return left(); }
- LOperand* length() const { return right(); }
+ LBoundsCheck(LOperand* index, LOperand* length) {
+ inputs_[0] = index;
+ inputs_[1] = length;
+ }
+
+ LOperand* index() { return inputs_[0]; }
+ LOperand* length() { return inputs_[1]; }
DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
};
-class LBitI: public LBinaryOperation<1> {
+class LBitI: public LTemplateInstruction<1, 2> {
public:
LBitI(Token::Value op, LOperand* left, LOperand* right)
- : LBinaryOperation<1>(left, right), op_(op) { }
+ : op_(op) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
Token::Value op() const { return op_; }
@@ -1049,10 +952,13 @@
};
-class LShiftI: public LBinaryOperation<1> {
+class LShiftI: public LTemplateInstruction<1, 2> {
public:
LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
- : LBinaryOperation<1>(left, right), op_(op), can_deopt_(can_deopt) {
}
+ : op_(op), can_deopt_(can_deopt) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
Token::Value op() const { return op_; }
@@ -1066,22 +972,25 @@
};
-class LSubI: public LBinaryOperation<1> {
+class LSubI: public LTemplateInstruction<1, 2> {
public:
- LSubI(LOperand* left, LOperand* right)
- : LBinaryOperation<1>(left, right) { }
+ LSubI(LOperand* left, LOperand* right) {
+ inputs_[0] = left;
+ inputs_[1] = right;
+ }
DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
DECLARE_HYDROGEN_ACCESSOR(Sub)
};
-class LConstant: public LTemplateInstruction<1, 0, 0> {
+template <int temp_count>
+class LConstant: public LTemplateInstruction<1, 0, temp_count> {
DECLARE_INSTRUCTION(Constant)
};
***The diff for this file has been truncated for email.***
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev