| Index: src/hydrogen-instructions.h
|
| ===================================================================
|
| --- src/hydrogen-instructions.h (revision 8261)
|
| +++ src/hydrogen-instructions.h (working copy)
|
| @@ -35,6 +35,7 @@
|
| #include "data-flow.h"
|
| #include "small-pointer-list.h"
|
| #include "string-stream.h"
|
| +#include "utils.h"
|
| #include "zone.h"
|
|
|
| namespace v8 {
|
| @@ -757,80 +758,69 @@
|
| };
|
|
|
|
|
| -class HControlInstruction: public HInstruction {
|
| +template<int V>
|
| +class HTemplateInstruction : public HInstruction {
|
| public:
|
| - HControlInstruction(HBasicBlock* first, HBasicBlock* second)
|
| - : first_successor_(first), second_successor_(second) {
|
| - }
|
| + int OperandCount() { return V; }
|
| + HValue* OperandAt(int i) { return inputs_[i]; }
|
|
|
| - HBasicBlock* FirstSuccessor() const { return first_successor_; }
|
| - HBasicBlock* SecondSuccessor() const { return second_successor_; }
|
| + protected:
|
| + void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; }
|
|
|
| - virtual void PrintDataTo(StringStream* stream);
|
| -
|
| - DECLARE_ABSTRACT_INSTRUCTION(ControlInstruction)
|
| -
|
| private:
|
| - HBasicBlock* first_successor_;
|
| - HBasicBlock* second_successor_;
|
| + EmbeddedContainer<HValue*, V> inputs_;
|
| };
|
|
|
|
|
| -template<int NumElements>
|
| -class HOperandContainer {
|
| +class HControlInstruction: public HInstruction {
|
| public:
|
| - HOperandContainer() : elems_() { }
|
| + virtual HBasicBlock* SuccessorAt(int i) = 0;
|
| + virtual int SuccessorCount() = 0;
|
|
|
| - int length() { return NumElements; }
|
| - HValue*& operator[](int i) {
|
| - ASSERT(i < length());
|
| - return elems_[i];
|
| + virtual void PrintDataTo(StringStream* stream);
|
| +
|
| + HBasicBlock* FirstSuccessor() {
|
| + return SuccessorCount() > 0 ? SuccessorAt(0) : NULL;
|
| }
|
| + HBasicBlock* SecondSuccessor() {
|
| + return SuccessorCount() > 1 ? SuccessorAt(1) : NULL;
|
| + }
|
|
|
| - private:
|
| - HValue* elems_[NumElements];
|
| + DECLARE_ABSTRACT_INSTRUCTION(ControlInstruction)
|
| };
|
|
|
|
|
| -template<>
|
| -class HOperandContainer<0> {
|
| +class HSuccessorIterator BASE_EMBEDDED {
|
| public:
|
| - int length() { return 0; }
|
| - HValue*& operator[](int i) {
|
| - UNREACHABLE();
|
| - static HValue* t = 0;
|
| - return t;
|
| - }
|
| -};
|
| + explicit HSuccessorIterator(HControlInstruction* instr)
|
| + : instr_(instr), current_(0) { }
|
|
|
| + bool Done() { return current_ >= instr_->SuccessorCount(); }
|
| + HBasicBlock* Current() { return instr_->SuccessorAt(current_); }
|
| + void Advance() { current_++; }
|
|
|
| -template<int V>
|
| -class HTemplateInstruction : public HInstruction {
|
| - public:
|
| - int OperandCount() { return V; }
|
| - HValue* OperandAt(int i) { return inputs_[i]; }
|
| -
|
| - protected:
|
| - void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; }
|
| -
|
| private:
|
| - HOperandContainer<V> inputs_;
|
| + HControlInstruction* instr_;
|
| + int current_;
|
| };
|
|
|
|
|
| -template<int V>
|
| -class HTemplateControlInstruction : public HControlInstruction {
|
| +template<int S, int V>
|
| +class HTemplateControlInstruction: public HControlInstruction {
|
| public:
|
| - HTemplateControlInstruction<V>(HBasicBlock* first, HBasicBlock* second)
|
| - : HControlInstruction(first, second) { }
|
| + int SuccessorCount() { return S; }
|
| + HBasicBlock* SuccessorAt(int i) { return successors_[i]; }
|
| +
|
| int OperandCount() { return V; }
|
| HValue* OperandAt(int i) { return inputs_[i]; }
|
|
|
| protected:
|
| + void SetSuccessorAt(int i, HBasicBlock* block) { successors_[i] = block; }
|
| void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; }
|
|
|
| private:
|
| - HOperandContainer<V> inputs_;
|
| + EmbeddedContainer<HBasicBlock*, S> successors_;
|
| + EmbeddedContainer<HValue*, V> inputs_;
|
| };
|
|
|
|
|
| @@ -859,9 +849,7 @@
|
|
|
| class HDeoptimize: public HControlInstruction {
|
| public:
|
| - explicit HDeoptimize(int environment_length)
|
| - : HControlInstruction(NULL, NULL),
|
| - values_(environment_length) { }
|
| + explicit HDeoptimize(int environment_length) : values_(environment_length) { }
|
|
|
| virtual Representation RequiredInputRepresentation(int index) const {
|
| return Representation::None();
|
| @@ -871,6 +859,12 @@
|
| virtual HValue* OperandAt(int index) { return values_[index]; }
|
| virtual void PrintDataTo(StringStream* stream);
|
|
|
| + virtual int SuccessorCount() { return 0; }
|
| + virtual HBasicBlock* SuccessorAt(int i) {
|
| + UNREACHABLE();
|
| + return NULL;
|
| + }
|
| +
|
| void AddEnvironmentValue(HValue* value) {
|
| values_.Add(NULL);
|
| SetOperandAt(values_.length() - 1, value);
|
| @@ -893,11 +887,12 @@
|
| };
|
|
|
|
|
| -class HGoto: public HTemplateControlInstruction<0> {
|
| +class HGoto: public HTemplateControlInstruction<1, 0> {
|
| public:
|
| explicit HGoto(HBasicBlock* target)
|
| - : HTemplateControlInstruction<0>(target, NULL),
|
| - include_stack_check_(false) { }
|
| + : include_stack_check_(false) {
|
| + SetSuccessorAt(0, target);
|
| + }
|
|
|
| void set_include_stack_check(bool include_stack_check) {
|
| include_stack_check_ = include_stack_check;
|
| @@ -915,13 +910,14 @@
|
| };
|
|
|
|
|
| -class HUnaryControlInstruction: public HTemplateControlInstruction<1> {
|
| +class HUnaryControlInstruction: public HTemplateControlInstruction<2, 1> {
|
| public:
|
| - explicit HUnaryControlInstruction(HValue* value,
|
| - HBasicBlock* true_target,
|
| - HBasicBlock* false_target)
|
| - : HTemplateControlInstruction<1>(true_target, false_target) {
|
| + HUnaryControlInstruction(HValue* value,
|
| + HBasicBlock* true_target,
|
| + HBasicBlock* false_target) {
|
| SetOperandAt(0, value);
|
| + SetSuccessorAt(0, true_target);
|
| + SetSuccessorAt(1, false_target);
|
| }
|
|
|
| virtual void PrintDataTo(StringStream* stream);
|
| @@ -973,24 +969,26 @@
|
| };
|
|
|
|
|
| -class HReturn: public HUnaryControlInstruction {
|
| +class HReturn: public HTemplateControlInstruction<0, 1> {
|
| public:
|
| - explicit HReturn(HValue* value)
|
| - : HUnaryControlInstruction(value, NULL, NULL) {
|
| + explicit HReturn(HValue* value) {
|
| + SetOperandAt(0, value);
|
| }
|
|
|
| virtual Representation RequiredInputRepresentation(int index) const {
|
| return Representation::Tagged();
|
| }
|
|
|
| + virtual void PrintDataTo(StringStream* stream);
|
| +
|
| + HValue* value() { return OperandAt(0); }
|
| +
|
| DECLARE_CONCRETE_INSTRUCTION(Return)
|
| };
|
|
|
|
|
| -class HAbnormalExit: public HTemplateControlInstruction<0> {
|
| +class HAbnormalExit: public HTemplateControlInstruction<0, 0> {
|
| public:
|
| - HAbnormalExit() : HTemplateControlInstruction<0>(NULL, NULL) { }
|
| -
|
| virtual Representation RequiredInputRepresentation(int index) const {
|
| return Representation::None();
|
| }
|
|
|