OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 ASSERT(!value->IsPropertyCell() && !value->IsCell()); | 627 ASSERT(!value->IsPropertyCell() && !value->IsCell()); |
628 return value; | 628 return value; |
629 } | 629 } |
630 | 630 |
631 | 631 |
632 Object* JSObject::SetNormalizedProperty(LookupResult* result, Object* value) { | 632 Object* JSObject::SetNormalizedProperty(LookupResult* result, Object* value) { |
633 ASSERT(!HasFastProperties()); | 633 ASSERT(!HasFastProperties()); |
634 if (IsGlobalObject()) { | 634 if (IsGlobalObject()) { |
635 PropertyCell* cell = PropertyCell::cast( | 635 PropertyCell* cell = PropertyCell::cast( |
636 property_dictionary()->ValueAt(result->GetDictionaryEntry())); | 636 property_dictionary()->ValueAt(result->GetDictionaryEntry())); |
637 cell->set_value(value); | 637 cell->set_value_infer_type(value); |
638 } else { | 638 } else { |
639 property_dictionary()->ValueAtPut(result->GetDictionaryEntry(), value); | 639 property_dictionary()->ValueAtPut(result->GetDictionaryEntry(), value); |
640 } | 640 } |
641 return value; | 641 return value; |
642 } | 642 } |
643 | 643 |
644 | 644 |
645 Handle<Object> JSObject::SetNormalizedProperty(Handle<JSObject> object, | 645 Handle<Object> JSObject::SetNormalizedProperty(Handle<JSObject> object, |
646 Handle<Name> key, | 646 Handle<Name> key, |
647 Handle<Object> value, | 647 Handle<Object> value, |
648 PropertyDetails details) { | 648 PropertyDetails details) { |
649 CALL_HEAP_FUNCTION(object->GetIsolate(), | 649 CALL_HEAP_FUNCTION(object->GetIsolate(), |
650 object->SetNormalizedProperty(*key, *value, details), | 650 object->SetNormalizedProperty(*key, *value, details), |
651 Object); | 651 Object); |
652 } | 652 } |
653 | 653 |
654 | 654 |
655 MaybeObject* JSObject::SetNormalizedProperty(Name* name, | 655 MaybeObject* JSObject::SetNormalizedProperty(Name* name, |
656 Object* value, | 656 Object* value, |
657 PropertyDetails details) { | 657 PropertyDetails details) { |
658 ASSERT(!HasFastProperties()); | 658 ASSERT(!HasFastProperties()); |
659 int entry = property_dictionary()->FindEntry(name); | 659 int entry = property_dictionary()->FindEntry(name); |
660 if (entry == NameDictionary::kNotFound) { | 660 if (entry == NameDictionary::kNotFound) { |
661 Object* store_value = value; | 661 Object* store_value = value; |
662 if (IsGlobalObject()) { | 662 if (IsGlobalObject()) { |
663 Heap* heap = name->GetHeap(); | 663 Heap* heap = name->GetHeap(); |
664 MaybeObject* maybe_store_value = | 664 MaybeObject* maybe_store_value = heap->AllocatePropertyCell(value); |
665 heap->AllocatePropertyCell(value); | |
666 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; | 665 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; |
667 } | 666 } |
668 Object* dict; | 667 Object* dict; |
669 { MaybeObject* maybe_dict = | 668 { MaybeObject* maybe_dict = |
670 property_dictionary()->Add(name, store_value, details); | 669 property_dictionary()->Add(name, store_value, details); |
671 if (!maybe_dict->ToObject(&dict)) return maybe_dict; | 670 if (!maybe_dict->ToObject(&dict)) return maybe_dict; |
672 } | 671 } |
673 set_properties(NameDictionary::cast(dict)); | 672 set_properties(NameDictionary::cast(dict)); |
674 return value; | 673 return value; |
675 } | 674 } |
676 | 675 |
677 PropertyDetails original_details = property_dictionary()->DetailsAt(entry); | 676 PropertyDetails original_details = property_dictionary()->DetailsAt(entry); |
678 int enumeration_index; | 677 int enumeration_index; |
679 // Preserve the enumeration index unless the property was deleted. | 678 // Preserve the enumeration index unless the property was deleted. |
680 if (original_details.IsDeleted()) { | 679 if (original_details.IsDeleted()) { |
681 enumeration_index = property_dictionary()->NextEnumerationIndex(); | 680 enumeration_index = property_dictionary()->NextEnumerationIndex(); |
682 property_dictionary()->SetNextEnumerationIndex(enumeration_index + 1); | 681 property_dictionary()->SetNextEnumerationIndex(enumeration_index + 1); |
683 } else { | 682 } else { |
684 enumeration_index = original_details.dictionary_index(); | 683 enumeration_index = original_details.dictionary_index(); |
685 ASSERT(enumeration_index > 0); | 684 ASSERT(enumeration_index > 0); |
686 } | 685 } |
687 | 686 |
688 details = PropertyDetails( | 687 details = PropertyDetails( |
689 details.attributes(), details.type(), enumeration_index); | 688 details.attributes(), details.type(), enumeration_index); |
690 | 689 |
691 if (IsGlobalObject()) { | 690 if (IsGlobalObject()) { |
692 PropertyCell* cell = | 691 PropertyCell* cell = |
693 PropertyCell::cast(property_dictionary()->ValueAt(entry)); | 692 PropertyCell::cast(property_dictionary()->ValueAt(entry)); |
694 cell->set_value(value); | 693 cell->set_value_infer_type(value); |
695 // Please note we have to update the property details. | 694 // Please note we have to update the property details. |
696 property_dictionary()->DetailsAtPut(entry, details); | 695 property_dictionary()->DetailsAtPut(entry, details); |
697 } else { | 696 } else { |
698 property_dictionary()->SetEntry(entry, name, value, details); | 697 property_dictionary()->SetEntry(entry, name, value, details); |
699 } | 698 } |
700 return value; | 699 return value; |
701 } | 700 } |
702 | 701 |
703 | 702 |
704 MaybeObject* JSObject::DeleteNormalizedProperty(Name* name, DeleteMode mode) { | 703 MaybeObject* JSObject::DeleteNormalizedProperty(Name* name, DeleteMode mode) { |
(...skipping 11 matching lines...) Expand all Loading... |
716 // from the DontDelete cell without checking if it contains | 715 // from the DontDelete cell without checking if it contains |
717 // the hole value. | 716 // the hole value. |
718 Map* new_map; | 717 Map* new_map; |
719 MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); | 718 MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); |
720 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 719 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
721 | 720 |
722 ASSERT(new_map->is_dictionary_map()); | 721 ASSERT(new_map->is_dictionary_map()); |
723 set_map(new_map); | 722 set_map(new_map); |
724 } | 723 } |
725 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry)); | 724 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry)); |
726 cell->set_value(cell->GetHeap()->the_hole_value()); | 725 cell->set_value_infer_type(cell->GetHeap()->the_hole_value()); |
727 dictionary->DetailsAtPut(entry, details.AsDeleted()); | 726 dictionary->DetailsAtPut(entry, details.AsDeleted()); |
728 } else { | 727 } else { |
729 Object* deleted = dictionary->DeleteProperty(entry, mode); | 728 Object* deleted = dictionary->DeleteProperty(entry, mode); |
730 if (deleted == GetHeap()->true_value()) { | 729 if (deleted == GetHeap()->true_value()) { |
731 FixedArray* new_properties = NULL; | 730 FixedArray* new_properties = NULL; |
732 MaybeObject* maybe_properties = dictionary->Shrink(name); | 731 MaybeObject* maybe_properties = dictionary->Shrink(name); |
733 if (!maybe_properties->To(&new_properties)) { | 732 if (!maybe_properties->To(&new_properties)) { |
734 return maybe_properties; | 733 return maybe_properties; |
735 } | 734 } |
736 set_properties(new_properties); | 735 set_properties(new_properties); |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1923 Object* value, | 1922 Object* value, |
1924 PropertyAttributes attributes) { | 1923 PropertyAttributes attributes) { |
1925 ASSERT(!HasFastProperties()); | 1924 ASSERT(!HasFastProperties()); |
1926 NameDictionary* dict = property_dictionary(); | 1925 NameDictionary* dict = property_dictionary(); |
1927 Object* store_value = value; | 1926 Object* store_value = value; |
1928 if (IsGlobalObject()) { | 1927 if (IsGlobalObject()) { |
1929 // In case name is an orphaned property reuse the cell. | 1928 // In case name is an orphaned property reuse the cell. |
1930 int entry = dict->FindEntry(name); | 1929 int entry = dict->FindEntry(name); |
1931 if (entry != NameDictionary::kNotFound) { | 1930 if (entry != NameDictionary::kNotFound) { |
1932 store_value = dict->ValueAt(entry); | 1931 store_value = dict->ValueAt(entry); |
1933 PropertyCell::cast(store_value)->set_value(value); | 1932 PropertyCell::cast(store_value)->set_value_infer_type(value); |
1934 // Assign an enumeration index to the property and update | 1933 // Assign an enumeration index to the property and update |
1935 // SetNextEnumerationIndex. | 1934 // SetNextEnumerationIndex. |
1936 int index = dict->NextEnumerationIndex(); | 1935 int index = dict->NextEnumerationIndex(); |
1937 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); | 1936 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); |
1938 dict->SetNextEnumerationIndex(index + 1); | 1937 dict->SetNextEnumerationIndex(index + 1); |
1939 dict->SetEntry(entry, name, store_value, details); | 1938 dict->SetEntry(entry, name, store_value, details); |
1940 return value; | 1939 return value; |
1941 } | 1940 } |
1942 Heap* heap = GetHeap(); | 1941 Heap* heap = GetHeap(); |
1943 { MaybeObject* maybe_store_value = | 1942 { MaybeObject* maybe_store_value = |
1944 heap->AllocatePropertyCell(value); | 1943 heap->AllocatePropertyCell(value); |
1945 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; | 1944 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; |
1946 } | 1945 } |
1947 PropertyCell::cast(store_value)->set_value(value); | 1946 PropertyCell::cast(store_value)->set_value_infer_type(value); |
1948 } | 1947 } |
1949 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); | 1948 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); |
1950 Object* result; | 1949 Object* result; |
1951 { MaybeObject* maybe_result = dict->Add(name, store_value, details); | 1950 { MaybeObject* maybe_result = dict->Add(name, store_value, details); |
1952 if (!maybe_result->ToObject(&result)) return maybe_result; | 1951 if (!maybe_result->ToObject(&result)) return maybe_result; |
1953 } | 1952 } |
1954 if (dict != result) set_properties(NameDictionary::cast(result)); | 1953 if (dict != result) set_properties(NameDictionary::cast(result)); |
1955 return value; | 1954 return value; |
1956 } | 1955 } |
1957 | 1956 |
(...skipping 8146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10104 return statement_position; | 10103 return statement_position; |
10105 } | 10104 } |
10106 | 10105 |
10107 | 10106 |
10108 SafepointEntry Code::GetSafepointEntry(Address pc) { | 10107 SafepointEntry Code::GetSafepointEntry(Address pc) { |
10109 SafepointTable table(this); | 10108 SafepointTable table(this); |
10110 return table.FindEntry(pc); | 10109 return table.FindEntry(pc); |
10111 } | 10110 } |
10112 | 10111 |
10113 | 10112 |
10114 Map* Code::FindFirstMap() { | 10113 Object* Code::FindNthObject(int n, Map* match_map) { |
10115 ASSERT(is_inline_cache_stub()); | 10114 ASSERT(is_inline_cache_stub()); |
10116 DisallowHeapAllocation no_allocation; | 10115 DisallowHeapAllocation no_allocation; |
10117 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10116 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10118 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10117 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10119 RelocInfo* info = it.rinfo(); | 10118 RelocInfo* info = it.rinfo(); |
10120 Object* object = info->target_object(); | 10119 Object* object = info->target_object(); |
10121 if (object->IsMap()) return Map::cast(object); | 10120 if (object->IsHeapObject()) { |
| 10121 if (HeapObject::cast(object)->map() == match_map) { |
| 10122 if (--n == 0) return object; |
| 10123 } |
| 10124 } |
10122 } | 10125 } |
10123 return NULL; | 10126 return NULL; |
10124 } | 10127 } |
10125 | 10128 |
10126 | 10129 |
10127 void Code::ReplaceFirstMap(Map* replace_with) { | 10130 Map* Code::FindFirstMap() { |
| 10131 Object* result = FindNthObject(1, GetHeap()->meta_map()); |
| 10132 if (result == NULL) return NULL; |
| 10133 return Map::cast(result); |
| 10134 } |
| 10135 |
| 10136 |
| 10137 void Code::ReplaceNthObject(int n, |
| 10138 Map* match_map, |
| 10139 Object* replace_with) { |
10128 ASSERT(is_inline_cache_stub()); | 10140 ASSERT(is_inline_cache_stub()); |
10129 DisallowHeapAllocation no_allocation; | 10141 DisallowHeapAllocation no_allocation; |
10130 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10142 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10131 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10143 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10132 RelocInfo* info = it.rinfo(); | 10144 RelocInfo* info = it.rinfo(); |
10133 Object* object = info->target_object(); | 10145 Object* object = info->target_object(); |
10134 if (object->IsMap()) { | 10146 if (object->IsHeapObject()) { |
10135 info->set_target_object(replace_with); | 10147 if (HeapObject::cast(object)->map() == match_map) { |
10136 return; | 10148 if (--n == 0) { |
| 10149 info->set_target_object(replace_with); |
| 10150 return; |
| 10151 } |
| 10152 } |
10137 } | 10153 } |
10138 } | 10154 } |
10139 UNREACHABLE(); | 10155 UNREACHABLE(); |
10140 } | 10156 } |
10141 | 10157 |
10142 | 10158 |
10143 void Code::FindAllMaps(MapHandleList* maps) { | 10159 void Code::FindAllMaps(MapHandleList* maps) { |
10144 ASSERT(is_inline_cache_stub()); | 10160 ASSERT(is_inline_cache_stub()); |
10145 DisallowHeapAllocation no_allocation; | 10161 DisallowHeapAllocation no_allocation; |
10146 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10162 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10147 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10163 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10148 RelocInfo* info = it.rinfo(); | 10164 RelocInfo* info = it.rinfo(); |
10149 Object* object = info->target_object(); | 10165 Object* object = info->target_object(); |
10150 if (object->IsMap()) maps->Add(Handle<Map>(Map::cast(object))); | 10166 if (object->IsMap()) maps->Add(Handle<Map>(Map::cast(object))); |
10151 } | 10167 } |
10152 } | 10168 } |
10153 | 10169 |
10154 | 10170 |
| 10171 void Code::ReplaceFirstMap(Map* replace_with) { |
| 10172 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with); |
| 10173 } |
| 10174 |
| 10175 |
10155 Code* Code::FindFirstCode() { | 10176 Code* Code::FindFirstCode() { |
10156 ASSERT(is_inline_cache_stub()); | 10177 ASSERT(is_inline_cache_stub()); |
10157 DisallowHeapAllocation no_allocation; | 10178 DisallowHeapAllocation no_allocation; |
10158 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | 10179 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); |
10159 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10180 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10160 RelocInfo* info = it.rinfo(); | 10181 RelocInfo* info = it.rinfo(); |
10161 return Code::GetCodeFromTargetAddress(info->target_address()); | 10182 return Code::GetCodeFromTargetAddress(info->target_address()); |
10162 } | 10183 } |
10163 return NULL; | 10184 return NULL; |
10164 } | 10185 } |
(...skipping 21 matching lines...) Expand all Loading... |
10186 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10207 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10187 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10208 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10188 RelocInfo* info = it.rinfo(); | 10209 RelocInfo* info = it.rinfo(); |
10189 Object* object = info->target_object(); | 10210 Object* object = info->target_object(); |
10190 if (object->IsName()) return Name::cast(object); | 10211 if (object->IsName()) return Name::cast(object); |
10191 } | 10212 } |
10192 return NULL; | 10213 return NULL; |
10193 } | 10214 } |
10194 | 10215 |
10195 | 10216 |
| 10217 void Code::ReplaceNthCell(int n, |
| 10218 Cell* replace_with) { |
| 10219 ASSERT(is_inline_cache_stub()); |
| 10220 DisallowHeapAllocation no_allocation; |
| 10221 int mask = RelocInfo::ModeMask(RelocInfo::CELL); |
| 10222 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
| 10223 RelocInfo* info = it.rinfo(); |
| 10224 if (--n == 0) { |
| 10225 info->set_target_cell(replace_with); |
| 10226 return; |
| 10227 } |
| 10228 } |
| 10229 UNREACHABLE(); |
| 10230 } |
| 10231 |
| 10232 |
10196 void Code::ClearInlineCaches() { | 10233 void Code::ClearInlineCaches() { |
10197 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | | 10234 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | |
10198 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | | 10235 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | |
10199 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | | 10236 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | |
10200 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); | 10237 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); |
10201 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10238 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10202 RelocInfo* info = it.rinfo(); | 10239 RelocInfo* info = it.rinfo(); |
10203 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); | 10240 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); |
10204 if (target->is_inline_cache_stub()) { | 10241 if (target->is_inline_cache_stub()) { |
10205 IC::Clear(info->pc()); | 10242 IC::Clear(info->pc()); |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11068 proto_transitions->length()); | 11105 proto_transitions->length()); |
11069 } | 11106 } |
11070 | 11107 |
11071 | 11108 |
11072 void Map::AddDependentCompilationInfo(DependentCode::DependencyGroup group, | 11109 void Map::AddDependentCompilationInfo(DependentCode::DependencyGroup group, |
11073 CompilationInfo* info) { | 11110 CompilationInfo* info) { |
11074 Handle<DependentCode> dep(dependent_code()); | 11111 Handle<DependentCode> dep(dependent_code()); |
11075 Handle<DependentCode> codes = | 11112 Handle<DependentCode> codes = |
11076 DependentCode::Insert(dep, group, info->object_wrapper()); | 11113 DependentCode::Insert(dep, group, info->object_wrapper()); |
11077 if (*codes != dependent_code()) set_dependent_code(*codes); | 11114 if (*codes != dependent_code()) set_dependent_code(*codes); |
11078 info->dependent_maps(group)->Add(Handle<Map>(this), info->zone()); | 11115 info->dependencies(group)->Add(Handle<HeapObject>(this), info->zone()); |
11079 } | 11116 } |
11080 | 11117 |
11081 | 11118 |
11082 void Map::AddDependentCode(DependentCode::DependencyGroup group, | 11119 void Map::AddDependentCode(DependentCode::DependencyGroup group, |
11083 Handle<Code> code) { | 11120 Handle<Code> code) { |
11084 Handle<DependentCode> codes = DependentCode::Insert( | 11121 Handle<DependentCode> codes = DependentCode::Insert( |
11085 Handle<DependentCode>(dependent_code()), group, code); | 11122 Handle<DependentCode>(dependent_code()), group, code); |
11086 if (*codes != dependent_code()) set_dependent_code(*codes); | 11123 if (*codes != dependent_code()) set_dependent_code(*codes); |
11087 } | 11124 } |
11088 | 11125 |
11089 | 11126 |
11090 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { | 11127 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { |
11091 Recompute(entries); | 11128 Recompute(entries); |
11092 } | 11129 } |
11093 | 11130 |
11094 | 11131 |
11095 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { | 11132 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { |
11096 start_indexes_[0] = 0; | 11133 start_indexes_[0] = 0; |
11097 for (int g = 1; g <= kGroupCount; g++) { | 11134 for (int g = 1; g <= kGroupCount; g++) { |
11098 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); | 11135 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); |
11099 start_indexes_[g] = start_indexes_[g - 1] + count; | 11136 start_indexes_[g] = start_indexes_[g - 1] + count; |
11100 } | 11137 } |
11101 } | 11138 } |
11102 | 11139 |
11103 | 11140 |
| 11141 DependentCode* DependentCode::ForObject(Handle<HeapObject> object, |
| 11142 DependencyGroup group) { |
| 11143 AllowDeferredHandleDereference dependencies_are_safe; |
| 11144 if (group == DependentCode::kPropertyCellChangedGroup) { |
| 11145 return Handle<PropertyCell>::cast(object)->dependent_code(); |
| 11146 } |
| 11147 return Handle<Map>::cast(object)->dependent_code(); |
| 11148 } |
| 11149 |
| 11150 |
11104 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, | 11151 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, |
11105 DependencyGroup group, | 11152 DependencyGroup group, |
11106 Handle<Object> object) { | 11153 Handle<Object> object) { |
11107 GroupStartIndexes starts(*entries); | 11154 GroupStartIndexes starts(*entries); |
11108 int start = starts.at(group); | 11155 int start = starts.at(group); |
11109 int end = starts.at(group + 1); | 11156 int end = starts.at(group + 1); |
11110 int number_of_entries = starts.number_of_entries(); | 11157 int number_of_entries = starts.number_of_entries(); |
11111 if (start < end && entries->object_at(end - 1) == *object) { | 11158 if (start < end && entries->object_at(end - 1) == *object) { |
11112 // Do not append the compilation info if it is already in the array. | 11159 // Do not append the compilation info if it is already in the array. |
11113 // It is sufficient to just check only the last element because | 11160 // It is sufficient to just check only the last element because |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11232 int start = starts.at(group); | 11279 int start = starts.at(group); |
11233 int end = starts.at(group + 1); | 11280 int end = starts.at(group + 1); |
11234 int code_entries = starts.number_of_entries(); | 11281 int code_entries = starts.number_of_entries(); |
11235 if (start == end) return; | 11282 if (start == end) return; |
11236 for (int i = start; i < end; i++) { | 11283 for (int i = start; i < end; i++) { |
11237 if (is_code_at(i)) { | 11284 if (is_code_at(i)) { |
11238 Code* code = code_at(i); | 11285 Code* code = code_at(i); |
11239 code->set_marked_for_deoptimization(true); | 11286 code->set_marked_for_deoptimization(true); |
11240 } else { | 11287 } else { |
11241 CompilationInfo* info = compilation_info_at(i); | 11288 CompilationInfo* info = compilation_info_at(i); |
11242 info->AbortDueToDependentMap(); | 11289 info->AbortDueToDependencyChange(); |
11243 } | 11290 } |
11244 } | 11291 } |
11245 // Compact the array by moving all subsequent groups to fill in the new holes. | 11292 // Compact the array by moving all subsequent groups to fill in the new holes. |
11246 for (int src = end, dst = start; src < code_entries; src++, dst++) { | 11293 for (int src = end, dst = start; src < code_entries; src++, dst++) { |
11247 copy(src, dst); | 11294 copy(src, dst); |
11248 } | 11295 } |
11249 // Now the holes are at the end of the array, zap them for heap-verifier. | 11296 // Now the holes are at the end of the array, zap them for heap-verifier. |
11250 int removed = end - start; | 11297 int removed = end - start; |
11251 for (int i = code_entries - removed; i < code_entries; i++) { | 11298 for (int i = code_entries - removed; i < code_entries; i++) { |
11252 clear_at(i); | 11299 clear_at(i); |
(...skipping 4512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15765 Type* PropertyCell::type() { | 15812 Type* PropertyCell::type() { |
15766 return static_cast<Type*>(type_raw()); | 15813 return static_cast<Type*>(type_raw()); |
15767 } | 15814 } |
15768 | 15815 |
15769 | 15816 |
15770 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) { | 15817 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) { |
15771 set_type_raw(type, ignored); | 15818 set_type_raw(type, ignored); |
15772 } | 15819 } |
15773 | 15820 |
15774 | 15821 |
| 15822 Type* PropertyCell::UnionType(Object* value) { |
| 15823 Isolate* isolate = GetIsolate(); |
| 15824 Handle<Object> value_handle(value, isolate); |
| 15825 Handle<Type> old_type(type(), isolate); |
| 15826 Handle<Type> new_type(Type::Constant(value_handle, isolate), isolate); |
| 15827 |
| 15828 if (new_type->Is(old_type) && !value->IsTheHole()) { |
| 15829 return *old_type; |
| 15830 } |
| 15831 |
| 15832 dependent_code()->DeoptimizeDependentCodeGroup( |
| 15833 isolate, DependentCode::kPropertyCellChangedGroup); |
| 15834 |
| 15835 if (*old_type == Type::None()) { |
| 15836 if (new_type->IsConstant() && !value->IsTheHole()) { |
| 15837 return *new_type; |
| 15838 } |
| 15839 } else if (old_type->IsConstant() && old_type->AsConstant()->IsUndefined()) { |
| 15840 return *new_type; |
| 15841 } |
| 15842 |
| 15843 return Type::Any(); |
| 15844 } |
| 15845 |
| 15846 |
| 15847 void PropertyCell::set_value_infer_type(Object* value, |
| 15848 WriteBarrierMode ignored) { |
| 15849 set_value(value, ignored); |
| 15850 set_type(UnionType(value)); |
| 15851 } |
| 15852 |
| 15853 |
| 15854 void PropertyCell::AddDependentCompilationInfo(CompilationInfo* info) { |
| 15855 Handle<DependentCode> dep(dependent_code()); |
| 15856 Handle<DependentCode> codes = |
| 15857 DependentCode::Insert(dep, DependentCode::kPropertyCellChangedGroup, |
| 15858 info->object_wrapper()); |
| 15859 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 15860 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 15861 Handle<HeapObject>(this), info->zone()); |
| 15862 } |
| 15863 |
| 15864 |
| 15865 void PropertyCell::AddDependentCode(Handle<Code> code) { |
| 15866 Handle<DependentCode> codes = DependentCode::Insert( |
| 15867 Handle<DependentCode>(dependent_code()), |
| 15868 DependentCode::kPropertyCellChangedGroup, code); |
| 15869 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 15870 } |
| 15871 |
| 15872 |
15775 } } // namespace v8::internal | 15873 } } // namespace v8::internal |
OLD | NEW |