Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index 707e81842f8364ac000a742f936b2b6b38838762..f8c1ebe28d770c62763454586896e5d4496beeab 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -425,6 +425,7 @@ const char* HType::ToString() { |
// Note: The c1visualizer syntax for locals allows only a sequence of the |
// following characters: A-Za-z0-9_-|: |
switch (type_) { |
+ case kNone: return "none"; |
case kTagged: return "tagged"; |
case kTaggedPrimitive: return "primitive"; |
case kTaggedNumber: return "number"; |
@@ -2607,6 +2608,7 @@ HConstant::HConstant(Handle<Object> handle, Representation r) |
has_smi_value_(false), |
has_int32_value_(false), |
has_double_value_(false), |
+ has_external_value_(false), |
is_internalized_string_(false), |
is_not_in_new_space_(true), |
is_cell_(false), |
@@ -2641,16 +2643,17 @@ HConstant::HConstant(Handle<Object> handle, |
bool is_not_in_new_space, |
bool is_cell, |
bool boolean_value) |
- : handle_(handle), |
- unique_id_(unique_id), |
- has_smi_value_(false), |
- has_int32_value_(false), |
- has_double_value_(false), |
- 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) { |
+ : handle_(handle), |
+ unique_id_(unique_id), |
+ has_smi_value_(false), |
+ has_int32_value_(false), |
+ has_double_value_(false), |
+ has_external_value_(false), |
+ 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) { |
ASSERT(!handle.is_null()); |
ASSERT(!type.IsUninitialized()); |
ASSERT(!type.IsTaggedNumber()); |
@@ -2662,16 +2665,17 @@ HConstant::HConstant(int32_t integer_value, |
Representation r, |
bool is_not_in_new_space, |
Handle<Object> optional_handle) |
- : handle_(optional_handle), |
- unique_id_(), |
- has_int32_value_(true), |
- has_double_value_(true), |
- is_internalized_string_(false), |
- is_not_in_new_space_(is_not_in_new_space), |
- is_cell_(false), |
- boolean_value_(integer_value != 0), |
- int32_value_(integer_value), |
- double_value_(FastI2D(integer_value)) { |
+ : handle_(optional_handle), |
+ unique_id_(), |
+ has_int32_value_(true), |
+ has_double_value_(true), |
+ has_external_value_(false), |
+ is_internalized_string_(false), |
+ is_not_in_new_space_(is_not_in_new_space), |
+ is_cell_(false), |
+ boolean_value_(integer_value != 0), |
+ int32_value_(integer_value), |
+ double_value_(FastI2D(integer_value)) { |
has_smi_value_ = Smi::IsValid(int32_value_); |
Initialize(r); |
} |
@@ -2681,21 +2685,36 @@ HConstant::HConstant(double double_value, |
Representation r, |
bool is_not_in_new_space, |
Handle<Object> optional_handle) |
- : handle_(optional_handle), |
- unique_id_(), |
- has_int32_value_(IsInteger32(double_value)), |
- has_double_value_(true), |
- is_internalized_string_(false), |
- is_not_in_new_space_(is_not_in_new_space), |
- is_cell_(false), |
- boolean_value_(double_value != 0 && !std::isnan(double_value)), |
- int32_value_(DoubleToInt32(double_value)), |
- double_value_(double_value) { |
+ : handle_(optional_handle), |
+ unique_id_(), |
+ has_int32_value_(IsInteger32(double_value)), |
+ has_double_value_(true), |
+ has_external_value_(false), |
+ is_internalized_string_(false), |
+ is_not_in_new_space_(is_not_in_new_space), |
+ is_cell_(false), |
+ boolean_value_(double_value != 0 && !std::isnan(double_value)), |
+ int32_value_(DoubleToInt32(double_value)), |
+ double_value_(double_value) { |
has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
Initialize(r); |
} |
+HConstant::HConstant(ExternalReference reference, Representation r) |
+ : has_smi_value_(false), |
+ has_int32_value_(false), |
+ has_double_value_(false), |
+ has_external_value_(true), |
+ is_internalized_string_(false), |
+ is_not_in_new_space_(true), |
+ is_cell_(false), |
+ boolean_value_(true), |
+ external_value_(reference) { |
+ Initialize(r); |
+} |
+ |
+ |
void HConstant::Initialize(Representation r) { |
if (r.IsNone()) { |
if (has_smi_value_) { |
@@ -2704,6 +2723,8 @@ void HConstant::Initialize(Representation r) { |
r = Representation::Integer32(); |
} else if (has_double_value_) { |
r = Representation::Double(); |
+ } else if (has_external_value_) { |
+ r = Representation::External(); |
} else { |
r = Representation::Tagged(); |
} |
@@ -2728,12 +2749,16 @@ HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
if (r.IsSmi() && !has_smi_value_) return NULL; |
if (r.IsInteger32() && !has_int32_value_) return NULL; |
if (r.IsDouble() && !has_double_value_) return NULL; |
+ if (r.IsExternal() && !has_external_value_) return NULL; |
if (has_int32_value_) { |
return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); |
} |
if (has_double_value_) { |
return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); |
} |
+ if (has_external_value_) { |
+ return new(zone) HConstant(external_value_, r); |
+ } |
ASSERT(!handle_.is_null()); |
return new(zone) HConstant(handle_, |
unique_id_, |
@@ -2786,6 +2811,8 @@ void HConstant::PrintDataTo(StringStream* stream) { |
stream->Add("%d ", int32_value_); |
} else if (has_double_value_) { |
stream->Add("%f ", FmtElm(double_value_)); |
+ } else if (has_external_value_) { |
+ stream->Add("%p ", reinterpret_cast<void*>(external_value_.address())); |
} else { |
handle()->ShortPrint(stream); |
} |
@@ -3624,6 +3651,7 @@ HType HConstant::CalculateInferredType() { |
return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber(); |
} |
if (has_double_value_) return HType::HeapNumber(); |
+ if (has_external_value_) return HType::None(); |
ASSERT(!type_from_value_.IsUninitialized()); |
return type_from_value_; |
} |