Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Unified Diff: src/hydrogen-instructions.h

Issue 6697023: Merge 6800:7180 from the bleeding edge branch to the experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.h
===================================================================
--- src/hydrogen-instructions.h (revision 7180)
+++ src/hydrogen-instructions.h (working copy)
@@ -51,14 +51,9 @@
V(BinaryCall) \
V(BinaryOperation) \
V(BitwiseBinaryOperation) \
- V(Call) \
V(ControlInstruction) \
V(Instruction) \
- V(LoadKeyed) \
- V(MaterializedLiteral) \
V(Phi) \
- V(StoreKeyed) \
- V(StoreNamed) \
V(UnaryCall) \
V(UnaryControlInstruction) \
V(UnaryOperation) \
@@ -96,6 +91,7 @@
V(CheckNonSmi) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
+ V(ClassOfTest) \
V(Compare) \
V(CompareJSObjectEq) \
V(CompareMap) \
@@ -105,24 +101,26 @@
V(Deoptimize) \
V(Div) \
V(EnterInlined) \
+ V(ExternalArrayLength) \
V(FixedArrayLength) \
V(FunctionLiteral) \
+ V(GetCachedArrayIndex) \
V(GlobalObject) \
V(GlobalReceiver) \
V(Goto) \
+ V(HasInstanceType) \
+ V(HasCachedArrayIndex) \
V(InstanceOf) \
V(InstanceOfKnownGlobal) \
V(IsNull) \
V(IsObject) \
V(IsSmi) \
V(IsConstructCall) \
- V(HasInstanceType) \
- V(HasCachedArrayIndex) \
V(JSArrayLength) \
- V(ClassOfTest) \
V(LeaveInlined) \
V(LoadContextSlot) \
V(LoadElements) \
+ V(LoadExternalArrayPointer) \
V(LoadFunctionPrototype) \
V(LoadGlobal) \
V(LoadKeyedFastElement) \
@@ -130,14 +128,12 @@
V(LoadNamedField) \
V(LoadNamedGeneric) \
V(LoadPixelArrayElement) \
- V(LoadPixelArrayExternalPointer) \
V(Mod) \
V(Mul) \
V(ObjectLiteral) \
V(OsrEntry) \
V(OuterContext) \
V(Parameter) \
- V(PixelArrayLength) \
V(Power) \
V(PushArgument) \
V(RegExpLiteral) \
@@ -150,10 +146,12 @@
V(StoreContextSlot) \
V(StoreGlobal) \
V(StoreKeyedFastElement) \
+ V(StorePixelArrayElement) \
V(StoreKeyedGeneric) \
V(StoreNamedField) \
V(StoreNamedGeneric) \
V(StringCharCodeAt) \
+ V(StringCharFromCode) \
V(StringLength) \
V(Sub) \
V(Test) \
@@ -191,91 +189,50 @@
DECLARE_INSTRUCTION(type)
-
-template<int kSize>
-class HOperandVector : public EmbeddedVector<HValue*, kSize> {
- public:
- HOperandVector() : EmbeddedVector<HValue*, kSize>(NULL) { }
-};
-
-
class Range: public ZoneObject {
public:
- Range() : lower_(kMinInt),
- upper_(kMaxInt),
- next_(NULL),
- can_be_minus_zero_(false) { }
+ Range()
+ : lower_(kMinInt),
+ upper_(kMaxInt),
+ next_(NULL),
+ can_be_minus_zero_(false) { }
Range(int32_t lower, int32_t upper)
- : lower_(lower), upper_(upper), next_(NULL), can_be_minus_zero_(false) { }
+ : lower_(lower),
+ upper_(upper),
+ next_(NULL),
+ can_be_minus_zero_(false) { }
- bool IsInSmiRange() const {
- return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue;
- }
- void KeepOrder();
- void Verify() const;
int32_t upper() const { return upper_; }
int32_t lower() const { return lower_; }
Range* next() const { return next_; }
Range* CopyClearLower() const { return new Range(kMinInt, upper_); }
Range* CopyClearUpper() const { return new Range(lower_, kMaxInt); }
- void ClearLower() { lower_ = kMinInt; }
- void ClearUpper() { upper_ = kMaxInt; }
Range* Copy() const { return new Range(lower_, upper_); }
- bool IsMostGeneric() const { return lower_ == kMinInt && upper_ == kMaxInt; }
int32_t Mask() const;
void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; }
bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; }
bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; }
bool CanBeNegative() const { return lower_ < 0; }
- bool Includes(int value) const {
- return lower_ <= value && upper_ >= value;
+ bool Includes(int value) const { return lower_ <= value && upper_ >= value; }
+ bool IsMostGeneric() const { return lower_ == kMinInt && upper_ == kMaxInt; }
+ bool IsInSmiRange() const {
+ return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue;
}
+ void KeepOrder();
+ void Verify() const;
- void Sar(int32_t value) {
- int32_t bits = value & 0x1F;
- lower_ = lower_ >> bits;
- upper_ = upper_ >> bits;
- set_can_be_minus_zero(false);
- }
-
- void Shl(int32_t value) {
- int32_t bits = value & 0x1F;
- int old_lower = lower_;
- int old_upper = upper_;
- lower_ = lower_ << bits;
- upper_ = upper_ << bits;
- if (old_lower != lower_ >> bits || old_upper != upper_ >> bits) {
- upper_ = kMaxInt;
- lower_ = kMinInt;
- }
- set_can_be_minus_zero(false);
- }
-
- // Adds a constant to the lower and upper bound of the range.
- void AddConstant(int32_t value);
-
void StackUpon(Range* other) {
Intersect(other);
next_ = other;
}
- void Intersect(Range* other) {
- upper_ = Min(upper_, other->upper_);
- lower_ = Max(lower_, other->lower_);
- bool b = CanBeMinusZero() && other->CanBeMinusZero();
- set_can_be_minus_zero(b);
- }
+ void Intersect(Range* other);
+ void Union(Range* other);
- void Union(Range* other) {
- upper_ = Max(upper_, other->upper_);
- lower_ = Min(lower_, other->lower_);
- bool b = CanBeMinusZero() || other->CanBeMinusZero();
- set_can_be_minus_zero(b);
- }
-
- // Compute a new result range and return true, if the operation
- // can overflow.
+ void AddConstant(int32_t value);
+ void Sar(int32_t value);
+ void Shl(int32_t value);
bool AddAndCheckOverflow(Range* other);
bool SubAndCheckOverflow(Range* other);
bool MulAndCheckOverflow(Range* other);
@@ -307,7 +264,7 @@
static Representation Double() { return Representation(kDouble); }
static Representation External() { return Representation(kExternal); }
- bool Equals(const Representation& other) const {
+ bool Equals(const Representation& other) {
return kind_ == other.kind_;
}
@@ -505,9 +462,9 @@
int id() const { return id_; }
void set_id(int id) { id_ = id; }
- const ZoneList<HValue*>* uses() const { return &uses_; }
+ ZoneList<HValue*>* uses() { return &uses_; }
- virtual bool EmitAtUses() const { return false; }
+ virtual bool EmitAtUses() { return false; }
Representation representation() const { return representation_; }
void ChangeRepresentation(Representation r) {
// Representation was already set and is allowed to be changed.
@@ -542,15 +499,12 @@
bool IsDefinedAfter(HBasicBlock* other) const;
// Operands.
- virtual int OperandCount() const { return 0; }
- virtual HValue* OperandAt(int index) const {
- UNREACHABLE();
- return NULL;
- }
+ virtual int OperandCount() = 0;
+ virtual HValue* OperandAt(int index) = 0;
void SetOperandAt(int index, HValue* value);
- int LookupOperandIndex(int occurrence_index, HValue* op) const;
- bool UsesMultipleTimes(HValue* op) const;
+ int LookupOperandIndex(int occurrence_index, HValue* op);
+ bool UsesMultipleTimes(HValue* op);
void ReplaceAndDelete(HValue* other);
void ReplaceValue(HValue* other);
@@ -576,10 +530,9 @@
void ComputeInitialRange();
// Representation helpers.
- virtual Representation RequiredInputRepresentation(int index) const {
- return Representation::None();
- }
- virtual Representation InferredRepresentation() const {
+ virtual Representation RequiredInputRepresentation(int index) const = 0;
+
+ virtual Representation InferredRepresentation() {
return representation();
}
@@ -594,11 +547,11 @@
HYDROGEN_ALL_INSTRUCTION_LIST(DECLARE_DO)
#undef DECLARE_DO
- bool Equals(HValue* other) const;
- virtual intptr_t Hashcode() const;
+ bool Equals(HValue* other);
+ virtual intptr_t Hashcode();
// Printing support.
- virtual void PrintTo(StringStream* stream) const = 0;
+ virtual void PrintTo(StringStream* stream) = 0;
void PrintNameTo(StringStream* stream);
static void PrintTypeTo(HType type, StringStream* stream);
@@ -609,7 +562,7 @@
// it has changed.
bool UpdateInferredType();
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
#ifdef DEBUG
virtual void Verify() = 0;
@@ -618,14 +571,14 @@
protected:
// This function must be overridden for instructions with flag kUseGVN, to
// compare the non-Operand parts of the instruction.
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
UNREACHABLE();
return false;
}
virtual void RepresentationChanged(Representation to) { }
virtual Range* InferRange();
virtual void DeleteFromGraph() = 0;
- virtual void InternalSetOperandAt(int index, HValue* value) { UNREACHABLE(); }
+ virtual void InternalSetOperandAt(int index, HValue* value) = 0;
void clear_block() {
ASSERT(block_ != NULL);
block_ = NULL;
@@ -667,8 +620,8 @@
HInstruction* next() const { return next_; }
HInstruction* previous() const { return previous_; }
- void PrintTo(StringStream* stream) const;
- virtual void PrintDataTo(StringStream* stream) const {}
+ virtual void PrintTo(StringStream* stream);
+ virtual void PrintDataTo(StringStream* stream) { }
bool IsLinked() const { return block() != NULL; }
void Unlink();
@@ -689,6 +642,8 @@
// instruction.
virtual bool IsCheckInstruction() const { return false; }
+ virtual bool IsCall() { return false; }
+
DECLARE_INSTRUCTION(Instruction)
protected:
@@ -715,12 +670,6 @@
};
-class HBlockEntry: public HInstruction {
- public:
- DECLARE_CONCRETE_INSTRUCTION(BlockEntry, "block_entry")
-};
-
-
class HControlInstruction: public HInstruction {
public:
HControlInstruction(HBasicBlock* first, HBasicBlock* second)
@@ -730,7 +679,7 @@
HBasicBlock* FirstSuccessor() const { return first_successor_; }
HBasicBlock* SecondSuccessor() const { return second_successor_; }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_INSTRUCTION(ControlInstruction)
@@ -740,25 +689,101 @@
};
-class HDeoptimize: public HControlInstruction {
+template<int NumElements>
+class HOperandContainer {
public:
- HDeoptimize() : HControlInstruction(NULL, NULL) { }
+ HOperandContainer() : elems_() { }
+ int length() { return NumElements; }
+ HValue*& operator[](int i) {
+ ASSERT(i < length());
+ return elems_[i];
+ }
+
+ private:
+ HValue* elems_[NumElements];
+};
+
+
+template<>
+class HOperandContainer<0> {
+ public:
+ int length() { return 0; }
+ HValue*& operator[](int i) {
+ UNREACHABLE();
+ static HValue* t = 0;
+ return t;
+ }
+};
+
+
+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_;
+};
+
+
+template<int V>
+class HTemplateControlInstruction : public HControlInstruction {
+ public:
+ HTemplateControlInstruction<V>(HBasicBlock* first, HBasicBlock* second)
+ : HControlInstruction(first, second) { }
+ 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_;
+};
+
+
+class HBlockEntry: public HTemplateInstruction<0> {
+ public:
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
+ DECLARE_CONCRETE_INSTRUCTION(BlockEntry, "block_entry")
+};
+
+
+class HDeoptimize: public HTemplateControlInstruction<0> {
+ public:
+ HDeoptimize() : HTemplateControlInstruction<0>(NULL, NULL) { }
+
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
};
-class HGoto: public HControlInstruction {
+class HGoto: public HTemplateControlInstruction<0> {
public:
explicit HGoto(HBasicBlock* target)
- : HControlInstruction(target, NULL), include_stack_check_(false) {
- }
+ : HTemplateControlInstruction<0>(target, NULL),
+ include_stack_check_(false) { }
void set_include_stack_check(bool include_stack_check) {
include_stack_check_ = include_stack_check;
}
bool include_stack_check() const { return include_stack_check_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
private:
@@ -766,34 +791,20 @@
};
-class HUnaryControlInstruction: public HControlInstruction {
+class HUnaryControlInstruction: public HTemplateControlInstruction<1> {
public:
explicit HUnaryControlInstruction(HValue* value,
HBasicBlock* true_target,
HBasicBlock* false_target)
- : HControlInstruction(true_target, false_target) {
+ : HTemplateControlInstruction<1>(true_target, false_target) {
SetOperandAt(0, value);
}
- virtual Representation RequiredInputRepresentation(int index) const {
- return Representation::Tagged();
- }
+ virtual void PrintDataTo(StringStream* stream);
- virtual void PrintDataTo(StringStream* stream) const;
+ HValue* value() { return OperandAt(0); }
- HValue* value() const { return OperandAt(0); }
- virtual int OperandCount() const { return 1; }
- virtual HValue* OperandAt(int index) const { return operands_[index]; }
-
DECLARE_INSTRUCTION(UnaryControlInstruction)
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- operands_[index] = value;
- }
-
- private:
- HOperandVector<1> operands_;
};
@@ -825,10 +836,14 @@
ASSERT(!map.is_null());
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
Handle<Map> map() const { return map_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(CompareMap, "compare_map")
private:
@@ -842,38 +857,36 @@
: HUnaryControlInstruction(value, NULL, NULL) {
}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(Return, "return")
};
-class HAbnormalExit: public HControlInstruction {
+class HAbnormalExit: public HTemplateControlInstruction<0> {
public:
- HAbnormalExit() : HControlInstruction(NULL, NULL) { }
+ HAbnormalExit() : HTemplateControlInstruction<0>(NULL, NULL) { }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(AbnormalExit, "abnormal_exit")
};
-class HUnaryOperation: public HInstruction {
+class HUnaryOperation: public HTemplateInstruction<1> {
public:
explicit HUnaryOperation(HValue* value) {
SetOperandAt(0, value);
}
- HValue* value() const { return OperandAt(0); }
- virtual void PrintDataTo(StringStream* stream) const;
- virtual int OperandCount() const { return 1; }
- virtual HValue* OperandAt(int index) const { return operands_[index]; }
+ HValue* value() { return OperandAt(0); }
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_INSTRUCTION(UnaryOperation)
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- operands_[index] = value;
- }
-
- private:
- HOperandVector<1> operands_;
};
@@ -895,13 +908,14 @@
public:
HChange(HValue* value,
Representation from,
- Representation to)
+ Representation to,
+ bool is_truncating)
: HUnaryOperation(value), from_(from), to_(to) {
ASSERT(!from.IsNone() && !to.IsNone());
ASSERT(!from.Equals(to));
set_representation(to);
SetFlag(kUseGVN);
-
+ if (is_truncating) SetFlag(kTruncatingToInt32);
if (from.IsInteger32() && to.IsTagged() && value->range() != NULL &&
value->range()->IsInSmiRange()) {
set_type(HType::Smi());
@@ -916,25 +930,19 @@
return from_;
}
- bool CanTruncateToInt32() const {
- for (int i = 0; i < uses()->length(); ++i) {
- if (!uses()->at(i)->CheckFlag(HValue::kTruncatingToInt32)) return false;
- }
- return true;
- }
+ bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(Change,
CanTruncateToInt32() ? "truncate" : "change")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
if (!other->IsChange()) return false;
HChange* change = HChange::cast(other);
return value() == change->value()
- && to().Equals(change->to())
- && CanTruncateToInt32() == change->CanTruncateToInt32();
+ && to().Equals(change->to());
}
private:
@@ -953,7 +961,7 @@
assigned_indexes_(2) {}
virtual ~HSimulate() {}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
bool HasAstId() const { return ast_id_ != AstNode::kNoNumber; }
int ast_id() const { return ast_id_; }
@@ -978,9 +986,13 @@
void AddPushedValue(HValue* value) {
AddValue(kNoIndex, value);
}
- virtual int OperandCount() const { return values_.length(); }
- virtual HValue* OperandAt(int index) const { return values_[index]; }
+ virtual int OperandCount() { return values_.length(); }
+ virtual HValue* OperandAt(int index) { return values_[index]; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(Simulate, "simulate")
#ifdef DEBUG
@@ -1010,25 +1022,33 @@
};
-class HStackCheck: public HInstruction {
+class HStackCheck: public HTemplateInstruction<0> {
public:
HStackCheck() { }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack_check")
};
-class HEnterInlined: public HInstruction {
+class HEnterInlined: public HTemplateInstruction<0> {
public:
HEnterInlined(Handle<JSFunction> closure, FunctionLiteral* function)
: closure_(closure), function_(function) {
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
Handle<JSFunction> closure() const { return closure_; }
FunctionLiteral* function() const { return function_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(EnterInlined, "enter_inlined")
private:
@@ -1037,39 +1057,49 @@
};
-class HLeaveInlined: public HInstruction {
+class HLeaveInlined: public HTemplateInstruction<0> {
public:
HLeaveInlined() {}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(LeaveInlined, "leave_inlined")
};
class HPushArgument: public HUnaryOperation {
public:
- explicit HPushArgument(HValue* value) : HUnaryOperation(value) { }
+ explicit HPushArgument(HValue* value) : HUnaryOperation(value) {
+ set_representation(Representation::Tagged());
+ }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- HValue* argument() const { return OperandAt(0); }
+ HValue* argument() { return OperandAt(0); }
DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push_argument")
};
-class HContext: public HInstruction {
+class HContext: public HTemplateInstruction<0> {
public:
HContext() {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(Context, "context");
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -1082,8 +1112,12 @@
DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer_context");
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -1096,8 +1130,12 @@
DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global_object")
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -1111,94 +1149,79 @@
DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global_receiver")
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HCall: public HInstruction {
+template <int V>
+class HCall: public HTemplateInstruction<V> {
public:
// The argument count includes the receiver.
- explicit HCall(int argument_count) : argument_count_(argument_count) {
- set_representation(Representation::Tagged());
- SetAllSideEffects();
+ explicit HCall<V>(int argument_count) : argument_count_(argument_count) {
+ this->set_representation(Representation::Tagged());
+ this->SetAllSideEffects();
}
- virtual HType CalculateInferredType() const { return HType::Tagged(); }
+ virtual HType CalculateInferredType() { return HType::Tagged(); }
virtual int argument_count() const { return argument_count_; }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual bool IsCall() { return true; }
- DECLARE_INSTRUCTION(Call)
-
private:
int argument_count_;
};
-class HUnaryCall: public HCall {
+class HUnaryCall: public HCall<1> {
public:
HUnaryCall(HValue* value, int argument_count)
- : HCall(argument_count), value_(NULL) {
+ : HCall<1>(argument_count) {
SetOperandAt(0, value);
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
- HValue* value() const { return value_; }
+ virtual void PrintDataTo(StringStream* stream);
- virtual int OperandCount() const { return 1; }
- virtual HValue* OperandAt(int index) const {
- ASSERT(index == 0);
- return value_;
- }
+ HValue* value() { return OperandAt(0); }
DECLARE_INSTRUCTION(UnaryCall)
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- ASSERT(index == 0);
- value_ = value;
- }
-
- private:
- HValue* value_;
};
-class HBinaryCall: public HCall {
+class HBinaryCall: public HCall<2> {
public:
HBinaryCall(HValue* first, HValue* second, int argument_count)
- : HCall(argument_count) {
+ : HCall<2>(argument_count) {
SetOperandAt(0, first);
SetOperandAt(1, second);
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
- HValue* first() const { return operands_[0]; }
- HValue* second() const { return operands_[1]; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
- virtual int OperandCount() const { return 2; }
- virtual HValue* OperandAt(int index) const { return operands_[index]; }
+ HValue* first() { return OperandAt(0); }
+ HValue* second() { return OperandAt(1); }
DECLARE_INSTRUCTION(BinaryCall)
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- operands_[index] = value;
- }
-
- private:
- HOperandVector<2> operands_;
};
-class HCallConstantFunction: public HCall {
+class HCallConstantFunction: public HCall<0> {
public:
HCallConstantFunction(Handle<JSFunction> function, int argument_count)
- : HCall(argument_count), function_(function) { }
+ : HCall<0>(argument_count), function_(function) { }
Handle<JSFunction> function() const { return function_; }
@@ -1206,8 +1229,12 @@
return function_->code() == Builtins::builtin(Builtins::FunctionApply);
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call_constant_function")
private:
@@ -1225,8 +1252,8 @@
return Representation::Tagged();
}
- HValue* context() const { return first(); }
- HValue* key() const { return second(); }
+ HValue* context() { return first(); }
+ HValue* key() { return second(); }
DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call_keyed")
};
@@ -1238,13 +1265,17 @@
: HUnaryCall(context, argument_count), name_(name) {
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
- HValue* context() const { return value(); }
+ HValue* context() { return value(); }
Handle<String> name() const { return name_; }
DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call_named")
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
private:
Handle<String> name_;
};
@@ -1256,8 +1287,12 @@
: HUnaryCall(context, argument_count) {
}
- HValue* context() const { return value(); }
+ HValue* context() { return value(); }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call_function")
};
@@ -1268,11 +1303,15 @@
: HUnaryCall(context, argument_count), name_(name) {
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
- HValue* context() const { return value(); }
+ HValue* context() { return value(); }
Handle<String> name() const { return name_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call_global")
private:
@@ -1280,15 +1319,19 @@
};
-class HCallKnownGlobal: public HCall {
+class HCallKnownGlobal: public HCall<0> {
public:
HCallKnownGlobal(Handle<JSFunction> target, int argument_count)
- : HCall(argument_count), target_(target) { }
+ : HCall<0>(argument_count), target_(target) { }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
Handle<JSFunction> target() const { return target_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call_known_global")
private:
@@ -1306,24 +1349,28 @@
return Representation::Tagged();
}
- HValue* context() const { return first(); }
- HValue* constructor() const { return second(); }
+ HValue* context() { return first(); }
+ HValue* constructor() { return second(); }
DECLARE_CONCRETE_INSTRUCTION(CallNew, "call_new")
};
-class HCallRuntime: public HCall {
+class HCallRuntime: public HCall<0> {
public:
HCallRuntime(Handle<String> name,
Runtime::Function* c_function,
int argument_count)
- : HCall(argument_count), c_function_(c_function), name_(name) { }
- virtual void PrintDataTo(StringStream* stream) const;
+ : HCall<0>(argument_count), c_function_(c_function), name_(name) { }
+ virtual void PrintDataTo(StringStream* stream);
Runtime::Function* function() const { return c_function_; }
Handle<String> name() const { return name_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call_runtime")
private:
@@ -1350,7 +1397,7 @@
DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js_array_length")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -1369,13 +1416,13 @@
DECLARE_CONCRETE_INSTRUCTION(FixedArrayLength, "fixed_array_length")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HPixelArrayLength: public HUnaryOperation {
+class HExternalArrayLength: public HUnaryOperation {
public:
- explicit HPixelArrayLength(HValue* value) : HUnaryOperation(value) {
+ explicit HExternalArrayLength(HValue* value) : HUnaryOperation(value) {
set_representation(Representation::Integer32());
// The result of this instruction is idempotent as long as its inputs don't
// change. The length of a pixel array cannot change once set, so it's not
@@ -1387,10 +1434,10 @@
return Representation::Tagged();
}
- DECLARE_CONCRETE_INSTRUCTION(PixelArrayLength, "pixel_array_length")
+ DECLARE_CONCRETE_INSTRUCTION(ExternalArrayLength, "external_array_length")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -1405,12 +1452,12 @@
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Integer32();
}
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(BitNot, "bit_not")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -1441,9 +1488,9 @@
SetFlag(kUseGVN);
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
@@ -1458,11 +1505,10 @@
case kMathSin:
case kMathCos:
return Representation::Double();
- break;
case kMathAbs:
return representation();
- break;
default:
+ UNREACHABLE();
return Representation::None();
}
}
@@ -1483,7 +1529,7 @@
DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary_math_operation")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HUnaryMathOperation* b = HUnaryMathOperation::cast(other);
return op_ == b->op();
}
@@ -1508,13 +1554,13 @@
DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HLoadPixelArrayExternalPointer: public HUnaryOperation {
+class HLoadExternalArrayPointer: public HUnaryOperation {
public:
- explicit HLoadPixelArrayExternalPointer(HValue* value)
+ explicit HLoadExternalArrayPointer(HValue* value)
: HUnaryOperation(value) {
set_representation(Representation::External());
// The result of this instruction is idempotent as long as its inputs don't
@@ -1528,11 +1574,11 @@
return Representation::Tagged();
}
- DECLARE_CONCRETE_INSTRUCTION(LoadPixelArrayExternalPointer,
- "load-pixel-array-external-pointer")
+ DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
+ "load-external-array-pointer")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -1550,8 +1596,8 @@
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
- virtual HType CalculateInferredType() const;
+ virtual void PrintDataTo(StringStream* stream);
+ virtual HType CalculateInferredType();
#ifdef DEBUG
virtual void Verify();
@@ -1562,7 +1608,7 @@
DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check_map")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HCheckMap* b = HCheckMap::cast(other);
return map_.is_identical_to(b->map());
}
@@ -1585,8 +1631,8 @@
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
- virtual HType CalculateInferredType() const;
+ virtual void PrintDataTo(StringStream* stream);
+ virtual HType CalculateInferredType();
#ifdef DEBUG
virtual void Verify();
@@ -1597,7 +1643,7 @@
DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check_function")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HCheckFunction* b = HCheckFunction::cast(other);
return target_.is_identical_to(b->target());
}
@@ -1645,7 +1691,7 @@
// TODO(ager): It could be nice to allow the ommision of instance
// type checks if we have already performed an instance type check
// with a larger range.
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HCheckInstanceType* b = HCheckInstanceType::cast(other);
return (first_ == b->first()) && (last_ == b->last());
}
@@ -1669,7 +1715,7 @@
return Representation::Tagged();
}
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
#ifdef DEBUG
virtual void Verify();
@@ -1678,11 +1724,11 @@
DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check_non_smi")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HCheckPrototypeMaps: public HInstruction {
+class HCheckPrototypeMaps: public HTemplateInstruction<0> {
public:
HCheckPrototypeMaps(Handle<JSObject> prototype, Handle<JSObject> holder)
: prototype_(prototype), holder_(holder) {
@@ -1701,7 +1747,11 @@
DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check_prototype_maps")
- virtual intptr_t Hashcode() const {
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
+ virtual intptr_t Hashcode() {
ASSERT(!Heap::IsAllocationAllowed());
intptr_t hash = reinterpret_cast<intptr_t>(*prototype());
hash = 17 * hash + reinterpret_cast<intptr_t>(*holder());
@@ -1709,7 +1759,7 @@
}
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other);
return prototype_.is_identical_to(b->prototype()) &&
holder_.is_identical_to(b->holder());
@@ -1733,7 +1783,7 @@
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
#ifdef DEBUG
virtual void Verify();
@@ -1742,7 +1792,7 @@
DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check_smi")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -1751,7 +1801,8 @@
explicit HPhi(int merged_index)
: inputs_(2),
merged_index_(merged_index),
- phi_id_(-1) {
+ phi_id_(-1),
+ is_live_(false) {
for (int i = 0; i < Representation::kNumRepresentations; i++) {
non_phi_uses_[i] = 0;
indirect_uses_[i] = 0;
@@ -1761,7 +1812,7 @@
SetFlag(kFlexibleRepresentation);
}
- virtual Representation InferredRepresentation() const {
+ virtual Representation InferredRepresentation() {
bool double_occurred = false;
bool int32_occurred = false;
for (int i = 0; i < OperandCount(); ++i) {
@@ -1780,11 +1831,12 @@
virtual Representation RequiredInputRepresentation(int index) const {
return representation();
}
- virtual HType CalculateInferredType() const;
- virtual int OperandCount() const { return inputs_.length(); }
- virtual HValue* OperandAt(int index) const { return inputs_[index]; }
- HValue* GetRedundantReplacement() const;
+ virtual HType CalculateInferredType();
+ virtual int OperandCount() { return inputs_.length(); }
+ virtual HValue* OperandAt(int index) { return inputs_[index]; }
+ HValue* GetRedundantReplacement();
void AddInput(HValue* value);
+ bool HasRealUses();
bool IsReceiver() { return merged_index_ == 0; }
@@ -1792,7 +1844,7 @@
virtual const char* Mnemonic() const { return "phi"; }
- virtual void PrintTo(StringStream* stream) const;
+ virtual void PrintTo(StringStream* stream);
#ifdef DEBUG
virtual void Verify();
@@ -1823,6 +1875,8 @@
return indirect_uses_[Representation::kDouble];
}
int phi_id() { return phi_id_; }
+ bool is_live() { return is_live_; }
+ void set_is_live(bool b) { is_live_ = b; }
protected:
virtual void DeleteFromGraph();
@@ -1837,21 +1891,26 @@
int non_phi_uses_[Representation::kNumRepresentations];
int indirect_uses_[Representation::kNumRepresentations];
int phi_id_;
+ bool is_live_;
};
-class HArgumentsObject: public HInstruction {
+class HArgumentsObject: public HTemplateInstruction<0> {
public:
HArgumentsObject() {
set_representation(Representation::Tagged());
SetFlag(kIsArguments);
}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject, "arguments-object")
};
-class HConstant: public HInstruction {
+class HConstant: public HTemplateInstruction<0> {
public:
HConstant(Handle<Object> handle, Representation r);
@@ -1859,9 +1918,13 @@
bool InOldSpace() const { return !Heap::InNewSpace(*handle_); }
- virtual bool EmitAtUses() const { return !representation().IsDouble(); }
- virtual void PrintDataTo(StringStream* stream) const;
- virtual HType CalculateInferredType() const;
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
+ virtual bool EmitAtUses() { return !representation().IsDouble(); }
+ virtual void PrintDataTo(StringStream* stream);
+ virtual HType CalculateInferredType();
bool IsInteger() const { return handle_->IsSmi(); }
HConstant* CopyToRepresentation(Representation r) const;
HConstant* CopyToTruncatedInt32() const;
@@ -1877,7 +1940,7 @@
}
bool HasStringValue() const { return handle_->IsString(); }
- virtual intptr_t Hashcode() const {
+ virtual intptr_t Hashcode() {
ASSERT(!Heap::allow_allocation(false));
return reinterpret_cast<intptr_t>(*handle());
}
@@ -1891,7 +1954,7 @@
protected:
virtual Range* InferRange();
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HConstant* other_constant = HConstant::cast(other);
return handle().is_identical_to(other_constant->handle());
}
@@ -1910,7 +1973,7 @@
};
-class HBinaryOperation: public HInstruction {
+class HBinaryOperation: public HTemplateInstruction<2> {
public:
HBinaryOperation(HValue* left, HValue* right) {
ASSERT(left != NULL && right != NULL);
@@ -1918,38 +1981,29 @@
SetOperandAt(1, right);
}
- HValue* left() const { return OperandAt(0); }
- HValue* right() const { return OperandAt(1); }
+ HValue* left() { return OperandAt(0); }
+ HValue* right() { return OperandAt(1); }
// TODO(kasperl): Move these helpers to the IA-32 Lithium
// instruction sequence builder.
- HValue* LeastConstantOperand() const {
+ HValue* LeastConstantOperand() {
if (IsCommutative() && left()->IsConstant()) return right();
return left();
}
- HValue* MostConstantOperand() const {
+ HValue* MostConstantOperand() {
if (IsCommutative() && left()->IsConstant()) return left();
return right();
}
virtual bool IsCommutative() const { return false; }
- virtual void PrintDataTo(StringStream* stream) const;
- virtual int OperandCount() const { return operands_.length(); }
- virtual HValue* OperandAt(int index) const { return operands_[index]; }
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_INSTRUCTION(BinaryOperation)
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- operands_[index] = value;
- }
-
- HOperandVector<2> operands_;
};
-class HApplyArguments: public HInstruction {
+class HApplyArguments: public HTemplateInstruction<4> {
public:
HApplyArguments(HValue* function,
HValue* receiver,
@@ -1970,27 +2024,16 @@
: Representation::Tagged();
}
- HValue* function() const { return OperandAt(0); }
- HValue* receiver() const { return OperandAt(1); }
- HValue* length() const { return OperandAt(2); }
- HValue* elements() const { return OperandAt(3); }
+ HValue* function() { return OperandAt(0); }
+ HValue* receiver() { return OperandAt(1); }
+ HValue* length() { return OperandAt(2); }
+ HValue* elements() { return OperandAt(3); }
- virtual int OperandCount() const { return operands_.length(); }
- virtual HValue* OperandAt(int index) const { return operands_[index]; }
-
DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply_arguments")
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- operands_[index] = value;
- }
-
- private:
- HOperandVector<4> operands_;
};
-class HArgumentsElements: public HInstruction {
+class HArgumentsElements: public HTemplateInstruction<0> {
public:
HArgumentsElements() {
// The value produced by this instruction is a pointer into the stack
@@ -2001,8 +2044,12 @@
DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments_elements")
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2013,14 +2060,18 @@
SetFlag(kUseGVN);
}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments_length")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HAccessArgumentsAt: public HInstruction {
+class HAccessArgumentsAt: public HTemplateInstruction<3> {
public:
HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) {
set_representation(Representation::Tagged());
@@ -2030,7 +2081,7 @@
SetOperandAt(2, index);
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
virtual Representation RequiredInputRepresentation(int index) const {
// The arguments elements is considered tagged.
@@ -2039,24 +2090,13 @@
: Representation::Integer32();
}
- HValue* arguments() const { return operands_[0]; }
- HValue* length() const { return operands_[1]; }
- HValue* index() const { return operands_[2]; }
+ HValue* arguments() { return OperandAt(0); }
+ HValue* length() { return OperandAt(1); }
+ HValue* index() { return OperandAt(2); }
- virtual int OperandCount() const { return operands_.length(); }
- virtual HValue* OperandAt(int index) const { return operands_[index]; }
-
DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access_arguments_at")
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- operands_[index] = value;
- }
-
- virtual bool DataEquals(HValue* other) const { return true; }
-
- private:
- HOperandVector<3> operands_;
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2077,13 +2117,13 @@
virtual void Verify();
#endif
- HValue* index() const { return left(); }
- HValue* length() const { return right(); }
+ HValue* index() { return left(); }
+ HValue* length() { return right(); }
DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds_check")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2109,7 +2149,7 @@
}
}
- HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_INSTRUCTION(BitwiseBinaryOperation)
};
@@ -2131,11 +2171,11 @@
}
}
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
virtual Representation RequiredInputRepresentation(int index) const {
return representation();
}
- virtual Representation InferredRepresentation() const {
+ virtual Representation InferredRepresentation() {
if (left()->representation().Equals(right()->representation())) {
return left()->representation();
}
@@ -2157,7 +2197,7 @@
void SetInputRepresentation(Representation r);
- virtual bool EmitAtUses() const {
+ virtual bool EmitAtUses() {
return !HasSideEffects() && (uses()->length() <= 1);
}
@@ -2168,18 +2208,18 @@
return input_representation_;
}
Token::Value token() const { return token_; }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
- virtual intptr_t Hashcode() const {
+ virtual intptr_t Hashcode() {
return HValue::Hashcode() * 7 + token_;
}
DECLARE_CONCRETE_INSTRUCTION(Compare, "compare")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HCompare* comp = HCompare::cast(other);
return token_ == comp->token();
}
@@ -2198,19 +2238,19 @@
SetFlag(kUseGVN);
}
- virtual bool EmitAtUses() const {
+ virtual bool EmitAtUses() {
return !HasSideEffects() && (uses()->length() <= 1);
}
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(CompareJSObjectEq, "compare-js-object-eq")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2221,14 +2261,14 @@
SetFlag(kUseGVN);
}
- virtual bool EmitAtUses() const {
+ virtual bool EmitAtUses() {
return !HasSideEffects() && (uses()->length() <= 1);
}
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
};
@@ -2242,7 +2282,7 @@
DECLARE_CONCRETE_INSTRUCTION(IsNull, "is_null")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HIsNull* b = HIsNull::cast(other);
return is_strict_ == b->is_strict();
}
@@ -2259,7 +2299,7 @@
DECLARE_CONCRETE_INSTRUCTION(IsObject, "is_object")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2270,25 +2310,29 @@
DECLARE_CONCRETE_INSTRUCTION(IsSmi, "is_smi")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HIsConstructCall: public HInstruction {
+class HIsConstructCall: public HTemplateInstruction<0> {
public:
HIsConstructCall() {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
}
- virtual bool EmitAtUses() const {
+ virtual bool EmitAtUses() {
return !HasSideEffects() && (uses()->length() <= 1);
}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(IsConstructCall, "is_construct_call")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2304,12 +2348,12 @@
InstanceType from() { return from_; }
InstanceType to() { return to_; }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(HasInstanceType, "has_instance_type")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HHasInstanceType* b = HHasInstanceType::cast(other);
return (from_ == b->from()) && (to_ == b->to());
}
@@ -2327,10 +2371,21 @@
DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has_cached_array_index")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
+class HGetCachedArrayIndex: public HUnaryPredicate {
+ public:
+ explicit HGetCachedArrayIndex(HValue* value) : HUnaryPredicate(value) { }
+
+ DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get_cached_array_index")
+
+ protected:
+ virtual bool DataEquals(HValue* other) { return true; }
+};
+
+
class HClassOfTest: public HUnaryPredicate {
public:
HClassOfTest(HValue* value, Handle<String> class_name)
@@ -2338,12 +2393,12 @@
DECLARE_CONCRETE_INSTRUCTION(ClassOfTest, "class_of_test")
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
Handle<String> class_name() const { return class_name_; }
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HClassOfTest* b = HClassOfTest::cast(other);
return class_name_.is_identical_to(b->class_name_);
}
@@ -2359,12 +2414,12 @@
: HUnaryPredicate(value), type_literal_(type_literal) { }
Handle<String> type_literal() { return type_literal_; }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(TypeofIs, "typeof_is")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HTypeofIs* b = HTypeofIs::cast(other);
return type_literal_.is_identical_to(b->type_literal_);
}
@@ -2374,7 +2429,7 @@
};
-class HInstanceOf: public HInstruction {
+class HInstanceOf: public HTemplateInstruction<3> {
public:
HInstanceOf(HValue* context, HValue* left, HValue* right) {
SetOperandAt(0, context);
@@ -2384,11 +2439,11 @@
SetAllSideEffects();
}
- HValue* context() const { return operands_[0]; }
- HValue* left() const { return operands_[1]; }
- HValue* right() const { return operands_[2]; }
+ HValue* context() { return OperandAt(0); }
+ HValue* left() { return OperandAt(1); }
+ HValue* right() { return OperandAt(2); }
- virtual bool EmitAtUses() const {
+ virtual bool EmitAtUses() {
return !HasSideEffects() && (uses()->length() <= 1);
}
@@ -2396,20 +2451,9 @@
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
- virtual int OperandCount() const { return 3; }
- virtual HValue* OperandAt(int index) const { return operands_[index]; }
-
DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance_of")
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- operands_[index] = value;
- }
-
- private:
- HOperandVector<3> operands_;
};
@@ -2450,7 +2494,7 @@
DECLARE_CONCRETE_INSTRUCTION(Power, "power")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2468,12 +2512,12 @@
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(Add, "add")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange();
};
@@ -2490,7 +2534,7 @@
DECLARE_CONCRETE_INSTRUCTION(Sub, "sub")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange();
};
@@ -2512,7 +2556,7 @@
DECLARE_CONCRETE_INSTRUCTION(Mul, "mul")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange();
};
@@ -2524,12 +2568,22 @@
SetFlag(kCanBeDivByZero);
}
+ bool HasPowerOf2Divisor() {
+ if (right()->IsConstant() &&
+ HConstant::cast(right())->HasInteger32Value()) {
+ int32_t value = HConstant::cast(right())->Integer32Value();
+ return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
+ }
+
+ return false;
+ }
+
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
DECLARE_CONCRETE_INSTRUCTION(Mod, "mod")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange();
};
@@ -2547,7 +2601,7 @@
DECLARE_CONCRETE_INSTRUCTION(Div, "div")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange();
};
@@ -2559,12 +2613,12 @@
: HBitwiseBinaryOperation(left, right) { }
virtual bool IsCommutative() const { return true; }
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(BitAnd, "bit_and")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange();
};
@@ -2576,12 +2630,12 @@
: HBitwiseBinaryOperation(left, right) { }
virtual bool IsCommutative() const { return true; }
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(BitXor, "bit_xor")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2591,12 +2645,12 @@
: HBitwiseBinaryOperation(left, right) { }
virtual bool IsCommutative() const { return true; }
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(BitOr, "bit_or")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange();
};
@@ -2608,12 +2662,12 @@
: HBitwiseBinaryOperation(left, right) { }
virtual Range* InferRange();
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(Shl, "shl")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2622,12 +2676,12 @@
HShr(HValue* left, HValue* right)
: HBitwiseBinaryOperation(left, right) { }
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(Shr, "shr")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2637,16 +2691,16 @@
: HBitwiseBinaryOperation(left, right) { }
virtual Range* InferRange();
- virtual HType CalculateInferredType() const;
+ virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(Sar, "sar")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HOsrEntry: public HInstruction {
+class HOsrEntry: public HTemplateInstruction<0> {
public:
explicit HOsrEntry(int ast_id) : ast_id_(ast_id) {
SetFlag(kChangesOsrEntries);
@@ -2654,6 +2708,10 @@
int ast_id() const { return ast_id_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr_entry")
private:
@@ -2661,7 +2719,7 @@
};
-class HParameter: public HInstruction {
+class HParameter: public HTemplateInstruction<0> {
public:
explicit HParameter(unsigned index) : index_(index) {
set_representation(Representation::Tagged());
@@ -2669,8 +2727,12 @@
unsigned index() const { return index_; }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
private:
@@ -2688,7 +2750,7 @@
CodeStub::Major major_key() { return major_key_; }
- HValue* context() const { return value(); }
+ HValue* context() { return value(); }
void set_transcendental_type(TranscendentalCache::Type transcendental_type) {
transcendental_type_ = transcendental_type;
@@ -2697,8 +2759,12 @@
return transcendental_type_;
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(CallStub, "call_stub")
private:
@@ -2707,15 +2773,19 @@
};
-class HUnknownOSRValue: public HInstruction {
+class HUnknownOSRValue: public HTemplateInstruction<0> {
public:
HUnknownOSRValue() { set_representation(Representation::Tagged()); }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown_osr_value")
};
-class HLoadGlobal: public HInstruction {
+class HLoadGlobal: public HTemplateInstruction<0> {
public:
HLoadGlobal(Handle<JSGlobalPropertyCell> cell, bool check_hole_value)
: cell_(cell), check_hole_value_(check_hole_value) {
@@ -2727,20 +2797,21 @@
Handle<JSGlobalPropertyCell> cell() const { return cell_; }
bool check_hole_value() const { return check_hole_value_; }
- virtual Representation RequiredInputRepresentation(int index) const {
- return Representation::Tagged();
- }
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
- virtual intptr_t Hashcode() const {
+ virtual intptr_t Hashcode() {
ASSERT(!Heap::allow_allocation(false));
return reinterpret_cast<intptr_t>(*cell_);
}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(LoadGlobal, "load_global")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HLoadGlobal* b = HLoadGlobal::cast(other);
return cell_.is_identical_to(b->cell());
}
@@ -2768,7 +2839,7 @@
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store_global")
@@ -2793,12 +2864,12 @@
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load_context_slot")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HLoadContextSlot* b = HLoadContextSlot::cast(other);
return (slot_index() == b->slot_index());
}
@@ -2821,11 +2892,11 @@
SetFlag(kChangesContextSlots);
}
- HValue* context() const { return OperandAt(0); }
- HValue* value() const { return OperandAt(1); }
+ HValue* context() { return OperandAt(0); }
+ HValue* value() { return OperandAt(1); }
int slot_index() const { return slot_index_; }
- bool NeedsWriteBarrier() const {
+ bool NeedsWriteBarrier() {
return StoringValueNeedsWriteBarrier(value());
}
@@ -2833,7 +2904,7 @@
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store_context_slot")
@@ -2857,19 +2928,19 @@
}
}
- HValue* object() const { return OperandAt(0); }
+ HValue* object() { return OperandAt(0); }
bool is_in_object() const { return is_in_object_; }
int offset() const { return offset_; }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load_named_field")
protected:
- virtual bool DataEquals(HValue* other) const {
+ virtual bool DataEquals(HValue* other) {
HLoadNamedField* b = HLoadNamedField::cast(other);
return is_in_object_ == b->is_in_object_ && offset_ == b->offset_;
}
@@ -2888,8 +2959,8 @@
SetAllSideEffects();
}
- HValue* context() const { return OperandAt(0); }
- HValue* object() const { return OperandAt(1); }
+ HValue* context() { return OperandAt(0); }
+ HValue* object() { return OperandAt(1); }
Handle<Object> name() const { return name_; }
virtual Representation RequiredInputRepresentation(int index) const {
@@ -2912,7 +2983,7 @@
SetFlag(kDependsOnCalls);
}
- HValue* function() const { return OperandAt(0); }
+ HValue* function() { return OperandAt(0); }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
@@ -2921,46 +2992,34 @@
DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load_function_prototype")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HLoadKeyed: public HBinaryOperation {
+class HLoadKeyedFastElement: public HBinaryOperation {
public:
- HLoadKeyed(HValue* obj, HValue* key) : HBinaryOperation(obj, key) {
+ HLoadKeyedFastElement(HValue* obj, HValue* key) : HBinaryOperation(obj, key) {
set_representation(Representation::Tagged());
- }
-
- virtual void PrintDataTo(StringStream* stream) const;
-
- virtual Representation RequiredInputRepresentation(int index) const {
- return Representation::Tagged();
- }
- HValue* object() const { return OperandAt(0); }
- HValue* key() const { return OperandAt(1); }
-
- DECLARE_INSTRUCTION(LoadKeyed)
-};
-
-
-class HLoadKeyedFastElement: public HLoadKeyed {
- public:
- HLoadKeyedFastElement(HValue* obj, HValue* key) : HLoadKeyed(obj, key) {
SetFlag(kDependsOnArrayElements);
SetFlag(kUseGVN);
}
+ HValue* object() { return OperandAt(0); }
+ HValue* key() { return OperandAt(1); }
+
virtual Representation RequiredInputRepresentation(int index) const {
// The key is supposed to be Integer32.
return (index == 1) ? Representation::Integer32()
: Representation::Tagged();
}
+ virtual void PrintDataTo(StringStream* stream);
+
DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement,
"load_keyed_fast_element")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
@@ -2975,7 +3034,7 @@
SetFlag(kUseGVN);
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
virtual Representation RequiredInputRepresentation(int index) const {
// The key is supposed to be Integer32, but the base pointer
@@ -2984,76 +3043,50 @@
: Representation::External();
}
- HValue* external_pointer() const { return OperandAt(0); }
- HValue* key() const { return OperandAt(1); }
+ HValue* external_pointer() { return OperandAt(0); }
+ HValue* key() { return OperandAt(1); }
DECLARE_CONCRETE_INSTRUCTION(LoadPixelArrayElement,
"load_pixel_array_element")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
};
-class HLoadKeyedGeneric: public HLoadKeyed {
+class HLoadKeyedGeneric: public HTemplateInstruction<3> {
public:
- HLoadKeyedGeneric(HContext* context, HValue* obj, HValue* key)
- : HLoadKeyed(obj, key), context_(NULL) {
+ HLoadKeyedGeneric(HContext* context, HValue* obj, HValue* key) {
+ set_representation(Representation::Tagged());
+ SetOperandAt(0, obj);
+ SetOperandAt(1, key);
SetOperandAt(2, context);
SetAllSideEffects();
}
- HValue* context() const { return context_; }
- HValue* object() const { return operands_[0]; }
- HValue* key() const { return operands_[1]; }
+ HValue* object() { return OperandAt(0); }
+ HValue* key() { return OperandAt(1); }
+ HValue* context() { return OperandAt(2); }
- virtual int OperandCount() const { return 3; }
- virtual HValue* OperandAt(int index) const {
- return (index < 2) ? operands_[index] : context_;
- }
+ virtual void PrintDataTo(StringStream* stream);
- DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load_keyed_generic")
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value);
-
- private:
- HValue* context_;
-};
-
-
-class HStoreNamed: public HBinaryOperation {
- public:
- HStoreNamed(HValue* obj, Handle<String> name, HValue* val)
- : HBinaryOperation(obj, val), name_(name) {
- }
-
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
-
- HValue* object() const { return OperandAt(0); }
- Handle<String> name() const { return name_; }
- HValue* value() const { return OperandAt(1); }
- void set_value(HValue* value) { SetOperandAt(1, value); }
-
- DECLARE_INSTRUCTION(StoreNamed)
-
- private:
- Handle<String> name_;
+ DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load_keyed_generic")
};
-class HStoreNamedField: public HStoreNamed {
+class HStoreNamedField: public HBinaryOperation {
public:
HStoreNamedField(HValue* obj,
Handle<String> name,
HValue* val,
bool in_object,
int offset)
- : HStoreNamed(obj, name, val),
+ : HBinaryOperation(obj, val),
+ name_(name),
is_in_object_(in_object),
offset_(offset) {
if (is_in_object_) {
@@ -3068,137 +3101,143 @@
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
- virtual void PrintDataTo(StringStream* stream) const;
+ virtual void PrintDataTo(StringStream* stream);
+ HValue* object() { return OperandAt(0); }
+ HValue* value() { return OperandAt(1); }
+
+ Handle<String> name() const { return name_; }
bool is_in_object() const { return is_in_object_; }
int offset() const { return offset_; }
Handle<Map> transition() const { return transition_; }
void set_transition(Handle<Map> map) { transition_ = map; }
- bool NeedsWriteBarrier() const {
+ bool NeedsWriteBarrier() {
return StoringValueNeedsWriteBarrier(value());
}
private:
+ Handle<String> name_;
bool is_in_object_;
int offset_;
Handle<Map> transition_;
};
-class HStoreNamedGeneric: public HStoreNamed {
+class HStoreNamedGeneric: public HTemplateInstruction<3> {
public:
HStoreNamedGeneric(HValue* context,
HValue* object,
Handle<String> name,
HValue* value)
- : HStoreNamed(object, name, value), context_(NULL) {
+ : name_(name) {
+ SetOperandAt(0, object);
+ SetOperandAt(1, value);
SetOperandAt(2, context);
SetAllSideEffects();
}
- HValue* context() const { return context_; }
- HValue* object() const { return operands_[0]; }
- HValue* value() const { return operands_[1]; }
+ HValue* object() { return OperandAt(0); }
+ HValue* value() { return OperandAt(1); }
+ HValue* context() { return OperandAt(2); }
+ Handle<String> name() { return name_; }
- virtual int OperandCount() const { return 3; }
+ virtual void PrintDataTo(StringStream* stream);
- virtual HValue* OperandAt(int index) const {
- return (index < 2) ? operands_[index] : context_;
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
}
DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store_named_generic")
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value);
-
private:
- HValue* context_;
+ Handle<String> name_;
};
-class HStoreKeyed: public HInstruction {
+class HStoreKeyedFastElement: public HTemplateInstruction<3> {
public:
- HStoreKeyed(HValue* obj, HValue* key, HValue* val) {
+ HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val) {
SetOperandAt(0, obj);
SetOperandAt(1, key);
SetOperandAt(2, val);
+ SetFlag(kChangesArrayElements);
}
- virtual void PrintDataTo(StringStream* stream) const;
- virtual int OperandCount() const { return operands_.length(); }
- virtual HValue* OperandAt(int index) const { return operands_[index]; }
-
virtual Representation RequiredInputRepresentation(int index) const {
- return Representation::Tagged();
+ // The key is supposed to be Integer32.
+ return (index == 1) ? Representation::Integer32()
+ : Representation::Tagged();
}
- HValue* object() const { return OperandAt(0); }
- HValue* key() const { return OperandAt(1); }
- HValue* value() const { return OperandAt(2); }
+ HValue* object() { return OperandAt(0); }
+ HValue* key() { return OperandAt(1); }
+ HValue* value() { return OperandAt(2); }
- bool NeedsWriteBarrier() const {
+ bool NeedsWriteBarrier() {
return StoringValueNeedsWriteBarrier(value());
}
- DECLARE_INSTRUCTION(StoreKeyed)
+ virtual void PrintDataTo(StringStream* stream);
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- operands_[index] = value;
- }
-
- HOperandVector<3> operands_;
+ DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
+ "store_keyed_fast_element")
};
-class HStoreKeyedFastElement: public HStoreKeyed {
+class HStorePixelArrayElement: public HTemplateInstruction<3> {
public:
- HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val)
- : HStoreKeyed(obj, key, val) {
- SetFlag(kChangesArrayElements);
+ HStorePixelArrayElement(HValue* external_elements, HValue* key, HValue* val) {
+ SetFlag(kChangesPixelArrayElements);
+ SetOperandAt(0, external_elements);
+ SetOperandAt(1, key);
+ SetOperandAt(2, val);
}
+ virtual void PrintDataTo(StringStream* stream);
+
virtual Representation RequiredInputRepresentation(int index) const {
- // The key is supposed to be Integer32.
- return (index == 1) ? Representation::Integer32()
- : Representation::Tagged();
+ if (index == 0) {
+ return Representation::External();
+ } else {
+ return Representation::Integer32();
+ }
}
- DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
- "store_keyed_fast_element")
+ HValue* external_pointer() { return OperandAt(0); }
+ HValue* key() { return OperandAt(1); }
+ HValue* value() { return OperandAt(2); }
+
+ DECLARE_CONCRETE_INSTRUCTION(StorePixelArrayElement,
+ "store_pixel_array_element")
};
-class HStoreKeyedGeneric: public HStoreKeyed {
+class HStoreKeyedGeneric: public HTemplateInstruction<4> {
public:
HStoreKeyedGeneric(HValue* context,
HValue* object,
HValue* key,
- HValue* value)
- : HStoreKeyed(object, key, value), context_(NULL) {
+ HValue* value) {
+ SetOperandAt(0, object);
+ SetOperandAt(1, key);
+ SetOperandAt(2, value);
SetOperandAt(3, context);
SetAllSideEffects();
}
- HValue* context() const { return context_; }
- HValue* object() const { return operands_[0]; }
- HValue* key() const { return operands_[1]; }
- HValue* value() const { return operands_[2]; }
+ HValue* object() { return OperandAt(0); }
+ HValue* key() { return OperandAt(1); }
+ HValue* value() { return OperandAt(2); }
+ HValue* context() { return OperandAt(3); }
- virtual int OperandCount() const { return 4; }
-
- virtual HValue* OperandAt(int index) const {
- return (index < 3) ? operands_[index] : context_;
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
}
+ virtual void PrintDataTo(StringStream* stream);
+
DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store_keyed_generic")
-
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value);
-
- private:
- HValue* context_;
};
@@ -3216,13 +3255,13 @@
: Representation::Tagged();
}
- HValue* string() const { return OperandAt(0); }
- HValue* index() const { return OperandAt(1); }
+ HValue* string() { return OperandAt(0); }
+ HValue* index() { return OperandAt(1); }
DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string_char_code_at")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange() {
return new Range(0, String::kMaxUC16CharCode);
@@ -3230,6 +3269,23 @@
};
+class HStringCharFromCode: public HUnaryOperation {
+ public:
+ explicit HStringCharFromCode(HValue* char_code) : HUnaryOperation(char_code) {
+ set_representation(Representation::Tagged());
+ SetFlag(kUseGVN);
+ }
+
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Integer32();
+ }
+
+ virtual bool DataEquals(HValue* other) { return true; }
+
+ DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string_char_from_code")
+};
+
+
class HStringLength: public HUnaryOperation {
public:
explicit HStringLength(HValue* string) : HUnaryOperation(string) {
@@ -3241,7 +3297,7 @@
return Representation::Tagged();
}
- virtual HType CalculateInferredType() const {
+ virtual HType CalculateInferredType() {
STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
return HType::Smi();
}
@@ -3249,7 +3305,7 @@
DECLARE_CONCRETE_INSTRUCTION(StringLength, "string_length")
protected:
- virtual bool DataEquals(HValue* other) const { return true; }
+ virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange() {
return new Range(0, String::kMaxLength);
@@ -3257,31 +3313,30 @@
};
-class HMaterializedLiteral: public HInstruction {
+template <int V>
+class HMaterializedLiteral: public HTemplateInstruction<V> {
public:
- HMaterializedLiteral(int index, int depth)
+ HMaterializedLiteral<V>(int index, int depth)
: literal_index_(index), depth_(depth) {
- set_representation(Representation::Tagged());
+ this->set_representation(Representation::Tagged());
}
int literal_index() const { return literal_index_; }
int depth() const { return depth_; }
- DECLARE_INSTRUCTION(MaterializedLiteral)
-
private:
int literal_index_;
int depth_;
};
-class HArrayLiteral: public HMaterializedLiteral {
+class HArrayLiteral: public HMaterializedLiteral<0> {
public:
HArrayLiteral(Handle<FixedArray> constant_elements,
int length,
int literal_index,
int depth)
- : HMaterializedLiteral(literal_index, depth),
+ : HMaterializedLiteral<0>(literal_index, depth),
length_(length),
constant_elements_(constant_elements) {}
@@ -3290,6 +3345,10 @@
bool IsCopyOnWrite() const;
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array_literal")
private:
@@ -3298,55 +3357,53 @@
};
-class HObjectLiteral: public HMaterializedLiteral {
+class HObjectLiteral: public HMaterializedLiteral<1> {
public:
HObjectLiteral(HValue* context,
Handle<FixedArray> constant_properties,
bool fast_elements,
int literal_index,
int depth)
- : HMaterializedLiteral(literal_index, depth),
- context_(NULL),
+ : HMaterializedLiteral<1>(literal_index, depth),
constant_properties_(constant_properties),
fast_elements_(fast_elements) {
SetOperandAt(0, context);
}
- HValue* context() const { return context_; }
+ HValue* context() { return OperandAt(0); }
Handle<FixedArray> constant_properties() const {
return constant_properties_;
}
bool fast_elements() const { return fast_elements_; }
- virtual int OperandCount() const { return 1; }
- virtual HValue* OperandAt(int index) const { return context_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object_literal")
- protected:
- virtual void InternalSetOperandAt(int index, HValue* value) {
- context_ = value;
- }
-
private:
- HValue* context_;
Handle<FixedArray> constant_properties_;
bool fast_elements_;
};
-class HRegExpLiteral: public HMaterializedLiteral {
+class HRegExpLiteral: public HMaterializedLiteral<0> {
public:
HRegExpLiteral(Handle<String> pattern,
Handle<String> flags,
int literal_index)
- : HMaterializedLiteral(literal_index, 0),
+ : HMaterializedLiteral<0>(literal_index, 0),
pattern_(pattern),
flags_(flags) { }
Handle<String> pattern() { return pattern_; }
Handle<String> flags() { return flags_; }
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp_literal")
private:
@@ -3355,13 +3412,17 @@
};
-class HFunctionLiteral: public HInstruction {
+class HFunctionLiteral: public HTemplateInstruction<0> {
public:
HFunctionLiteral(Handle<SharedFunctionInfo> shared, bool pretenure)
: shared_info_(shared), pretenure_(pretenure) {
set_representation(Representation::Tagged());
}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::None();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function_literal")
Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
@@ -3393,6 +3454,10 @@
set_representation(Representation::Tagged());
}
+ virtual Representation RequiredInputRepresentation(int index) const {
+ return Representation::Tagged();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value_of")
};
@@ -3411,8 +3476,8 @@
DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete_property")
- HValue* object() const { return left(); }
- HValue* key() const { return right(); }
+ HValue* object() { return left(); }
+ HValue* key() { return right(); }
};
#undef DECLARE_INSTRUCTION
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698