Reviewers: Toon Verwaest, Sven Panne,
Description:
Remove Uninitialized from HType.
BUG=
Please review this at https://codereview.chromium.org/20711002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen-instructions.h
M src/hydrogen-instructions.cc
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index
707e81842f8364ac000a742f936b2b6b38838762..c485736b6bce724eea94feb5dad4ef44df8f3d05
100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -435,7 +435,6 @@ const char* HType::ToString() {
case kNonPrimitive: return "non-primitive";
case kJSArray: return "array";
case kJSObject: return "object";
- case kUninitialized: return "uninitialized";
}
UNREACHABLE();
return "unreachable";
@@ -1609,9 +1608,7 @@ HValue* HUnaryMathOperation::Canonicalize() {
HValue* HCheckInstanceType::Canonicalize() {
- if (check_ == IS_STRING &&
- !value()->type().IsUninitialized() &&
- value()->type().IsString()) {
+ if (check_ == IS_STRING && value()->type().IsString()) {
return NULL;
}
@@ -2611,6 +2608,8 @@ HConstant::HConstant(Handle<Object> handle,
Representation r)
is_not_in_new_space_(true),
is_cell_(false),
boolean_value_(handle->BooleanValue()) {
+ set_type(HType::TypeFromValue(handle));
+
if (handle_->IsHeapObject()) {
Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap();
is_not_in_new_space_ = !heap->InNewSpace(*handle);
@@ -2623,7 +2622,6 @@ HConstant::HConstant(Handle<Object> handle,
Representation r)
double_value_ = n;
has_double_value_ = true;
} else {
- type_from_value_ = HType::TypeFromValue(handle_);
is_internalized_string_ = handle_->IsInternalizedString();
}
@@ -2649,11 +2647,10 @@ HConstant::HConstant(Handle<Object> handle,
is_internalized_string_(is_internalize_string),
is_not_in_new_space_(is_not_in_new_space),
is_cell_(is_cell),
- boolean_value_(boolean_value),
- type_from_value_(type) {
+ boolean_value_(boolean_value) {
ASSERT(!handle.is_null());
- ASSERT(!type.IsUninitialized());
ASSERT(!type.IsTaggedNumber());
+ set_type(type);
Initialize(r);
}
@@ -2664,6 +2661,7 @@ HConstant::HConstant(int32_t integer_value,
Handle<Object> optional_handle)
: handle_(optional_handle),
unique_id_(),
+ has_smi_value_(Smi::IsValid(integer_value)),
has_int32_value_(true),
has_double_value_(true),
is_internalized_string_(false),
@@ -2672,7 +2670,7 @@ HConstant::HConstant(int32_t integer_value,
boolean_value_(integer_value != 0),
int32_value_(integer_value),
double_value_(FastI2D(integer_value)) {
- has_smi_value_ = Smi::IsValid(int32_value_);
+ set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber());
Initialize(r);
}
@@ -2692,6 +2690,7 @@ HConstant::HConstant(double double_value,
int32_value_(DoubleToInt32(double_value)),
double_value_(double_value) {
has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
+ set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber());
Initialize(r);
}
@@ -2738,7 +2737,7 @@ HConstant*
HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
return new(zone) HConstant(handle_,
unique_id_,
r,
- type_from_value_,
+ type_,
is_internalized_string_,
is_not_in_new_space_,
is_cell_,
@@ -3610,8 +3609,9 @@ HType HCheckSmi::CalculateInferredType() {
HType HPhi::CalculateInferredType() {
- HType result = HType::Uninitialized();
- for (int i = 0; i < OperandCount(); ++i) {
+ if (OperandCount() == 0) return HType::Tagged();
+ HType result = OperandAt(0)->type();
+ for (int i = 1; i < OperandCount(); ++i) {
HType current = OperandAt(i)->type();
result = result.Combine(current);
}
@@ -3619,16 +3619,6 @@ HType HPhi::CalculateInferredType() {
}
-HType HConstant::CalculateInferredType() {
- if (has_int32_value_) {
- return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber();
- }
- if (has_double_value_) return HType::HeapNumber();
- ASSERT(!type_from_value_.IsUninitialized());
- return type_from_value_;
-}
-
-
HType HCompareGeneric::CalculateInferredType() {
return HType::Boolean();
}
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
b43efc80baa9cb111b764a375e656ab9f522538e..5d1bcd58b844b0372d2ab43aa9e86ed84c066639
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -350,8 +350,6 @@ class UniqueValueId {
class HType {
public:
- HType() : type_(kUninitialized) { }
-
static HType Tagged() { return HType(kTagged); }
static HType TaggedPrimitive() { return HType(kTaggedPrimitive); }
static HType TaggedNumber() { return HType(kTaggedNumber); }
@@ -362,7 +360,6 @@ class HType {
static HType NonPrimitive() { return HType(kNonPrimitive); }
static HType JSArray() { return HType(kJSArray); }
static HType JSObject() { return HType(kJSObject); }
- static HType Uninitialized() { return HType(kUninitialized); }
// Return the weakest (least precise) common type.
HType Combine(HType other) {
@@ -378,32 +375,26 @@ class HType {
}
bool IsTagged() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kTagged) == kTagged);
}
bool IsTaggedPrimitive() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kTaggedPrimitive) == kTaggedPrimitive);
}
bool IsTaggedNumber() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kTaggedNumber) == kTaggedNumber);
}
bool IsSmi() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kSmi) == kSmi);
}
bool IsHeapNumber() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kHeapNumber) == kHeapNumber);
}
bool IsString() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kString) == kString);
}
@@ -413,31 +404,22 @@ class HType {
}
bool IsBoolean() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kBoolean) == kBoolean);
}
bool IsNonPrimitive() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kNonPrimitive) == kNonPrimitive);
}
bool IsJSArray() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kJSArray) == kJSArray);
}
bool IsJSObject() const {
- ASSERT(type_ != kUninitialized);
return ((type_ & kJSObject) == kJSObject);
}
- bool IsUninitialized() const {
- return type_ == kUninitialized;
- }
-
bool IsHeapObject() const {
- ASSERT(type_ != kUninitialized);
return IsHeapNumber() || IsString() || IsBoolean() || IsNonPrimitive();
}
@@ -456,12 +438,11 @@ class HType {
kBoolean = 0x85, // 0000 0000 1000 0101
kNonPrimitive = 0x101, // 0000 0001 0000 0001
kJSObject = 0x301, // 0000 0011 0000 0001
- kJSArray = 0x701, // 0000 0111 0000 0001
- kUninitialized = 0x1fff // 0001 1111 1111 1111
+ kJSArray = 0x701 // 0000 0111 0000 0001
};
// Make sure type fits in int16.
- STATIC_ASSERT(kUninitialized < (1 << (2 * kBitsPerByte)));
+ STATIC_ASSERT(kJSArray < (1 << (2 * kBitsPerByte)));
explicit HType(Type t) : type_(t) { }
@@ -2930,11 +2911,7 @@ class HCheckHeapObject: public HUnaryOperation {
#endif
virtual HValue* Canonicalize() {
- HType value_type = value()->type();
- if (!value_type.IsUninitialized() && value_type.IsHeapObject()) {
- return NULL;
- }
- return this;
+ return value()->type().IsHeapObject() ? NULL : this;
}
DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject)
@@ -3533,7 +3510,6 @@ class HConstant: public HTemplateInstruction<0> {
virtual bool EmitAtUses();
virtual void PrintDataTo(StringStream* stream);
- virtual HType CalculateInferredType();
bool IsInteger() { return handle()->IsSmi(); }
HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone);
@@ -3570,7 +3546,7 @@ class HConstant: public HTemplateInstruction<0> {
bool HasStringValue() const {
if (has_double_value_ || has_int32_value_) return false;
ASSERT(!handle_.is_null());
- return type_from_value_.IsString();
+ return type_.IsString();
}
Handle<String> StringValue() const {
ASSERT(HasStringValue());
@@ -3655,7 +3631,6 @@ class HConstant: public HTemplateInstruction<0> {
bool boolean_value_ : 1;
int32_t int32_value_;
double double_value_;
- HType type_from_value_;
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.