Commit 44e4c275 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Avoid the use of set_type() in instruction constructors.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/21348002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15984 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8823e8e8
...@@ -2640,7 +2640,8 @@ static bool IsInteger32(double value) { ...@@ -2640,7 +2640,8 @@ static bool IsInteger32(double value) {
HConstant::HConstant(Handle<Object> handle, Representation r) HConstant::HConstant(Handle<Object> handle, Representation r)
: handle_(handle), : HTemplateInstruction<0>(HType::TypeFromValue(handle)),
handle_(handle),
unique_id_(), unique_id_(),
has_smi_value_(false), has_smi_value_(false),
has_int32_value_(false), has_int32_value_(false),
...@@ -2650,8 +2651,6 @@ HConstant::HConstant(Handle<Object> handle, Representation r) ...@@ -2650,8 +2651,6 @@ HConstant::HConstant(Handle<Object> handle, Representation r)
is_not_in_new_space_(true), is_not_in_new_space_(true),
is_cell_(false), is_cell_(false),
boolean_value_(handle->BooleanValue()) { boolean_value_(handle->BooleanValue()) {
set_type(HType::TypeFromValue(handle));
if (handle_->IsHeapObject()) { if (handle_->IsHeapObject()) {
Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap();
is_not_in_new_space_ = !heap->InNewSpace(*handle); is_not_in_new_space_ = !heap->InNewSpace(*handle);
...@@ -2681,7 +2680,8 @@ HConstant::HConstant(Handle<Object> handle, ...@@ -2681,7 +2680,8 @@ HConstant::HConstant(Handle<Object> handle,
bool is_not_in_new_space, bool is_not_in_new_space,
bool is_cell, bool is_cell,
bool boolean_value) bool boolean_value)
: handle_(handle), : HTemplateInstruction<0>(type),
handle_(handle),
unique_id_(unique_id), unique_id_(unique_id),
has_smi_value_(false), has_smi_value_(false),
has_int32_value_(false), has_int32_value_(false),
...@@ -2693,7 +2693,6 @@ HConstant::HConstant(Handle<Object> handle, ...@@ -2693,7 +2693,6 @@ HConstant::HConstant(Handle<Object> handle,
boolean_value_(boolean_value) { boolean_value_(boolean_value) {
ASSERT(!handle.is_null()); ASSERT(!handle.is_null());
ASSERT(!type.IsTaggedNumber()); ASSERT(!type.IsTaggedNumber());
set_type(type);
Initialize(r); Initialize(r);
} }
......
...@@ -1451,12 +1451,12 @@ class HBlockEntry: public HTemplateInstruction<0> { ...@@ -1451,12 +1451,12 @@ class HBlockEntry: public HTemplateInstruction<0> {
class HDummyUse: public HTemplateInstruction<1> { class HDummyUse: public HTemplateInstruction<1> {
public: public:
explicit HDummyUse(HValue* value) { explicit HDummyUse(HValue* value)
: HTemplateInstruction<1>(HType::Smi()) {
SetOperandAt(0, value); SetOperandAt(0, value);
// Pretend to be a Smi so that the HChange instructions inserted // Pretend to be a Smi so that the HChange instructions inserted
// before any use generate as little code as possible. // before any use generate as little code as possible.
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
set_type(HType::Smi());
} }
HValue* value() { return OperandAt(0); } HValue* value() { return OperandAt(0); }
...@@ -1665,7 +1665,8 @@ class HAbnormalExit: public HTemplateControlInstruction<0, 0> { ...@@ -1665,7 +1665,8 @@ class HAbnormalExit: public HTemplateControlInstruction<0, 0> {
class HUnaryOperation: public HTemplateInstruction<1> { class HUnaryOperation: public HTemplateInstruction<1> {
public: public:
explicit HUnaryOperation(HValue* value) { HUnaryOperation(HValue* value, HType type = HType::Tagged())
: HTemplateInstruction<1>(type) {
SetOperandAt(0, value); SetOperandAt(0, value);
} }
...@@ -2510,8 +2511,8 @@ class HCallRuntime: public HCall<1> { ...@@ -2510,8 +2511,8 @@ class HCallRuntime: public HCall<1> {
class HMapEnumLength: public HUnaryOperation { class HMapEnumLength: public HUnaryOperation {
public: public:
explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) { explicit HMapEnumLength(HValue* value)
set_type(HType::Smi()); : HUnaryOperation(value, HType::Smi()) {
set_representation(Representation::Smi()); set_representation(Representation::Smi());
SetFlag(kUseGVN); SetFlag(kUseGVN);
SetGVNFlag(kDependsOnMaps); SetGVNFlag(kDependsOnMaps);
...@@ -2555,12 +2556,12 @@ class HElementsKind: public HUnaryOperation { ...@@ -2555,12 +2556,12 @@ class HElementsKind: public HUnaryOperation {
class HBitNot: public HUnaryOperation { class HBitNot: public HUnaryOperation {
public: public:
explicit HBitNot(HValue* value) : HUnaryOperation(value) { explicit HBitNot(HValue* value)
: HUnaryOperation(value, HType::TaggedNumber()) {
set_representation(Representation::Integer32()); set_representation(Representation::Integer32());
SetFlag(kUseGVN); SetFlag(kUseGVN);
SetFlag(kTruncatingToInt32); SetFlag(kTruncatingToInt32);
SetFlag(kAllowUndefinedAsNaN); SetFlag(kAllowUndefinedAsNaN);
set_type(HType::TaggedNumber());
} }
virtual Representation RequiredInputRepresentation(int index) { virtual Representation RequiredInputRepresentation(int index) {
...@@ -2638,7 +2639,7 @@ class HUnaryMathOperation: public HTemplateInstruction<2> { ...@@ -2638,7 +2639,7 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
private: private:
HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op)
: op_(op) { : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) {
SetOperandAt(0, context); SetOperandAt(0, context);
SetOperandAt(1, value); SetOperandAt(1, value);
switch (op) { switch (op) {
...@@ -2672,7 +2673,6 @@ class HUnaryMathOperation: public HTemplateInstruction<2> { ...@@ -2672,7 +2673,6 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
} }
SetFlag(kUseGVN); SetFlag(kUseGVN);
SetFlag(kAllowUndefinedAsNaN); SetFlag(kAllowUndefinedAsNaN);
set_type(HType::TaggedNumber());
} }
virtual bool IsDeletable() const { return true; } virtual bool IsDeletable() const { return true; }
...@@ -2761,7 +2761,8 @@ class HCheckMaps: public HTemplateInstruction<2> { ...@@ -2761,7 +2761,8 @@ class HCheckMaps: public HTemplateInstruction<2> {
private: private:
// Clients should use one of the static New* methods above. // Clients should use one of the static New* methods above.
HCheckMaps(HValue* value, Zone *zone, HValue* typecheck) HCheckMaps(HValue* value, Zone *zone, HValue* typecheck)
: omit_(false), map_unique_ids_(0, zone) { : HTemplateInstruction<2>(value->type()),
omit_(false), map_unique_ids_(0, zone) {
SetOperandAt(0, value); SetOperandAt(0, value);
// Use the object value for the dependency if NULL is passed. // Use the object value for the dependency if NULL is passed.
// TODO(titzer): do GVN flags already express this dependency? // TODO(titzer): do GVN flags already express this dependency?
...@@ -2771,7 +2772,6 @@ class HCheckMaps: public HTemplateInstruction<2> { ...@@ -2771,7 +2772,6 @@ class HCheckMaps: public HTemplateInstruction<2> {
SetFlag(kTrackSideEffectDominators); SetFlag(kTrackSideEffectDominators);
SetGVNFlag(kDependsOnMaps); SetGVNFlag(kDependsOnMaps);
SetGVNFlag(kDependsOnElementsKind); SetGVNFlag(kDependsOnElementsKind);
set_type(value->type());
} }
void omit(CompilationInfo* info) { void omit(CompilationInfo* info) {
...@@ -2792,11 +2792,11 @@ class HCheckMaps: public HTemplateInstruction<2> { ...@@ -2792,11 +2792,11 @@ class HCheckMaps: public HTemplateInstruction<2> {
class HCheckFunction: public HUnaryOperation { class HCheckFunction: public HUnaryOperation {
public: public:
HCheckFunction(HValue* value, Handle<JSFunction> function) HCheckFunction(HValue* value, Handle<JSFunction> function)
: HUnaryOperation(value), target_(function), target_unique_id_() { : HUnaryOperation(value, value->type()),
target_(function), target_unique_id_() {
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetFlag(kUseGVN); SetFlag(kUseGVN);
target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function); target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function);
set_type(value->type());
} }
virtual Representation RequiredInputRepresentation(int index) { virtual Representation RequiredInputRepresentation(int index) {
...@@ -2894,10 +2894,9 @@ class HCheckInstanceType: public HUnaryOperation { ...@@ -2894,10 +2894,9 @@ class HCheckInstanceType: public HUnaryOperation {
class HCheckSmi: public HUnaryOperation { class HCheckSmi: public HUnaryOperation {
public: public:
explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { explicit HCheckSmi(HValue* value) : HUnaryOperation(value, HType::Smi()) {
set_representation(Representation::Smi()); set_representation(Representation::Smi());
SetFlag(kUseGVN); SetFlag(kUseGVN);
set_type(HType::Smi());
} }
virtual Representation RequiredInputRepresentation(int index) { virtual Representation RequiredInputRepresentation(int index) {
...@@ -2936,10 +2935,10 @@ class HIsNumberAndBranch: public HUnaryControlInstruction { ...@@ -2936,10 +2935,10 @@ class HIsNumberAndBranch: public HUnaryControlInstruction {
class HCheckHeapObject: public HUnaryOperation { class HCheckHeapObject: public HUnaryOperation {
public: public:
explicit HCheckHeapObject(HValue* value) : HUnaryOperation(value) { explicit HCheckHeapObject(HValue* value)
: HUnaryOperation(value, HType::NonPrimitive()) {
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetFlag(kUseGVN); SetFlag(kUseGVN);
set_type(HType::NonPrimitive());
} }
virtual Representation RequiredInputRepresentation(int index) { virtual Representation RequiredInputRepresentation(int index) {
...@@ -3694,8 +3693,10 @@ class HConstant: public HTemplateInstruction<0> { ...@@ -3694,8 +3693,10 @@ class HConstant: public HTemplateInstruction<0> {
class HBinaryOperation: public HTemplateInstruction<3> { class HBinaryOperation: public HTemplateInstruction<3> {
public: public:
HBinaryOperation(HValue* context, HValue* left, HValue* right) HBinaryOperation(HValue* context, HValue* left, HValue* right,
: observed_output_representation_(Representation::None()) { HType type = HType::Tagged())
: HTemplateInstruction<3>(type),
observed_output_representation_(Representation::None()) {
ASSERT(left != NULL && right != NULL); ASSERT(left != NULL && right != NULL);
SetOperandAt(0, context); SetOperandAt(0, context);
SetOperandAt(1, left); SetOperandAt(1, left);
...@@ -4046,8 +4047,9 @@ class HBoundsCheckBaseIndexInformation: public HTemplateInstruction<2> { ...@@ -4046,8 +4047,9 @@ class HBoundsCheckBaseIndexInformation: public HTemplateInstruction<2> {
class HBitwiseBinaryOperation: public HBinaryOperation { class HBitwiseBinaryOperation: public HBinaryOperation {
public: public:
HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right,
: HBinaryOperation(context, left, right) { HType type = HType::Tagged())
: HBinaryOperation(context, left, right, type) {
SetFlag(kFlexibleRepresentation); SetFlag(kFlexibleRepresentation);
SetFlag(kTruncatingToInt32); SetFlag(kTruncatingToInt32);
SetFlag(kAllowUndefinedAsNaN); SetFlag(kAllowUndefinedAsNaN);
...@@ -4123,11 +4125,10 @@ class HMathFloorOfDiv: public HBinaryOperation { ...@@ -4123,11 +4125,10 @@ class HMathFloorOfDiv: public HBinaryOperation {
class HArithmeticBinaryOperation: public HBinaryOperation { class HArithmeticBinaryOperation: public HBinaryOperation {
public: public:
HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right)
: HBinaryOperation(context, left, right) { : HBinaryOperation(context, left, right, HType::TaggedNumber()) {
SetAllSideEffects(); SetAllSideEffects();
SetFlag(kFlexibleRepresentation); SetFlag(kFlexibleRepresentation);
SetFlag(kAllowUndefinedAsNaN); SetFlag(kAllowUndefinedAsNaN);
set_type(HType::TaggedNumber());
} }
virtual void RepresentationChanged(Representation to) { virtual void RepresentationChanged(Representation to) {
...@@ -4153,10 +4154,10 @@ class HCompareGeneric: public HBinaryOperation { ...@@ -4153,10 +4154,10 @@ class HCompareGeneric: public HBinaryOperation {
HValue* left, HValue* left,
HValue* right, HValue* right,
Token::Value token) Token::Value token)
: HBinaryOperation(context, left, right), token_(token) { : HBinaryOperation(context, left, right, HType::Boolean()),
token_(token) {
ASSERT(Token::IsCompareOp(token)); ASSERT(Token::IsCompareOp(token));
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
set_type(HType::Boolean());
SetAllSideEffects(); SetAllSideEffects();
} }
...@@ -4444,9 +4445,8 @@ class HTypeofIsAndBranch: public HUnaryControlInstruction { ...@@ -4444,9 +4445,8 @@ class HTypeofIsAndBranch: public HUnaryControlInstruction {
class HInstanceOf: public HBinaryOperation { class HInstanceOf: public HBinaryOperation {
public: public:
HInstanceOf(HValue* context, HValue* left, HValue* right) HInstanceOf(HValue* context, HValue* left, HValue* right)
: HBinaryOperation(context, left, right) { : HBinaryOperation(context, left, right, HType::Boolean()) {
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
set_type(HType::Boolean());
SetAllSideEffects(); SetAllSideEffects();
} }
...@@ -4465,10 +4465,9 @@ class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { ...@@ -4465,10 +4465,9 @@ class HInstanceOfKnownGlobal: public HTemplateInstruction<2> {
HInstanceOfKnownGlobal(HValue* context, HInstanceOfKnownGlobal(HValue* context,
HValue* left, HValue* left,
Handle<JSFunction> right) Handle<JSFunction> right)
: function_(right) { : HTemplateInstruction<2>(HType::Boolean()), function_(right) {
SetOperandAt(0, context); SetOperandAt(0, context);
SetOperandAt(1, left); SetOperandAt(1, left);
set_type(HType::Boolean());
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetAllSideEffects(); SetAllSideEffects();
} }
...@@ -4869,7 +4868,8 @@ class HBitwise: public HBitwiseBinaryOperation { ...@@ -4869,7 +4868,8 @@ class HBitwise: public HBitwiseBinaryOperation {
private: private:
HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right)
: HBitwiseBinaryOperation(context, left, right), op_(op) { : HBitwiseBinaryOperation(context, left, right, HType::TaggedNumber()),
op_(op) {
ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR);
// BIT_AND with a smi-range positive value will always unset the // BIT_AND with a smi-range positive value will always unset the
// entire sign-extension of the smi-sign. // entire sign-extension of the smi-sign.
...@@ -4892,7 +4892,6 @@ class HBitwise: public HBitwiseBinaryOperation { ...@@ -4892,7 +4892,6 @@ class HBitwise: public HBitwiseBinaryOperation {
HConstant::cast(right)->Integer32Value() < 0))) { HConstant::cast(right)->Integer32Value() < 0))) {
SetFlag(kTruncatingToSmi); SetFlag(kTruncatingToSmi);
} }
set_type(HType::TaggedNumber());
} }
Token::Value op_; Token::Value op_;
...@@ -5234,10 +5233,10 @@ class HAllocate: public HTemplateInstruction<2> { ...@@ -5234,10 +5233,10 @@ class HAllocate: public HTemplateInstruction<2> {
HValue* size, HValue* size,
HType type, HType type,
bool pretenure, bool pretenure,
ElementsKind kind = FAST_ELEMENTS) { ElementsKind kind = FAST_ELEMENTS)
: HTemplateInstruction<2>(type) {
SetOperandAt(0, context); SetOperandAt(0, context);
SetOperandAt(1, size); SetOperandAt(1, size);
set_type(type);
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetFlag(kTrackSideEffectDominators); SetFlag(kTrackSideEffectDominators);
SetGVNFlag(kChangesNewSpacePromotion); SetGVNFlag(kChangesNewSpacePromotion);
...@@ -5336,10 +5335,9 @@ class HAllocate: public HTemplateInstruction<2> { ...@@ -5336,10 +5335,9 @@ class HAllocate: public HTemplateInstruction<2> {
class HInnerAllocatedObject: public HTemplateInstruction<1> { class HInnerAllocatedObject: public HTemplateInstruction<1> {
public: public:
HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged())
: offset_(offset) { : HTemplateInstruction<1>(type), offset_(offset) {
ASSERT(value->IsAllocate()); ASSERT(value->IsAllocate());
SetOperandAt(0, value); SetOperandAt(0, value);
set_type(type);
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
} }
...@@ -6477,12 +6475,11 @@ class HStringAdd: public HBinaryOperation { ...@@ -6477,12 +6475,11 @@ class HStringAdd: public HBinaryOperation {
private: private:
HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags) HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags)
: HBinaryOperation(context, left, right), flags_(flags) { : HBinaryOperation(context, left, right, HType::String()), flags_(flags) {
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetFlag(kUseGVN); SetFlag(kUseGVN);
SetGVNFlag(kDependsOnMaps); SetGVNFlag(kDependsOnMaps);
SetGVNFlag(kChangesNewSpacePromotion); SetGVNFlag(kChangesNewSpacePromotion);
set_type(HType::String());
} }
// No side-effects except possible allocation. // No side-effects except possible allocation.
...@@ -6551,13 +6548,13 @@ class HStringCharFromCode: public HTemplateInstruction<2> { ...@@ -6551,13 +6548,13 @@ class HStringCharFromCode: public HTemplateInstruction<2> {
DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode)
private: private:
HStringCharFromCode(HValue* context, HValue* char_code) { HStringCharFromCode(HValue* context, HValue* char_code)
: HTemplateInstruction<2>(HType::String()) {
SetOperandAt(0, context); SetOperandAt(0, context);
SetOperandAt(1, char_code); SetOperandAt(1, char_code);
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetFlag(kUseGVN); SetFlag(kUseGVN);
SetGVNFlag(kChangesNewSpacePromotion); SetGVNFlag(kChangesNewSpacePromotion);
set_type(HType::String());
} }
virtual bool IsDeletable() const { virtual bool IsDeletable() const {
...@@ -6584,12 +6581,12 @@ class HStringLength: public HUnaryOperation { ...@@ -6584,12 +6581,12 @@ class HStringLength: public HUnaryOperation {
} }
private: private:
explicit HStringLength(HValue* string) : HUnaryOperation(string) { explicit HStringLength(HValue* string)
: HUnaryOperation(string, HType::Smi()) {
STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetFlag(kUseGVN); SetFlag(kUseGVN);
SetGVNFlag(kDependsOnMaps); SetGVNFlag(kDependsOnMaps);
set_type(HType::Smi());
} }
virtual bool IsDeletable() const { return true; } virtual bool IsDeletable() const { return true; }
...@@ -6664,13 +6661,13 @@ class HFunctionLiteral: public HTemplateInstruction<1> { ...@@ -6664,13 +6661,13 @@ class HFunctionLiteral: public HTemplateInstruction<1> {
HFunctionLiteral(HValue* context, HFunctionLiteral(HValue* context,
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
bool pretenure) bool pretenure)
: shared_info_(shared), : HTemplateInstruction<1>(HType::JSObject()),
shared_info_(shared),
pretenure_(pretenure), pretenure_(pretenure),
has_no_literals_(shared->num_literals() == 0), has_no_literals_(shared->num_literals() == 0),
is_generator_(shared->is_generator()), is_generator_(shared->is_generator()),
language_mode_(shared->language_mode()) { language_mode_(shared->language_mode()) {
SetOperandAt(0, context); SetOperandAt(0, context);
set_type(HType::JSObject());
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetGVNFlag(kChangesNewSpacePromotion); SetGVNFlag(kChangesNewSpacePromotion);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment