Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index c1a23f9b0366a6f848abef9efb04e2f0613127ed..d13b7ee70ceccacb9f2973a69b85caf5639366a4 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -1380,6 +1380,17 @@ void HCheckMapValue::PrintDataTo(StringStream* stream) { |
} |
+HValue* HCheckMapValue::Canonicalize() { |
+ if (map()->IsConstant()) { |
+ HConstant* c_map = HConstant::cast(map()); |
+ return HCheckMaps::CreateAndInsertAfter( |
+ block()->graph()->zone(), value(), c_map->MapValue(), |
+ c_map->HasStableMapValue(), this); |
+ } |
+ return this; |
+} |
+ |
+ |
void HForInPrepareMap::PrintDataTo(StringStream* stream) { |
enumerable()->PrintNameTo(stream); |
} |
@@ -1682,7 +1693,7 @@ void HCheckMaps::PrintDataTo(StringStream* stream) { |
HValue* HCheckMaps::Canonicalize() { |
if (!IsStabilityCheck() && maps_are_stable() && value()->IsConstant()) { |
HConstant* c_value = HConstant::cast(value()); |
- if (c_value->HasObjectMap() && c_value->ObjectMapIsStable()) { |
+ if (c_value->HasObjectMap()) { |
for (int i = 0; i < maps()->size(); ++i) { |
if (c_value->ObjectMap() == maps()->at(i)) { |
if (maps()->size() > 1) { |
@@ -2685,7 +2696,7 @@ HConstant::HConstant(Handle<Object> object, Representation r) |
: HTemplateInstruction<0>(HType::TypeFromValue(object)), |
object_(Unique<Object>::CreateUninitialized(object)), |
object_map_(Handle<Map>::null()), |
- object_map_is_stable_(false), |
+ has_stable_map_value_(false), |
has_smi_value_(false), |
has_int32_value_(false), |
has_double_value_(false), |
@@ -2695,13 +2706,15 @@ HConstant::HConstant(Handle<Object> object, Representation r) |
is_undetectable_(false), |
instance_type_(kUnknownInstanceType) { |
if (object->IsHeapObject()) { |
- Isolate* isolate = Handle<HeapObject>::cast(object)->GetIsolate(); |
- Handle<Map> map(Handle<HeapObject>::cast(object)->map(), isolate); |
+ Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); |
+ Isolate* isolate = heap_object->GetIsolate(); |
+ Handle<Map> map(heap_object->map(), isolate); |
is_not_in_new_space_ = !isolate->heap()->InNewSpace(*object); |
instance_type_ = map->instance_type(); |
is_undetectable_ = map->is_undetectable(); |
- object_map_ = Unique<Map>::CreateImmovable(map); |
- object_map_is_stable_ = map->is_stable(); |
+ if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map); |
+ has_stable_map_value_ = (instance_type_ == MAP_TYPE && |
+ Handle<Map>::cast(heap_object)->is_stable()); |
} |
if (object->IsNumber()) { |
double n = object->Number(); |
@@ -2717,7 +2730,9 @@ HConstant::HConstant(Handle<Object> object, Representation r) |
} |
-HConstant::HConstant(Unique<Object> unique, |
+HConstant::HConstant(Unique<Object> object, |
+ Unique<Map> object_map, |
+ bool has_stable_map_value, |
Representation r, |
HType type, |
bool is_not_in_new_space, |
@@ -2725,9 +2740,9 @@ HConstant::HConstant(Unique<Object> unique, |
bool is_undetectable, |
InstanceType instance_type) |
: HTemplateInstruction<0>(type), |
- object_(unique), |
- object_map_(Handle<Map>::null()), |
- object_map_is_stable_(false), |
+ object_(object), |
+ object_map_(object_map), |
+ has_stable_map_value_(has_stable_map_value), |
has_smi_value_(false), |
has_int32_value_(false), |
has_double_value_(false), |
@@ -2736,7 +2751,7 @@ HConstant::HConstant(Unique<Object> unique, |
boolean_value_(boolean_value), |
is_undetectable_(is_undetectable), |
instance_type_(instance_type) { |
- ASSERT(!unique.handle().is_null()); |
+ ASSERT(!object.handle().is_null()); |
ASSERT(!type.IsTaggedNumber()); |
Initialize(r); |
} |
@@ -2748,7 +2763,7 @@ HConstant::HConstant(int32_t integer_value, |
Unique<Object> object) |
: object_(object), |
object_map_(Handle<Map>::null()), |
- object_map_is_stable_(false), |
+ has_stable_map_value_(false), |
has_smi_value_(Smi::IsValid(integer_value)), |
has_int32_value_(true), |
has_double_value_(true), |
@@ -2774,7 +2789,7 @@ HConstant::HConstant(double double_value, |
Unique<Object> object) |
: object_(object), |
object_map_(Handle<Map>::null()), |
- object_map_is_stable_(false), |
+ has_stable_map_value_(false), |
has_int32_value_(IsInteger32(double_value)), |
has_double_value_(true), |
has_external_reference_value_(false), |
@@ -2798,7 +2813,7 @@ HConstant::HConstant(ExternalReference reference) |
: HTemplateInstruction<0>(HType::None()), |
object_(Unique<Object>(Handle<Object>::null())), |
object_map_(Handle<Map>::null()), |
- object_map_is_stable_(false), |
+ has_stable_map_value_(false), |
has_smi_value_(false), |
has_int32_value_(false), |
has_double_value_(false), |
@@ -2904,6 +2919,8 @@ HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
} |
ASSERT(!object_.handle().is_null()); |
return new(zone) HConstant(object_, |
+ object_map_, |
+ has_stable_map_value_, |
r, |
type_, |
is_not_in_new_space_, |
@@ -2955,6 +2972,13 @@ void HConstant::PrintDataTo(StringStream* stream) { |
external_reference_value_.address())); |
} else { |
handle(Isolate::Current())->ShortPrint(stream); |
+ stream->Add(" "); |
+ if (HasStableMapValue()) { |
+ stream->Add("[stable-map] "); |
+ } |
+ if (HasObjectMap()) { |
+ stream->Add("[map %p] ", *ObjectMap().handle()); |
+ } |
} |
if (!is_not_in_new_space_) { |
stream->Add("[new space] "); |