Revision: 6275
Author: [email protected]
Date: Tue Jan 11 07:47:34 2011
Log: Introduce two more template parameter for Lithium instructions for
input and temp operands.
Each LInstruction is now a subclass of LTemplateInstruction<R, I, T>
where R is number of outputs, I number of inputs and T number of temps.
This change only actually uses the parameter I for input operands.
Since the parameter T for temps is 0, it incurs no extra cost.
A separate change will introduce using the temps parameter.
Review URL: http://codereview.chromium.org/6215002
http://code.google.com/p/v8/source/detail?r=6275
Modified:
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.h
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Mon Jan 10 06:16:47 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Tue Jan 11 07:47:34 2011
@@ -5788,7 +5788,6 @@
#ifdef DEBUG
if (graph_ != NULL) graph_->Verify();
- if (chunk_ != NULL) chunk_->Verify();
if (allocator_ != NULL) allocator_->Verify();
#endif
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue Jan 11 06:38:13
2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue Jan 11 07:47:34
2011
@@ -67,9 +67,9 @@
void LInstruction::PrintTo(StringStream* stream) {
stream->Add("%s ", this->Mnemonic());
if (HasResult()) {
- LTemplateInstruction<1>::cast(this)->result()->PrintTo(stream);
- stream->Add(" ");
- }
+ PrintOutputOperandTo(stream);
+ }
+
PrintDataTo(stream);
if (HasEnvironment()) {
@@ -82,6 +82,24 @@
pointer_map()->PrintTo(stream);
}
}
+
+
+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);
+ }
+}
+
+
+template<int R, int I, int T>
+void LTemplateInstruction<R, I, T>::PrintOutputOperandTo(StringStream*
stream) {
+ if (this->HasResult()) {
+ this->result()->PrintTo(stream);
+ stream->Add(" ");
+ }
+}
void LLabel::PrintDataTo(StringStream* stream) {
@@ -141,15 +159,6 @@
return NULL;
}
}
-
-
-
-void LBinaryOperation::PrintDataTo(StringStream* stream) {
- stream->Add("= ");
- left()->PrintTo(stream);
- stream->Add(" ");
- right()->PrintTo(stream);
-}
void LGoto::PrintDataTo(StringStream* stream) {
@@ -267,7 +276,8 @@
void LCallNew::PrintDataTo(StringStream* stream) {
- LUnaryOperation<1>::PrintDataTo(stream);
+ stream->Add("= ");
+ input()->PrintTo(stream);
stream->Add(" #%d / ", arity());
}
@@ -277,13 +287,6 @@
input()->PrintTo(stream);
stream->Add(", \"%o\")", *hydrogen()->class_name());
}
-
-
-template <int R>
-void LUnaryOperation<R>::PrintDataTo(StringStream* stream) {
- stream->Add("= ");
- input()->PrintTo(stream);
-}
void LAccessArgumentsAt::PrintDataTo(StringStream* stream) {
@@ -295,11 +298,6 @@
stream->Add(" index ");
index()->PrintTo(stream);
}
-
-
-void LChunk::Verify() const {
- // TODO(twuerthinger): Implement verification for chunk.
-}
int LChunk::GetNextSpillIndex(bool is_double) {
@@ -573,35 +571,54 @@
}
-LInstruction* LChunkBuilder::Define(LTemplateInstruction<1>* instr) {
+template<int I, int T>
+LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr,
+ LUnallocated* result) {
+ allocator_->RecordDefinition(current_instruction_, result);
+ instr->set_result(result);
+ return instr;
+}
+
+
+template<int I, int T>
+LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr) {
return Define(instr, new LUnallocated(LUnallocated::NONE));
}
-LInstruction* LChunkBuilder::DefineAsRegister(LTemplateInstruction<1>*
instr) {
+template<int I, int T>
+LInstruction* LChunkBuilder::DefineAsRegister(
+ LTemplateInstruction<1, I, T>* instr) {
return Define(instr, new LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
}
-LInstruction* LChunkBuilder::DefineAsSpilled(LTemplateInstruction<1>*
instr,
- int index) {
+template<int I, int T>
+LInstruction* LChunkBuilder::DefineAsSpilled(
+ LTemplateInstruction<1, I, T>* instr,
+ int index) {
return Define(instr, new LUnallocated(LUnallocated::FIXED_SLOT, index));
}
-LInstruction* LChunkBuilder::DefineSameAsFirst(LTemplateInstruction<1>*
instr) {
+template<int I, int T>
+LInstruction* LChunkBuilder::DefineSameAsFirst(
+ LTemplateInstruction<1, I, T>* instr) {
return Define(instr, new
LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT));
}
-LInstruction* LChunkBuilder::DefineFixed(LTemplateInstruction<1>* instr,
+template<int I, int T>
+LInstruction* LChunkBuilder::DefineFixed(LTemplateInstruction<1, I, T>*
instr,
Register reg) {
return Define(instr, ToUnallocated(reg));
}
-LInstruction* LChunkBuilder::DefineFixedDouble(LTemplateInstruction<1>*
instr,
- XMMRegister reg) {
+template<int I, int T>
+LInstruction* LChunkBuilder::DefineFixedDouble(
+ LTemplateInstruction<1, I, T>* instr,
+ XMMRegister reg) {
return Define(instr, ToUnallocated(reg));
}
@@ -667,14 +684,6 @@
instr->set_pointer_map(new LPointerMap(position_));
return instr;
}
-
-
-LInstruction* LChunkBuilder::Define(LTemplateInstruction<1>* instr,
- LUnallocated* result) {
- allocator_->RecordDefinition(current_instruction_, result);
- instr->set_result(result);
- return instr;
-}
LUnallocated* LChunkBuilder::TempRegister() {
@@ -1279,7 +1288,9 @@
LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) {
ASSERT(instr->value()->representation().IsInteger32());
ASSERT(instr->representation().IsInteger32());
- return DefineSameAsFirst(new
LBitNotI(UseRegisterAtStart(instr->value())));
+ LOperand* input = UseRegisterAtStart(instr->value());
+ LBitNotI* result = new LBitNotI(input);
+ return DefineSameAsFirst(result);
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h Tue Jan 11 06:38:13 2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h Tue Jan 11 07:47:34 2011
@@ -295,7 +295,8 @@
virtual void CompileToNative(LCodeGen* generator) = 0;
virtual const char* Mnemonic() const = 0;
virtual void PrintTo(StringStream* stream);
- virtual void PrintDataTo(StringStream* stream) { }
+ virtual void PrintDataTo(StringStream* stream) = 0;
+ virtual void PrintOutputOperandTo(StringStream* stream) = 0;
// Declare virtual type testers.
#define DECLARE_DO(type) virtual bool Is##type() const { return false; }
@@ -334,32 +335,61 @@
};
-template <int Result>
-class LTemplateInstruction: public LInstruction { };
+template<typename T, int N>
+class OperandContainer {
+ public:
+ 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; }
+ private:
+ T elems_[N];
+};
-template<>
-class LTemplateInstruction<0>: public LInstruction {
- virtual bool HasResult() const { return false; }
+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();
+ }
};
-template<>
-class LTemplateInstruction<1>: public LInstruction {
+template<int R, int I, int T>
+class LTemplateInstruction: public LInstruction {
public:
- static LTemplateInstruction<1>* cast(LInstruction* instr) {
- ASSERT(instr->HasResult());
- return reinterpret_cast<LTemplateInstruction<1>*>(instr);
- }
- void set_result(LOperand* operand) { result_.set(operand); }
- LOperand* result() const { return result_.get(); }
- virtual bool HasResult() const { return result_.is_set(); }
+ // 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); }
+
+ virtual void PrintDataTo(StringStream* stream);
+ virtual void PrintOutputOperandTo(StringStream* stream);
+
private:
- SetOncePointer<LOperand> result_;
+ OperandContainer<LOperand*, R> outputs_;
+ OperandContainer<LOperand*, I> inputs_;
+ OperandContainer<LOperand*, T> temps_;
};
-class LGap: public LTemplateInstruction<0> {
+class LGap: public LTemplateInstruction<0, 0, 0> {
public:
explicit LGap(HBasicBlock* block)
: block_(block) {
@@ -400,7 +430,7 @@
};
-class LGoto: public LTemplateInstruction<0> {
+class LGoto: public LTemplateInstruction<0, 0, 0> {
public:
LGoto(int block_id, bool include_stack_check = false)
: block_id_(block_id), include_stack_check_(include_stack_check) { }
@@ -418,7 +448,7 @@
};
-class LLazyBailout: public LTemplateInstruction<0> {
+class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
public:
LLazyBailout() : gap_instructions_size_(0) { }
@@ -434,7 +464,7 @@
};
-class LDeoptimize: public LTemplateInstruction<0> {
+class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
};
@@ -462,13 +492,13 @@
};
-class LParameter: public LTemplateInstruction<1> {
+class LParameter: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
};
-class LCallStub: public LTemplateInstruction<1> {
+class LCallStub: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
DECLARE_HYDROGEN_ACCESSOR(CallStub)
@@ -479,85 +509,76 @@
};
-class LUnknownOSRValue: public LTemplateInstruction<1> {
+class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
};
template<int R>
-class LUnaryOperation: public LTemplateInstruction<R> {
+class LUnaryOperation: public LTemplateInstruction<R, 1, 0> {
public:
- explicit LUnaryOperation(LOperand* input) : input_(input) { }
-
- DECLARE_INSTRUCTION(UnaryOperation)
-
- LOperand* input() const { return input_; }
-
- virtual void PrintDataTo(StringStream* stream);
-
- private:
- LOperand* input_;
+ explicit LUnaryOperation<R>(LOperand* input) {
+ this->SetInputAt(0, input);
+ }
+
+ LOperand* input() const { return this->InputAt(0); }
+
+ DECLARE_INSTRUCTION(UnaryOperation)
};
-class LBinaryOperation: public LTemplateInstruction<1> {
+template<int R>
+class LBinaryOperation: public LTemplateInstruction<R, 2, 0> {
public:
- LBinaryOperation(LOperand* left, LOperand* right)
- : left_(left), right_(right) { }
+ LBinaryOperation(LOperand* left, LOperand* right) {
+ this->SetInputAt(0, left);
+ this->SetInputAt(1, right);
+ }
DECLARE_INSTRUCTION(BinaryOperation)
- LOperand* left() const { return left_; }
- LOperand* right() const { return right_; }
- virtual void PrintDataTo(StringStream* stream);
-
- private:
- LOperand* left_;
- LOperand* right_;
+ LOperand* left() const { return this->InputAt(0); }
+ LOperand* right() const { return this->InputAt(1); }
};
-class LApplyArguments: public LBinaryOperation {
+class LApplyArguments: public LTemplateInstruction<1, 4, 0> {
public:
LApplyArguments(LOperand* function,
LOperand* receiver,
LOperand* length,
- LOperand* elements)
- : LBinaryOperation(function, receiver),
- length_(length),
- elements_(elements) { }
+ LOperand* elements) {
+ this->SetInputAt(0, function);
+ this->SetInputAt(1, receiver);
+ this->SetInputAt(2, length);
+ this->SetInputAt(3, elements);
+ }
DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
- LOperand* function() const { return left(); }
- LOperand* receiver() const { return right(); }
- LOperand* length() const { return length_; }
- LOperand* elements() const { return elements_; }
-
- private:
- LOperand* length_;
- LOperand* elements_;
+ LOperand* function() const { return InputAt(0); }
+ LOperand* receiver() const { return InputAt(1); }
+ LOperand* length() const { return InputAt(2); }
+ LOperand* elements() const { return InputAt(3); }
};
-class LAccessArgumentsAt: public LTemplateInstruction<1> {
+class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
public:
- LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand*
index)
- : arguments_(arguments), length_(length), index_(index) { }
+ LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand*
index) {
+ this->SetInputAt(0, arguments);
+ this->SetInputAt(1, length);
+ this->SetInputAt(2, index);
+ }
DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
- LOperand* arguments() const { return arguments_; }
- LOperand* length() const { return length_; }
- LOperand* index() const { return index_; }
+ LOperand* arguments() const { return this->InputAt(0); }
+ LOperand* length() const { return this->InputAt(1); }
+ LOperand* index() const { return this->InputAt(2); }
virtual void PrintDataTo(StringStream* stream);
-
- private:
- LOperand* arguments_;
- LOperand* length_;
- LOperand* index_;
};
@@ -570,7 +591,7 @@
};
-class LArgumentsElements: public LTemplateInstruction<1> {
+class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
public:
LArgumentsElements() { }
@@ -578,29 +599,29 @@
};
-class LModI: public LBinaryOperation {
+class LModI: public LBinaryOperation<1> {
public:
- LModI(LOperand* left, LOperand* right) : LBinaryOperation(left, right) {
}
+ LModI(LOperand* left, LOperand* right) : LBinaryOperation<1>(left,
right) { }
DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
DECLARE_HYDROGEN_ACCESSOR(Mod)
};
-class LDivI: public LBinaryOperation {
+class LDivI: public LBinaryOperation<1> {
public:
LDivI(LOperand* left, LOperand* right)
- : LBinaryOperation(left, right) { }
+ : LBinaryOperation<1>(left, right) { }
DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
DECLARE_HYDROGEN_ACCESSOR(Div)
};
-class LMulI: public LBinaryOperation {
+class LMulI: public LBinaryOperation<1> {
public:
LMulI(LOperand* left, LOperand* right, LOperand* temp)
- : LBinaryOperation(left, right), temp_(temp) { }
+ : LBinaryOperation<1>(left, right), temp_(temp) { }
DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
DECLARE_HYDROGEN_ACCESSOR(Mul)
@@ -612,10 +633,10 @@
};
-class LCmpID: public LBinaryOperation {
+class LCmpID: public LBinaryOperation<1> {
public:
LCmpID(Token::Value op, LOperand* left, LOperand* right, bool is_double)
- : LBinaryOperation(left, right), op_(op), is_double_(is_double) { }
+ : LBinaryOperation<1>(left, right), op_(op), is_double_(is_double) {
}
Token::Value op() const { return op_; }
bool is_double() const { return is_double_; }
@@ -666,10 +687,10 @@
};
-class LCmpJSObjectEq: public LBinaryOperation {
+class LCmpJSObjectEq: public LBinaryOperation<1> {
public:
LCmpJSObjectEq(LOperand* left, LOperand* right)
- : LBinaryOperation(left, right) {}
+ : LBinaryOperation<1>(left, right) {}
DECLARE_CONCRETE_INSTRUCTION(CmpJSObjectEq, "cmp-jsobject-eq")
};
@@ -930,9 +951,9 @@
};
-class LCmpT: public LBinaryOperation {
+class LCmpT: public LBinaryOperation<1> {
public:
- LCmpT(LOperand* left, LOperand* right) : LBinaryOperation(left, right) {}
+ LCmpT(LOperand* left, LOperand* right) : LBinaryOperation<1>(left,
right) {}
DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
DECLARE_HYDROGEN_ACCESSOR(Compare)
@@ -962,10 +983,10 @@
};
-class LInstanceOf: public LBinaryOperation {
+class LInstanceOf: public LBinaryOperation<1> {
public:
LInstanceOf(LOperand* left, LOperand* right)
- : LBinaryOperation(left, right) { }
+ : LBinaryOperation<1>(left, right) { }
DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
};
@@ -1009,10 +1030,10 @@
};
-class LBoundsCheck: public LBinaryOperation {
+class LBoundsCheck: public LBinaryOperation<0> {
public:
LBoundsCheck(LOperand* index, LOperand* length)
- : LBinaryOperation(index, length) { }
+ : LBinaryOperation<0>(index, length) { }
LOperand* index() const { return left(); }
LOperand* length() const { return right(); }
@@ -1021,10 +1042,10 @@
};
-class LBitI: public LBinaryOperation {
+class LBitI: public LBinaryOperation<1> {
public:
LBitI(Token::Value op, LOperand* left, LOperand* right)
- : LBinaryOperation(left, right), op_(op) { }
+ : LBinaryOperation<1>(left, right), op_(op) { }
Token::Value op() const { return op_; }
@@ -1035,10 +1056,10 @@
};
-class LShiftI: public LBinaryOperation {
+class LShiftI: public LBinaryOperation<1> {
public:
LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
- : LBinaryOperation(left, right), op_(op), can_deopt_(can_deopt) { }
+ : LBinaryOperation<1>(left, right), op_(op), can_deopt_(can_deopt) {
}
Token::Value op() const { return op_; }
@@ -1052,17 +1073,17 @@
};
-class LSubI: public LBinaryOperation {
+class LSubI: public LBinaryOperation<1> {
public:
LSubI(LOperand* left, LOperand* right)
- : LBinaryOperation(left, right) { }
+ : LBinaryOperation<1>(left, right) { }
DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
DECLARE_HYDROGEN_ACCESSOR(Sub)
};
-class LConstant: public LTemplateInstruction<1> {
+class LConstant: public LTemplateInstruction<1, 0, 0> {
DECLARE_INSTRUCTION(Constant)
};
@@ -1187,36 +1208,36 @@
class LBitNotI: public LUnaryOperation<1> {
public:
- explicit LBitNotI(LOperand* use) : LUnaryOperation<1>(use) { }
+ explicit LBitNotI(LOperand* input) : LUnaryOperation<1>(input) { }
DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
};
-class LAddI: public LBinaryOperation {
+class LAddI: public LBinaryOperation<1> {
public:
LAddI(LOperand* left, LOperand* right)
- : LBinaryOperation(left, right) { }
+ : LBinaryOperation<1>(left, right) { }
DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
DECLARE_HYDROGEN_ACCESSOR(Add)
};
-class LPower: public LBinaryOperation {
+class LPower: public LBinaryOperation<1> {
public:
LPower(LOperand* left, LOperand* right)
- : LBinaryOperation(left, right) { }
+ : LBinaryOperation<1>(left, right) { }
DECLARE_CONCRETE_INSTRUCTION(Power, "power")
DECLARE_HYDROGEN_ACCESSOR(Power)
};
-class LArithmeticD: public LBinaryOperation {
+class LArithmeticD: public LBinaryOperation<1> {
public:
LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
- : LBinaryOperation(left, right), op_(op) { }
+ : LBinaryOperation<1>(left, right), op_(op) { }
Token::Value op() const { return op_; }
@@ -1228,10 +1249,10 @@
};
-class LArithmeticT: public LBinaryOperation {
+class LArithmeticT: public LBinaryOperation<1> {
public:
LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
- : LBinaryOperation(left, right), op_(op) { }
+ : LBinaryOperation<1>(left, right), op_(op) { }
virtual void CompileToNative(LCodeGen* generator);
virtual const char* Mnemonic() const;
@@ -1296,10 +1317,10 @@
};
-class LLoadKeyedFastElement: public LBinaryOperation {
+class LLoadKeyedFastElement: public LBinaryOperation<1> {
public:
LLoadKeyedFastElement(LOperand* elements, LOperand* key)
- : LBinaryOperation(elements, key) { }
+ : LBinaryOperation<1>(elements, key) { }
DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
@@ -1309,10 +1330,10 @@
};
-class LLoadKeyedGeneric: public LBinaryOperation {
+class LLoadKeyedGeneric: public LBinaryOperation<1> {
public:
LLoadKeyedGeneric(LOperand* obj, LOperand* key)
- : LBinaryOperation(obj, key) { }
+ : LBinaryOperation<1>(obj, key) { }
DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
@@ -1321,7 +1342,7 @@
};
-class LLoadGlobal: public LTemplateInstruction<1> {
+class LLoadGlobal: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(LoadGlobal, "load-global")
DECLARE_HYDROGEN_ACCESSOR(LoadGlobal)
@@ -1345,31 +1366,31 @@
};
-class LGlobalObject: public LTemplateInstruction<1> {
+class LGlobalObject: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
};
-class LGlobalReceiver: public LTemplateInstruction<1> {
+class LGlobalReceiver: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
};
-class LCallConstantFunction: public LTemplateInstruction<1> {
+class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
virtual void PrintDataTo(StringStream* stream);
- Handle<JSFunction> function() const { return hydrogen()->function(); }
+ Handle<JSFunction> function() { return hydrogen()->function(); }
int arity() const { return hydrogen()->argument_count() - 1; }
};
-class LCallKeyed: public LTemplateInstruction<1> {
+class LCallKeyed: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
@@ -1380,7 +1401,7 @@
};
-class LCallNamed: public LTemplateInstruction<1> {
+class LCallNamed: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
DECLARE_HYDROGEN_ACCESSOR(CallNamed)
@@ -1392,7 +1413,7 @@
};
-class LCallFunction: public LTemplateInstruction<1> {
+class LCallFunction: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
DECLARE_HYDROGEN_ACCESSOR(CallFunction)
@@ -1401,7 +1422,7 @@
};
-class LCallGlobal: public LTemplateInstruction<1> {
+class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
@@ -1413,7 +1434,7 @@
};
-class LCallKnownGlobal: public LTemplateInstruction<1> {
+class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
@@ -1438,7 +1459,7 @@
};
-class LCallRuntime: public LTemplateInstruction<1> {
+class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
@@ -1542,22 +1563,21 @@
};
-class LStoreNamed: public LTemplateInstruction<0> {
+class LStoreNamed: public LTemplateInstruction<0, 2, 0> {
public:
- LStoreNamed(LOperand* obj, LOperand* val) : object_(obj), value_(val) { }
+ LStoreNamed(LOperand* obj, LOperand* val) {
+ this->SetInputAt(0, obj);
+ this->SetInputAt(1, val);
+ }
DECLARE_INSTRUCTION(StoreNamed)
DECLARE_HYDROGEN_ACCESSOR(StoreNamed)
virtual void PrintDataTo(StringStream* stream);
- LOperand* object() const { return object_; }
+ LOperand* object() const { return this->InputAt(0); }
+ LOperand* value() const { return this->InputAt(1); }
Handle<Object> name() const { return hydrogen()->name(); }
- LOperand* value() const { return value_; }
-
- private:
- LOperand* object_;
- LOperand* value_;
};
@@ -1571,9 +1591,10 @@
bool is_in_object() { return hydrogen()->is_in_object(); }
int offset() { return hydrogen()->offset(); }
- LOperand* temp() { return temp_; }
bool needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
Handle<Map> transition() const { return hydrogen()->transition(); }
+
+ LOperand* temp() { return temp_; }
private:
LOperand* temp_;
@@ -1590,23 +1611,21 @@
};
-class LStoreKeyed: public LTemplateInstruction<0> {
+class LStoreKeyed: public LTemplateInstruction<0, 3, 0> {
public:
- LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val)
- : object_(obj), key_(key), value_(val) { }
+ LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
+ this->SetInputAt(0, obj);
+ this->SetInputAt(1, key);
+ this->SetInputAt(2, val);
+ }
DECLARE_INSTRUCTION(StoreKeyed)
virtual void PrintDataTo(StringStream* stream);
- LOperand* object() const { return object_; }
- LOperand* key() const { return key_; }
- LOperand* value() const { return value_; }
-
- private:
- LOperand* object_;
- LOperand* key_;
- LOperand* value_;
+ LOperand* object() const { return this->InputAt(0); }
+ LOperand* key() const { return this->InputAt(1); }
+ LOperand* value() const { return this->InputAt(2); }
};
@@ -1663,7 +1682,7 @@
};
-class LCheckPrototypeMaps: public LTemplateInstruction<0> {
+class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 0> {
public:
explicit LCheckPrototypeMaps(LOperand* temp) : temp_(temp) { }
@@ -1672,6 +1691,7 @@
Handle<JSObject> holder() const { return hydrogen()->holder(); }
Handle<Map> receiver_map() const { return hydrogen()->receiver_map(); }
+
LOperand* temp() const { return temp_; }
private:
@@ -1696,7 +1716,7 @@
};
-class LMaterializedLiteral: public LTemplateInstruction<1> {
+class LMaterializedLiteral: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_INSTRUCTION(MaterializedLiteral)
};
@@ -1723,7 +1743,7 @@
};
-class LFunctionLiteral: public LTemplateInstruction<1> {
+class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
@@ -1775,9 +1795,10 @@
};
-class LDeleteProperty: public LBinaryOperation {
+class LDeleteProperty: public LBinaryOperation<1> {
public:
- LDeleteProperty(LOperand* obj, LOperand* key) : LBinaryOperation(obj,
key) {}
+ LDeleteProperty(LOperand* obj, LOperand* key)
+ : LBinaryOperation<1>(obj, key) { }
DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
@@ -1786,7 +1807,7 @@
};
-class LOsrEntry: public LTemplateInstruction<0> {
+class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
public:
LOsrEntry();
@@ -1809,7 +1830,7 @@
};
-class LStackCheck: public LTemplateInstruction<0> {
+class LStackCheck: public LTemplateInstruction<0, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
};
@@ -1971,8 +1992,6 @@
void AddInlinedClosure(Handle<JSFunction> closure) {
inlined_closures_.Add(closure);
}
-
- void Verify() const;
private:
int spill_slot_count_;
@@ -2056,14 +2075,24 @@
// Methods for setting up define-use relationships.
// Return the same instruction that they are passed.
- LInstruction* Define(LTemplateInstruction<1>* instr, LUnallocated*
result);
- LInstruction* Define(LTemplateInstruction<1>* instr);
- LInstruction* DefineAsRegister(LTemplateInstruction<1>* instr);
- LInstruction* DefineAsSpilled(LTemplateInstruction<1>* instr, int index);
- LInstruction* DefineSameAsFirst(LTemplateInstruction<1>* instr);
- LInstruction* DefineFixed(LTemplateInstruction<1>* instr, Register reg);
- LInstruction* DefineFixedDouble(LTemplateInstruction<1>* instr,
- XMMRegister reg);
+ template<int I, int T>
+ LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
+ LUnallocated* result);
+ template<int I, int T>
+ LInstruction* Define(LTemplateInstruction<1, I, T>* instr);
+ template<int I, int T>
+ LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
+ template<int I, int T>
+ LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
+ int index);
+ template<int I, int T>
+ LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>*
instr);
+ template<int I, int T>
+ LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
+ Register reg);
+ template<int I, int T>
+ LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
+ XMMRegister reg);
LInstruction* AssignEnvironment(LInstruction* instr);
LInstruction* AssignPointerMap(LInstruction* instr);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev