Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index 932b9b219d2ca96eaba24096de8456cdd8acd059..924dc00d42e1973d9a319ef18ac8dee618482ec6 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"; |
@@ -2171,10 +2172,12 @@ 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), |
- boolean_value_(handle->BooleanValue()) { |
+ boolean_value_(handle->BooleanValue()), |
+ external_value_(ExternalReference::null()) { |
if (handle_->IsHeapObject()) { |
Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); |
is_not_in_new_space_ = !heap->InNewSpace(*handle); |
@@ -2205,16 +2208,18 @@ 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), |
+ external_value_(ExternalReference::null()), |
+ type_from_value_(type) { |
ASSERT(!handle.is_null()); |
ASSERT(!type.IsUninitialized()); |
ASSERT(!type.IsTaggedNumber()); |
@@ -2226,16 +2231,18 @@ 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)), |
+ external_value_(ExternalReference::null()) { |
has_smi_value_ = Smi::IsValid(int32_value_); |
Initialize(r); |
} |
@@ -2245,21 +2252,37 @@ 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), |
+ external_value_(ExternalReference::null()) { |
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_) { |
@@ -2268,6 +2291,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(); |
} |
@@ -2298,6 +2323,9 @@ HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
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_, |
@@ -2332,6 +2360,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); |
} |
@@ -3121,6 +3151,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_; |
} |