Remove Uninitialized from HType.

BUG=
R=verwaest@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15925 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
titzer@chromium.org 2013-07-29 09:42:57 +00:00
parent 45e77c2b66
commit f403969d1f
2 changed files with 16 additions and 51 deletions

View File

@ -458,7 +458,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";
@ -1632,9 +1631,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;
}
@ -2651,6 +2648,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);
@ -2663,7 +2662,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();
}
@ -2689,11 +2687,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);
}
@ -2704,6 +2701,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),
@ -2712,7 +2710,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);
}
@ -2732,6 +2730,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);
}
@ -2778,7 +2777,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_,
@ -3653,8 +3652,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);
}
@ -3662,16 +3662,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();
}

View File

@ -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) { }
@ -2937,11 +2918,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)
@ -3540,7 +3517,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);
@ -3577,7 +3553,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());
@ -3662,7 +3638,6 @@ class HConstant: public HTemplateInstruction<0> {
bool boolean_value_ : 1;
int32_t int32_value_;
double double_value_;
HType type_from_value_;
};