Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 4a3b54252dca409223e2227572b0a247e8c40c78..4a0173b5f3a64c5b0fa12d185f88f9c7e1ce7401 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -63,15 +63,16 @@ namespace internal { |
| Handle<HeapType> Object::OptimalType(Isolate* isolate, |
| Representation representation) { |
| - if (!FLAG_track_field_types) return HeapType::Any(isolate); |
| - if (representation.IsNone()) return HeapType::None(isolate); |
| - if (representation.IsHeapObject() && IsHeapObject()) { |
| - // We can track only JavaScript objects with stable maps. |
| - Handle<Map> map(HeapObject::cast(this)->map(), isolate); |
| - if (map->is_stable() && |
| - map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE && |
| - map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE) { |
| - return HeapType::Class(map, isolate); |
| + if (FLAG_track_field_types) { |
| + if (representation.IsNone()) return HeapType::None(isolate); |
| + if (representation.IsHeapObject() && IsHeapObject()) { |
| + // We can track only JavaScript objects with stable maps. |
| + Handle<Map> map(HeapObject::cast(this)->map(), isolate); |
| + if (map->is_stable() && |
| + map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE && |
| + map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE) { |
| + return HeapType::Class(map, isolate); |
| + } |
| } |
| } |
| return HeapType::Any(isolate); |
| @@ -2531,6 +2532,14 @@ Handle<HeapType> Map::GeneralizeFieldType(Handle<HeapType> old_field_type, |
| Isolate* isolate) { |
| if (new_field_type->NowIs(old_field_type)) return old_field_type; |
| if (old_field_type->NowIs(new_field_type)) return new_field_type; |
| + int num_old_classes = old_field_type->NumClasses(); |
| + int num_new_classes = new_field_type->NumClasses(); |
| + if (num_old_classes > 0 && |
| + num_new_classes > 0 && |
| + num_old_classes + num_new_classes <= 5 && |
|
Sven Panne
2014/04/17 06:43:41
Perhaps give the "5" a name...
Benedikt Meurer
2014/04/17 07:26:35
Done.
|
| + old_field_type->NowStable() && new_field_type->NowStable()) { |
| + return HeapType::Union(new_field_type, old_field_type, isolate); |
|
Sven Panne
2014/04/17 06:43:41
As discussed offline: Perhaps calculate the union
Benedikt Meurer
2014/04/17 07:26:35
Done.
|
| + } |
| return HeapType::Any(isolate); |
| } |